Mark
03/05/2024, 1:00 PMonValueChangeFinished
called as soon as the first step is dragged to (even though not released). The drag event then cannot proceed further. https://issuetracker.google.com/issues/232597954#comment5 Note: M2 Slider worked without any problem.Mark
03/05/2024, 1:05 PMval speedState = speedPref.stateFlowIncludingDefaults().collectAsStateWithLifecycle()
val dynamicSpeedState = remember(speedState.value) {
mutableFloatStateOf(speedState.value.toFloat())
}
Slider(
value = dynamicSpeedState.floatValue,
onValueChange = { speed ->
dynamicSpeedState.floatValue = speed
},
onValueChangeFinished = {
// This is called as soon as the value changes even though user still dragging. However, the drag stops at the
// first step.
// Note: commenting out the following code means the drag can continue beyond the first step
scope.launch {
speedPref.write(dynamicSpeedState.floatValue.toInt())
}
},
valueRange = minSpeed.toFloat()..maxSpeed.toFloat(),
steps = (maxSpeed - minSpeed) / incSpeed - 1,
modifier = Modifier.padding(start = 60.dp, end = 8.dp),
enabled = enabled,
)
Mark
03/07/2024, 4:02 AM