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