Skip to content

Commit 80a9499

Browse files
authored
Re-add back gesture handler after end of transition animation (#2046)
Due to iOS specifics, it changes container view that used for back gesture handling after the end of modal transition animation. Fixes https://youtrack.jetbrains.com/issue/CMP-7765/iOS-Back-handler.-Doesnt-work-after-opening-video-player-LocalUIViewController ## Release Notes ### Fixes - iOS - _(prerelease fix)_ Fix back gesture handling after modal view controller dismissal
1 parent 27481b8 commit 80a9499

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/backhandler/UIKitBackGestureDispatcher.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ internal class UIKitBackGestureDispatcher(
9393

9494
fun onDidMoveToWindow(window: UIWindow?, composeRootView: UIView) {
9595
if (enableBackGesture) {
96-
if (window == null) {
97-
removeGestureListeners()
98-
} else {
96+
removeGestureListeners()
97+
if (window != null) {
9998
var view: UIView = composeRootView
10099
while (view.superview != window) {
101100
view = requireNotNull(view.superview) {

Diff for: compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/ComposeHostingViewController.uikit.kt

+4
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ internal class ComposeHostingViewController(
246246
mediator?.sceneDidAppear()
247247
layers?.viewDidAppear()
248248
configuration.delegate.viewDidAppear(animated)
249+
250+
// Because the container view can change during the modal transition animation,
251+
// the gesture handlers are added back when the animation ends.
252+
backGestureDispatcher.onDidMoveToWindow(view.window, rootView)
249253
}
250254

251255
@Suppress("DEPRECATION")

0 commit comments

Comments
 (0)