Skip to content

Commit

Permalink
Improve Preference
Browse files Browse the repository at this point in the history
  • Loading branch information
yasanglass committed Feb 3, 2024
1 parent 3420d98 commit e40c4b0
Showing 1 changed file with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -18,25 +19,28 @@ 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,
) {
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() }
}
Expand All @@ -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
Expand Down

0 comments on commit e40c4b0

Please sign in to comment.