-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supported right-to-left layout #445
Merged
Merged
Conversation
This file contains 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
Going for new approach - ViewPager for LTR and ViewPager2 for RTL
Want ViewPager2 and ViewPager events to match. ViewPager2 raises an initial page selected that ViewPager doesn't, so ignore if the position is 0 (might be non-zero if controlled tab prop)
If go from A,B,C with B selected and remove A then it selected C instead of B with dataSetChanged. With itemInserted it selected A which matches ViewPager
They don't match ViewPager exactly, e.g., an initial event fires on first render event for tab 0. But can't get them to match exactly because a selected event fires when the recycler view layout runs. Test case is A,B,C and select B and remove C - with ViewPager that fires B once and ViewPager2 fires B twice, the second one coming from the CoordinatorLayout layout runing
When starting a new stack the initial scene fragment wasn't loaded until the view is attached to window. This causes a black background to show when switching tabs with stacks. Instead, ran the first navigation as soon as the scenes are added. Catered for when the stack is loaded without a navigation. In this case don't need a start navigation because the onUpdateAfterTransaction fires after children and keys set when the navigation finally happens. Identified this case by passing empty keys. Only need special handling for when it loads with a navigation - when keys not empty
This matches ViewPager2 approach. ViewPager2 is final so couldn't subclass and intercept touch
Hard-coded TabBarPager and TabLayout to LTR because ViewPager doesn't work in RTL and there are RTL versions of these components
Not sure if this is necessary - tried in iOS 12 and seemed to be needed, but then edited out and it still worked?! Anyway, including for completeness and sure it's needed
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.
On Android,
setLayoutDirection
from the react nativeisRTL
flag. On iOS, setsemanticContentAttribute
from the react nativeisRTL
flag.The problem was that
ViewPager
doesn’t support RTL layout direction. The swipe gesture to switch tabs doesn’t change when RTL. Android stopped development onViewPager
. Instead, they’ve createdViewPager2
for RTL support. ButViewPager2
isn’t as feature rich asViewPager
, for example, can’t have horizontally scrolling tab content.Decided to keep
ViewPager
for LTR and useViewPager2
for RTL. Means LTR isn’t compromised and that RTL is supported.