Skip to content

Commit e8d56fa

Browse files
committed
feat: add button to quickly switch layout direction
1 parent a3e4dd9 commit e8d56fa

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

example/src/App.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
TouchableOpacity,
1111
Button,
1212
Alert,
13+
DevSettings,
14+
I18nManager,
1315
} from 'react-native';
1416
import { NavigationContainer, useNavigation } from '@react-navigation/native';
1517
import { createStackNavigator } from '@react-navigation/stack';
@@ -119,6 +121,16 @@ export function Navigation() {
119121
color="orange"
120122
/>
121123
),
124+
headerLeft: () => (
125+
<Button
126+
title={I18nManager.getConstants().isRTL ? 'RTL' : 'LTR'}
127+
color="orange"
128+
onPress={() => {
129+
I18nManager.forceRTL(!I18nManager.getConstants().isRTL);
130+
DevSettings.reload();
131+
}}
132+
/>
133+
),
122134
}}
123135
/>
124136
{examples.map((example, index) => (

fabricexample/src/App.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
TouchableOpacity,
1111
Button,
1212
Alert,
13+
DevSettings,
14+
I18nManager,
1315
} from 'react-native';
1416
import { NavigationContainer, useNavigation } from '@react-navigation/native';
1517
import { createStackNavigator } from '@react-navigation/stack';
@@ -119,6 +121,16 @@ export function Navigation() {
119121
color="orange"
120122
/>
121123
),
124+
headerLeft: () => (
125+
<Button
126+
title={I18nManager.getConstants().isRTL ? 'RTL' : 'LTR'}
127+
color="orange"
128+
onPress={() => {
129+
I18nManager.forceRTL(!I18nManager.getConstants().isRTL);
130+
DevSettings.reload();
131+
}}
132+
/>
133+
),
122134
}}
123135
/>
124136
{examples.map((example, index) => (

0 commit comments

Comments
 (0)