From 939fc56ae8c676800f8e4de704bbab9133205b63 Mon Sep 17 00:00:00 2001 From: Alex Schwemler Date: Wed, 6 May 2026 20:38:20 +0200 Subject: [PATCH] feat: added reusable slider step functions --- .../features/settings/PlaybackSettingsPage.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/PlaybackSettingsPage.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/PlaybackSettingsPage.kt index 40c2dfb6..862446ba 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/PlaybackSettingsPage.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/settings/PlaybackSettingsPage.kt @@ -64,6 +64,7 @@ import kotlinx.coroutines.launch import nuvio.composeapp.generated.resources.* import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.stringResource +import kotlin.math.roundToInt internal fun LazyListScope.playbackSettingsContent( isTablet: Boolean, @@ -103,6 +104,26 @@ internal fun LazyListScope.playbackSettingsContent( } } +private fun formatStep(value: Float): String { + return if (value % 1f == 0f) { + value.toInt().toString() + } else { + value.toString() + } +} + +fun snapToStep(value: Float, step: Float): Float { + return (value / step).roundToInt() * step +} + +fun calculateSteps( + min: Float, + max: Float, + stepSize: Float +): Int { + val totalSteps = ((max - min) / stepSize).roundToInt() + return (totalSteps - 1).coerceAtLeast(0) +} @Composable private fun PlaybackSettingsSection( isTablet: Boolean,