Restore overlay when user cancel the dragging
This commit is contained in:
committed by
Benoit Marty
parent
f55da9027b
commit
5e506be062
@@ -27,6 +27,7 @@ fun MediaViewerFlickToDismiss(
|
||||
onDismiss: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onDragging: () -> Unit = {},
|
||||
onResetting: () -> Unit = {},
|
||||
content: @Composable BoxScope.() -> Unit,
|
||||
) {
|
||||
val flickState = rememberFlickToDismissState(dismissThresholdRatio = 0.1f, rotateOnDrag = false)
|
||||
@@ -37,6 +38,7 @@ fun MediaViewerFlickToDismiss(
|
||||
onDismiss()
|
||||
},
|
||||
onDragging = onDragging,
|
||||
onResetting = onResetting,
|
||||
)
|
||||
FlickToDismiss(
|
||||
state = flickState,
|
||||
@@ -50,9 +52,11 @@ private fun DismissFlickEffects(
|
||||
flickState: FlickToDismissState,
|
||||
onDismissing: suspend (Duration) -> Unit,
|
||||
onDragging: suspend () -> Unit,
|
||||
onResetting: suspend () -> Unit,
|
||||
) {
|
||||
val currentOnDismissing by rememberUpdatedState(onDismissing)
|
||||
val currentOnDragging by rememberUpdatedState(onDragging)
|
||||
val currentOnResetting by rememberUpdatedState(onResetting)
|
||||
|
||||
when (val gestureState = flickState.gestureState) {
|
||||
is FlickToDismissState.GestureState.Dismissing -> {
|
||||
@@ -65,6 +69,11 @@ private fun DismissFlickEffects(
|
||||
currentOnDragging()
|
||||
}
|
||||
}
|
||||
is FlickToDismissState.GestureState.Resetting -> {
|
||||
LaunchedEffect(Unit) {
|
||||
currentOnResetting()
|
||||
}
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,6 +290,9 @@ private fun MediaViewerPage(
|
||||
onDragging = {
|
||||
currentOnShowOverlayChange(false)
|
||||
},
|
||||
onResetting = {
|
||||
currentOnShowOverlayChange(true)
|
||||
},
|
||||
modifier = modifier,
|
||||
) {
|
||||
val downloadedMedia by data.downloadedMedia
|
||||
|
||||
Reference in New Issue
Block a user