forked from react-native-picker/picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
93 lines (90 loc) · 2.54 KB
/
App.tsx
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
88
89
90
91
92
93
import * as React from 'react';
import {
Platform,
ScrollView,
StyleSheet,
Text,
View,
SafeAreaView,
I18nManager,
Switch,
} from 'react-native';
import * as PickerExamples from './PickerExample';
import * as PickerIOSExamples from './PickerIOSExample';
import * as PickerWindowsExamples from './PickerWindowsExamples';
export default function App() {
const [isRTL, setIsRTL] = React.useState(I18nManager.isRTL);
React.useEffect(() => {
I18nManager.allowRTL(true);
}, []);
return (
<SafeAreaView style={styles.main}>
<ScrollView>
<View style={styles.rtlSwitchContainer}>
<Switch
value={isRTL}
onValueChange={(newValue) => {
setIsRTL(newValue);
I18nManager.forceRTL(newValue);
}}
/>
<Text>{I18nManager.isRTL ? 'RTL' : 'LTR'}</Text>
</View>
<View style={styles.container}>
<Text style={styles.heading}>Picker Examples</Text>
{PickerExamples.examples.map((element) => (
<View style={styles.elementContainer} key={element.title}>
<Text style={styles.title}> {element.title} </Text>
{element.render()}
</View>
))}
{Platform.OS === 'ios' && (
<Text style={styles.heading}>PickerIOS Examples</Text>
)}
{Platform.OS === 'ios' &&
PickerIOSExamples.examples.map((element) => (
<View style={styles.elementContainer} key={element.title}>
<Text style={styles.title}> {element.title} </Text>
{element.render()}
</View>
))}
{Platform.OS === 'windows' && (
<Text style={styles.heading}>PickerWindows Examples</Text>
)}
{Platform.OS === 'windows' &&
PickerWindowsExamples.examples.map((element) => (
<View style={styles.elementContainer} key={element.title}>
<Text style={styles.title}> {element.title} </Text>
{element.render()}
</View>
))}
</View>
</ScrollView>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
main: {
backgroundColor: '#F5FCFF',
},
container: {
padding: 24,
paddingBottom: 60,
},
title: {
fontSize: 18,
},
elementContainer: {
marginTop: 8,
},
heading: {
fontSize: 22,
color: 'black',
},
rtlSwitchContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
paddingHorizontal: 40,
paddingTop: 20,
},
});