forked from phaneendra-rao/FontsTestApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomView.tsx
91 lines (86 loc) · 2.31 KB
/
CustomView.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
import React from 'react';
import {
View,
I18nManager,
Platform,
ScrollView,
TouchableOpacity,
Text,
} from 'react-native';
import {useTranslation} from 'react-i18next';
import RNRestart from 'react-native-restart';
const CustomView = props => {
const {t, i18n} = useTranslation();
const selectedLanguageCode = i18n.language;
const setLanguage = language => {
i18n.changeLanguage(language);
I18nManager.forceRTL(language === 'ar');
I18nManager.allowRTL(language === 'ar');
setTimeout(() => {
RNRestart.Restart();
}, 10);
return;
};
const marginTop = Platform.OS === 'ios' ? 50 : 0;
return (
<View
style={{
width: '100%',
height: '100%',
padding: 16,
marginTop,
}}>
<View
style={{
flexDirection: 'row',
width: '100%',
justifyContent: 'space-evenly',
paddingBottom: 24,
alignItems: 'center',
}}>
<TouchableOpacity
activeOpacity={1}
style={{
padding: 16,
backgroundColor:
selectedLanguageCode === 'en' ? '#753bbd' : 'transparent',
borderRadius: 8,
}}
onPress={() => {
selectedLanguageCode !== 'en' && setLanguage('en');
}}>
<Text
style={{
color: selectedLanguageCode === 'en' ? '#ffffff' : '#000000',
}}>
English
</Text>
</TouchableOpacity>
<TouchableOpacity
activeOpacity={1}
style={{
padding: 16,
backgroundColor:
selectedLanguageCode === 'ar' ? '#753bbd' : 'transparent',
borderRadius: 8,
}}
onPress={() => {
selectedLanguageCode !== 'ar' && setLanguage('ar');
}}>
<Text
style={{
color: selectedLanguageCode === 'ar' ? '#ffffff' : '#000000',
}}>
Arabic
</Text>
</TouchableOpacity>
</View>
<View style={{width: '100%', height: 1, backgroundColor: '#cacaca'}} />
<ScrollView style={{paddingVertical: 24}} showsVerticalScrollIndicator={false}>
{props.children}
<View style={{height: 24}} />
</ScrollView>
</View>
);
};
export default CustomView;