mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-07 19:14:12 +08:00
refactor: adjust the priority of Modifier
This commit is contained in:
@@ -87,10 +87,11 @@ fun Button(
|
||||
backgroundColor = Color.Transparent
|
||||
)
|
||||
Box(
|
||||
modifier = modifier.status(enabled)
|
||||
modifier = Modifier.status(enabled)
|
||||
.clip(style.shape)
|
||||
.background(colors.backgroundColor, style.shape)
|
||||
.borderOrNot(style.border, style.shape)
|
||||
.then(modifier)
|
||||
.rippleClickable(
|
||||
enabled = enabled,
|
||||
role = Role.Button,
|
||||
@@ -104,7 +105,7 @@ fun Button(
|
||||
LocalProgressIndicatorColors provides localProgressIndicatorColors
|
||||
) {
|
||||
Row(
|
||||
Modifier.padding(
|
||||
modifier = Modifier.padding(
|
||||
top = style.topPadding.orElse() ?: style.padding,
|
||||
start = style.startPadding.orElse() ?: style.padding,
|
||||
bottom = style.bottomPadding.orElse() ?: style.padding,
|
||||
|
@@ -94,7 +94,7 @@ fun CheckBox(
|
||||
val animatedContentScale by animateFloatAsState(if (hovered) style.hoveredGain else 1f)
|
||||
val animatedContentAlpha by animateFloatAsState(if (checked) 1f else 0f)
|
||||
val animatedContentLayer by animateFloatAsState(if (checked) 1f else 0f)
|
||||
Row(modifier = modifier.status(enabled), verticalAlignment = Alignment.CenterVertically) {
|
||||
Row(modifier = Modifier.status(enabled).then(modifier), verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(
|
||||
modifier = Modifier.clickable(
|
||||
interactionSource = interactionSource,
|
||||
|
@@ -95,7 +95,7 @@ fun RadioButton(
|
||||
val animatedContentScale by animateFloatAsState(if (hovered) style.hoveredGain else 1f)
|
||||
val animatedContentShadow by animateDpAsState(if (selected) style.contentShadowSize else 0.dp)
|
||||
val animatedContentAlpha by animateFloatAsState(if (selected) 1f else 0f)
|
||||
Row(modifier = modifier.status(enabled), verticalAlignment = Alignment.CenterVertically) {
|
||||
Row(modifier = Modifier.status(enabled).then(modifier), verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(
|
||||
modifier = Modifier.clickable(
|
||||
interactionSource = interactionSource,
|
||||
|
@@ -211,7 +211,8 @@ fun Slider(
|
||||
)
|
||||
}
|
||||
Box(
|
||||
modifier = modifier.status(enabled)
|
||||
modifier = Modifier.status(enabled)
|
||||
.then(modifier)
|
||||
.hoverable(interactionSource, enabled)
|
||||
.pointerInput(Unit) {
|
||||
if (enabled) detectTapGestures(
|
||||
|
@@ -67,11 +67,14 @@ fun Surface(
|
||||
backgroundPrimary = colors.backgroundColor,
|
||||
textPrimary = colors.contentColor
|
||||
)
|
||||
) { Box(modifier.surface(colors, style), content = content) }
|
||||
) { Box(Modifier.surface(colors, style).then(modifier), content = content) }
|
||||
}
|
||||
|
||||
private fun Modifier.surface(colors: SurfaceColors, style: SurfaceStyle) =
|
||||
background(colors.backgroundColor).padding(
|
||||
private fun Modifier.surface(
|
||||
colors: SurfaceColors,
|
||||
style: SurfaceStyle
|
||||
) = background(colors.backgroundColor)
|
||||
.padding(
|
||||
top = style.topPadding.orElse() ?: style.padding,
|
||||
start = style.startPadding.orElse() ?: style.padding,
|
||||
bottom = style.bottomPadding.orElse() ?: style.padding,
|
||||
|
@@ -181,7 +181,7 @@ fun Switch(
|
||||
)
|
||||
)
|
||||
}
|
||||
Row(modifier = modifier.status(enabled)) {
|
||||
Row(modifier = Modifier.status(enabled).then(modifier)) {
|
||||
Box(
|
||||
modifier = Modifier.padding(end = contentSpacing)
|
||||
.clickable(enabled = enabled) { onCheckedChange(!checked) }
|
||||
|
@@ -237,13 +237,13 @@ private fun TextFieldDecorationBox(
|
||||
else -> style.borderInactive
|
||||
}.copy(animatedBorderWidth, SolidColor(animatedBorderColor))
|
||||
Box(
|
||||
modifier.textField(
|
||||
Modifier.textField(
|
||||
colors = colors,
|
||||
style = style,
|
||||
border = border,
|
||||
enabled = enabled,
|
||||
interactionSource = interactionSource
|
||||
)
|
||||
).then(modifier)
|
||||
) {
|
||||
Row {
|
||||
header()
|
||||
|
Reference in New Issue
Block a user