diff options
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt | 84 |
1 files changed, 36 insertions, 48 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt index 3227611b841d..6fe5cef8b1e3 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt @@ -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 @@ -277,7 +278,6 @@ fun CommunalHub( if (viewModel.isEditMode && onOpenWidgetPicker != null && onEditDone != null) { Toolbar( - isDraggingToRemove = isDraggingToRemove, setToolbarSize = { toolbarSize = it }, setRemoveButtonCoordinates = { removeButtonCoordinates = it }, onEditDone = onEditDone, @@ -577,7 +577,6 @@ private fun LockStateIcon( */ @Composable private fun Toolbar( - isDraggingToRemove: Boolean, removeEnabled: Boolean, onRemoveClicked: () -> Unit, setToolbarSize: (toolbarSize: IntSize) -> Unit, @@ -591,7 +590,7 @@ private fun Toolbar( label = "RemoveButtonAlphaAnimation" ) - Row( + Box( modifier = Modifier.fillMaxWidth() .padding( @@ -600,65 +599,54 @@ private fun Toolbar( end = Dimensions.ToolbarPaddingHorizontal, ) .onSizeChanged { setToolbarSize(it) }, - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically ) { val spacerModifier = Modifier.width(ButtonDefaults.IconSpacing) - Button( - onClick = onOpenWidgetPicker, - colors = filledButtonColors(), - contentPadding = Dimensions.ButtonPadding - ) { - Icon(Icons.Default.Add, stringResource(R.string.hub_mode_add_widget_button_text)) - Spacer(spacerModifier) - Text( - 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) } + modifier = Modifier.align(Alignment.CenterStart), + onClick = onOpenWidgetPicker, + colors = filledButtonColors(), + contentPadding = Dimensions.ButtonPadding ) { - RemoveButtonContent(spacerModifier) + Icon(Icons.Default.Add, stringResource(R.string.hub_mode_add_widget_button_text)) + Spacer(spacerModifier) + Text( + text = stringResource(R.string.hub_mode_add_widget_button_text), + ) } - } else { - OutlinedButton( - enabled = removeEnabled, + } + + if (removeEnabled) { + Button( 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) } } - Button( - onClick = onEditDone, - colors = filledButtonColors(), - contentPadding = Dimensions.ButtonPadding - ) { - Text( - text = stringResource(R.string.hub_mode_editing_exit_button_text), - ) + 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), + ) + } } } } @@ -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), |