mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-07 19:14:12 +08:00
refactor: move decoration style to InnerDecorationBox in TextField
This commit is contained in:
@@ -146,9 +146,12 @@ fun TextField(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
header?.also {
|
||||
Box(modifier = Modifier.textFieldPadding(style, fitStart = true)) {
|
||||
DecorationBoxStyle(animatedDecorTint) { it() }
|
||||
}
|
||||
InnerDecorationBox(
|
||||
decorTint = animatedDecorTint,
|
||||
style = style,
|
||||
header = true,
|
||||
content = it
|
||||
)
|
||||
}
|
||||
Box(modifier = Modifier.weight(1f, fill = false).textFieldPadding(style)) {
|
||||
TextFieldStyle(colors) {
|
||||
@@ -179,9 +182,27 @@ fun TextField(
|
||||
}
|
||||
}
|
||||
footer?.also {
|
||||
Box(modifier = Modifier.textFieldPadding(style, fitEnd = true)) {
|
||||
DecorationBoxStyle(animatedDecorTint) { it() }
|
||||
}
|
||||
InnerDecorationBox(
|
||||
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(
|
||||
colors: TextFieldColors,
|
||||
style: TextFieldStyle,
|
||||
|
Reference in New Issue
Block a user