import { I18nManager , ViewStyle , } from 'react-native' ; import { RtlFlexMap } from './rtlFlexMap' ; class RTLServiceStatic { returns public isRTL ( ) { return I18nManager . isRTL ; } public select < T > ( ltr , rtl ) { return this . isRTL ( ) ? rtl : ltr ; } param { ViewStyle } source param { boolean } rtl returns { ViewStyle } public ignoreRTL ( source , rtl = this . isRTL ( ) ) { const rtlStyle = Object . keys ( RtlFlexMap ) . reduce ( ( style , prop ) : ViewStyle => { const currentStyleValue = source [ prop ] ; if ( currentStyleValue ) { const i18nStyleValue = RtlFlexMap [ prop ] . toRTL ( currentStyleValue , rtl ) ; return { ... style , [ prop ] : i18nStyleValue , } ; } return style ; } , { } ) ; return { ... source , ... rtlStyle } ; } } export const RTLService = new RTLServiceStatic ( ) ;