feat(ios): mirror the side drawer for right-to-left layouts - #57
Open
3adeling wants to merge 1 commit into
Open
Conversation
The drawer host hand-rolls its geometry with physical `.offset(x:)` math and drag-translation signs, which SwiftUI's `.layoutDirection` environment does not mirror on its own. Read `@Environment(\.layoutDirection)` and invert the edge, offsets, and gesture thresholds so the drawer opens from the trailing (right) edge in RTL while LTR behavior is unchanged. - Drawer pins to leading (LTR) / trailing (RTL) via a derived alignment. - Content slide and modal-drawer slide use a direction sign (`openSign`). - Edge-swipe open / drag-close use direction-agnostic translation checks. - The edge detector is now positioned at the leading/trailing edge and its `ignoresSafeArea` edge follows the direction. - settleOpen/settleClose map translation + velocity onto the "open" axis. The logical ☰ button (`.topLeading` / `.padding(.leading)`) already flips automatically, so no change is needed there — it now lines up with the mirrored drawer.
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.
Summary
Mirrors the iOS side drawer for right-to-left layouts. This is the
mobile-uicompanion to the opt-in RTL support landed innativephp/mobile-air(PR #362).NativeUIDrawerHosthand-rolls its geometry with physical.offset(x:)math and drag-translation signs. SwiftUI's.layoutDirectionenvironment does not mirror those — it only flips logical.leading/.trailingalignment. As a result, when core sets.environment(\.layoutDirection, .rightToLeft):.topLeading+.padding(.leading)are logical), butChanges
NativeUIDrawerHost.swiftnow reads@Environment(\.layoutDirection)and inverts every physical direction:.leading(LTR) /.trailing(RTL) via a deriveddrawerAlignment.openSign(+1 LTR / -1 RTL).ignoresSafeAreaedge follows the direction.settleOpen/settleClosemap translation + predicted velocity onto the "open" axis, so threshold and flick-velocity checks are direction-agnostic.The ☰ button needs no change — its logical
.topLeading/.padding(.leading)already flip and now line up with the mirrored drawer.Compatibility
openSign == 1).Note on testing
mobile-uiCI runs PHP-only (pint+pest) and has no Swift test target for the renderers, so this change is validated by review rather than an automated native test.