Mirror default Navigation3 push/pop transitions on iOS in RTL layouts - #3346
Open
Mohamad Jaber (mhammadjaber00) wants to merge 1 commit into
Open
Conversation
The iOS defaultTransitionSpec/defaultPopTransitionSpec slid with the physical SlideDirection.Left/Right, ignoring LayoutDirection, so an RTL push entered from the right like in LTR while a native UINavigationController push mirrors. Use Start/End, which resolve through LayoutDirection and flip the parallax offsets automatically; LTR behavior is unchanged. The predictive pop spec is already direction-aware via its swipe edge parameter and other platform defaults do not slide. Test: NavDisplayLayoutDirectionTest (iosTest) asserts the incoming entry's edge for default push and pop under LTR and RTL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The iOS
defaultTransitionSpec()anddefaultPopTransitionSpec()inNavDisplay.ios.ktslide using the physicalSlideDirection.Left/Right, which ignore the composition'sLayoutDirection. In an RTL layout (Arabic/Hebrew locales) a push therefore enters from the physical right — exactly as in LTR — while a nativeUINavigationControllerpush mirrors and enters from the left. To an RTL user the default push animation reads as a back navigation.This replaces
Left/Rightwith the direction-awareStart/End:Start; outgoing slides towardStartwith the existingit / 4parallax andveilOutEnd, keepinginitialOffset = { it / 4 }andunveilInStart/Endresolve throughLayoutDirectionand flip the computed offsets automatically, so the offset lambdas, duration, and easing are untouched. LTR behavior is pixel-identical (Start==Left,End==Rightin LTR).defaultPredictivePopTransitionSpec()is already direction-aware via the swipe edge parameter (made RTL-correct for the gesture in #3196) and is not changed. The other platform actuals are unaffected: the Android default is a fade, and desktop/macOS/web useEnterTransition.None/ExitTransition.None.Adds
NavDisplayLayoutDirectionTestin a newiosTestsource set for:navigation3:navigation3-ui, asserting the incoming entry's edge for default push and pop under both LTR and RTL (frame-stepped clock, unclipped bounds). The ui-test dependency is wired the same way:navigation:navigation-composewiresproject(":compose:ui:ui-test")for its compose tests.Fixes: https://youtrack.jetbrains.com/issue/CMP-10703/Navigation3-default-push-pop-transitions-on-iOS-are-not-mirrored-in-RTL-layouts
Testing
NavDisplayLayoutDirectionTest(iosTest) — default push/pop enter edges under LTR and RTL. Run on an iOS simulator against the currently publishednavigation3-uidefaults, both LTR cases pass and both RTL cases fail (push incoming appears a full width off the right edge, pop incoming a quarter width off the left), demonstrating the test catches the bug; with this change all four pass.ContentTransforms driven throughAnimatedContentunder LTR and RTL —Left/Rightspecs animate identically in both directions,Start/Endspecs keep LTR unchanged and mirror in RTL.Release Notes
Fixes - iOS
UINavigationControllerbehavior