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

Commit 6e4ca3e9 authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Finish Volume Panel styling" into main

parents ff0bef4b 1d649116
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ object ComposeFacade : BaseComposeFacade {
    override fun setVolumePanelActivityContent(
        activity: ComponentActivity,
        viewModel: VolumePanelViewModel,
        onDismissAnimationFinished: () -> Unit,
        onDismiss: () -> Unit,
    ) {
        throwComposeUnavailableError()
    }
+2 −2
Original line number Diff line number Diff line
@@ -102,12 +102,12 @@ object ComposeFacade : BaseComposeFacade {
    override fun setVolumePanelActivityContent(
        activity: ComponentActivity,
        viewModel: VolumePanelViewModel,
        onDismissAnimationFinished: () -> Unit,
        onDismiss: () -> Unit,
    ) {
        activity.setContent {
            VolumePanelRoot(
                viewModel = viewModel,
                onDismissAnimationFinished = onDismissAnimationFinished,
                onDismiss = onDismiss,
            )
        }
    }
+9 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@@ -49,7 +51,13 @@ constructor(
            horizontalArrangement = Arrangement.SpaceBetween,
            verticalAlignment = Alignment.CenterVertically,
        ) {
            PlatformOutlinedButton(onClick = viewModel::onSettingsClicked) {
            PlatformOutlinedButton(
                onClick = viewModel::onSettingsClicked,
                colors =
                    ButtonDefaults.outlinedButtonColors(
                        contentColor = MaterialTheme.colorScheme.onSurface,
                    ),
            ) {
                Text(text = stringResource(R.string.volume_panel_dialog_settings_button))
            }
            PlatformButton(onClick = viewModel::onDoneClicked) {
+74 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.volume.panel.ui.composable

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.fillMaxWidth
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.android.systemui.volume.panel.ui.layout.ComponentsLayout

@Composable
fun VolumePanelComposeScope.HorizontalVolumePanelContent(
    layout: ComponentsLayout,
    modifier: Modifier = Modifier,
) {
    val spacing = 20.dp
    Row(modifier = modifier, horizontalArrangement = Arrangement.spacedBy(space = spacing)) {
        Column(
            modifier = Modifier.weight(1f),
            verticalArrangement = Arrangement.spacedBy(spacing)
        ) {
            for (component in layout.contentComponents) {
                AnimatedVisibility(component.isVisible) {
                    with(component.component as ComposeVolumePanelUiComponent) { Content(Modifier) }
                }
            }
        }

        Column(
            modifier = Modifier.weight(1f),
            verticalArrangement = Arrangement.spacedBy(space = spacing, alignment = Alignment.Top)
        ) {
            for (component in layout.headerComponents) {
                AnimatedVisibility(component.isVisible) {
                    with(component.component as ComposeVolumePanelUiComponent) {
                        Content(Modifier.weight(1f))
                    }
                }
            }
            Row(
                modifier = Modifier.fillMaxWidth().wrapContentHeight(),
                horizontalArrangement = Arrangement.spacedBy(spacing),
            ) {
                for (component in layout.footerComponents) {
                    AnimatedVisibility(component.isVisible) {
                        with(component.component as ComposeVolumePanelUiComponent) {
                            Content(Modifier.weight(1f))
                        }
                    }
                }
            }
        }
    }
}
+9 −5
Original line number Diff line number Diff line
@@ -16,17 +16,21 @@

package com.android.systemui.volume.panel.ui.composable

import android.content.res.Configuration
import android.content.res.Configuration.Orientation
import com.android.systemui.volume.panel.ui.viewmodel.VolumePanelState

class VolumePanelComposeScope(private val state: VolumePanelState) {

    /**
     * Layout orientation of the panel. It doesn't necessarily aligns with the device orientation,
     * because in some cases we want to show bigger version of a portrait orientation when the
     * device is in landscape.
     */
    /** Layout orientation of the panel. This aligns with the device orientation. */
    @Orientation
    val orientation: Int
        get() = state.orientation

    /** Is true when Volume Panel is using wide-screen layout and false the otherwise. */
    val isWideScreen: Boolean
        get() = state.isWideScreen
}

val VolumePanelComposeScope.isPortrait: Boolean
    get() = orientation == Configuration.ORIENTATION_PORTRAIT
Loading