Вот текущий код:
Код: Выделить всё
// range is a value from the backend which can be different types, when it is a number Gson deserializes it as a double
val inputRange = (range.minValue as Double).toFloat()..(range.maxValue as Double).toFloat()
val sliderState = remember {
RangeSliderState(
activeRangeStart = inputRange.start,
activeRangeEnd = inputRange.endInclusive,
steps = (inputRange.endInclusive - inputRange.start).toInt() - 1,
valueRange = inputRange,
onValueChangeFinished = {}
)
}
val startInteractionSource = remember {
MutableInteractionSource()
}
val endInteractionSource = remember {
MutableInteractionSource()
}
androidx.compose.material3.RangeSlider(
state = sliderState,
startInteractionSource = startInteractionSource,
endInteractionSource = endInteractionSource,
modifier = Modifier
.padding(horizontal = 16.dp)
.padding(bottom = 16.dp),
startThumb = {
Label(
label = {
PlainTooltip {
Text(
text = it.activeRangeStart.toString(),
modifier = Modifier.padding(horizontal = 4.dp),
textAlign = TextAlign.Center
)
}
},
interactionSource = startInteractionSource,
isPersistent = true
) {
SliderDefaults.Thumb(interactionSource = startInteractionSource)
}
},
endThumb = {
Label(
label = {
PlainTooltip {
Text(
text = sliderState.activeRangeEnd.toString(),
modifier = Modifier.padding(horizontal = 4.dp),
textAlign = TextAlign.Center
)
}
},
interactionSource = endInteractionSource,
isPersistent = true
) {
SliderDefaults.Thumb(interactionSource = endInteractionSource)
}
}
)
Две точки не являются целыми числами.
Когда оба больших пальца оказываются на одном из нецелых чисел, происходит сбой
Код: Выделить всё
java.lang.IllegalArgumentException: start(673.12866) must be
Подробнее здесь: [url]https://stackoverflow.com/questions/78669151/jetpack-compose-rangeslider-crash-for-discrete-values[/url]
Мобильная версия