From f79f0a7e97a6a754a5fbe621faeda6d0e62993f8 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 14 Oct 2023 22:47:02 -0400 Subject: [PATCH] Add haptics to SliderItem --- .../presentation/core/components/SettingsItems.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt index 08bf2d567b..4f339dc495 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt @@ -40,6 +40,8 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.hapticfeedback.HapticFeedbackType +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import tachiyomi.core.preference.Preference @@ -160,6 +162,8 @@ fun SliderItem( valueText: String, onChange: (Int) -> Unit, ) { + val haptic = LocalHapticFeedback.current + Row( modifier = Modifier .fillMaxWidth() @@ -180,7 +184,13 @@ fun SliderItem( Slider( value = value.toFloat(), - onValueChange = { onChange(it.toInt()) }, + onValueChange = { + val newValue = it.toInt() + if (newValue != value) { + onChange(newValue) + haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove) + } + }, modifier = Modifier.weight(1.5f), valueRange = min.toFloat()..max.toFloat(), steps = max - min,