File tree Expand file tree Collapse file tree
android/src/main/java/com/reactnativepagerview Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,14 +171,8 @@ class PagerViewViewManager : ViewGroupManager<ViewPager2>() {
171171 " rtl" -> {
172172 viewPager.layoutDirection = View .LAYOUT_DIRECTION_RTL
173173 }
174- " ltr" -> {
175- viewPager.layoutDirection = View .LAYOUT_DIRECTION_LTR
176- }
177- " locale" -> {
178- viewPager.layoutDirection = View .LAYOUT_DIRECTION_LOCALE
179- }
180174 else -> {
181- viewPager.layoutDirection = View .LAYOUT_DIRECTION_INHERIT
175+ viewPager.layoutDirection = View .LAYOUT_DIRECTION_LTR
182176 }
183177 }
184178 }
Original file line number Diff line number Diff line change @@ -437,10 +437,6 @@ - (NSString *)determineScrollDirection:(UIScrollView *)scrollView {
437437}
438438
439439- (BOOL )isLtrLayout {
440- if ([_layoutDirection isEqualToString: @" locale" ]) {
441- return [UIApplication sharedApplication ].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionLeftToRight;
442- } else {
443- return [_layoutDirection isEqualToString: @" ltr" ];
444- }
440+ return [_layoutDirection isEqualToString: @" ltr" ];
445441}
446442@end
Original file line number Diff line number Diff line change 11import React , { ReactElement } from 'react' ;
22import { Platform , UIManager , Keyboard } from 'react-native' ;
3- import ReactNative from 'react-native' ;
3+ import ReactNative , { I18nManager } from 'react-native' ;
44import type {
55 PagerViewOnPageScrollEvent ,
66 PagerViewOnPageSelectedEvent ,
@@ -147,12 +147,24 @@ export class PagerView extends React.Component<PagerViewProps> {
147147 return this . isScrolling ;
148148 } ;
149149
150+ private get deducedLayoutDirection ( ) {
151+ const shouldUseDeviceRtlSetup =
152+ ! this . props . layoutDirection || this . props . layoutDirection === 'locale' ;
153+
154+ if ( shouldUseDeviceRtlSetup ) {
155+ return I18nManager . isRTL ? 'rtl' : 'ltr' ;
156+ } else {
157+ return this . props . layoutDirection ;
158+ }
159+ }
160+
150161 render ( ) {
151162 return (
152163 < PagerViewViewManager
153164 { ...this . props }
154165 ref = { this . PagerView as any /** TODO: Fix ref type */ }
155166 style = { this . props . style }
167+ layoutDirection = { this . deducedLayoutDirection }
156168 onPageScroll = { this . _onPageScroll }
157169 onPageScrollStateChanged = { this . _onPageScrollStateChanged }
158170 onPageSelected = { this . _onPageSelected }
You can’t perform that action at this time.
0 commit comments