diff --git a/concrete/src/main/kotlin/glass/yasan/concrete/component/Preference.kt b/concrete/src/main/kotlin/glass/yasan/concrete/component/Preference.kt index 67673b2..7661227 100644 --- a/concrete/src/main/kotlin/glass/yasan/concrete/component/Preference.kt +++ b/concrete/src/main/kotlin/glass/yasan/concrete/component/Preference.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.Dp import glass.yasan.concrete.theme.ConcreteTheme import glass.yasan.spine.compose.foundation.grid @@ -18,11 +19,11 @@ public fun Preference( title: @Composable () -> Unit, modifier: Modifier = Modifier, description: @Composable (() -> Unit)? = null, - applyPaddings: Boolean = true, + paddingVertical: Dp = 2.grid, + paddingHorizontal: Dp = 2.grid, start: @Composable (() -> Unit)? = null, end: @Composable (() -> Unit)? = null, ) { - val paddingValue = if (applyPaddings) 2.grid else 0.grid TopBar( modifier = modifier, @@ -30,13 +31,16 @@ public fun Preference( Row( modifier = Modifier .fillMaxWidth() - .padding(paddingValue), + .padding( + horizontal = paddingHorizontal, + vertical = paddingVertical, + ), verticalAlignment = Alignment.CenterVertically, ) { start?.let { it() } Column( modifier = Modifier.weight(1f), - ){ + ) { title() description?.let { it() } } @@ -45,6 +49,30 @@ public fun Preference( } } +@Composable +public fun Preference( + title: @Composable () -> Unit, + modifier: Modifier = Modifier, + description: @Composable (() -> Unit)? = null, + applyPaddings: Boolean = true, + start: @Composable (() -> Unit)? = null, + end: @Composable (() -> Unit)? = null, +) { + val paddingHorizontal = if (applyPaddings) 2.grid else 0.grid + val paddingVertical = if (applyPaddings) 1.grid else 0.grid + + Preference( + title = title, + modifier = modifier, + description = description, + paddingVertical = paddingVertical, + paddingHorizontal = paddingHorizontal, + start = start, + end = end, + ) +} + + // region Preview @Preview