Loading packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +36 −48 Original line number Diff line number Diff line Loading @@ -59,7 +59,8 @@ import androidx.compose.foundation.lazy.grid.rememberLazyGridState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.outlined.Delete import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.outlined.Edit import androidx.compose.material.icons.outlined.TouchApp import androidx.compose.material.icons.outlined.Widgets Loading Loading @@ -277,7 +278,6 @@ fun CommunalHub( if (viewModel.isEditMode && onOpenWidgetPicker != null && onEditDone != null) { Toolbar( isDraggingToRemove = isDraggingToRemove, setToolbarSize = { toolbarSize = it }, setRemoveButtonCoordinates = { removeButtonCoordinates = it }, onEditDone = onEditDone, Loading Loading @@ -577,7 +577,6 @@ private fun LockStateIcon( */ @Composable private fun Toolbar( isDraggingToRemove: Boolean, removeEnabled: Boolean, onRemoveClicked: () -> Unit, setToolbarSize: (toolbarSize: IntSize) -> Unit, Loading @@ -591,7 +590,7 @@ private fun Toolbar( label = "RemoveButtonAlphaAnimation" ) Row( Box( modifier = Modifier.fillMaxWidth() .padding( Loading @@ -600,11 +599,12 @@ private fun Toolbar( end = Dimensions.ToolbarPaddingHorizontal, ) .onSizeChanged { setToolbarSize(it) }, horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { val spacerModifier = Modifier.width(ButtonDefaults.IconSpacing) if (!removeEnabled) { Button( modifier = Modifier.align(Alignment.CenterStart), onClick = onOpenWidgetPicker, colors = filledButtonColors(), contentPadding = Dimensions.ButtonPadding Loading @@ -615,53 +615,41 @@ private fun Toolbar( text = stringResource(R.string.hub_mode_add_widget_button_text), ) } } val colors = LocalAndroidColorScheme.current if (isDraggingToRemove) { if (removeEnabled) { Button( // Button is disabled to make it non-clickable enabled = false, onClick = {}, colors = ButtonDefaults.buttonColors( disabledContainerColor = colors.primary, disabledContentColor = colors.onPrimary, ), contentPadding = Dimensions.ButtonPadding, modifier = Modifier.onGloballyPositioned { setRemoveButtonCoordinates(it) } ) { RemoveButtonContent(spacerModifier) } } else { OutlinedButton( enabled = removeEnabled, onClick = onRemoveClicked, colors = ButtonDefaults.outlinedButtonColors( contentColor = colors.primary, disabledContentColor = colors.primary ), border = BorderStroke(width = 1.0.dp, color = colors.primary), colors = filledButtonColors(), contentPadding = Dimensions.ButtonPadding, modifier = Modifier.graphicsLayer { alpha = removeButtonAlpha } .onGloballyPositioned { setRemoveButtonCoordinates(it) } .align(Alignment.Center) ) { RemoveButtonContent(spacerModifier) } } if (!removeEnabled) { Button( modifier = Modifier.align(Alignment.CenterEnd), onClick = onEditDone, colors = filledButtonColors(), contentPadding = Dimensions.ButtonPadding ) { Icon( Icons.Default.Check, stringResource(id = R.string.hub_mode_editing_exit_button_text) ) Spacer(spacerModifier) Text( text = stringResource(R.string.hub_mode_editing_exit_button_text), ) } } } } @OptIn(ExperimentalAnimationApi::class) @Composable Loading Loading @@ -762,7 +750,7 @@ private fun PopupOnDismissCtaTile(onHidePopup: () -> Unit) { @Composable private fun RemoveButtonContent(spacerModifier: Modifier) { Icon(Icons.Outlined.Delete, stringResource(R.string.button_to_remove_widget)) Icon(Icons.Default.Close, stringResource(R.string.button_to_remove_widget)) Spacer(spacerModifier) Text( text = stringResource(R.string.button_to_remove_widget), Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +36 −48 Original line number Diff line number Diff line Loading @@ -59,7 +59,8 @@ import androidx.compose.foundation.lazy.grid.rememberLazyGridState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.outlined.Delete import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.outlined.Edit import androidx.compose.material.icons.outlined.TouchApp import androidx.compose.material.icons.outlined.Widgets Loading Loading @@ -277,7 +278,6 @@ fun CommunalHub( if (viewModel.isEditMode && onOpenWidgetPicker != null && onEditDone != null) { Toolbar( isDraggingToRemove = isDraggingToRemove, setToolbarSize = { toolbarSize = it }, setRemoveButtonCoordinates = { removeButtonCoordinates = it }, onEditDone = onEditDone, Loading Loading @@ -577,7 +577,6 @@ private fun LockStateIcon( */ @Composable private fun Toolbar( isDraggingToRemove: Boolean, removeEnabled: Boolean, onRemoveClicked: () -> Unit, setToolbarSize: (toolbarSize: IntSize) -> Unit, Loading @@ -591,7 +590,7 @@ private fun Toolbar( label = "RemoveButtonAlphaAnimation" ) Row( Box( modifier = Modifier.fillMaxWidth() .padding( Loading @@ -600,11 +599,12 @@ private fun Toolbar( end = Dimensions.ToolbarPaddingHorizontal, ) .onSizeChanged { setToolbarSize(it) }, horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { val spacerModifier = Modifier.width(ButtonDefaults.IconSpacing) if (!removeEnabled) { Button( modifier = Modifier.align(Alignment.CenterStart), onClick = onOpenWidgetPicker, colors = filledButtonColors(), contentPadding = Dimensions.ButtonPadding Loading @@ -615,53 +615,41 @@ private fun Toolbar( text = stringResource(R.string.hub_mode_add_widget_button_text), ) } } val colors = LocalAndroidColorScheme.current if (isDraggingToRemove) { if (removeEnabled) { Button( // Button is disabled to make it non-clickable enabled = false, onClick = {}, colors = ButtonDefaults.buttonColors( disabledContainerColor = colors.primary, disabledContentColor = colors.onPrimary, ), contentPadding = Dimensions.ButtonPadding, modifier = Modifier.onGloballyPositioned { setRemoveButtonCoordinates(it) } ) { RemoveButtonContent(spacerModifier) } } else { OutlinedButton( enabled = removeEnabled, onClick = onRemoveClicked, colors = ButtonDefaults.outlinedButtonColors( contentColor = colors.primary, disabledContentColor = colors.primary ), border = BorderStroke(width = 1.0.dp, color = colors.primary), colors = filledButtonColors(), contentPadding = Dimensions.ButtonPadding, modifier = Modifier.graphicsLayer { alpha = removeButtonAlpha } .onGloballyPositioned { setRemoveButtonCoordinates(it) } .align(Alignment.Center) ) { RemoveButtonContent(spacerModifier) } } if (!removeEnabled) { Button( modifier = Modifier.align(Alignment.CenterEnd), onClick = onEditDone, colors = filledButtonColors(), contentPadding = Dimensions.ButtonPadding ) { Icon( Icons.Default.Check, stringResource(id = R.string.hub_mode_editing_exit_button_text) ) Spacer(spacerModifier) Text( text = stringResource(R.string.hub_mode_editing_exit_button_text), ) } } } } @OptIn(ExperimentalAnimationApi::class) @Composable Loading Loading @@ -762,7 +750,7 @@ private fun PopupOnDismissCtaTile(onHidePopup: () -> Unit) { @Composable private fun RemoveButtonContent(spacerModifier: Modifier) { Icon(Icons.Outlined.Delete, stringResource(R.string.button_to_remove_widget)) Icon(Icons.Default.Close, stringResource(R.string.button_to_remove_widget)) Spacer(spacerModifier) Text( text = stringResource(R.string.button_to_remove_widget), Loading