fix: disable not effect in Slider and TextField

This commit is contained in:
2023-11-14 01:59:01 +08:00
parent f5d37462f2
commit 5ef9f21ef2
2 changed files with 6 additions and 3 deletions

View File

@@ -63,7 +63,9 @@ import com.highcapable.flexiui.LocalColors
import com.highcapable.flexiui.LocalShapes import com.highcapable.flexiui.LocalShapes
import com.highcapable.flexiui.LocalSizes import com.highcapable.flexiui.LocalSizes
import com.highcapable.flexiui.utils.borderOrNot import com.highcapable.flexiui.utils.borderOrNot
import com.highcapable.flexiui.utils.status
import kotlin.math.roundToInt import kotlin.math.roundToInt
@Immutable @Immutable
data class SliderColors( data class SliderColors(
val trackInactiveColor: Color, val trackInactiveColor: Color,
@@ -165,9 +167,10 @@ fun Slider(
) )
} }
Box( Box(
modifier = modifier.hoverable(interactionSource) modifier = modifier.status(enabled)
.hoverable(interactionSource, enabled)
.pointerInput(Unit) { .pointerInput(Unit) {
detectTapGestures( if (enabled) detectTapGestures(
onTap = { offset -> onTap = { offset ->
val tapedOffsetX = offset.x - thumbRadius.toPx() val tapedOffsetX = offset.x - thumbRadius.toPx()
offsetX = tapedOffsetX.coerceIn(0f, maxOffset) offsetX = tapedOffsetX.coerceIn(0f, maxOffset)

View File

@@ -267,7 +267,7 @@ private fun Modifier.textField(
enabled: Boolean, enabled: Boolean,
interactionSource: MutableInteractionSource interactionSource: MutableInteractionSource
) = status(enabled) ) = status(enabled)
.hoverable(interactionSource) .hoverable(interactionSource, enabled)
.clip(style.shape) .clip(style.shape)
.background(colors.backgroundColor, style.shape) .background(colors.backgroundColor, style.shape)
.borderOrNot(border, style.shape) .borderOrNot(border, style.shape)