Added null safety to 'steps' in Slider object

This commit is contained in:
tristancorbellari 2024-01-09 09:39:31 +02:00
parent 32416efe50
commit 9b35f31afa
2 changed files with 3 additions and 3 deletions

View file

@ -51,7 +51,7 @@ sealed class Preference {
val value: Int, val value: Int,
val min: Int = 0, val min: Int = 0,
val max: Int, val max: Int,
val steps: Int = 0, val steps: Int? = null,
override val title: String = "", override val title: String = "",
override val subtitle: String? = null, override val subtitle: String? = null,
override val icon: ImageVector? = null, override val icon: ImageVector? = null,

View file

@ -161,7 +161,7 @@ fun SliderItem(
onChange: (Int) -> Unit, onChange: (Int) -> Unit,
max: Int, max: Int,
min: Int = 0, min: Int = 0,
steps: Int = 0, steps: Int? = null,
) { ) {
val haptic = LocalHapticFeedback.current val haptic = LocalHapticFeedback.current
@ -194,7 +194,7 @@ fun SliderItem(
}, },
modifier = Modifier.weight(1.5f), modifier = Modifier.weight(1.5f),
valueRange = min.toFloat()..max.toFloat(), valueRange = min.toFloat()..max.toFloat(),
steps = if (steps > 0) steps else max - min, steps = steps ?: (max - min),
) )
} }
} }