mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-29 16:33:15 -05:00
ChapterNavigator: Fix haptic feedback (#9458)
This commit is contained in:
parent
08e4863d94
commit
fce9cb820c
1 changed files with 13 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
package eu.kanade.presentation.reader
|
package eu.kanade.presentation.reader
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
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.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
@ -19,6 +21,9 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.surfaceColorAtElevation
|
import androidx.compose.material3.surfaceColorAtElevation
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
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.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
@ -87,6 +92,13 @@ fun ChapterNavigator(
|
||||||
) {
|
) {
|
||||||
Text(text = currentPage.toString())
|
Text(text = currentPage.toString())
|
||||||
|
|
||||||
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
|
val sliderDragged by interactionSource.collectIsDraggedAsState()
|
||||||
|
LaunchedEffect(currentPage) {
|
||||||
|
if (sliderDragged) {
|
||||||
|
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||||
|
}
|
||||||
|
}
|
||||||
Slider(
|
Slider(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
|
@ -96,8 +108,8 @@ fun ChapterNavigator(
|
||||||
steps = totalPages,
|
steps = totalPages,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
onSliderValueChange(it.toInt() - 1)
|
onSliderValueChange(it.toInt() - 1)
|
||||||
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
|
||||||
},
|
},
|
||||||
|
interactionSource = interactionSource,
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(text = totalPages.toString())
|
Text(text = totalPages.toString())
|
||||||
|
|
Loading…
Reference in a new issue