fix: clamp scale midpoint and handle edge case in wheel session answer UI
This commit is contained in:
parent
c6df885e1e
commit
7926289153
|
|
@ -391,7 +391,7 @@ private fun AnswerOptions(
|
|||
value = selectedScaleValue.toFloat(),
|
||||
onValueChange = { onScaleChanged(it.toInt()) },
|
||||
valueRange = cfg.minScale.toFloat()..cfg.maxScale.toFloat(),
|
||||
steps = (cfg.maxScale - cfg.minScale - 1).coerceAtLeast(0),
|
||||
steps = if (cfg.maxScale > cfg.minScale) (cfg.maxScale - cfg.minScale - 1).coerceAtLeast(0) else 0,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = SliderDefaults.colors(
|
||||
thumbColor = Color(0xFF56306F),
|
||||
|
|
|
|||
|
|
@ -50,7 +50,10 @@ class WheelSessionViewModel @Inject constructor(
|
|||
private fun defaultScaleValue(question: Question?): Int {
|
||||
val config = question?.answerConfig
|
||||
if (config is app.closer.domain.model.ScaleAnswerConfigImpl) {
|
||||
return (config.config.minScale + config.config.maxScale) / 2
|
||||
val cfg = config.config
|
||||
val midpoint = (cfg.minScale + cfg.maxScale) / 2
|
||||
// Clamp to valid range
|
||||
return midpoint.coerceIn(cfg.minScale..cfg.maxScale)
|
||||
}
|
||||
return 3
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue