File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
modalsheet/src/main/kotlin/dev/hrach/navigation/modalsheet Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import android.window.OnBackInvokedCallback
1313import android.window.OnBackInvokedDispatcher
1414import androidx.activity.BackEventCompat
1515import androidx.activity.ComponentDialog
16+ import androidx.activity.addCallback
1617import androidx.activity.setViewTreeOnBackPressedDispatcherOwner
1718import androidx.annotation.DoNotInline
1819import androidx.annotation.RequiresApi
@@ -309,6 +310,17 @@ internal class ModalSheetDialogWrapper(
309310 dialogLayout.setViewTreeOnBackPressedDispatcherOwner(this )
310311 // Initial setup
311312 updateParameters(securePolicy, layoutDirection, darkThemeEnabled)
313+
314+ // Due to how the onDismissRequest callback works
315+ // (it enforces a just-in-time decision on whether to update the state to hide the dialog)
316+ // we need to unconditionally add a callback here that is always enabled,
317+ // meaning we'll never get a system UI controlled predictive back animation
318+ // for these dialogs
319+ onBackPressedDispatcher.addCallback(this ) {
320+ scope.launch {
321+ onPredictiveBack.value.invoke(flowOf())
322+ }
323+ }
312324 }
313325
314326 private fun setLayoutDirection (layoutDirection : LayoutDirection ) {
You can’t perform that action at this time.
0 commit comments