Loading packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +4 −0 Original line number Diff line number Diff line Loading @@ -862,6 +862,7 @@ private fun BoxScope.CommunalHubLazyGrid( ) { var gridModifier = Modifier.align(Alignment.TopStart).onGloballyPositioned { setGridCoordinates(it) } var gridItemSize: SizeInfo? by remember { mutableStateOf(null) } var list = communalContent var dragDropState: GridDragDropState? = null var arrangementSpacing = Dimensions.ItemSpacing Loading @@ -888,6 +889,7 @@ private fun BoxScope.CommunalHubLazyGrid( val dragAndDropTargetState = rememberDragAndDropTargetState( gridState = gridState, gridItemSize = gridItemSize, contentListState = contentListState, contentOffset = contentOffset, ) Loading @@ -914,6 +916,8 @@ private fun BoxScope.CommunalHubLazyGrid( minVerticalArrangement = arrangementSpacing, setContentOffset = setContentOffset, ) { sizeInfo -> gridItemSize = sizeInfo /** Override spans based on the responsive grid size */ val finalizedList = if (sizeInfo != null) { Loading packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/DragAndDropTargetState.kt +6 −7 Original line number Diff line number Diff line Loading @@ -56,16 +56,19 @@ import kotlinx.coroutines.launch @Composable fun rememberDragAndDropTargetState( gridState: LazyGridState, gridItemSize: SizeInfo?, contentOffset: Offset, contentListState: ContentListState, ): DragAndDropTargetState { val scope = rememberCoroutineScope() val autoScrollThreshold = with(LocalDensity.current) { 60.dp.toPx() } val columnWidth = with(LocalDensity.current) { gridItemSize?.cellSize?.width?.roundToPx() ?: 0 } val state = remember(gridState, contentOffset, contentListState, autoScrollThreshold, scope) { DragAndDropTargetState( state = gridState, columnWidth = columnWidth, contentOffset = contentOffset, contentListState = contentListState, autoScrollThreshold = autoScrollThreshold, Loading Loading @@ -136,6 +139,7 @@ fun Modifier.dragAndDropTarget(dragDropTargetState: DragAndDropTargetState): Mod */ class DragAndDropTargetState( state: LazyGridState, columnWidth: Int, contentOffset: Offset, contentListState: ContentListState, autoScrollThreshold: Float, Loading @@ -145,6 +149,7 @@ class DragAndDropTargetState( if (glanceableHubV2()) { DragAndDropTargetStateV2( state = state, columnWidth = columnWidth, contentListState = contentListState, scope = scope, autoScrollThreshold = autoScrollThreshold, Loading Loading @@ -339,6 +344,7 @@ private class DragAndDropTargetStateV1( */ private class DragAndDropTargetStateV2( private val state: LazyGridState, private val columnWidth: Int, private val contentOffset: Offset, private val contentListState: ContentListState, private val autoScrollThreshold: Float, Loading @@ -352,7 +358,6 @@ private class DragAndDropTargetStateV2( private var placeHolderIndex: Int? = null private var previousTargetItemKey: Any? = null private var dragOffset = Offset.Zero private var columnWidth = 0 private val scrollChannel = Channel<Float>() Loading Loading @@ -384,12 +389,6 @@ private class DragAndDropTargetStateV2( // assume item will be added to the end. contentListState.list.add(placeHolder) placeHolderIndex = contentListState.list.size - 1 // Use the width of the first item as the column width. columnWidth = state.layoutInfo.visibleItemsInfo.first().size.width + state.layoutInfo.beforeContentPadding + state.layoutInfo.afterContentPadding } override fun onMoved(event: DragAndDropEvent) { Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +4 −0 Original line number Diff line number Diff line Loading @@ -862,6 +862,7 @@ private fun BoxScope.CommunalHubLazyGrid( ) { var gridModifier = Modifier.align(Alignment.TopStart).onGloballyPositioned { setGridCoordinates(it) } var gridItemSize: SizeInfo? by remember { mutableStateOf(null) } var list = communalContent var dragDropState: GridDragDropState? = null var arrangementSpacing = Dimensions.ItemSpacing Loading @@ -888,6 +889,7 @@ private fun BoxScope.CommunalHubLazyGrid( val dragAndDropTargetState = rememberDragAndDropTargetState( gridState = gridState, gridItemSize = gridItemSize, contentListState = contentListState, contentOffset = contentOffset, ) Loading @@ -914,6 +916,8 @@ private fun BoxScope.CommunalHubLazyGrid( minVerticalArrangement = arrangementSpacing, setContentOffset = setContentOffset, ) { sizeInfo -> gridItemSize = sizeInfo /** Override spans based on the responsive grid size */ val finalizedList = if (sizeInfo != null) { Loading
packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/DragAndDropTargetState.kt +6 −7 Original line number Diff line number Diff line Loading @@ -56,16 +56,19 @@ import kotlinx.coroutines.launch @Composable fun rememberDragAndDropTargetState( gridState: LazyGridState, gridItemSize: SizeInfo?, contentOffset: Offset, contentListState: ContentListState, ): DragAndDropTargetState { val scope = rememberCoroutineScope() val autoScrollThreshold = with(LocalDensity.current) { 60.dp.toPx() } val columnWidth = with(LocalDensity.current) { gridItemSize?.cellSize?.width?.roundToPx() ?: 0 } val state = remember(gridState, contentOffset, contentListState, autoScrollThreshold, scope) { DragAndDropTargetState( state = gridState, columnWidth = columnWidth, contentOffset = contentOffset, contentListState = contentListState, autoScrollThreshold = autoScrollThreshold, Loading Loading @@ -136,6 +139,7 @@ fun Modifier.dragAndDropTarget(dragDropTargetState: DragAndDropTargetState): Mod */ class DragAndDropTargetState( state: LazyGridState, columnWidth: Int, contentOffset: Offset, contentListState: ContentListState, autoScrollThreshold: Float, Loading @@ -145,6 +149,7 @@ class DragAndDropTargetState( if (glanceableHubV2()) { DragAndDropTargetStateV2( state = state, columnWidth = columnWidth, contentListState = contentListState, scope = scope, autoScrollThreshold = autoScrollThreshold, Loading Loading @@ -339,6 +344,7 @@ private class DragAndDropTargetStateV1( */ private class DragAndDropTargetStateV2( private val state: LazyGridState, private val columnWidth: Int, private val contentOffset: Offset, private val contentListState: ContentListState, private val autoScrollThreshold: Float, Loading @@ -352,7 +358,6 @@ private class DragAndDropTargetStateV2( private var placeHolderIndex: Int? = null private var previousTargetItemKey: Any? = null private var dragOffset = Offset.Zero private var columnWidth = 0 private val scrollChannel = Channel<Float>() Loading Loading @@ -384,12 +389,6 @@ private class DragAndDropTargetStateV2( // assume item will be added to the end. contentListState.list.add(placeHolder) placeHolderIndex = contentListState.list.size - 1 // Use the width of the first item as the column width. columnWidth = state.layoutInfo.visibleItemsInfo.first().size.width + state.layoutInfo.beforeContentPadding + state.layoutInfo.afterContentPadding } override fun onMoved(event: DragAndDropEvent) { Loading