mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 18:21:48 +01:00
Add haptics to SliderItem
This commit is contained in:
parent
82a9d36df7
commit
f79f0a7e97
@ -40,6 +40,8 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
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.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import tachiyomi.core.preference.Preference
|
import tachiyomi.core.preference.Preference
|
||||||
@ -160,6 +162,8 @@ fun SliderItem(
|
|||||||
valueText: String,
|
valueText: String,
|
||||||
onChange: (Int) -> Unit,
|
onChange: (Int) -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val haptic = LocalHapticFeedback.current
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@ -180,7 +184,13 @@ fun SliderItem(
|
|||||||
|
|
||||||
Slider(
|
Slider(
|
||||||
value = value.toFloat(),
|
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),
|
modifier = Modifier.weight(1.5f),
|
||||||
valueRange = min.toFloat()..max.toFloat(),
|
valueRange = min.toFloat()..max.toFloat(),
|
||||||
steps = max - min,
|
steps = max - min,
|
||||||
|
Loading…
Reference in New Issue
Block a user