mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
fix: no need alpha in inner box
This commit is contained in:
@@ -47,6 +47,7 @@ import androidx.compose.ui.draw.scale
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
|
import androidx.compose.ui.semantics.Role
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.highcapable.flexiui.LocalColors
|
import com.highcapable.flexiui.LocalColors
|
||||||
@@ -94,14 +95,12 @@ fun CheckBox(
|
|||||||
val animatedContentLayer by animateFloatAsState(if (checked) 1f else 0f)
|
val animatedContentLayer by animateFloatAsState(if (checked) 1f else 0f)
|
||||||
val sModifier = if (enabled) modifier else modifier.alpha(0.5f)
|
val sModifier = if (enabled) modifier else modifier.alpha(0.5f)
|
||||||
Row(modifier = sModifier, verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = sModifier, verticalAlignment = Alignment.CenterVertically) {
|
||||||
val cModifier = if (enabled)
|
Box(
|
||||||
Modifier.clickable(
|
modifier = Modifier.clickable(
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
interactionSource = interactionSource
|
interactionSource = interactionSource
|
||||||
) { onCheckedChange(!checked) }
|
) { onCheckedChange(!checked) }
|
||||||
else Modifier.alpha(0.5f)
|
.size(style.strokeSize)
|
||||||
Box(
|
|
||||||
modifier = cModifier.size(style.strokeSize)
|
|
||||||
.scale(animatedStrokeScale)
|
.scale(animatedStrokeScale)
|
||||||
.background(animatedColor, style.shape)
|
.background(animatedColor, style.shape)
|
||||||
.borderOrNot(style.border, style.shape),
|
.borderOrNot(style.border, style.shape),
|
||||||
|
@@ -119,8 +119,8 @@ fun Switch(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Track(content: @Composable RowScope.() -> Unit) {
|
fun Track(content: @Composable RowScope.() -> Unit) {
|
||||||
val cModifier = if (enabled)
|
Row(
|
||||||
Modifier.clickable(
|
modifier = Modifier.clickable(
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
role = Role.Switch
|
role = Role.Switch
|
||||||
@@ -128,11 +128,7 @@ fun Switch(
|
|||||||
distance = maxOffset
|
distance = maxOffset
|
||||||
offsetX = if (checked) 0f else maxOffset
|
offsetX = if (checked) 0f else maxOffset
|
||||||
onCheckedChange(!checked)
|
onCheckedChange(!checked)
|
||||||
}
|
}.background(if (efficientDragging) trackColor else animatedTrackColor, style.trackShape)
|
||||||
else Modifier.alpha(0.5f)
|
|
||||||
Row(
|
|
||||||
modifier = cModifier
|
|
||||||
.background(if (efficientDragging) trackColor else animatedTrackColor, style.trackShape)
|
|
||||||
.borderOrNot(style.trackBorder, style.trackShape)
|
.borderOrNot(style.trackBorder, style.trackShape)
|
||||||
.size(style.trackWidth, style.trackHeight)
|
.size(style.trackWidth, style.trackHeight)
|
||||||
.padding(start = padding, end = padding),
|
.padding(start = padding, end = padding),
|
||||||
|
Reference in New Issue
Block a user