@@ -2,15 +2,19 @@ import * as React from 'react';
22import { I18nManager , StyleSheet , View , Platform } from 'react-native' ;
33
44import { DrawerContentScrollView } from '@react-navigation/drawer' ;
5+ import Constants , { ExecutionEnvironment } from 'expo-constants' ;
56import * as Updates from 'expo-updates' ;
67import {
78 Badge ,
9+ Button ,
10+ Dialog ,
811 Drawer ,
912 MD2Colors ,
1013 MD3Colors ,
1114 Switch ,
1215 Text ,
1316 TouchableRipple ,
17+ Portal ,
1418} from 'react-native-paper' ;
1519
1620import { deviceColorsSupported , isWeb } from '../utils' ;
@@ -87,12 +91,15 @@ const DrawerCollapsedItemsData = [
8791
8892function DrawerItems ( ) {
8993 const [ drawerItemIndex , setDrawerItemIndex ] = React . useState < number > ( 0 ) ;
94+ const [ showRTLDialog , setShowRTLDialog ] = React . useState ( false ) ;
9095 const preferences = React . useContext ( PreferencesContext ) ;
9196
9297 const _setDrawerItem = ( index : number ) => setDrawerItemIndex ( index ) ;
9398
9499 const { isV3, colors } = useExampleTheme ( ) ;
95100 const isIOS = Platform . OS === 'ios' ;
101+ const expoGoExecution =
102+ Constants . executionEnvironment === ExecutionEnvironment . StoreClient ;
96103
97104 if ( ! preferences ) throw new Error ( 'PreferencesContext not provided' ) ;
98105
@@ -113,13 +120,22 @@ function DrawerItems() {
113120 } = preferences ;
114121
115122 const _handleToggleRTL = ( ) => {
123+ if ( expoGoExecution ) {
124+ setShowRTLDialog ( true ) ;
125+ return ;
126+ }
127+
116128 toggleRTL ( ) ;
117129 I18nManager . forceRTL ( ! isRTL ) ;
118130 if ( isWeb ) {
119131 Updates . reloadAsync ( ) ;
120132 }
121133 } ;
122134
135+ const _handleDismissRTLDialog = ( ) => {
136+ setShowRTLDialog ( false ) ;
137+ } ;
138+
123139 const coloredLabelTheme = {
124140 colors : isV3
125141 ? {
@@ -254,6 +270,24 @@ function DrawerItems() {
254270 </ Text >
255271 </ >
256272 ) }
273+ < Portal >
274+ < Dialog visible = { showRTLDialog } onDismiss = { _handleDismissRTLDialog } >
275+ < Dialog . Title > Changing to RTL</ Dialog . Title >
276+ < Dialog . Content >
277+ < Text variant = "bodyMedium" >
278+ Due to Expo Go limitations it is impossible to change RTL
279+ dynamically. To do so, you need to create a development build of
280+ Example app or change it statically by setting{ ' ' }
281+ < Text variant = "labelMedium" > forcesRTL</ Text > property to true in{ ' ' }
282+ < Text variant = "labelMedium" > app.json</ Text > within{ ' ' }
283+ < Text variant = "labelMedium" > example</ Text > directory.
284+ </ Text >
285+ < Dialog . Actions >
286+ < Button onPress = { _handleDismissRTLDialog } > Ok</ Button >
287+ </ Dialog . Actions >
288+ </ Dialog . Content >
289+ </ Dialog >
290+ </ Portal >
257291 </ DrawerContentScrollView >
258292 ) ;
259293}
0 commit comments