mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
refactor: decoupling padding in TextField
This commit is contained in:
@@ -125,6 +125,10 @@ fun TextField(
|
|||||||
focused || hovered -> style.borderInactive
|
focused || hovered -> style.borderInactive
|
||||||
else -> style.borderInactive
|
else -> style.borderInactive
|
||||||
}.copy(animatedBorderWidth, SolidColor(animatedBorderColor))
|
}.copy(animatedBorderWidth, SolidColor(animatedBorderColor))
|
||||||
|
val topPadding = style.topPadding.orElse() ?: style.padding
|
||||||
|
val startPadding = style.startPadding.orElse() ?: style.padding
|
||||||
|
val bottomPadding = style.bottomPadding.orElse() ?: style.padding
|
||||||
|
val endPadding = style.endPadding.orElse() ?: style.padding
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.textField(
|
modifier = Modifier.textField(
|
||||||
colors = colors,
|
colors = colors,
|
||||||
@@ -136,8 +140,16 @@ fun TextField(
|
|||||||
),
|
),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
header?.invoke()
|
header?.also { Box(modifier = Modifier.padding(start = startPadding)) { it() } }
|
||||||
Box(modifier = Modifier.weight(1f, fill = false)) {
|
Box(
|
||||||
|
modifier = Modifier.weight(1f, fill = false)
|
||||||
|
.padding(
|
||||||
|
top = topPadding,
|
||||||
|
start = startPadding,
|
||||||
|
bottom = bottomPadding,
|
||||||
|
end = endPadding
|
||||||
|
)
|
||||||
|
) {
|
||||||
TextFieldStyle(colors) {
|
TextFieldStyle(colors) {
|
||||||
BasicTextField(
|
BasicTextField(
|
||||||
value = value,
|
value = value,
|
||||||
@@ -165,7 +177,7 @@ fun TextField(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
footer?.invoke()
|
footer?.also { Box(modifier = Modifier.padding(end = endPadding)) { it() } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,12 +217,6 @@ private fun Modifier.textField(
|
|||||||
.background(colors.backgroundColor, style.shape)
|
.background(colors.backgroundColor, style.shape)
|
||||||
.borderOrNot(border, style.shape)
|
.borderOrNot(border, style.shape)
|
||||||
.then(modifier)
|
.then(modifier)
|
||||||
.padding(
|
|
||||||
top = style.topPadding.orElse() ?: style.padding,
|
|
||||||
start = style.startPadding.orElse() ?: style.padding,
|
|
||||||
bottom = style.bottomPadding.orElse() ?: style.padding,
|
|
||||||
end = style.endPadding.orElse() ?: style.padding
|
|
||||||
)
|
|
||||||
|
|
||||||
object TextField {
|
object TextField {
|
||||||
val colors: TextFieldColors
|
val colors: TextFieldColors
|
||||||
|
Reference in New Issue
Block a user