-
-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathTest3438.tsx
More file actions
87 lines (80 loc) · 1.95 KB
/
Test3438.tsx
File metadata and controls
87 lines (80 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React from 'react';
import {
View,
Text,
StyleSheet,
I18nManager,
Button,
DevSettings,
} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
const Stack = createNativeStackNavigator();
function toggleRTL(forceRTL: boolean) {
if (I18nManager.isRTL === forceRTL) return;
I18nManager.forceRTL(forceRTL);
I18nManager.allowRTL(forceRTL);
DevSettings.reload();
}
function HeaderTitle() {
return (
<Text style={{ fontSize: 18, fontWeight: 'bold' }}>Custom Title</Text>
);
}
function HomeScreen() {
return (
<View style={styles.container}>
<Text style={styles.heading}>Issue #3438</Text>
<Text>headerTitleAlign: center + headerTitle as function</Text>
<Text>RTL mode: {I18nManager.isRTL ? 'YES' : 'NO'}</Text>
<Text style={styles.note}>
The header title above should say "Custom Title".
{'\n'}If it's missing or there's extra space, the bug is present.
</Text>
<View style={styles.buttons}>
<Button title="Force RTL" onPress={() => toggleRTL(true)} />
<Button title="Force LTR" onPress={() => toggleRTL(false)} />
</View>
</View>
);
}
function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{
headerTitleAlign: 'center',
headerTitle: HeaderTitle,
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
padding: 20,
gap: 8,
},
heading: {
fontWeight: 'bold',
fontSize: 16,
},
note: {
textAlign: 'center',
marginTop: 20,
color: 'gray',
},
buttons: {
flexDirection: 'row',
gap: 12,
marginTop: 20,
},
});
export default App;