mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-07 19:14:12 +08:00
feat: add initializer for Modifier
This commit is contained in:
@@ -68,6 +68,7 @@ data class AreaBoxStyle(
|
||||
@Composable
|
||||
fun AreaBox(
|
||||
modifier: Modifier = Modifier,
|
||||
initializer: Modifier.() -> Modifier = { Modifier },
|
||||
color: Color = AreaBox.color,
|
||||
style: AreaBoxStyle = AreaBox.style,
|
||||
contentAlignment: Alignment = Alignment.TopStart,
|
||||
@@ -79,7 +80,7 @@ fun AreaBox(
|
||||
LocalAreaBoxShape provides style.shape
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.box(style, color, modifier),
|
||||
modifier = Modifier.box(style, color, modifier, initializer),
|
||||
contentAlignment = contentAlignment,
|
||||
propagateMinConstraints = propagateMinConstraints,
|
||||
content = content
|
||||
@@ -90,6 +91,7 @@ fun AreaBox(
|
||||
@Composable
|
||||
fun AreaRow(
|
||||
modifier: Modifier = Modifier,
|
||||
initializer: Modifier.() -> Modifier = { Modifier },
|
||||
color: Color = AreaBox.color,
|
||||
style: AreaBoxStyle = AreaBox.style,
|
||||
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
|
||||
@@ -101,7 +103,7 @@ fun AreaRow(
|
||||
LocalAreaBoxShape provides style.shape
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.box(style, color, modifier),
|
||||
modifier = Modifier.box(style, color, modifier, initializer),
|
||||
horizontalArrangement = horizontalArrangement,
|
||||
verticalAlignment = verticalAlignment,
|
||||
content = content
|
||||
@@ -112,6 +114,7 @@ fun AreaRow(
|
||||
@Composable
|
||||
fun AreaColumn(
|
||||
modifier: Modifier = Modifier,
|
||||
initializer: Modifier.() -> Modifier = { Modifier },
|
||||
color: Color = AreaBox.color,
|
||||
style: AreaBoxStyle = AreaBox.style,
|
||||
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
|
||||
@@ -123,7 +126,7 @@ fun AreaColumn(
|
||||
LocalAreaBoxShape provides style.shape
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.box(style, color, modifier),
|
||||
modifier = Modifier.box(style, color, modifier, initializer),
|
||||
verticalArrangement = verticalArrangement,
|
||||
horizontalAlignment = horizontalAlignment,
|
||||
content = content
|
||||
@@ -135,7 +138,9 @@ private fun Modifier.box(
|
||||
style: AreaBoxStyle,
|
||||
color: Color,
|
||||
modifier: Modifier,
|
||||
) = shadow(style.shadowSize, style.shape)
|
||||
initializer: Modifier.() -> Modifier
|
||||
) = initializer()
|
||||
.shadow(style.shadowSize, style.shape)
|
||||
.clip(style.shape)
|
||||
.background(color, style.shape)
|
||||
.borderOrNot(style.border, style.shape)
|
||||
|
@@ -58,6 +58,7 @@ data class SurfaceStyle(
|
||||
@Composable
|
||||
fun Surface(
|
||||
modifier: Modifier = Modifier,
|
||||
initializer: Modifier.() -> Modifier = { Modifier },
|
||||
colors: SurfaceColors = Surface.colors,
|
||||
style: SurfaceStyle = Surface.style,
|
||||
content: @Composable BoxScope.() -> Unit
|
||||
@@ -67,14 +68,16 @@ fun Surface(
|
||||
backgroundPrimary = colors.backgroundColor,
|
||||
textPrimary = colors.contentColor
|
||||
)
|
||||
) { Box(Modifier.surface(colors, style, modifier), content = content) }
|
||||
) { Box(Modifier.surface(colors, style, modifier, initializer), content = content) }
|
||||
}
|
||||
|
||||
private fun Modifier.surface(
|
||||
colors: SurfaceColors,
|
||||
style: SurfaceStyle,
|
||||
modifier: Modifier
|
||||
) = background(colors.backgroundColor)
|
||||
modifier: Modifier,
|
||||
initializer: Modifier.() -> Modifier
|
||||
) = initializer()
|
||||
.background(colors.backgroundColor)
|
||||
.then(modifier)
|
||||
.padding(
|
||||
top = style.topPadding.orElse() ?: style.padding,
|
||||
|
Reference in New Issue
Block a user