@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.
Files changed (110) hide show
  1. package/package.json +1 -1
  2. package/template/src/common/ImageResources.g.ts +33 -1
  3. package/template/src/common/components/Background.tsx +3 -1
  4. package/template/src/common/components/Container.tsx +1 -1
  5. package/template/src/common/components/OTPInput.tsx +3 -2
  6. package/template/src/common/components/PrimaryButton.tsx +23 -23
  7. package/template/src/common/components/PrimaryTextInput.tsx +189 -199
  8. package/template/src/common/components/RadioIcon.tsx +4 -4
  9. package/template/src/common/components/SafeText.tsx +41 -0
  10. package/template/src/common/components/SearchBar.tsx +19 -17
  11. package/template/src/common/components/TryAgain.tsx +3 -3
  12. package/template/src/common/localization/localization.ts +10 -0
  13. package/template/src/common/localization/translations/commonLocalization.ts +97 -0
  14. package/template/src/common/localization/translations/homeLocalization.ts +24 -0
  15. package/template/src/common/localization/translations/loginLocalization.ts +28 -2
  16. package/template/src/common/localization/translations/mainNavigationLocalization.ts +30 -0
  17. package/template/src/common/localization/translations/navigationLocalization.ts +48 -0
  18. package/template/src/common/localization/translations/otpLocalization.ts +28 -0
  19. package/template/src/common/localization/translations/passwordLocalization.ts +54 -0
  20. package/template/src/common/localization/translations/posLocalization.ts +196 -0
  21. package/template/src/common/utils/FeesCaalculation.tsx +37 -0
  22. package/template/src/common/utils/index.tsx +11 -0
  23. package/template/src/common/utils/printData.tsx +161 -0
  24. package/template/src/common/validations/errorValidations.ts +3 -2
  25. package/template/src/components/PrinterExample.js +226 -0
  26. package/template/src/core/api/serverHeaders.ts +62 -1
  27. package/template/src/core/store/Categories/categoryActions.ts +33 -0
  28. package/template/src/core/store/Categories/categorySlice.ts +75 -0
  29. package/template/src/core/store/Categories/categoryState.ts +41 -0
  30. package/template/src/core/store/Providers/providersActions.ts +102 -0
  31. package/template/src/core/store/Providers/providersSlice.ts +136 -0
  32. package/template/src/core/store/Providers/providersState.ts +37 -0
  33. package/template/src/core/store/Services/servicesActions.ts +191 -0
  34. package/template/src/core/store/Services/servicesSlice.ts +205 -0
  35. package/template/src/core/store/Services/servicesState.ts +466 -0
  36. package/template/src/core/store/app/appSlice.ts +13 -5
  37. package/template/src/core/store/app/appState.ts +10 -2
  38. package/template/src/core/store/rootReducer.ts +6 -1
  39. package/template/src/core/store/store.tsx +55 -2
  40. package/template/src/core/store/user/userActions.ts +164 -26
  41. package/template/src/core/store/user/userSlice.ts +193 -21
  42. package/template/src/core/store/user/userState.ts +148 -25
  43. package/template/src/core/theme/colors.ts +70 -94
  44. package/template/src/core/theme/commonConsts.ts +1 -1
  45. package/template/src/core/theme/commonSizes.ts +94 -119
  46. package/template/src/core/theme/commonStyles.ts +22 -22
  47. package/template/src/core/theme/fonts.ts +14 -13
  48. package/template/src/core/theme/themes.ts +75 -386
  49. package/template/src/core/theme/types.ts +15 -201
  50. package/template/src/core/utils/stringUtils.ts +114 -0
  51. package/template/src/modules/SunmiCard.js +212 -0
  52. package/template/src/modules/SunmiPrepaid.ts +122 -0
  53. package/template/src/navigation/AuthStack.tsx +8 -0
  54. package/template/src/navigation/HeaderComponents.tsx +76 -1
  55. package/template/src/navigation/MainNavigation.tsx +3 -1
  56. package/template/src/navigation/MainStack.tsx +130 -56
  57. package/template/src/navigation/TabBar.tsx +111 -59
  58. package/template/src/navigation/types.ts +24 -0
  59. package/template/src/screens/Categories/Categories.tsx +141 -0
  60. package/template/src/screens/Categories/hooks/useCategoriesData.ts +33 -0
  61. package/template/src/screens/Categories/types.ts +7 -0
  62. package/template/src/screens/Favorites/Favorites.tsx +130 -0
  63. package/template/src/screens/ForceChangePassword/ForceChangePasswordScreen.tsx +155 -0
  64. package/template/src/screens/History/History.tsx +430 -0
  65. package/template/src/screens/History/hooks/useHistoryData.ts +49 -0
  66. package/template/src/screens/History/types.ts +7 -0
  67. package/template/src/screens/InquiredBill/InquiredBill.tsx +443 -0
  68. package/template/src/screens/InquiredBill/hooks/useInquiredData.ts +91 -0
  69. package/template/src/screens/Login/Login.tsx +85 -85
  70. package/template/src/screens/OTP/OTPScreen.tsx +170 -0
  71. package/template/src/screens/PaymentConfirmation/PaymentConfirmation.tsx +326 -0
  72. package/template/src/screens/Providers/Providers.tsx +166 -0
  73. package/template/src/screens/Providers/hooks/useProvidersData.ts +33 -0
  74. package/template/src/screens/Providers/types.ts +7 -0
  75. package/template/src/screens/ReceiptScreen/ReceiptScreen.tsx +181 -0
  76. package/template/src/screens/ReceiptScreen/hooks/useReceiptData.ts +46 -0
  77. package/template/src/screens/ReceiptScreen/utils/utils.tsx +156 -0
  78. package/template/src/screens/Services/Services.tsx +144 -0
  79. package/template/src/screens/Services/hooks/useServicesData.ts +41 -0
  80. package/template/src/screens/SingleService/Components/FawryInputs.tsx +446 -0
  81. package/template/src/screens/SingleService/SingleService.tsx +229 -0
  82. package/template/src/screens/SingleService/hooks/useServiceData.ts +164 -0
  83. package/template/src/screens/home/Components/PayByCode.tsx +129 -0
  84. package/template/src/screens/home/HomeScreen.tsx +268 -77
  85. package/template/src/screens/home/hooks/useHomeData.ts +32 -38
  86. package/template/src/screens/index.tsx +24 -0
  87. package/template/src/screens/profile/Profile.tsx +290 -2
  88. package/template/src/services/SunmiPrinterInternal.js +268 -0
  89. package/template/src/types/sunmiPrepaid.d.ts +20 -0
  90. package/template/src/utils/SunmiPrinter.ts +442 -0
  91. package/template/src/utils/feesCalculator.ts +92 -0
  92. package/template/src/common/components/Stepper.tsx +0 -153
  93. package/template/src/common/components/Svg.tsx +0 -25
  94. package/template/src/common/hooks/useDebounce.ts +0 -17
  95. package/template/src/common/hooks/usePrevious.ts +0 -11
  96. package/template/src/common/localization/intlFormatter.ts +0 -37
  97. package/template/src/common/urls/emailUrl.ts +0 -20
  98. package/template/src/common/urls/mapUrl.ts +0 -22
  99. package/template/src/common/utils/listHandlers.ts +0 -30
  100. package/template/src/common/utils/serializeQueryParams.ts +0 -10
  101. package/template/src/common/validations/hooks/useDatesError.ts +0 -40
  102. package/template/src/common/validations/profileValidations.ts +0 -30
  103. package/template/src/core/theme/shadows.ts +0 -135
  104. package/template/src/navigation/TopTabBar.tsx +0 -77
  105. package/template/src/screens/Settings/Settings.tsx +0 -5
  106. package/template/src/screens/home/components/CarouselSection.tsx +0 -79
  107. package/template/src/screens/home/components/FeaturedCarousel.tsx +0 -128
  108. package/template/src/screens/main/Main.tsx +0 -5
  109. package/template/src/screens/registration/RegistrationScreen.tsx +0 -198
  110. 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: 'white',
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 {HomeScreen} from '../screens/home/HomeScreen';
5
- import {Profile} from '../screens/profile/Profile';
6
- import {Settings} from '../screens/Settings/Settings';
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
- const MainScreens = [
10
- {
11
- id: 'Home',
12
- component: HomeScreen,
13
- options: {
14
- tabBarLabel: 'Profile',
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
- id: 'Profile',
19
- component: Profile,
20
- options: {
21
- tabBarLabel: 'Profile',
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
- const AppStack = [
27
- {
28
- id: 'Home',
29
- component: MainTabs,
30
- options: {
31
- headerShown: false,
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
- id: 'Settings',
36
- component: Settings,
37
- options: {},
38
- },
39
- ];
40
-
41
- const Stack = createNativeStackNavigator();
42
-
43
- const Tab = createBottomTabNavigator();
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="Home"
49
- tabBar={props => <TabBar {...props} />}>
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 {NaturalColors, PrimaryColors} from '../core/theme/colors';
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
- return (
20
- <View style={styles.container}>
21
- {state.routes.map((route, index) => {
22
- const {options} = descriptors[route.key] as unknown as {
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
- const isFocused = state.index === index;
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
- const onPress = () => {
35
- const event = navigation.emit({
36
- type: 'tabPress',
37
- target: route.key,
38
- canPreventDefault: true,
39
- });
55
+ const {options} = descriptors[route.key] as unknown as {
56
+ options: TabBarOptions;
57
+ };
40
58
 
41
- if (!isFocused && !event.defaultPrevented) {
42
- navigation.navigate(route.name, route.params);
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
- const onLongPress = () => {
47
- navigation.emit({
48
- type: 'tabLongPress',
49
- target: route.key,
50
- });
51
- };
73
+ const onPress = () => {
74
+ const event = navigation.emit({
75
+ type: 'tabPress',
76
+ target: route.key,
77
+ canPreventDefault: true,
78
+ });
52
79
 
53
- return (
54
- <TouchableOpacity
55
- key={route.key}
56
- accessibilityRole="button"
57
- accessibilityState={isFocused ? {selected: true} : {}}
58
- accessibilityLabel={options.tabBarAccessibilityLabel}
59
- testID={options.tabBarTestID}
60
- onPress={onPress}
61
- onLongPress={onLongPress}
62
- style={styles.tabButton}>
63
- <Image source={isFocused ? options.selectedIcon : options.icon} />
64
- <Text style={[styles.label, isFocused && styles.labelFocused]}>
65
- {toString(label)}
66
- </Text>
67
- </TouchableOpacity>
68
- );
69
- })}
70
- </View>
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: 100,
79
- borderTopLeftRadius: 50,
80
- borderTopRightRadius: 50,
127
+ height: scaleHeight(130),
128
+ borderTopLeftRadius: CommonSizes.borderRadius.huge,
129
+ borderTopRightRadius: CommonSizes.borderRadius.huge,
81
130
  justifyContent: 'space-evenly',
82
- ...CommonStyles.shadow,
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: PrimaryColors.PlatinateBlue_700,
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
+ });