fix: clamp scale midpoint and handle edge case in wheel session answer UI

This commit is contained in:
null 2026-06-18 01:17:47 -05:00
parent c6df885e1e
commit 7926289153
2 changed files with 5 additions and 2 deletions

View File

@ -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),

View File

@ -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
}