@fadyshawky/react-native-magic 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/App.tsx +21 -16
- package/template/ios/reactnativemagic/AppDelegate.mm +5 -0
- package/template/src/common/ImageResources.g.ts +1 -33
- package/template/src/common/components/Background.tsx +7 -7
- package/template/src/common/components/Container.tsx +7 -10
- package/template/src/common/localization/LocalizationProvider.tsx +14 -17
- package/template/src/common/localization/RTLInitializer.tsx +90 -0
- package/template/src/common/localization/intlFormatter.ts +37 -0
- package/template/src/common/localization/localization.ts +1 -3
- package/template/src/common/localization/translations/commonLocalization.ts +11 -81
- package/template/src/common/localization/translations/emptyLocalization.ts +6 -2
- package/template/src/common/localization/translations/errorsLocalization.ts +33 -13
- package/template/src/common/localization/translations/homeLocalization.ts +4 -24
- package/template/src/common/localization/translations/loginLocalization.ts +26 -29
- package/template/src/common/localization/translations/mainNavigationLocalization.ts +2 -2
- package/template/src/common/localization/translations/onboardingLocalization.ts +40 -9
- package/template/src/common/localization/translations/otpLocalization.ts +8 -8
- package/template/src/common/localization/translations/pagesLocalization.ts +13 -1
- package/template/src/common/localization/translations/passwordLocalization.ts +3 -3
- package/template/src/common/localization/translations/profileLocalization.ts +4 -4
- package/template/src/core/store/app/appSlice.ts +2 -2
- package/template/src/core/store/app/appState.ts +1 -1
- package/template/src/core/theme/colors.ts +106 -70
- package/template/src/core/theme/commonConsts.ts +1 -1
- package/template/src/core/theme/commonSizes.ts +119 -94
- package/template/src/core/theme/commonStyles.ts +22 -22
- package/template/src/core/theme/fonts.ts +13 -14
- package/template/src/core/theme/shadows.ts +135 -0
- package/template/src/core/theme/themes.ts +386 -75
- package/template/src/core/theme/types.ts +201 -15
- package/template/src/navigation/HeaderComponents.tsx +6 -30
- package/template/src/navigation/MainNavigation.tsx +2 -3
- package/template/src/navigation/MainStack.tsx +6 -97
- package/template/src/screens/Login/Login.tsx +5 -7
- package/template/src/screens/OTP/OTPScreen.tsx +12 -13
- package/template/src/screens/home/HomeScreen.tsx +2 -295
- package/template/src/screens/profile/Profile.tsx +2 -290
- package/template/src/common/localization/translations/posLocalization.ts +0 -196
- package/template/src/components/PrinterExample.js +0 -226
- package/template/src/core/store/Categories/categoryActions.ts +0 -33
- package/template/src/core/store/Categories/categorySlice.ts +0 -75
- package/template/src/core/store/Categories/categoryState.ts +0 -41
- package/template/src/core/store/Providers/providersActions.ts +0 -102
- package/template/src/core/store/Providers/providersSlice.ts +0 -136
- package/template/src/core/store/Providers/providersState.ts +0 -37
- package/template/src/core/store/Services/servicesActions.ts +0 -191
- package/template/src/core/store/Services/servicesSlice.ts +0 -205
- package/template/src/core/store/Services/servicesState.ts +0 -466
- package/template/src/modules/SunmiCard.js +0 -212
- package/template/src/modules/SunmiPrepaid.ts +0 -122
- package/template/src/screens/Categories/Categories.tsx +0 -141
- package/template/src/screens/Categories/hooks/useCategoriesData.ts +0 -33
- package/template/src/screens/Categories/types.ts +0 -7
- package/template/src/screens/Favorites/Favorites.tsx +0 -130
- package/template/src/screens/ForceChangePassword/ForceChangePasswordScreen.tsx +0 -155
- package/template/src/screens/History/History.tsx +0 -430
- package/template/src/screens/History/hooks/useHistoryData.ts +0 -49
- package/template/src/screens/History/types.ts +0 -7
- package/template/src/screens/InquiredBill/InquiredBill.tsx +0 -443
- package/template/src/screens/InquiredBill/hooks/useInquiredData.ts +0 -91
- package/template/src/screens/PaymentConfirmation/PaymentConfirmation.tsx +0 -326
- package/template/src/screens/Providers/Providers.tsx +0 -166
- package/template/src/screens/Providers/hooks/useProvidersData.ts +0 -33
- package/template/src/screens/Providers/types.ts +0 -7
- package/template/src/screens/ReceiptScreen/ReceiptScreen.tsx +0 -181
- package/template/src/screens/ReceiptScreen/hooks/useReceiptData.ts +0 -46
- package/template/src/screens/ReceiptScreen/utils/utils.tsx +0 -156
- package/template/src/screens/Services/Services.tsx +0 -144
- package/template/src/screens/Services/hooks/useServicesData.ts +0 -41
- package/template/src/screens/SingleService/Components/FawryInputs.tsx +0 -446
- package/template/src/screens/SingleService/SingleService.tsx +0 -229
- package/template/src/screens/SingleService/hooks/useServiceData.ts +0 -164
- package/template/src/services/SunmiPrinterInternal.js +0 -268
- package/template/src/types/sunmiPrepaid.d.ts +0 -20
- package/template/src/utils/SunmiPrinter.ts +0 -442
- package/template/src/utils/feesCalculator.ts +0 -92
|
@@ -1,298 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
|
|
3
|
-
import React, {useEffect, useRef} from 'react';
|
|
4
|
-
import {Image, ImageURISource, StyleSheet, View, ViewStyle} from 'react-native';
|
|
5
|
-
import {SkypeIndicator} from 'react-native-indicators';
|
|
6
|
-
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view';
|
|
7
|
-
import {ButtonType} from '../../../types';
|
|
8
|
-
import {Card} from '../../common/components/Cards';
|
|
9
|
-
import {Container} from '../../common/components/Container';
|
|
10
|
-
import {FlatListWrapper} from '../../common/components/FlatListWrapper';
|
|
11
|
-
import {PrimaryButton} from '../../common/components/PrimaryButton';
|
|
12
|
-
import {RTLAwareText} from '../../common/components/RTLAwareText';
|
|
13
|
-
import {RTLAwareView} from '../../common/components/RTLAwareView';
|
|
14
|
-
import {ImageResources} from '../../common/ImageResources.g';
|
|
15
|
-
import {
|
|
16
|
-
useRTL,
|
|
17
|
-
useTranslation,
|
|
18
|
-
} from '../../common/localization/LocalizationProvider';
|
|
19
|
-
import {
|
|
20
|
-
clearSelectedCategory,
|
|
21
|
-
setSelectedCategory,
|
|
22
|
-
} from '../../core/store/Categories/categorySlice';
|
|
23
|
-
import {Category} from '../../core/store/Categories/categoryState';
|
|
24
|
-
import {setSelectedProvider} from '../../core/store/Providers/providersSlice';
|
|
25
|
-
import {ServiceProvider} from '../../core/store/Providers/providersState';
|
|
26
|
-
import {useAppDispatch, useAppSelector} from '../../core/store/reduxHelpers';
|
|
27
|
-
import {RootState} from '../../core/store/rootReducer';
|
|
28
|
-
import {UserStatus} from '../../core/store/user/userState';
|
|
29
|
-
import {CommonSizes} from '../../core/theme/commonSizes';
|
|
30
|
-
import {scaleHeight, scaleWidth} from '../../core/theme/scaling';
|
|
31
|
-
import {useTheme} from '../../core/theme/ThemeProvider';
|
|
32
|
-
import {HomeHeader} from '../../navigation/HeaderComponents';
|
|
33
|
-
import {RootStackParamList} from '../../navigation/types';
|
|
34
|
-
import {useHomeData} from './hooks/useHomeData';
|
|
35
|
-
import {PayByCode} from './Components/PayByCode';
|
|
36
|
-
|
|
37
|
-
// Props for balance section component
|
|
38
|
-
interface BalanceSectionProps {
|
|
39
|
-
title: string;
|
|
40
|
-
image: ImageURISource;
|
|
41
|
-
amount?: string;
|
|
42
|
-
style?: ViewStyle;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Balance section component
|
|
46
|
-
function BalanceSections({
|
|
47
|
-
title,
|
|
48
|
-
image,
|
|
49
|
-
amount,
|
|
50
|
-
style,
|
|
51
|
-
}: BalanceSectionProps): JSX.Element {
|
|
52
|
-
const {theme} = useTheme();
|
|
53
|
-
const t = useTranslation();
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<View style={[styles.balanceSection, style]}>
|
|
57
|
-
<Image
|
|
58
|
-
style={{...styles.sectionImage, tintColor: theme.colors.tintColor}}
|
|
59
|
-
source={image}
|
|
60
|
-
resizeMode="contain"
|
|
61
|
-
/>
|
|
62
|
-
<RTLAwareText style={[theme.text.balanceAmount, styles.amountText]}>
|
|
63
|
-
<RTLAwareText style={theme.text.balanceLabel}>
|
|
64
|
-
{t('currency') + '\n'}
|
|
65
|
-
</RTLAwareText>
|
|
66
|
-
{amount}
|
|
67
|
-
</RTLAwareText>
|
|
68
|
-
<RTLAwareText style={theme.text.balanceTitle}>{title}</RTLAwareText>
|
|
69
|
-
</View>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Props for see more section component
|
|
74
|
-
interface SeeMoreSectionProps {
|
|
75
|
-
title: string;
|
|
76
|
-
image: ImageURISource;
|
|
77
|
-
style?: ViewStyle;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// See more section component
|
|
81
|
-
function SeeMoreSection({
|
|
82
|
-
title,
|
|
83
|
-
image,
|
|
84
|
-
style,
|
|
85
|
-
}: SeeMoreSectionProps): JSX.Element {
|
|
86
|
-
const {theme} = useTheme();
|
|
87
|
-
return (
|
|
88
|
-
<View style={[styles.seeMoreSection, style]}>
|
|
89
|
-
<RTLAwareText style={theme.text.balanceTitle}>{title}</RTLAwareText>
|
|
90
|
-
<Image
|
|
91
|
-
style={{...styles.sectionImage, tintColor: theme.colors.tintColor}}
|
|
92
|
-
source={image}
|
|
93
|
-
resizeMode="contain"
|
|
94
|
-
/>
|
|
95
|
-
</View>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Balance card component
|
|
100
|
-
function BalanceCard(): JSX.Element {
|
|
101
|
-
const {theme} = useTheme();
|
|
102
|
-
const t = useTranslation();
|
|
103
|
-
const isRTL = useRTL();
|
|
104
|
-
const {current_balance, daily_commission} = useAppSelector(
|
|
105
|
-
(state: RootState) => state.user,
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<RTLAwareView
|
|
110
|
-
style={[
|
|
111
|
-
styles.balanceCard,
|
|
112
|
-
{backgroundColor: theme.colors.balanceBackground},
|
|
113
|
-
]}>
|
|
114
|
-
<RTLAwareView
|
|
115
|
-
style={{
|
|
116
|
-
width: '100%',
|
|
117
|
-
flexDirection: 'row',
|
|
118
|
-
justifyContent: 'space-evenly',
|
|
119
|
-
paddingVertical: CommonSizes.spacing.large,
|
|
120
|
-
}}>
|
|
121
|
-
<BalanceSections
|
|
122
|
-
title={t('currentBalance', 'home')}
|
|
123
|
-
image={ImageResources.balance}
|
|
124
|
-
amount={`${current_balance?.toFixed(2) ?? 0}`}
|
|
125
|
-
/>
|
|
126
|
-
<BalanceSections
|
|
127
|
-
title={t('dailyCommission', 'home')}
|
|
128
|
-
image={ImageResources.commission}
|
|
129
|
-
amount={`${daily_commission ?? 0}`}
|
|
130
|
-
/>
|
|
131
|
-
</RTLAwareView>
|
|
132
|
-
</RTLAwareView>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
1
|
+
import React from 'react';
|
|
135
2
|
|
|
136
3
|
export function HomeScreen(): JSX.Element {
|
|
137
|
-
|
|
138
|
-
isLoading,
|
|
139
|
-
refreshData,
|
|
140
|
-
fetchData,
|
|
141
|
-
user,
|
|
142
|
-
categories,
|
|
143
|
-
loadState,
|
|
144
|
-
homeProviders,
|
|
145
|
-
isPayByCodeModalVisible,
|
|
146
|
-
setIsPayByCodeModalVisible,
|
|
147
|
-
} = useHomeData();
|
|
148
|
-
const dispatch = useAppDispatch();
|
|
149
|
-
|
|
150
|
-
const t = useTranslation();
|
|
151
|
-
|
|
152
|
-
const navigation =
|
|
153
|
-
useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
|
154
|
-
|
|
155
|
-
const {theme} = useTheme();
|
|
156
|
-
const scroll = useRef<KeyboardAwareScrollView>(null);
|
|
157
|
-
const isFocused = useIsFocused();
|
|
158
|
-
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
if (user.status === UserStatus.REGISTERED) {
|
|
161
|
-
navigation.navigate('ForceChangePassword');
|
|
162
|
-
}
|
|
163
|
-
}, [user.status]);
|
|
164
|
-
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
if (categories.length === 0) {
|
|
167
|
-
fetchData();
|
|
168
|
-
}
|
|
169
|
-
}, [isFocused]);
|
|
170
|
-
|
|
171
|
-
function navigateToServices(provider: ServiceProvider) {
|
|
172
|
-
dispatch(clearSelectedCategory());
|
|
173
|
-
setTimeout(() => {
|
|
174
|
-
dispatch(setSelectedProvider(provider));
|
|
175
|
-
navigation.navigate('Services', {
|
|
176
|
-
providerID:
|
|
177
|
-
provider?.provider === 'Fawry'
|
|
178
|
-
? provider?.BillerId?.toString()
|
|
179
|
-
: (provider?.id?.toString() as string),
|
|
180
|
-
});
|
|
181
|
-
}, 200);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function navigateToProviders(category: Category) {
|
|
185
|
-
dispatch(setSelectedCategory(category));
|
|
186
|
-
navigation.navigate('Providers', {
|
|
187
|
-
categoryID: category.id?.toString(),
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return (
|
|
192
|
-
<Container
|
|
193
|
-
ref={scroll}
|
|
194
|
-
testID={'HomeScreenID'}
|
|
195
|
-
contentContainerStyle={styles.contentContainer}
|
|
196
|
-
style={styles.container}
|
|
197
|
-
backgroundImage={ImageResources[`${theme.mode}_background_1`]}
|
|
198
|
-
withoutPadding
|
|
199
|
-
backgroundColor={theme.colors.background}>
|
|
200
|
-
{isLoading ? (
|
|
201
|
-
<SkypeIndicator size={80} color={theme.colors.mutedLavender} />
|
|
202
|
-
) : (
|
|
203
|
-
<>
|
|
204
|
-
<HomeHeader onPress={refreshData} />
|
|
205
|
-
<PrimaryButton
|
|
206
|
-
label={t('payByCode', 'home')}
|
|
207
|
-
type={ButtonType.solid}
|
|
208
|
-
onPress={() => setIsPayByCodeModalVisible(!isPayByCodeModalVisible)}
|
|
209
|
-
/>
|
|
210
|
-
<BalanceCard />
|
|
211
|
-
<PrimaryButton
|
|
212
|
-
onPressIn={async () => {
|
|
213
|
-
navigation.navigate('Categories');
|
|
214
|
-
}}
|
|
215
|
-
label={t('allServices', 'common')}
|
|
216
|
-
type={ButtonType.solid}
|
|
217
|
-
/>
|
|
218
|
-
<FlatListWrapper
|
|
219
|
-
keyExtractor={(item, index) => `${item.id}-${index}`}
|
|
220
|
-
loadState={loadState}
|
|
221
|
-
data={categories?.slice(1, 6)}
|
|
222
|
-
horizontal
|
|
223
|
-
renderItem={({item}) => (
|
|
224
|
-
<Card
|
|
225
|
-
key={item.id}
|
|
226
|
-
icon={{uri: item.img_url}}
|
|
227
|
-
title={item.name}
|
|
228
|
-
onPress={() => {
|
|
229
|
-
navigateToProviders(item);
|
|
230
|
-
}}
|
|
231
|
-
marginRight={CommonSizes.spacing.extraLarge}
|
|
232
|
-
/>
|
|
233
|
-
)}
|
|
234
|
-
/>
|
|
235
|
-
<FlatListWrapper
|
|
236
|
-
keyExtractor={(item, index) => `${item.id}-${index}`}
|
|
237
|
-
loadState={loadState}
|
|
238
|
-
data={homeProviders?.slice(0, 5)}
|
|
239
|
-
horizontal
|
|
240
|
-
renderItem={({item}) => (
|
|
241
|
-
<Card
|
|
242
|
-
key={item.id}
|
|
243
|
-
icon={{uri: item.img_url}}
|
|
244
|
-
title={item.name || item.BillerName}
|
|
245
|
-
onPress={() => navigateToServices(item)}
|
|
246
|
-
marginRight={CommonSizes.spacing.extraLarge}
|
|
247
|
-
/>
|
|
248
|
-
)}
|
|
249
|
-
/>
|
|
250
|
-
</>
|
|
251
|
-
)}
|
|
252
|
-
<PayByCode
|
|
253
|
-
isVisible={isPayByCodeModalVisible}
|
|
254
|
-
onClose={() => setIsPayByCodeModalVisible(false)}
|
|
255
|
-
/>
|
|
256
|
-
</Container>
|
|
257
|
-
);
|
|
4
|
+
return <></>;
|
|
258
5
|
}
|
|
259
|
-
|
|
260
|
-
const styles = StyleSheet.create({
|
|
261
|
-
container: {
|
|
262
|
-
paddingBottom: scaleHeight(130),
|
|
263
|
-
borderTopRightRadius: CommonSizes.spacing.large,
|
|
264
|
-
borderTopLeftRadius: CommonSizes.spacing.large,
|
|
265
|
-
paddingHorizontal: CommonSizes.spacing.large,
|
|
266
|
-
gap: CommonSizes.spacing.large,
|
|
267
|
-
justifyContent: 'flex-start',
|
|
268
|
-
},
|
|
269
|
-
contentContainer: {
|
|
270
|
-
flexGrow: 1,
|
|
271
|
-
},
|
|
272
|
-
formContainer: {
|
|
273
|
-
alignItems: 'center',
|
|
274
|
-
paddingHorizontal: CommonSizes.spacing.large,
|
|
275
|
-
gap: CommonSizes.spacing.large,
|
|
276
|
-
},
|
|
277
|
-
balanceSection: {
|
|
278
|
-
alignItems: 'center',
|
|
279
|
-
justifyContent: 'space-evenly',
|
|
280
|
-
gap: CommonSizes.spacing.large,
|
|
281
|
-
},
|
|
282
|
-
seeMoreSection: {
|
|
283
|
-
alignItems: 'center',
|
|
284
|
-
gap: CommonSizes.spacing.large,
|
|
285
|
-
alignSelf: 'center',
|
|
286
|
-
},
|
|
287
|
-
sectionImage: {
|
|
288
|
-
width: scaleWidth(120),
|
|
289
|
-
height: scaleHeight(70),
|
|
290
|
-
},
|
|
291
|
-
amountText: {
|
|
292
|
-
textAlign: 'left',
|
|
293
|
-
},
|
|
294
|
-
balanceCard: {
|
|
295
|
-
width: '100%',
|
|
296
|
-
borderRadius: CommonSizes.spacing.huge,
|
|
297
|
-
},
|
|
298
|
-
});
|
|
@@ -1,293 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
ScrollView,
|
|
4
|
-
StyleSheet,
|
|
5
|
-
Switch,
|
|
6
|
-
TouchableOpacity,
|
|
7
|
-
View,
|
|
8
|
-
Text,
|
|
9
|
-
Alert,
|
|
10
|
-
Image,
|
|
11
|
-
} from 'react-native';
|
|
12
|
-
import {ImageResources} from '../../common/ImageResources.g';
|
|
13
|
-
import {Container} from '../../common/components/Container';
|
|
14
|
-
import {RTLAwareText} from '../../common/components/RTLAwareText';
|
|
15
|
-
import {RTLAwareView} from '../../common/components/RTLAwareView';
|
|
16
|
-
import {
|
|
17
|
-
useLocalization,
|
|
18
|
-
useRTL,
|
|
19
|
-
useTranslation,
|
|
20
|
-
} from '../../common/localization/LocalizationProvider';
|
|
21
|
-
import {Languages} from '../../common/localization/localization';
|
|
22
|
-
import {useTheme} from '../../core/theme/ThemeProvider';
|
|
23
|
-
import {Theme} from '../../core/theme/types';
|
|
24
|
-
import {scaleWidth, scaleHeight} from '../../core/theme/scaling';
|
|
25
|
-
import {useAppDispatch, useAppSelector} from '../../core/store/reduxHelpers';
|
|
26
|
-
import {setProvidersLogout} from '../../core/store/Providers/providersSlice';
|
|
27
|
-
import {setServiceLogout} from '../../core/store/Services/servicesSlice';
|
|
28
|
-
import {setCategoriesLogout} from '../../core/store/Categories/categorySlice';
|
|
29
|
-
import {setLogout} from '../../core/store/user/userSlice';
|
|
30
|
-
import DeviceInfo from 'react-native-device-info';
|
|
31
|
-
|
|
32
|
-
function SwitchButton({
|
|
33
|
-
onValueChange,
|
|
34
|
-
value,
|
|
35
|
-
}: {
|
|
36
|
-
onValueChange: () => void;
|
|
37
|
-
value: boolean;
|
|
38
|
-
}) {
|
|
39
|
-
const {theme} = useTheme();
|
|
40
|
-
return (
|
|
41
|
-
<TouchableOpacity
|
|
42
|
-
onPressIn={() => {
|
|
43
|
-
onValueChange();
|
|
44
|
-
}}
|
|
45
|
-
style={{
|
|
46
|
-
width: scaleWidth(100),
|
|
47
|
-
height: scaleHeight(53),
|
|
48
|
-
backgroundColor: theme.colors.mutedLavender,
|
|
49
|
-
borderRadius: theme.borderRadius.xl,
|
|
50
|
-
paddingHorizontal: scaleWidth(5),
|
|
51
|
-
justifyContent: 'center',
|
|
52
|
-
alignItems: 'center',
|
|
53
|
-
}}>
|
|
54
|
-
<View
|
|
55
|
-
style={{
|
|
56
|
-
width: scaleWidth(42),
|
|
57
|
-
height: scaleWidth(42),
|
|
58
|
-
backgroundColor: theme.colors.indigoBlue,
|
|
59
|
-
borderRadius: theme.borderRadius.xl,
|
|
60
|
-
alignSelf: value ? 'flex-end' : 'flex-start',
|
|
61
|
-
}}
|
|
62
|
-
/>
|
|
63
|
-
</TouchableOpacity>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
1
|
+
import React from 'react';
|
|
66
2
|
|
|
67
3
|
export function Profile(): JSX.Element {
|
|
68
|
-
|
|
69
|
-
const {currentLanguage, changeLanguage} = useLocalization();
|
|
70
|
-
const t = useTranslation();
|
|
71
|
-
const isRTL = useRTL();
|
|
72
|
-
const isArabic = currentLanguage === Languages.ar;
|
|
73
|
-
const isDarkMode = theme.mode === 'dark';
|
|
74
|
-
const {language: storedLanguage} = useAppSelector(state => state.app);
|
|
75
|
-
const dispatch = useAppDispatch();
|
|
76
|
-
|
|
77
|
-
const styles = createStyles(theme);
|
|
78
|
-
|
|
79
|
-
const handleLanguageToggle = () => {
|
|
80
|
-
const newLanguage = isArabic ? Languages.en : Languages.ar;
|
|
81
|
-
|
|
82
|
-
Alert.alert(
|
|
83
|
-
t('languageChangeTitle', 'profile'),
|
|
84
|
-
t('languageChangeMessage', 'profile'),
|
|
85
|
-
[
|
|
86
|
-
{
|
|
87
|
-
text: t('cancel', 'common'),
|
|
88
|
-
style: 'cancel',
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
text: t('change', 'common'),
|
|
92
|
-
onPress: () => changeLanguage(newLanguage),
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
{cancelable: true},
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
function logout(): any {
|
|
100
|
-
throw new Error('Function not implemented.');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<Container
|
|
105
|
-
backgroundImage={ImageResources[`${theme.mode}_background_1`]}
|
|
106
|
-
withoutPadding
|
|
107
|
-
backgroundColor={theme.colors.background}>
|
|
108
|
-
<ScrollView showsVerticalScrollIndicator={false}>
|
|
109
|
-
<View style={styles.titleSection}>
|
|
110
|
-
<RTLAwareText style={styles.mainTitle}>
|
|
111
|
-
{t('account', 'profile')}
|
|
112
|
-
</RTLAwareText>
|
|
113
|
-
</View>
|
|
114
|
-
|
|
115
|
-
<View style={styles.menuSection}>
|
|
116
|
-
<TouchableOpacity style={styles.menuItem}>
|
|
117
|
-
<View style={styles.menuItemLeft}>
|
|
118
|
-
<Image source={ImageResources.account} style={styles.menuIcon} />
|
|
119
|
-
<RTLAwareText style={theme.text.header2}>
|
|
120
|
-
{t('editProfile', 'profile')}
|
|
121
|
-
</RTLAwareText>
|
|
122
|
-
</View>
|
|
123
|
-
</TouchableOpacity>
|
|
124
|
-
|
|
125
|
-
<RTLAwareView style={styles.menuItem}>
|
|
126
|
-
<View
|
|
127
|
-
style={{
|
|
128
|
-
flexDirection: 'row',
|
|
129
|
-
alignItems: 'center',
|
|
130
|
-
justifyContent: 'space-between',
|
|
131
|
-
}}>
|
|
132
|
-
<Image
|
|
133
|
-
source={ImageResources.en}
|
|
134
|
-
style={{
|
|
135
|
-
...styles.menuIcon,
|
|
136
|
-
marginRight: scaleWidth(10),
|
|
137
|
-
width: scaleWidth(48),
|
|
138
|
-
height: scaleWidth(48),
|
|
139
|
-
}}
|
|
140
|
-
/>
|
|
141
|
-
<SwitchButton
|
|
142
|
-
onValueChange={handleLanguageToggle}
|
|
143
|
-
value={isArabic}
|
|
144
|
-
/>
|
|
145
|
-
<Image
|
|
146
|
-
tintColor={theme.colors.tintColor}
|
|
147
|
-
source={ImageResources.ar}
|
|
148
|
-
style={{
|
|
149
|
-
...styles.menuIcon,
|
|
150
|
-
marginLeft: scaleWidth(10),
|
|
151
|
-
width: scaleWidth(48),
|
|
152
|
-
height: scaleWidth(48),
|
|
153
|
-
}}
|
|
154
|
-
/>
|
|
155
|
-
</View>
|
|
156
|
-
<View style={styles.menuItemLeft}>
|
|
157
|
-
<Image
|
|
158
|
-
tintColor={theme.colors.tintColor}
|
|
159
|
-
source={ImageResources.language}
|
|
160
|
-
style={styles.menuIcon}
|
|
161
|
-
/>
|
|
162
|
-
<RTLAwareText style={theme.text.header2}>
|
|
163
|
-
{t('language', 'profile')}
|
|
164
|
-
</RTLAwareText>
|
|
165
|
-
</View>
|
|
166
|
-
</RTLAwareView>
|
|
167
|
-
|
|
168
|
-
<RTLAwareView style={styles.menuItem}>
|
|
169
|
-
<View
|
|
170
|
-
style={{
|
|
171
|
-
flexDirection: 'row',
|
|
172
|
-
alignItems: 'center',
|
|
173
|
-
justifyContent: 'space-between',
|
|
174
|
-
}}>
|
|
175
|
-
<Image
|
|
176
|
-
tintColor={theme.colors.tintColor}
|
|
177
|
-
source={ImageResources.light}
|
|
178
|
-
style={{
|
|
179
|
-
...styles.menuIcon,
|
|
180
|
-
marginRight: scaleWidth(10),
|
|
181
|
-
width: scaleWidth(48),
|
|
182
|
-
height: scaleWidth(48),
|
|
183
|
-
}}
|
|
184
|
-
/>
|
|
185
|
-
<SwitchButton onValueChange={toggleTheme} value={isDarkMode} />
|
|
186
|
-
<Image
|
|
187
|
-
tintColor={theme.colors.tintColor}
|
|
188
|
-
source={ImageResources.dark}
|
|
189
|
-
style={{
|
|
190
|
-
...styles.menuIcon,
|
|
191
|
-
marginLeft: scaleWidth(10),
|
|
192
|
-
width: scaleWidth(48),
|
|
193
|
-
height: scaleWidth(48),
|
|
194
|
-
}}
|
|
195
|
-
/>
|
|
196
|
-
</View>
|
|
197
|
-
<View style={styles.menuItemLeft}>
|
|
198
|
-
<Image
|
|
199
|
-
tintColor={theme.colors.tintColor}
|
|
200
|
-
source={ImageResources.display}
|
|
201
|
-
style={styles.menuIcon}
|
|
202
|
-
/>
|
|
203
|
-
<RTLAwareText style={theme.text.header2}>
|
|
204
|
-
{t('darkMode', 'profile')}
|
|
205
|
-
</RTLAwareText>
|
|
206
|
-
</View>
|
|
207
|
-
</RTLAwareView>
|
|
208
|
-
|
|
209
|
-
<TouchableOpacity
|
|
210
|
-
onPressIn={() => {
|
|
211
|
-
dispatch(setProvidersLogout());
|
|
212
|
-
dispatch(setServiceLogout());
|
|
213
|
-
dispatch(setCategoriesLogout());
|
|
214
|
-
dispatch(setLogout());
|
|
215
|
-
}}
|
|
216
|
-
style={styles.menuItem}>
|
|
217
|
-
<View style={styles.menuItemLeft}>
|
|
218
|
-
<Image
|
|
219
|
-
source={ImageResources.services}
|
|
220
|
-
style={[styles.menuIcon, styles.logoutIcon]}
|
|
221
|
-
/>
|
|
222
|
-
<RTLAwareText style={[theme.text.header2, styles.logoutText]}>
|
|
223
|
-
{t('logout', 'profile')}
|
|
224
|
-
</RTLAwareText>
|
|
225
|
-
</View>
|
|
226
|
-
</TouchableOpacity>
|
|
227
|
-
</View>
|
|
228
|
-
<RTLAwareText style={{...theme.text.body1, alignSelf: 'center'}}>
|
|
229
|
-
{DeviceInfo.getVersion()}
|
|
230
|
-
</RTLAwareText>
|
|
231
|
-
</ScrollView>
|
|
232
|
-
</Container>
|
|
233
|
-
);
|
|
4
|
+
return <></>;
|
|
234
5
|
}
|
|
235
|
-
|
|
236
|
-
const createStyles = (theme: Theme) =>
|
|
237
|
-
StyleSheet.create({
|
|
238
|
-
titleSection: {
|
|
239
|
-
paddingHorizontal: scaleWidth(20),
|
|
240
|
-
paddingTop: scaleWidth(20),
|
|
241
|
-
paddingBottom: scaleWidth(10),
|
|
242
|
-
},
|
|
243
|
-
mainTitle: {
|
|
244
|
-
...theme.text.header1,
|
|
245
|
-
marginBottom: scaleWidth(10),
|
|
246
|
-
},
|
|
247
|
-
menuSection: {
|
|
248
|
-
paddingHorizontal: scaleWidth(20),
|
|
249
|
-
paddingVertical: scaleWidth(10),
|
|
250
|
-
},
|
|
251
|
-
menuItem: {
|
|
252
|
-
flexDirection: 'row',
|
|
253
|
-
justifyContent: 'space-between',
|
|
254
|
-
alignItems: 'center',
|
|
255
|
-
paddingVertical: scaleWidth(15),
|
|
256
|
-
borderBottomWidth: 1,
|
|
257
|
-
borderBottomColor: theme.colors.shadow,
|
|
258
|
-
},
|
|
259
|
-
menuItemLeft: {
|
|
260
|
-
flexDirection: 'row',
|
|
261
|
-
alignItems: 'center',
|
|
262
|
-
},
|
|
263
|
-
menuIcon: {
|
|
264
|
-
width: scaleWidth(71),
|
|
265
|
-
height: scaleWidth(71),
|
|
266
|
-
marginRight: scaleWidth(15),
|
|
267
|
-
tintColor: theme.colors.tintColor,
|
|
268
|
-
resizeMode: 'contain',
|
|
269
|
-
},
|
|
270
|
-
menuText: {
|
|
271
|
-
...theme.text.body1,
|
|
272
|
-
},
|
|
273
|
-
logoutText: {
|
|
274
|
-
color: theme.colors.red,
|
|
275
|
-
},
|
|
276
|
-
logoutIcon: {
|
|
277
|
-
tintColor: theme.colors.red,
|
|
278
|
-
},
|
|
279
|
-
languageOptions: {
|
|
280
|
-
flexDirection: 'row',
|
|
281
|
-
marginTop: scaleWidth(10),
|
|
282
|
-
},
|
|
283
|
-
languageOption: {
|
|
284
|
-
marginRight: scaleWidth(20),
|
|
285
|
-
paddingVertical: scaleWidth(5),
|
|
286
|
-
paddingHorizontal: scaleWidth(10),
|
|
287
|
-
borderRadius: theme.borderRadius.sm,
|
|
288
|
-
},
|
|
289
|
-
activeLanguage: {
|
|
290
|
-
backgroundColor: theme.colors.indigoBlue,
|
|
291
|
-
color: theme.colors.white,
|
|
292
|
-
},
|
|
293
|
-
});
|