From 3dd541b3676cb8b21fb70c15a1d4b1685934766e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernat=20Borr=C3=A1s?= Date: Fri, 1 Mar 2024 10:43:29 +0100 Subject: [PATCH] Make Divider -> VerticalDivider --- .../ui/internal/SettingsTileScaffold.kt | 123 +++++++++--------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/compose-settings-ui/src/commonMain/kotlin/com/alorma/compose/settings/ui/internal/SettingsTileScaffold.kt b/compose-settings-ui/src/commonMain/kotlin/com/alorma/compose/settings/ui/internal/SettingsTileScaffold.kt index 43bf6922..ae6ed877 100644 --- a/compose-settings-ui/src/commonMain/kotlin/com/alorma/compose/settings/ui/internal/SettingsTileScaffold.kt +++ b/compose-settings-ui/src/commonMain/kotlin/com/alorma/compose/settings/ui/internal/SettingsTileScaffold.kt @@ -5,9 +5,9 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.material3.Divider import androidx.compose.material3.DividerDefaults import androidx.compose.material3.ListItem +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -15,66 +15,65 @@ import androidx.compose.ui.unit.dp @Composable internal fun SettingsTileScaffold( - enabled: Boolean = true, - title: @Composable () -> Unit, - subtitle: @Composable (() -> Unit)? = null, - icon: (@Composable () -> Unit)? = null, - action: (@Composable (Boolean) -> Unit)? = null, - actionDivider: Boolean = false, + enabled: Boolean = true, + title: @Composable () -> Unit, + subtitle: @Composable (() -> Unit)? = null, + icon: (@Composable () -> Unit)? = null, + action: (@Composable (Boolean) -> Unit)? = null, + actionDivider: Boolean = false, ) { - val minHeight = if (subtitle == null) 72.dp else 88.dp - ListItem( - modifier = Modifier - .defaultMinSize(minHeight = minHeight), - headlineContent = { - WrapContentColor(enabled = enabled) { - title() - } - }, - supportingContent = if (subtitle == null) { - null - } else { - { - WrapContentColor(enabled = enabled) { - subtitle() - } - } - }, - leadingContent = if (icon == null) { - null - } else { - { - WrapContentColor(enabled = enabled) { - icon() - } - } - }, - trailingContent = if (action == null) { - null - } else { - { - Row( - verticalAlignment = Alignment.CenterVertically, - ) { - if (actionDivider) { - val color = DividerDefaults.color.copy( - alpha = if (enabled) { - 1f - } else { - 0.6f - }, - ) - Divider( - color = color, - modifier = Modifier - .padding(vertical = 4.dp) - .width(1.dp), - ) - Spacer(modifier = Modifier.width(2.dp)) - } - action(enabled) - } - } - }, - ) + val minHeight = if (subtitle == null) 72.dp else 88.dp + ListItem( + modifier = Modifier + .defaultMinSize(minHeight = minHeight), + headlineContent = { + WrapContentColor(enabled = enabled) { + title() + } + }, + supportingContent = if (subtitle == null) { + null + } else { + { + WrapContentColor(enabled = enabled) { + subtitle() + } + } + }, + leadingContent = if (icon == null) { + null + } else { + { + WrapContentColor(enabled = enabled) { + icon() + } + } + }, + trailingContent = if (action == null) { + null + } else { + { + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + if (actionDivider) { + val color = DividerDefaults.color.copy( + alpha = if (enabled) { + 1f + } else { + 0.6f + }, + ) + VerticalDivider( + color = color, + modifier = Modifier + .padding(vertical = 4.dp), + ) + Spacer(modifier = Modifier.width(2.dp)) + } + action(enabled) + } + } + }, + ) }