mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-12-12 00:33:43 +08:00
refactor: move decoration style to InnerDecorationBox in TextField
This commit is contained in:
@@ -146,9 +146,12 @@ fun TextField(
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
header?.also {
|
header?.also {
|
||||||
Box(modifier = Modifier.textFieldPadding(style, fitStart = true)) {
|
InnerDecorationBox(
|
||||||
DecorationBoxStyle(animatedDecorTint) { it() }
|
decorTint = animatedDecorTint,
|
||||||
}
|
style = style,
|
||||||
|
header = true,
|
||||||
|
content = it
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Box(modifier = Modifier.weight(1f, fill = false).textFieldPadding(style)) {
|
Box(modifier = Modifier.weight(1f, fill = false).textFieldPadding(style)) {
|
||||||
TextFieldStyle(colors) {
|
TextFieldStyle(colors) {
|
||||||
@@ -179,9 +182,27 @@ fun TextField(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
footer?.also {
|
footer?.also {
|
||||||
Box(modifier = Modifier.textFieldPadding(style, fitEnd = true)) {
|
InnerDecorationBox(
|
||||||
DecorationBoxStyle(animatedDecorTint) { it() }
|
decorTint = animatedDecorTint,
|
||||||
}
|
style = style,
|
||||||
|
footer = true,
|
||||||
|
content = it
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun InnerDecorationBox(
|
||||||
|
decorTint: Color,
|
||||||
|
style: TextFieldStyle,
|
||||||
|
header: Boolean = false,
|
||||||
|
footer: Boolean = false,
|
||||||
|
content: @Composable () -> Unit
|
||||||
|
) {
|
||||||
|
Box(modifier = Modifier.textFieldPadding(style, fitStart = header, fitEnd = footer)) {
|
||||||
|
CompositionLocalProvider(LocalIconTint provides decorTint) {
|
||||||
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,13 +229,6 @@ private fun TextFieldStyle(colors: TextFieldColors, content: @Composable () -> U
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun DecorationBoxStyle(decorTint: Color, content: @Composable () -> Unit) {
|
|
||||||
CompositionLocalProvider(LocalIconTint provides decorTint) {
|
|
||||||
content()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Modifier.textField(
|
private fun Modifier.textField(
|
||||||
colors: TextFieldColors,
|
colors: TextFieldColors,
|
||||||
style: TextFieldStyle,
|
style: TextFieldStyle,
|
||||||
|
|||||||
Reference in New Issue
Block a user