diff options
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VerticalVolumePanelContent.kt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VerticalVolumePanelContent.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VerticalVolumePanelContent.kt index dd767817a5ae..9ea20b9da4b6 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VerticalVolumePanelContent.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/ui/composable/VerticalVolumePanelContent.kt @@ -20,6 +20,7 @@ import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.rememberScrollState @@ -27,6 +28,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import androidx.compose.ui.util.fastSumBy import com.android.systemui.volume.panel.ui.layout.ComponentsLayout @Composable @@ -53,6 +55,14 @@ fun VolumePanelComposeScope.VerticalVolumePanelContent( modifier = Modifier.fillMaxWidth().wrapContentHeight(), horizontalArrangement = Arrangement.spacedBy(if (isLargeScreen) 28.dp else 20.dp), ) { + val visibleComponentsCount = + layout.footerComponents.fastSumBy { if (it.isVisible) 1 else 0 } + + // Center footer component if there is only one present + if (visibleComponentsCount == 1) { + Spacer(modifier = Modifier.weight(0.5f)) + } + for (component in layout.footerComponents) { AnimatedVisibility( visible = component.isVisible, @@ -63,6 +73,10 @@ fun VolumePanelComposeScope.VerticalVolumePanelContent( } } } + + if (visibleComponentsCount == 1) { + Spacer(modifier = Modifier.weight(0.5f)) + } } } } |