@fadyshawky/react-native-magic 2.0.3 → 2.0.5
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/src/common/ImageResources.g.ts +33 -1
- package/template/src/common/components/Background.tsx +3 -1
- package/template/src/common/components/Container.tsx +1 -1
- package/template/src/common/components/OTPInput.tsx +3 -2
- package/template/src/common/components/PrimaryButton.tsx +23 -23
- package/template/src/common/components/PrimaryTextInput.tsx +189 -199
- package/template/src/common/components/RadioIcon.tsx +4 -4
- package/template/src/common/components/SafeText.tsx +41 -0
- package/template/src/common/components/SearchBar.tsx +19 -17
- package/template/src/common/components/TryAgain.tsx +3 -3
- package/template/src/common/localization/localization.ts +10 -0
- package/template/src/common/localization/translations/commonLocalization.ts +97 -0
- package/template/src/common/localization/translations/homeLocalization.ts +24 -0
- package/template/src/common/localization/translations/loginLocalization.ts +28 -2
- package/template/src/common/localization/translations/mainNavigationLocalization.ts +30 -0
- package/template/src/common/localization/translations/navigationLocalization.ts +48 -0
- package/template/src/common/localization/translations/otpLocalization.ts +28 -0
- package/template/src/common/localization/translations/passwordLocalization.ts +54 -0
- package/template/src/common/localization/translations/posLocalization.ts +196 -0
- package/template/src/common/utils/FeesCaalculation.tsx +37 -0
- package/template/src/common/utils/index.tsx +11 -0
- package/template/src/common/utils/printData.tsx +161 -0
- package/template/src/common/validations/errorValidations.ts +3 -2
- package/template/src/components/PrinterExample.js +226 -0
- package/template/src/core/api/serverHeaders.ts +62 -1
- package/template/src/core/store/Categories/categoryActions.ts +33 -0
- package/template/src/core/store/Categories/categorySlice.ts +75 -0
- package/template/src/core/store/Categories/categoryState.ts +41 -0
- package/template/src/core/store/Providers/providersActions.ts +102 -0
- package/template/src/core/store/Providers/providersSlice.ts +136 -0
- package/template/src/core/store/Providers/providersState.ts +37 -0
- package/template/src/core/store/Services/servicesActions.ts +191 -0
- package/template/src/core/store/Services/servicesSlice.ts +205 -0
- package/template/src/core/store/Services/servicesState.ts +466 -0
- package/template/src/core/store/app/appSlice.ts +13 -5
- package/template/src/core/store/app/appState.ts +10 -2
- package/template/src/core/store/rootReducer.ts +6 -1
- package/template/src/core/store/store.tsx +55 -2
- package/template/src/core/store/user/userActions.ts +164 -26
- package/template/src/core/store/user/userSlice.ts +193 -21
- package/template/src/core/store/user/userState.ts +148 -25
- package/template/src/core/theme/colors.ts +70 -94
- package/template/src/core/theme/commonConsts.ts +1 -1
- package/template/src/core/theme/commonSizes.ts +94 -119
- package/template/src/core/theme/commonStyles.ts +22 -22
- package/template/src/core/theme/fonts.ts +14 -13
- package/template/src/core/theme/themes.ts +75 -386
- package/template/src/core/theme/types.ts +15 -201
- package/template/src/core/utils/stringUtils.ts +114 -0
- package/template/src/modules/SunmiCard.js +212 -0
- package/template/src/modules/SunmiPrepaid.ts +122 -0
- package/template/src/navigation/AuthStack.tsx +8 -0
- package/template/src/navigation/HeaderComponents.tsx +76 -1
- package/template/src/navigation/MainNavigation.tsx +3 -1
- package/template/src/navigation/MainStack.tsx +130 -56
- package/template/src/navigation/TabBar.tsx +111 -59
- package/template/src/navigation/types.ts +24 -0
- package/template/src/screens/Categories/Categories.tsx +141 -0
- package/template/src/screens/Categories/hooks/useCategoriesData.ts +33 -0
- package/template/src/screens/Categories/types.ts +7 -0
- package/template/src/screens/Favorites/Favorites.tsx +130 -0
- package/template/src/screens/ForceChangePassword/ForceChangePasswordScreen.tsx +155 -0
- package/template/src/screens/History/History.tsx +430 -0
- package/template/src/screens/History/hooks/useHistoryData.ts +49 -0
- package/template/src/screens/History/types.ts +7 -0
- package/template/src/screens/InquiredBill/InquiredBill.tsx +443 -0
- package/template/src/screens/InquiredBill/hooks/useInquiredData.ts +91 -0
- package/template/src/screens/Login/Login.tsx +85 -85
- package/template/src/screens/OTP/OTPScreen.tsx +170 -0
- package/template/src/screens/PaymentConfirmation/PaymentConfirmation.tsx +326 -0
- package/template/src/screens/Providers/Providers.tsx +166 -0
- package/template/src/screens/Providers/hooks/useProvidersData.ts +33 -0
- package/template/src/screens/Providers/types.ts +7 -0
- package/template/src/screens/ReceiptScreen/ReceiptScreen.tsx +181 -0
- package/template/src/screens/ReceiptScreen/hooks/useReceiptData.ts +46 -0
- package/template/src/screens/ReceiptScreen/utils/utils.tsx +156 -0
- package/template/src/screens/Services/Services.tsx +144 -0
- package/template/src/screens/Services/hooks/useServicesData.ts +41 -0
- package/template/src/screens/SingleService/Components/FawryInputs.tsx +446 -0
- package/template/src/screens/SingleService/SingleService.tsx +229 -0
- package/template/src/screens/SingleService/hooks/useServiceData.ts +164 -0
- package/template/src/screens/home/Components/PayByCode.tsx +129 -0
- package/template/src/screens/home/HomeScreen.tsx +268 -77
- package/template/src/screens/home/hooks/useHomeData.ts +32 -38
- package/template/src/screens/index.tsx +24 -0
- package/template/src/screens/profile/Profile.tsx +290 -2
- package/template/src/services/SunmiPrinterInternal.js +268 -0
- package/template/src/types/sunmiPrepaid.d.ts +20 -0
- package/template/src/utils/SunmiPrinter.ts +442 -0
- package/template/src/utils/feesCalculator.ts +92 -0
- package/template/src/common/components/Stepper.tsx +0 -153
- package/template/src/common/components/Svg.tsx +0 -25
- package/template/src/common/hooks/useDebounce.ts +0 -17
- package/template/src/common/hooks/usePrevious.ts +0 -11
- package/template/src/common/localization/intlFormatter.ts +0 -37
- package/template/src/common/urls/emailUrl.ts +0 -20
- package/template/src/common/urls/mapUrl.ts +0 -22
- package/template/src/common/utils/listHandlers.ts +0 -30
- package/template/src/common/utils/serializeQueryParams.ts +0 -10
- package/template/src/common/validations/hooks/useDatesError.ts +0 -40
- package/template/src/common/validations/profileValidations.ts +0 -30
- package/template/src/core/theme/shadows.ts +0 -135
- package/template/src/navigation/TopTabBar.tsx +0 -77
- package/template/src/screens/Settings/Settings.tsx +0 -5
- package/template/src/screens/home/components/CarouselSection.tsx +0 -79
- package/template/src/screens/home/components/FeaturedCarousel.tsx +0 -128
- package/template/src/screens/main/Main.tsx +0 -5
- package/template/src/screens/registration/RegistrationScreen.tsx +0 -198
- package/template/src/screens/resetPassword/ForgotPasswordScreen.tsx +0 -129
|
@@ -1,18 +1,93 @@
|
|
|
1
|
+
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import {StyleSheet, View} from 'react-native';
|
|
3
|
+
import {Image, StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
4
|
+
import {ImageResources} from '../common/ImageResources.g';
|
|
3
5
|
import {CommonSizes} from '../core/theme/commonSizes';
|
|
4
6
|
import {screenWidth} from '../core/theme/commonStyles';
|
|
7
|
+
import {useTheme} from '../core/theme/ThemeProvider';
|
|
8
|
+
import {RootStackParamList} from './types';
|
|
9
|
+
import {useRTL} from '../common/localization/LocalizationProvider';
|
|
5
10
|
import {scaleWidth} from '../core/theme/scaling';
|
|
11
|
+
export function Header() {
|
|
12
|
+
return (
|
|
13
|
+
<View style={styles.headerBase}>
|
|
14
|
+
<Image source={ImageResources.light_header_logo} style={styles.logo} />
|
|
15
|
+
</View>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function HeaderBack({onPress}: {onPress: () => void}) {
|
|
20
|
+
return (
|
|
21
|
+
<View style={styles.headerWithBack}>
|
|
22
|
+
<BackButton onPress={onPress} />
|
|
23
|
+
<Image source={ImageResources.light_header_logo} style={styles.logo} />
|
|
24
|
+
<View style={{width: 40}} />
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
6
28
|
|
|
7
29
|
export function HeaderButton({onPress}: {onPress: () => void}) {
|
|
8
30
|
return (
|
|
9
31
|
<View style={styles.headerWithBack}>
|
|
32
|
+
<BackButton onPress={onPress} />
|
|
10
33
|
<View style={styles.logo} />
|
|
11
34
|
<View style={{width: 40}} />
|
|
12
35
|
</View>
|
|
13
36
|
);
|
|
14
37
|
}
|
|
15
38
|
|
|
39
|
+
export function HomeHeader({onPress}: {onPress: () => void}) {
|
|
40
|
+
return (
|
|
41
|
+
<View style={styles.headerWithBack}>
|
|
42
|
+
<RefreshButton onPress={onPress} />
|
|
43
|
+
<Image source={ImageResources.light_header_logo} style={styles.logo} />
|
|
44
|
+
<View style={{width: 40}} />
|
|
45
|
+
</View>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function WebViewHeader({
|
|
50
|
+
navigation,
|
|
51
|
+
}: {
|
|
52
|
+
navigation: NativeStackNavigationProp<RootStackParamList>;
|
|
53
|
+
}) {
|
|
54
|
+
return (
|
|
55
|
+
<View style={styles.webViewHeader}>
|
|
56
|
+
{/* <BackButton navigation={navigation} /> */}
|
|
57
|
+
</View>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function BackButton({onPress}: {onPress: () => void}) {
|
|
62
|
+
const {theme} = useTheme();
|
|
63
|
+
const isRTL = useRTL();
|
|
64
|
+
return (
|
|
65
|
+
<TouchableOpacity style={styles.backButton} onPressIn={onPress}>
|
|
66
|
+
<Image
|
|
67
|
+
tintColor={theme.colors.tintColor}
|
|
68
|
+
style={{
|
|
69
|
+
...styles.backIcon,
|
|
70
|
+
transform: [{rotate: isRTL ? '180deg' : '0deg'}],
|
|
71
|
+
}}
|
|
72
|
+
source={ImageResources.arrow_left}
|
|
73
|
+
/>
|
|
74
|
+
</TouchableOpacity>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function RefreshButton({onPress}: {onPress: () => void}) {
|
|
79
|
+
const {theme} = useTheme();
|
|
80
|
+
return (
|
|
81
|
+
<TouchableOpacity style={styles.backButton} onPressIn={onPress}>
|
|
82
|
+
<Image
|
|
83
|
+
tintColor={theme.colors.tintColor}
|
|
84
|
+
style={styles.backIcon}
|
|
85
|
+
source={ImageResources.repeat}
|
|
86
|
+
/>
|
|
87
|
+
</TouchableOpacity>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
16
91
|
const styles = StyleSheet.create({
|
|
17
92
|
headerBase: {
|
|
18
93
|
width: '100%',
|
|
@@ -7,6 +7,8 @@ import {useAppSelector} from '../core/store/reduxHelpers';
|
|
|
7
7
|
import {AuthStack} from './AuthStack';
|
|
8
8
|
import {AppMainNavigator} from './MainStack';
|
|
9
9
|
import {navigationRef} from './RootNavigation';
|
|
10
|
+
import {NewColors} from '../core/theme/colors';
|
|
11
|
+
import {Fonts} from '../core/theme/fonts';
|
|
10
12
|
|
|
11
13
|
function AppNavigator() {
|
|
12
14
|
const routeNameRef = useRef<string | undefined>(undefined);
|
|
@@ -22,7 +24,7 @@ function AppNavigator() {
|
|
|
22
24
|
dark: false,
|
|
23
25
|
colors: {
|
|
24
26
|
primary: '#000',
|
|
25
|
-
background:
|
|
27
|
+
background: NewColors.background,
|
|
26
28
|
card: '#fff',
|
|
27
29
|
text: '#000',
|
|
28
30
|
border: '#000',
|
|
@@ -1,52 +1,143 @@
|
|
|
1
1
|
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
|
|
2
|
-
import {createNativeStackNavigator} from '@react-navigation/native-stack';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
3
|
+
import {ImageResources} from '../common/ImageResources.g';
|
|
4
|
+
import {useTranslation} from '../common/localization/LocalizationProvider';
|
|
5
|
+
|
|
7
6
|
import {TabBar} from './TabBar';
|
|
7
|
+
import {createNativeStackNavigator} from '@react-navigation/native-stack';
|
|
8
|
+
import {
|
|
9
|
+
Favorites,
|
|
10
|
+
History,
|
|
11
|
+
Profile,
|
|
12
|
+
Services,
|
|
13
|
+
SingleService,
|
|
14
|
+
InquiredBill,
|
|
15
|
+
PaymentConfirmation,
|
|
16
|
+
Categories,
|
|
17
|
+
Providers,
|
|
18
|
+
ReceiptScreen,
|
|
19
|
+
} from '../screens';
|
|
20
|
+
import {ForceChangePasswordScreen} from '../screens/ForceChangePassword/ForceChangePasswordScreen';
|
|
21
|
+
import {HomeScreen} from '../screens/home/HomeScreen';
|
|
22
|
+
|
|
23
|
+
const Tab = createBottomTabNavigator();
|
|
24
|
+
const Stack = createNativeStackNavigator();
|
|
8
25
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
26
|
+
export function AppMainNavigator() {
|
|
27
|
+
const t = useTranslation();
|
|
28
|
+
|
|
29
|
+
const MainScreens = [
|
|
30
|
+
{
|
|
31
|
+
id: 'Main',
|
|
32
|
+
component: HomeScreen,
|
|
33
|
+
options: {
|
|
34
|
+
tabBarLabel: t('tabs.Main', 'mainNavigation'),
|
|
35
|
+
headerShown: false,
|
|
36
|
+
icon: ImageResources.services,
|
|
37
|
+
selectedIcon: ImageResources.services,
|
|
38
|
+
},
|
|
15
39
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
40
|
+
{
|
|
41
|
+
id: 'Favorites',
|
|
42
|
+
component: Favorites,
|
|
43
|
+
options: {
|
|
44
|
+
tabBarLabel: t('tabs.Favorites', 'mainNavigation'),
|
|
45
|
+
headerShown: false,
|
|
46
|
+
icon: ImageResources.favourites,
|
|
47
|
+
selectedIcon: ImageResources.favourites,
|
|
48
|
+
},
|
|
22
49
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
{
|
|
51
|
+
id: 'Financials',
|
|
52
|
+
component: History,
|
|
53
|
+
options: {
|
|
54
|
+
tabBarLabel: t('tabs.Financials', 'mainNavigation'),
|
|
55
|
+
headerShown: false,
|
|
56
|
+
icon: ImageResources.financials,
|
|
57
|
+
selectedIcon: ImageResources.financials,
|
|
58
|
+
},
|
|
32
59
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
{
|
|
61
|
+
id: 'Account',
|
|
62
|
+
component: Profile,
|
|
63
|
+
options: {
|
|
64
|
+
tabBarLabel: t('tabs.Account', 'mainNavigation'),
|
|
65
|
+
headerShown: false,
|
|
66
|
+
icon: ImageResources.account,
|
|
67
|
+
selectedIcon: ImageResources.account,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'ForceChangePassword',
|
|
72
|
+
component: ForceChangePasswordScreen,
|
|
73
|
+
options: {
|
|
74
|
+
headerShown: false,
|
|
75
|
+
title: t('screens.ForceChangePassword', 'mainNavigation'),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'Services',
|
|
80
|
+
component: Services,
|
|
81
|
+
options: {
|
|
82
|
+
headerShown: false,
|
|
83
|
+
title: t('screens.Services', 'mainNavigation'),
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'SingleService',
|
|
88
|
+
component: SingleService,
|
|
89
|
+
options: {
|
|
90
|
+
headerShown: false,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'InquiredBill',
|
|
95
|
+
component: InquiredBill,
|
|
96
|
+
options: {
|
|
97
|
+
headerShown: false,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'PaymentConfirmation',
|
|
102
|
+
component: PaymentConfirmation,
|
|
103
|
+
options: {
|
|
104
|
+
headerShown: false,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: 'ReceiptScreen',
|
|
109
|
+
component: ReceiptScreen,
|
|
110
|
+
options: {
|
|
111
|
+
headerShown: false,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: 'Categories',
|
|
116
|
+
component: Categories,
|
|
117
|
+
options: {
|
|
118
|
+
headerShown: false,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: 'Providers',
|
|
123
|
+
component: Providers,
|
|
124
|
+
options: {
|
|
125
|
+
headerShown: false,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
];
|
|
44
129
|
|
|
45
|
-
function MainTabs() {
|
|
46
130
|
return (
|
|
47
131
|
<Tab.Navigator
|
|
48
|
-
initialRouteName="
|
|
49
|
-
|
|
132
|
+
initialRouteName="Main"
|
|
133
|
+
backBehavior="history"
|
|
134
|
+
detachInactiveScreens
|
|
135
|
+
tabBar={props => {
|
|
136
|
+
return <TabBar {...props} />;
|
|
137
|
+
}}
|
|
138
|
+
screenOptions={{
|
|
139
|
+
tabBarHideOnKeyboard: true,
|
|
140
|
+
}}>
|
|
50
141
|
{MainScreens.map(s => (
|
|
51
142
|
<Tab.Screen
|
|
52
143
|
key={s.id}
|
|
@@ -58,20 +149,3 @@ function MainTabs() {
|
|
|
58
149
|
</Tab.Navigator>
|
|
59
150
|
);
|
|
60
151
|
}
|
|
61
|
-
|
|
62
|
-
export function AppMainNavigator() {
|
|
63
|
-
return (
|
|
64
|
-
<Stack.Navigator screenOptions={{animation: 'none'}}>
|
|
65
|
-
{AppStack.map(s => {
|
|
66
|
-
return (
|
|
67
|
-
<Stack.Screen
|
|
68
|
-
key={s.id}
|
|
69
|
-
name={s.id}
|
|
70
|
-
component={s.component}
|
|
71
|
-
options={s.options}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
})}
|
|
75
|
-
</Stack.Navigator>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {View, Text, TouchableOpacity, Image, StyleSheet} from 'react-native';
|
|
3
|
-
import {CommonStyles} from '../core/theme/commonStyles';
|
|
4
1
|
import {
|
|
5
2
|
BottomTabBarProps,
|
|
6
3
|
BottomTabNavigationOptions,
|
|
7
4
|
} from '@react-navigation/bottom-tabs';
|
|
8
|
-
import {ImageSourcePropType} from 'react-native';
|
|
9
5
|
import {toString} from 'lodash';
|
|
10
|
-
import
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import {
|
|
8
|
+
Image,
|
|
9
|
+
ImageSourcePropType,
|
|
10
|
+
StyleSheet,
|
|
11
|
+
TouchableOpacity,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
import {RTLAwareText} from '../common/components/RTLAwareText';
|
|
14
|
+
import {RTLAwareView} from '../common/components/RTLAwareView';
|
|
15
|
+
import {
|
|
16
|
+
useRTL,
|
|
17
|
+
useTranslation,
|
|
18
|
+
} from '../common/localization/LocalizationProvider';
|
|
19
|
+
import {BlackColors, NewColors} from '../core/theme/colors';
|
|
20
|
+
import {CommonSizes} from '../core/theme/commonSizes';
|
|
21
|
+
import {CommonStyles} from '../core/theme/commonStyles';
|
|
22
|
+
import {scaleHeight, scaleWidth} from '../core/theme/scaling';
|
|
23
|
+
import {useTheme} from '../core/theme/ThemeProvider';
|
|
11
24
|
|
|
12
25
|
interface TabBarOptions extends BottomTabNavigationOptions {
|
|
13
26
|
selectedIcon: ImageSourcePropType;
|
|
@@ -16,58 +29,94 @@ interface TabBarOptions extends BottomTabNavigationOptions {
|
|
|
16
29
|
}
|
|
17
30
|
|
|
18
31
|
export function TabBar({state, descriptors, navigation}: BottomTabBarProps) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
options: TabBarOptions;
|
|
24
|
-
};
|
|
25
|
-
const label =
|
|
26
|
-
options.tabBarLabel !== undefined
|
|
27
|
-
? options.tabBarLabel
|
|
28
|
-
: options.title !== undefined
|
|
29
|
-
? options.title
|
|
30
|
-
: route.name;
|
|
32
|
+
const {theme} = useTheme();
|
|
33
|
+
const t = useTranslation();
|
|
34
|
+
const isRTL = useRTL();
|
|
35
|
+
const tabArray = ['Main', 'Financials', 'Account'];
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
// Create a copy of routes array to avoid modifying the original
|
|
38
|
+
const routesToRender = [...state.routes].filter(r =>
|
|
39
|
+
tabArray.includes(r.name),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// If RTL, reverse the order of tabs
|
|
43
|
+
if (isRTL) {
|
|
44
|
+
routesToRender.reverse();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
state.index <= 3 && (
|
|
49
|
+
<RTLAwareView style={styles.container}>
|
|
50
|
+
{routesToRender.map((route, index) => {
|
|
51
|
+
// Calculate the correct index in the original array for focused state
|
|
52
|
+
const originalIndex = isRTL ? state.routes.length - 1 - index : index;
|
|
53
|
+
const isFocused = state.index === originalIndex;
|
|
33
54
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
target: route.key,
|
|
38
|
-
canPreventDefault: true,
|
|
39
|
-
});
|
|
55
|
+
const {options} = descriptors[route.key] as unknown as {
|
|
56
|
+
options: TabBarOptions;
|
|
57
|
+
};
|
|
40
58
|
|
|
41
|
-
|
|
42
|
-
|
|
59
|
+
// Get localized tab name
|
|
60
|
+
let label = route.name;
|
|
61
|
+
if (options.tabBarLabel !== undefined) {
|
|
62
|
+
label = options.tabBarLabel as string;
|
|
63
|
+
} else if (options.title !== undefined) {
|
|
64
|
+
label = options.title;
|
|
65
|
+
} else {
|
|
66
|
+
// Try to get localized name from mainNavigation translations
|
|
67
|
+
const localizedName = t(`tabs.${route.name}`, 'mainNavigation');
|
|
68
|
+
if (localizedName !== `tabs.${route.name}`) {
|
|
69
|
+
label = localizedName;
|
|
70
|
+
}
|
|
43
71
|
}
|
|
44
|
-
};
|
|
45
72
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
73
|
+
const onPress = () => {
|
|
74
|
+
const event = navigation.emit({
|
|
75
|
+
type: 'tabPress',
|
|
76
|
+
target: route.key,
|
|
77
|
+
canPreventDefault: true,
|
|
78
|
+
});
|
|
52
79
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
if (!isFocused && !event.defaultPrevented) {
|
|
81
|
+
navigation.navigate(route.name, route.params);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const onLongPress = () => {
|
|
86
|
+
navigation.emit({
|
|
87
|
+
type: 'tabLongPress',
|
|
88
|
+
target: route.key,
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<TouchableOpacity
|
|
94
|
+
key={route.key}
|
|
95
|
+
accessibilityRole="button"
|
|
96
|
+
accessibilityState={isFocused ? {selected: true} : {}}
|
|
97
|
+
accessibilityLabel={
|
|
98
|
+
options.tabBarAccessibilityLabel || label?.toString()
|
|
99
|
+
}
|
|
100
|
+
testID={options.tabBarTestID}
|
|
101
|
+
onPressIn={onPress}
|
|
102
|
+
onLongPress={onLongPress}
|
|
103
|
+
style={styles.tabButton}>
|
|
104
|
+
<Image
|
|
105
|
+
style={{
|
|
106
|
+
width: scaleWidth(57),
|
|
107
|
+
height: scaleHeight(63),
|
|
108
|
+
resizeMode: 'contain',
|
|
109
|
+
}}
|
|
110
|
+
source={isFocused ? options.selectedIcon : options.icon}
|
|
111
|
+
/>
|
|
112
|
+
<RTLAwareText style={[theme.text.navBar]}>
|
|
113
|
+
{toString(label)}
|
|
114
|
+
</RTLAwareText>
|
|
115
|
+
</TouchableOpacity>
|
|
116
|
+
);
|
|
117
|
+
})}
|
|
118
|
+
</RTLAwareView>
|
|
119
|
+
)
|
|
71
120
|
);
|
|
72
121
|
}
|
|
73
122
|
|
|
@@ -75,20 +124,23 @@ const styles = StyleSheet.create({
|
|
|
75
124
|
container: {
|
|
76
125
|
flexDirection: 'row',
|
|
77
126
|
alignItems: 'center',
|
|
78
|
-
height:
|
|
79
|
-
borderTopLeftRadius:
|
|
80
|
-
borderTopRightRadius:
|
|
127
|
+
height: scaleHeight(130),
|
|
128
|
+
borderTopLeftRadius: CommonSizes.borderRadius.huge,
|
|
129
|
+
borderTopRightRadius: CommonSizes.borderRadius.huge,
|
|
81
130
|
justifyContent: 'space-evenly',
|
|
82
|
-
...CommonStyles.
|
|
131
|
+
...CommonStyles.dropShadow,
|
|
132
|
+
backgroundColor: BlackColors.indigoBlue,
|
|
133
|
+
position: 'absolute',
|
|
134
|
+
bottom: 0,
|
|
135
|
+
left: 0,
|
|
136
|
+
right: 0,
|
|
83
137
|
},
|
|
84
138
|
tabButton: {
|
|
85
139
|
flex: 1,
|
|
86
140
|
alignItems: 'center',
|
|
87
141
|
},
|
|
88
|
-
label: {
|
|
89
|
-
color: NaturalColors.grayScale_50,
|
|
90
|
-
},
|
|
142
|
+
label: {},
|
|
91
143
|
labelFocused: {
|
|
92
|
-
color:
|
|
144
|
+
color: NewColors.blueNormalActive,
|
|
93
145
|
},
|
|
94
146
|
});
|
|
@@ -8,4 +8,28 @@ export type RootStackParamList = {
|
|
|
8
8
|
Profile: undefined;
|
|
9
9
|
Settings: undefined;
|
|
10
10
|
Splash: undefined;
|
|
11
|
+
OTP: {phone?: string};
|
|
12
|
+
ForceChangePassword: undefined;
|
|
13
|
+
Services: {providerID: string};
|
|
14
|
+
SingleService: {serviceID?: string};
|
|
15
|
+
InquiredBill: undefined;
|
|
16
|
+
Loading: undefined;
|
|
17
|
+
PaymentConfirmation: {
|
|
18
|
+
paymentData: {
|
|
19
|
+
amountToBePaid: string;
|
|
20
|
+
billInfo: any;
|
|
21
|
+
fees: number;
|
|
22
|
+
currencyCode: string;
|
|
23
|
+
billRec: {
|
|
24
|
+
BillingAcct: string;
|
|
25
|
+
BillerId: string;
|
|
26
|
+
BillTypeCode: number;
|
|
27
|
+
BillRefNumber: string;
|
|
28
|
+
BillStatus: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
Categories: undefined;
|
|
33
|
+
Providers: {categoryID: string};
|
|
34
|
+
ReceiptScreen: {type: 'print' | 'history'; historyID?: string};
|
|
11
35
|
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {useIsFocused, useNavigation} from '@react-navigation/native';
|
|
2
|
+
import {NativeStackNavigationProp} from '@react-navigation/native-stack';
|
|
3
|
+
import React, {useEffect, useRef} from 'react';
|
|
4
|
+
import {StyleSheet, View} from 'react-native';
|
|
5
|
+
import {SkypeIndicator} from 'react-native-indicators';
|
|
6
|
+
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view';
|
|
7
|
+
import {LoadState} 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 {ImageResources} from '../../common/ImageResources.g';
|
|
12
|
+
import {useTranslation} from '../../common/localization/LocalizationProvider';
|
|
13
|
+
import {CommonSizes} from '../../core/theme/commonSizes';
|
|
14
|
+
import {scaleHeight, scaleWidth} from '../../core/theme/scaling';
|
|
15
|
+
import {useTheme} from '../../core/theme/ThemeProvider';
|
|
16
|
+
import {HeaderBack} from '../../navigation/HeaderComponents';
|
|
17
|
+
import {RootStackParamList} from '../../navigation/types';
|
|
18
|
+
import {useCategoriesData} from './hooks/useCategoriesData';
|
|
19
|
+
import {setSelectedCategory} from '../../core/store/Categories/categorySlice';
|
|
20
|
+
import {useAppDispatch} from '../../core/store/reduxHelpers';
|
|
21
|
+
|
|
22
|
+
export function Categories(): JSX.Element {
|
|
23
|
+
const {isLoading, fetchData, categories} = useCategoriesData();
|
|
24
|
+
const t = useTranslation();
|
|
25
|
+
const navigation =
|
|
26
|
+
useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
|
27
|
+
const {theme} = useTheme();
|
|
28
|
+
const scroll = useRef<KeyboardAwareScrollView>(null);
|
|
29
|
+
const isFocused = useIsFocused();
|
|
30
|
+
const dispatch = useAppDispatch();
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (isFocused && categories.length === 0) {
|
|
34
|
+
fetchData();
|
|
35
|
+
}
|
|
36
|
+
}, [isFocused]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Container
|
|
40
|
+
ref={scroll}
|
|
41
|
+
testID={'CategoriesScreenID'}
|
|
42
|
+
contentContainerStyle={styles.contentContainer}
|
|
43
|
+
style={styles.container}
|
|
44
|
+
backgroundImage={ImageResources[`${theme.mode}_background_1`]}
|
|
45
|
+
withoutPadding
|
|
46
|
+
withoutScroll
|
|
47
|
+
backgroundColor={theme.colors.background}>
|
|
48
|
+
{isLoading ? (
|
|
49
|
+
<SkypeIndicator size={80} color={theme.colors.mutedLavender} />
|
|
50
|
+
) : (
|
|
51
|
+
<>
|
|
52
|
+
<HeaderBack onPress={navigation.goBack} />
|
|
53
|
+
<FlatListWrapper
|
|
54
|
+
contentContainerStyle={{
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
paddingBottom: scaleHeight(50),
|
|
57
|
+
}}
|
|
58
|
+
style={{
|
|
59
|
+
flex: 1,
|
|
60
|
+
alignSelf: 'center',
|
|
61
|
+
}}
|
|
62
|
+
ItemSeparatorComponent={() => (
|
|
63
|
+
<View style={{height: CommonSizes.spacing.large}} />
|
|
64
|
+
)}
|
|
65
|
+
keyExtractor={(item, index) => `${item.id}-${index}`}
|
|
66
|
+
loadState={
|
|
67
|
+
isLoading ? LoadState['loadingMore'] : LoadState['pullToRefresh']
|
|
68
|
+
}
|
|
69
|
+
data={categories}
|
|
70
|
+
numColumns={3}
|
|
71
|
+
renderItem={({item, index}) => (
|
|
72
|
+
<Card
|
|
73
|
+
cardStyle={{
|
|
74
|
+
width: scaleWidth(187),
|
|
75
|
+
height: scaleHeight(260),
|
|
76
|
+
}}
|
|
77
|
+
key={item.id}
|
|
78
|
+
icon={{uri: item.img_url}}
|
|
79
|
+
title={item.name}
|
|
80
|
+
onPress={() => {
|
|
81
|
+
dispatch(setSelectedCategory(item));
|
|
82
|
+
navigation.navigate('Providers', {
|
|
83
|
+
categoryID: item?.id?.toString(),
|
|
84
|
+
});
|
|
85
|
+
}}
|
|
86
|
+
marginRight={
|
|
87
|
+
(index % 3) + 1 !== 3 ? CommonSizes.spacing.medium : undefined
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
)}
|
|
91
|
+
/>
|
|
92
|
+
</>
|
|
93
|
+
)}
|
|
94
|
+
</Container>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const styles = StyleSheet.create({
|
|
99
|
+
container: {
|
|
100
|
+
flexGrow: 1,
|
|
101
|
+
borderTopRightRadius: CommonSizes.spacing.large,
|
|
102
|
+
borderTopLeftRadius: CommonSizes.spacing.large,
|
|
103
|
+
gap: CommonSizes.spacing.large,
|
|
104
|
+
justifyContent: 'flex-start',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
},
|
|
107
|
+
contentContainer: {
|
|
108
|
+
flexGrow: 1,
|
|
109
|
+
},
|
|
110
|
+
searchBar: {
|
|
111
|
+
width: '90%',
|
|
112
|
+
alignSelf: 'center',
|
|
113
|
+
marginTop: CommonSizes.spacing.medium,
|
|
114
|
+
},
|
|
115
|
+
formContainer: {
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
paddingHorizontal: CommonSizes.spacing.large,
|
|
118
|
+
gap: CommonSizes.spacing.large,
|
|
119
|
+
},
|
|
120
|
+
balanceSection: {
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
justifyContent: 'space-evenly',
|
|
123
|
+
gap: CommonSizes.spacing.large,
|
|
124
|
+
},
|
|
125
|
+
seeMoreSection: {
|
|
126
|
+
alignItems: 'center',
|
|
127
|
+
gap: CommonSizes.spacing.large,
|
|
128
|
+
alignSelf: 'center',
|
|
129
|
+
},
|
|
130
|
+
sectionImage: {
|
|
131
|
+
width: scaleWidth(120),
|
|
132
|
+
height: scaleHeight(70),
|
|
133
|
+
},
|
|
134
|
+
amountText: {
|
|
135
|
+
textAlign: 'left',
|
|
136
|
+
},
|
|
137
|
+
balanceCard: {
|
|
138
|
+
width: '100%',
|
|
139
|
+
borderRadius: CommonSizes.spacing.huge,
|
|
140
|
+
},
|
|
141
|
+
});
|