Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f91e5dff authored by Anton Potapov's avatar Anton Potapov
Browse files

Center footer component when there is only one available

Flag: aconfig new_volume_panel TRUNKFOOD
Test: manual on a phone and a tablet. Open Volume Panel when there is a
single footer component available
Fixes: 331182713

Change-Id: I560fbef82fbb23bd9d29b27423d7c18614090afb
parent 7e865633
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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))
                }
            }
        }
    }