File tree Expand file tree Collapse file tree 3 files changed +15
-13
lines changed
android/src/main/java/com/reactnativepagerview Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -171,14 +171,8 @@ class PagerViewViewManager : ViewGroupManager<ViewPager2>() {
171
171
" rtl" -> {
172
172
viewPager.layoutDirection = View .LAYOUT_DIRECTION_RTL
173
173
}
174
- " ltr" -> {
175
- viewPager.layoutDirection = View .LAYOUT_DIRECTION_LTR
176
- }
177
- " locale" -> {
178
- viewPager.layoutDirection = View .LAYOUT_DIRECTION_LOCALE
179
- }
180
174
else -> {
181
- viewPager.layoutDirection = View .LAYOUT_DIRECTION_INHERIT
175
+ viewPager.layoutDirection = View .LAYOUT_DIRECTION_LTR
182
176
}
183
177
}
184
178
}
Original file line number Diff line number Diff line change @@ -437,10 +437,6 @@ - (NSString *)determineScrollDirection:(UIScrollView *)scrollView {
437
437
}
438
438
439
439
- (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" ];
445
441
}
446
442
@end
Original file line number Diff line number Diff line change 1
1
import React , { ReactElement } from 'react' ;
2
2
import { Platform , UIManager , Keyboard } from 'react-native' ;
3
- import ReactNative from 'react-native' ;
3
+ import ReactNative , { I18nManager } from 'react-native' ;
4
4
import type {
5
5
PagerViewOnPageScrollEvent ,
6
6
PagerViewOnPageSelectedEvent ,
@@ -147,12 +147,24 @@ export class PagerView extends React.Component<PagerViewProps> {
147
147
return this . isScrolling ;
148
148
} ;
149
149
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
+
150
161
render ( ) {
151
162
return (
152
163
< PagerViewViewManager
153
164
{ ...this . props }
154
165
ref = { this . PagerView as any /** TODO: Fix ref type */ }
155
166
style = { this . props . style }
167
+ layoutDirection = { this . deducedLayoutDirection }
156
168
onPageScroll = { this . _onPageScroll }
157
169
onPageScrollStateChanged = { this . _onPageScrollStateChanged }
158
170
onPageSelected = { this . _onPageSelected }
You can’t perform that action at this time.
0 commit comments