File tree Expand file tree Collapse file tree 5 files changed +61
-19
lines changed Expand file tree Collapse file tree 5 files changed +61
-19
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ function resolveBoxStyle(
6969
7070 const styleForEnd = style [ prefix + 'End' ] ;
7171 if ( styleForEnd != null ) {
72- if ( I18nManager . isRTL && I18nManager . doLeftAndRightSwapInRTL ) {
72+ const constants = I18nManager . getConstants ( ) ;
73+ if ( constants . isRTL && constants . doLeftAndRightSwapInRTL ) {
7374 result . left = styleForEnd ;
7475 } else {
7576 result . right = styleForEnd ;
@@ -78,7 +79,8 @@ function resolveBoxStyle(
7879 }
7980 const styleForStart = style [ prefix + 'Start' ] ;
8081 if ( styleForStart != null ) {
81- if ( I18nManager . isRTL && I18nManager . doLeftAndRightSwapInRTL ) {
82+ const constants = I18nManager . getConstants ( ) ;
83+ if ( constants . isRTL && constants . doLeftAndRightSwapInRTL ) {
8284 result . right = styleForStart ;
8385 } else {
8486 result . left = styleForStart ;
Original file line number Diff line number Diff line change @@ -271,7 +271,7 @@ class Modal extends React.Component<Props> {
271271 }
272272}
273273
274- const side = I18nManager . isRTL ? 'right' : 'left' ;
274+ const side = I18nManager . getConstants ( ) . isRTL ? 'right' : 'left' ;
275275const styles = StyleSheet . create ( {
276276 modal : {
277277 position : 'absolute' ,
Original file line number Diff line number Diff line change 99 */
1010'use strict' ;
1111
12- type I18nManagerStatus = {
13- isRTL : boolean ,
14- doLeftAndRightSwapInRTL : boolean ,
15- allowRTL : ( allowRTL : boolean ) => { } ,
16- forceRTL : ( forceRTL : boolean ) => { } ,
17- swapLeftAndRightInRTL : ( flipStyles : boolean ) => { } ,
18- } ;
12+ import NativeI18nManager from './NativeI18nManager' ;
1913
20- const I18nManager : I18nManagerStatus = require ( '../BatchedBridge/NativeModules' )
21- . I18nManager || {
22- isRTL : false ,
23- doLeftAndRightSwapInRTL : true ,
24- allowRTL : ( ) => { } ,
25- forceRTL : ( ) => { } ,
26- swapLeftAndRightInRTL : ( ) => { } ,
27- } ;
14+ module . exports = {
15+ getConstants : ( ) => {
16+ return NativeI18nManager . getConstants ( ) ;
17+ } ,
18+
19+ allowRTL : ( shouldAllow : boolean ) => {
20+ NativeI18nManager . allowRTL ( shouldAllow ) ;
21+ } ,
2822
29- module . exports = I18nManager ;
23+ forceRTL : ( shouldForce : boolean ) => {
24+ NativeI18nManager . forceRTL ( shouldForce ) ;
25+ } ,
26+
27+ swapLeftAndRightInRTL : ( flipStyles : boolean ) => {
28+ NativeI18nManager . swapLeftAndRightInRTL ( flipStyles ) ;
29+ } ,
30+
31+ isRTL : NativeI18nManager . getConstants ( ) . isRTL ,
32+ doLeftAndRightSwapInRTL : NativeI18nManager . getConstants ( )
33+ . doLeftAndRightSwapInRTL ,
34+ } ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Facebook, Inc. and its affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @flow
8+ * @format
9+ */
10+
11+ 'use strict' ;
12+
13+ import type { TurboModule } from '../TurboModule/RCTExport' ;
14+ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry' ;
15+
16+ export interface Spec extends TurboModule {
17+ + getConstants : ( ) = > { |
18+ isRTL : boolean ,
19+ doLeftAndRightSwapInRTL : boolean ,
20+ | } ;
21+ allowRTL: ( allowRTL : boolean ) => void ;
22+ forceRTL: ( forceRTL : boolean ) => void ;
23+ swapLeftAndRightInRTL: ( flipStyles : boolean ) => void ;
24+ }
25+
26+ export default TurboModuleRegistry . getEnforcing < Spec > ( 'I18nManager' ) ;
Original file line number Diff line number Diff line change @@ -312,6 +312,15 @@ jest
312312 addListener : jest . fn ( ) ,
313313 removeListeners : jest . fn ( ) ,
314314 } ,
315+ I18nManager : {
316+ allowRTL : jest . fn ( ) ,
317+ forceRTL : jest . fn ( ) ,
318+ swapLeftAndRightInRTL : jest . fn ( ) ,
319+ getConstants : ( ) => ( {
320+ isRTL : false ,
321+ doLeftAndRightSwapInRTL : true ,
322+ } ) ,
323+ } ,
315324 } ) )
316325 . mock ( '../Libraries/ReactNative/requireNativeComponent' , ( ) => {
317326 const React = require ( 'react' ) ;
You can’t perform that action at this time.
0 commit comments