1 /* <lambda>null2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.volume.panel.ui.composable 18 19 import androidx.compose.animation.AnimatedContent 20 import androidx.compose.animation.AnimatedVisibility 21 import androidx.compose.foundation.layout.Arrangement 22 import androidx.compose.foundation.layout.Column 23 import androidx.compose.foundation.layout.Row 24 import androidx.compose.foundation.layout.fillMaxWidth 25 import androidx.compose.foundation.rememberScrollState 26 import androidx.compose.foundation.verticalScroll 27 import androidx.compose.runtime.Composable 28 import androidx.compose.ui.Alignment 29 import androidx.compose.ui.Modifier 30 import androidx.compose.ui.unit.dp 31 import com.android.systemui.volume.panel.ui.layout.ComponentsLayout 32 33 @Composable 34 fun VolumePanelComposeScope.HorizontalVolumePanelContent( 35 layout: ComponentsLayout, 36 modifier: Modifier = Modifier, 37 ) { 38 val spacing = 20.dp 39 Row(modifier = modifier, horizontalArrangement = Arrangement.spacedBy(space = spacing)) { 40 Column( 41 modifier = Modifier.weight(1f).verticalScroll(rememberScrollState()), 42 verticalArrangement = Arrangement.spacedBy(spacing) 43 ) { 44 for (component in layout.contentComponents) { 45 AnimatedVisibility(component.isVisible) { 46 with(component.component as ComposeVolumePanelUiComponent) { Content(Modifier) } 47 } 48 } 49 } 50 51 Column( 52 modifier = Modifier.weight(1f).verticalScroll(rememberScrollState()), 53 verticalArrangement = Arrangement.spacedBy(space = spacing, alignment = Alignment.Top) 54 ) { 55 for (component in layout.headerComponents) { 56 AnimatedVisibility(visible = component.isVisible) { 57 with(component.component as ComposeVolumePanelUiComponent) { Content(Modifier) } 58 } 59 } 60 AnimatedContent( 61 targetState = layout.footerComponents, 62 label = "FooterComponentAnimation", 63 ) { footerComponents -> 64 Row( 65 modifier = Modifier.fillMaxWidth(), 66 horizontalArrangement = Arrangement.spacedBy(spacing), 67 ) { 68 for (component in footerComponents) { 69 if (component.isVisible) { 70 with(component.component as ComposeVolumePanelUiComponent) { 71 Content(Modifier.weight(1f)) 72 } 73 } 74 } 75 } 76 } 77 } 78 } 79 } 80