mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 19:21:51 +01:00
ChapterNavigator: Fix haptic feedback (#9458)
This commit is contained in:
parent
08e4863d94
commit
fce9cb820c
@ -1,6 +1,8 @@
|
||||
package eu.kanade.presentation.reader
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsDraggedAsState
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
@ -19,6 +21,9 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.surfaceColorAtElevation
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
@ -87,6 +92,13 @@ fun ChapterNavigator(
|
||||
) {
|
||||
Text(text = currentPage.toString())
|
||||
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
val sliderDragged by interactionSource.collectIsDraggedAsState()
|
||||
LaunchedEffect(currentPage) {
|
||||
if (sliderDragged) {
|
||||
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||
}
|
||||
}
|
||||
Slider(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
@ -96,8 +108,8 @@ fun ChapterNavigator(
|
||||
steps = totalPages,
|
||||
onValueChange = {
|
||||
onSliderValueChange(it.toInt() - 1)
|
||||
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||
},
|
||||
interactionSource = interactionSource,
|
||||
)
|
||||
|
||||
Text(text = totalPages.toString())
|
||||
|
Loading…
Reference in New Issue
Block a user