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

Commit b20f4122 authored by Yuchen's avatar Yuchen
Browse files

[expressive design] Fix layout.

- Fix ZeroStatePreference Shape.
- Set min height to Preference.
- Fix title font of SettingsAlertDialogWithIcon.

Test: visual
Bug: 360916599
Flag: EXEMPT bug fix
Change-Id: I929bda58fb22d9bee2ab5ec9d4d3140f3dae7967
parent 0f59b839
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -85,4 +85,6 @@ object SettingsDimension {
    val illustrationMaxHeight = 300.dp
    val illustrationPadding = paddingLarge
    val illustrationCornerRadius = 28.dp

    val preferenceMinHeight = 72.dp
}
+5 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.settingslib.spa.widget.dialog

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
@@ -26,12 +25,13 @@ import androidx.compose.material.icons.filled.WarningAmber
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.window.DialogProperties
import com.android.settingslib.spa.framework.theme.isSpaExpressiveEnabled

@Composable
fun SettingsAlertDialogWithIcon(
@@ -57,7 +57,9 @@ fun SettingsAlertDialogWithIcon(
            title?.let {
                {
                    CenterRow {
                        Text(it, modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center)
                        if (isSpaExpressiveEnabled)
                            Text(it, style = MaterialTheme.typography.bodyLarge)
                        else Text(it)
                    }
                }
            },
+4 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ 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.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
@@ -35,6 +36,7 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.min
import com.android.settingslib.spa.framework.theme.SettingsDimension
import com.android.settingslib.spa.framework.theme.SettingsOpacity.alphaForEnabled
import com.android.settingslib.spa.framework.theme.SettingsShape
@@ -62,7 +64,8 @@ internal fun BaseLayout(
                .semantics(mergeDescendants = true) {}
                .then(
                    if (isSpaExpressiveEnabled)
                        Modifier.clip(SettingsShape.CornerExtraSmall)
                        Modifier.heightIn(min = SettingsDimension.preferenceMinHeight)
                            .clip(SettingsShape.CornerExtraSmall)
                            .background(MaterialTheme.colorScheme.surfaceBright)
                    else Modifier
                )
+29 −17
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settingslib.spa.widget.preference

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
@@ -25,6 +26,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.min
import com.android.settingslib.spa.framework.theme.SettingsDimension
import com.android.settingslib.spa.framework.theme.SettingsShape
import com.android.settingslib.spa.framework.theme.SettingsTheme
@@ -35,13 +37,19 @@ import com.android.settingslib.spa.framework.util.EntryHighlight
fun MainSwitchPreference(model: SwitchPreferenceModel) {
    EntryHighlight {
        Surface(
            modifier = Modifier.padding(SettingsDimension.itemPaddingEnd),
            color = when (model.checked()) {
            modifier =
                Modifier.padding(SettingsDimension.itemPaddingEnd)
                    .then(
                        if (isSpaExpressiveEnabled)
                            Modifier.heightIn(min = SettingsDimension.preferenceMinHeight)
                        else Modifier
                    ),
            color =
                when (model.checked()) {
                    true -> MaterialTheme.colorScheme.primaryContainer
                    else -> MaterialTheme.colorScheme.secondaryContainer
                },
            shape = if (isSpaExpressiveEnabled) CircleShape
            else SettingsShape.CornerExtraLarge,
            shape = if (isSpaExpressiveEnabled) CircleShape else SettingsShape.CornerExtraLarge,
        ) {
            InternalSwitchPreference(
                title = model.title,
@@ -61,16 +69,20 @@ fun MainSwitchPreference(model: SwitchPreferenceModel) {
private fun MainSwitchPreferencePreview() {
    SettingsTheme {
        Column {
            MainSwitchPreference(object : SwitchPreferenceModel {
            MainSwitchPreference(
                object : SwitchPreferenceModel {
                    override val title = "Use Dark theme"
                    override val checked = { true }
                    override val onCheckedChange: (Boolean) -> Unit = {}
            })
            MainSwitchPreference(object : SwitchPreferenceModel {
                }
            )
            MainSwitchPreference(
                object : SwitchPreferenceModel {
                    override val title = "Use Dark theme"
                    override val checked = { false }
                    override val onCheckedChange: (Boolean) -> Unit = {}
            })
                }
            )
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ fun ZeroStatePreference(icon: ImageVector, text: String? = null, description: St
    val zeroStateShape = remember {
        RoundedPolygon.star(
            numVerticesPerRadius = 6,
            innerRadius = 0.75f,
            innerRadius = 0.8f,
            rounding = CornerRounding(0.3f)
        )
    }