create-react-native-starter-kit 0.0.0-stage → 1.0.0

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 (210) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +378 -2
  3. package/bin/create-react-native-starter-kit.js +95 -0
  4. package/lib/copy-src.js +127 -0
  5. package/lib/creator.js +211 -0
  6. package/lib/deps.js +58 -0
  7. package/lib/patch-configs.js +318 -0
  8. package/lib/patch-native.js +387 -0
  9. package/package.json +47 -4
  10. package/scripts/sync-template.js +52 -0
  11. package/template/.env.example +3 -0
  12. package/template/patches/react-native-element-dropdown+2.12.4.patch +67 -0
  13. package/template/src/app/App.tsx +25 -0
  14. package/template/src/app/navigation/root.tsx +24 -0
  15. package/template/src/app/navigation/stacks/app.stack.tsx +67 -0
  16. package/template/src/app/navigation/stacks/app.tab.tsx +72 -0
  17. package/template/src/app/navigation/stacks/auth.stack.tsx +56 -0
  18. package/template/src/app/providers.tsx +43 -0
  19. package/template/src/assets/fonts/InterTight-Black.ttf +0 -0
  20. package/template/src/assets/fonts/InterTight-BlackItalic.ttf +0 -0
  21. package/template/src/assets/fonts/InterTight-Bold.ttf +0 -0
  22. package/template/src/assets/fonts/InterTight-BoldItalic.ttf +0 -0
  23. package/template/src/assets/fonts/InterTight-ExtraBold.ttf +0 -0
  24. package/template/src/assets/fonts/InterTight-ExtraBoldItalic.ttf +0 -0
  25. package/template/src/assets/fonts/InterTight-ExtraLight.ttf +0 -0
  26. package/template/src/assets/fonts/InterTight-ExtraLightItalic.ttf +0 -0
  27. package/template/src/assets/fonts/InterTight-Italic.ttf +0 -0
  28. package/template/src/assets/fonts/InterTight-Light.ttf +0 -0
  29. package/template/src/assets/fonts/InterTight-LightItalic.ttf +0 -0
  30. package/template/src/assets/fonts/InterTight-Medium.ttf +0 -0
  31. package/template/src/assets/fonts/InterTight-MediumItalic.ttf +0 -0
  32. package/template/src/assets/fonts/InterTight-Regular.ttf +0 -0
  33. package/template/src/assets/fonts/InterTight-SemiBold.ttf +0 -0
  34. package/template/src/assets/fonts/InterTight-SemiBoldItalic.ttf +0 -0
  35. package/template/src/assets/fonts/InterTight-Thin.ttf +0 -0
  36. package/template/src/assets/fonts/InterTight-ThinItalic.ttf +0 -0
  37. package/template/src/assets/icons/back.svg +3 -0
  38. package/template/src/assets/icons/calendar.svg +3 -0
  39. package/template/src/assets/icons/claim_upload.svg +3 -0
  40. package/template/src/assets/icons/clock.svg +1 -0
  41. package/template/src/assets/icons/downArrow.svg +3 -0
  42. package/template/src/assets/icons/edit.svg +3 -0
  43. package/template/src/assets/icons/eye.svg +4 -0
  44. package/template/src/assets/icons/eyeClose.svg +7 -0
  45. package/template/src/assets/icons/folder.svg +5 -0
  46. package/template/src/assets/icons/home.svg +4 -0
  47. package/template/src/assets/icons/index.ts +33 -0
  48. package/template/src/assets/icons/setting.svg +4 -0
  49. package/template/src/assets/icons/tabs/home/filled_dark.svg +3 -0
  50. package/template/src/assets/icons/tabs/home/filled_light.svg +3 -0
  51. package/template/src/assets/icons/tabs/home/outline.svg +4 -0
  52. package/template/src/assets/icons/tabs/index.ts +31 -0
  53. package/template/src/assets/icons/tabs/profile/filled_dark.svg +6 -0
  54. package/template/src/assets/icons/tabs/profile/filled_light.svg +6 -0
  55. package/template/src/assets/icons/tabs/profile/outline.svg +3 -0
  56. package/template/src/assets/icons/tooltip_dark.svg +1 -0
  57. package/template/src/assets/icons/tooltip_light.svg +1 -0
  58. package/template/src/assets/icons/upArrow.svg +3 -0
  59. package/template/src/assets/images/back.png +0 -0
  60. package/template/src/assets/images/index.ts +7 -0
  61. package/template/src/assets/images/placeholder/profile.png +0 -0
  62. package/template/src/components/shared/AppImage.tsx +190 -0
  63. package/template/src/components/shared/AvatarPicker.tsx +175 -0
  64. package/template/src/components/shared/CustomButton.tsx +273 -0
  65. package/template/src/components/shared/DocumentPicker.tsx +86 -0
  66. package/template/src/components/shared/GlobalLoader.tsx +47 -0
  67. package/template/src/components/shared/Icon.tsx +28 -0
  68. package/template/src/components/shared/PressableIcon.tsx +104 -0
  69. package/template/src/components/shared/bottom-sheet/BaseBottomSheet.tsx +30 -0
  70. package/template/src/components/shared/bottom-sheet/BaseBottomSheetModal.tsx +50 -0
  71. package/template/src/components/shared/bottom-sheet/sheets/ImagePickerSheet.tsx +310 -0
  72. package/template/src/components/shared/bottom-sheet/types.ts +4 -0
  73. package/template/src/components/shared/form-input/FormInput.tsx +139 -0
  74. package/template/src/components/shared/form-input/FormInputRenderer.tsx +82 -0
  75. package/template/src/components/shared/form-input/FullNameInput.tsx +243 -0
  76. package/template/src/components/shared/form-input/formFieldStyles.ts +43 -0
  77. package/template/src/components/shared/form-input/type.ts +188 -0
  78. package/template/src/components/shared/form-input/variants/CountryPhoneVariant.tsx +289 -0
  79. package/template/src/components/shared/form-input/variants/DateTimeVariant.tsx +280 -0
  80. package/template/src/components/shared/form-input/variants/DropdownVariant.tsx +221 -0
  81. package/template/src/components/shared/form-input/variants/TextInputVariant.tsx +300 -0
  82. package/template/src/components/shared/form-input/variants/ToggleVariant.tsx +194 -0
  83. package/template/src/components/shared/modal/BaseModal.tsx +83 -0
  84. package/template/src/components/shared/modal/common/AlertModal.tsx +173 -0
  85. package/template/src/components/shared/navigation/AnimatedTabIcon.tsx +37 -0
  86. package/template/src/components/shared/navigation/HeaderActionButton.tsx +70 -0
  87. package/template/src/components/shared/navigation/HeaderBackButton.tsx +38 -0
  88. package/template/src/components/shared/navigation/StackHeader.tsx +105 -0
  89. package/template/src/components/shared/navigation/tabIconRender.tsx +14 -0
  90. package/template/src/components/shared/offline/OfflineQueryBoundary.tsx +25 -0
  91. package/template/src/components/shared/offline/OfflineState.tsx +229 -0
  92. package/template/src/components/shared/offline/index.ts +6 -0
  93. package/template/src/components/shared/offline/types.ts +15 -0
  94. package/template/src/components/shared/offline/wifi-icon-animation/BrokenWifiAnimation.tsx +116 -0
  95. package/template/src/components/shared/offline/wifi-icon-animation/WifiPiece.tsx +80 -0
  96. package/template/src/components/shared/offline/wifi-icon-animation/geometry.ts +163 -0
  97. package/template/src/components/shared/offline/wifi-icon-animation/useWifiIconAnimationActive.ts +37 -0
  98. package/template/src/components/shared/skelton/BaseSkelton.tsx +71 -0
  99. package/template/src/components/shared/skelton/ShimmerHolder.ts +6 -0
  100. package/template/src/components/shared/skelton/holders/HomeShimmer.tsx +25 -0
  101. package/template/src/components/shared/skelton/holders/index.ts +1 -0
  102. package/template/src/components/shared/skelton/layouts/avatar.layout.ts +18 -0
  103. package/template/src/components/shared/skelton/layouts/home.layout.ts +26 -0
  104. package/template/src/components/shared/skelton/layouts/index.ts +3 -0
  105. package/template/src/components/shared/skelton/layouts/text.layout.ts +18 -0
  106. package/template/src/components/shared/text/CustomText.tsx +85 -0
  107. package/template/src/components/shared/text/ShimmerText.tsx +159 -0
  108. package/template/src/components/shared/text/types.ts +40 -0
  109. package/template/src/constants/device.ts +12 -0
  110. package/template/src/constants/endpoint.ts +11 -0
  111. package/template/src/constants/keyExtractor.ts +6 -0
  112. package/template/src/constants/limits.ts +9 -0
  113. package/template/src/constants/queryKey.ts +3 -0
  114. package/template/src/constants/regex.ts +7 -0
  115. package/template/src/context/NetworkContext.tsx +102 -0
  116. package/template/src/context/ThemeContext.tsx +56 -0
  117. package/template/src/hooks/app/index.ts +2 -0
  118. package/template/src/hooks/app/useGetProfile.ts +38 -0
  119. package/template/src/hooks/app/useUpdateProfile.ts +21 -0
  120. package/template/src/hooks/useAppDispatch.ts +6 -0
  121. package/template/src/hooks/useAppSelector.ts +4 -0
  122. package/template/src/hooks/useDebounce.ts +15 -0
  123. package/template/src/hooks/useDocumentPicker.ts +102 -0
  124. package/template/src/hooks/useImagePicker.ts +83 -0
  125. package/template/src/i18n/i18next.d.ts +9 -0
  126. package/template/src/i18n/index.ts +16 -0
  127. package/template/src/i18n/locales/en.json +274 -0
  128. package/template/src/i18n/locales/ru.json +165 -0
  129. package/template/src/i18n/resources.ts +11 -0
  130. package/template/src/redux/selectors/auth.selectors.ts +4 -0
  131. package/template/src/redux/slice/auth.slice.ts +23 -0
  132. package/template/src/redux/slice/loader.slice.ts +25 -0
  133. package/template/src/redux/slice/settings.slice.ts +26 -0
  134. package/template/src/redux/slice/user.slice.ts +25 -0
  135. package/template/src/screens/app/main-tab/index.tsx +73 -0
  136. package/template/src/screens/app/main-tab/style.ts +0 -0
  137. package/template/src/screens/app/profile-setup/index.tsx +161 -0
  138. package/template/src/screens/app/profile-setup/styles.ts +3 -0
  139. package/template/src/screens/auth/forgot-password/index.tsx +59 -0
  140. package/template/src/screens/auth/forgot-password/styles.ts +0 -0
  141. package/template/src/screens/auth/index.ts +4 -0
  142. package/template/src/screens/auth/login/index.tsx +137 -0
  143. package/template/src/screens/auth/login/styles.ts +3 -0
  144. package/template/src/screens/auth/signup/index.tsx +110 -0
  145. package/template/src/screens/auth/signup/styles.ts +3 -0
  146. package/template/src/screens/auth/verify-email/index.tsx +15 -0
  147. package/template/src/screens/auth/verify-email/styles.ts +3 -0
  148. package/template/src/screens/tab/home/index.tsx +49 -0
  149. package/template/src/screens/tab/home/styles.ts +3 -0
  150. package/template/src/screens/tab/index.ts +2 -0
  151. package/template/src/screens/tab/profile/index.tsx +50 -0
  152. package/template/src/screens/tab/profile/styles.ts +3 -0
  153. package/template/src/services/api/auth/auth.api.ts +22 -0
  154. package/template/src/services/api/auth/auth.endpoints.ts +7 -0
  155. package/template/src/services/api/auth/auth.types.ts +9 -0
  156. package/template/src/services/api/auth/index.ts +3 -0
  157. package/template/src/services/api/axios/axios.instance.ts +15 -0
  158. package/template/src/services/api/axios/axios.interceptors.ts +43 -0
  159. package/template/src/services/api/axios/index.ts +2 -0
  160. package/template/src/services/api/mock/mockAdapter.ts +97 -0
  161. package/template/src/services/api/user/index.ts +2 -0
  162. package/template/src/services/api/user/user.api.ts +67 -0
  163. package/template/src/services/api/user/user.endpoints.ts +0 -0
  164. package/template/src/services/api/user/user.types.ts +0 -0
  165. package/template/src/services/errors/backendErrorCodes.ts +7 -0
  166. package/template/src/services/errors/errorHandler.ts +94 -0
  167. package/template/src/services/errors/firebaseErrorMap.ts +61 -0
  168. package/template/src/services/errors/httpStatusMap.ts +47 -0
  169. package/template/src/services/errors/index.ts +4 -0
  170. package/template/src/services/network/index.ts +1 -0
  171. package/template/src/services/network/onlineManager.ts +22 -0
  172. package/template/src/services/query/index.ts +1 -0
  173. package/template/src/services/query/queryClient.ts +23 -0
  174. package/template/src/services/toast/ToastCard.tsx +137 -0
  175. package/template/src/services/toast/ToastConfig.tsx +32 -0
  176. package/template/src/services/toast/index.ts +3 -0
  177. package/template/src/services/toast/toast.ts +68 -0
  178. package/template/src/storage/mmkvAdapter.ts +3 -0
  179. package/template/src/storage/mmkvInstance.ts +16 -0
  180. package/template/src/store/index.ts +15 -0
  181. package/template/src/store/mmkv.ts +6 -0
  182. package/template/src/store/persist.ts +10 -0
  183. package/template/src/store/rootReducer.ts +26 -0
  184. package/template/src/theme/dark.ts +40 -0
  185. package/template/src/theme/fonts.ts +20 -0
  186. package/template/src/theme/index.ts +6 -0
  187. package/template/src/theme/layout.ts +22 -0
  188. package/template/src/theme/light.ts +41 -0
  189. package/template/src/theme/palette.ts +32 -0
  190. package/template/src/theme/spacing.ts +7 -0
  191. package/template/src/theme/typography.ts +80 -0
  192. package/template/src/types/api.types.ts +34 -0
  193. package/template/src/types/env.d.ts +6 -0
  194. package/template/src/types/index.ts +2 -0
  195. package/template/src/types/navigation.types.ts +94 -0
  196. package/template/src/utils/clearAppSession.ts +10 -0
  197. package/template/src/utils/date.ts +19 -0
  198. package/template/src/utils/documentPickerHandler.ts +96 -0
  199. package/template/src/utils/getFileNameFromUri.ts +18 -0
  200. package/template/src/utils/getInitials.ts +13 -0
  201. package/template/src/utils/hindiText.ts +33 -0
  202. package/template/src/utils/imageCompress.ts +97 -0
  203. package/template/src/utils/imagePickerHandler.ts +200 -0
  204. package/template/src/utils/maskPhone.ts +17 -0
  205. package/template/src/utils/normalize.ts +12 -0
  206. package/template/src/validation/messages.ts +11 -0
  207. package/template/src/validation/rules.ts +44 -0
  208. package/template/src/validation/schema/auth.schema.ts +53 -0
  209. package/template/src/validation/schema/user.schema.ts +46 -0
  210. package/template/src/validation/tValError.ts +13 -0
@@ -0,0 +1,175 @@
1
+ import React, { useState, useCallback, useEffect, useRef, memo } from 'react';
2
+ import { Pressable, StyleSheet, View, ViewStyle } from 'react-native';
3
+ import AppImage from './AppImage';
4
+ import { GlobalImage } from '@/assets/images';
5
+ import Icon from './Icon';
6
+ import { useAppTheme } from '@/context/ThemeContext';
7
+ import { isIOS } from '@/constants/device';
8
+ import { useImagePicker } from '@/hooks/useImagePicker';
9
+ import ImagePickerSheet from './bottom-sheet/sheets/ImagePickerSheet';
10
+ import { BSRef } from './bottom-sheet/types';
11
+ import BaseSkelton from './skelton/BaseSkelton';
12
+ import { avatarPickerLayout } from './skelton/layouts';
13
+
14
+ type SourceType = 'gallery' | 'camera' | 'both';
15
+
16
+ interface Props {
17
+ imageUrl?: string;
18
+ defaultImage?: any;
19
+ width?: number;
20
+ height?: number;
21
+ alignSelf?: ViewStyle['alignSelf'];
22
+ containerStyle?: ViewStyle;
23
+ editable?: boolean;
24
+ editIconSize?: number;
25
+ isLoading?: boolean;
26
+
27
+ source?: SourceType;
28
+ maxSize?: number;
29
+ quality?: number;
30
+ onImageChange?: (image: string) => void;
31
+ }
32
+
33
+ const AvatarPicker = ({
34
+ imageUrl,
35
+ defaultImage = GlobalImage.profilePlaceholder,
36
+ width = 100,
37
+ height = 100,
38
+ alignSelf = 'center',
39
+ containerStyle,
40
+ editable = false,
41
+ editIconSize = 28,
42
+ isLoading,
43
+ source = 'both',
44
+ maxSize = 256,
45
+ quality = 80,
46
+ onImageChange,
47
+ }: Props) => {
48
+ const { color } = useAppTheme();
49
+ const { captureFromCamera, images, pickFromGallery } = useImagePicker({
50
+ maxSize,
51
+ quality,
52
+ });
53
+ const [localImageUri, setLocalImageUri] = useState<string | undefined>(
54
+ imageUrl,
55
+ );
56
+ const imageSource = localImageUri ? { uri: localImageUri } : defaultImage;
57
+ const sheetRef = useRef<BSRef>(null);
58
+
59
+ useEffect(() => {
60
+ if (images?.length > 0) {
61
+ const image = images[0];
62
+
63
+ setLocalImageUri(image.uri);
64
+ onImageChange?.(image.uri);
65
+ }
66
+ }, [images, onImageChange]);
67
+
68
+ useEffect(() => {
69
+ setLocalImageUri(imageUrl);
70
+ }, [imageUrl]);
71
+
72
+ const dynamicContainerStyle: ViewStyle = {
73
+ width,
74
+ height,
75
+ borderRadius: width / 2,
76
+ alignSelf,
77
+ };
78
+
79
+ // Main press handler
80
+ const handleEditPress = useCallback(() => {
81
+ if (source === 'both') {
82
+ sheetRef.current?.open();
83
+ } else if (source === 'camera') {
84
+ captureFromCamera();
85
+ } else {
86
+ pickFromGallery();
87
+ }
88
+ }, [source, captureFromCamera, pickFromGallery]);
89
+
90
+ return (
91
+ <>
92
+ <BaseSkelton
93
+ isLoading={isLoading}
94
+ layout={avatarPickerLayout({
95
+ size: width,
96
+ })}
97
+ containerStyle={[
98
+ styles.container,
99
+ dynamicContainerStyle,
100
+ containerStyle,
101
+ ]}
102
+ >
103
+ <View
104
+ style={[
105
+ styles.imageContainer,
106
+ { borderRadius: width / 2, borderColor: color.border },
107
+ ]}
108
+ >
109
+ <AppImage
110
+ source={imageSource}
111
+ style={styles.image}
112
+ resizeMode="cover"
113
+ />
114
+ </View>
115
+
116
+ {editable && (
117
+ <Pressable
118
+ onPress={handleEditPress}
119
+ style={({ pressed }) => [
120
+ styles.editIconContainer,
121
+ pressed && isIOS && { opacity: 0.7 },
122
+ {
123
+ width: editIconSize,
124
+ height: editIconSize,
125
+ borderRadius: editIconSize / 2,
126
+ backgroundColor: color.primary,
127
+ borderColor: color.background_secondary,
128
+ },
129
+ ]}
130
+ android_ripple={{
131
+ color: 'rgba(255,255,255,0.2)',
132
+ borderless: true,
133
+ foreground: true,
134
+ }}
135
+ >
136
+ <Icon name="edit" size={14} />
137
+ </Pressable>
138
+ )}
139
+ </BaseSkelton>
140
+ <ImagePickerSheet
141
+ ref={sheetRef}
142
+ onCamera={captureFromCamera}
143
+ onGallery={pickFromGallery}
144
+ />
145
+ </>
146
+ );
147
+ };
148
+
149
+ export default memo(AvatarPicker);
150
+
151
+ const styles = StyleSheet.create({
152
+ container: {
153
+ marginTop: 16,
154
+ },
155
+ imageContainer: {
156
+ overflow: 'hidden',
157
+ width: '100%',
158
+ height: '100%',
159
+ borderWidth: 0.5,
160
+ },
161
+ image: {
162
+ width: '100%',
163
+ height: '100%',
164
+ },
165
+ editIconContainer: {
166
+ position: 'absolute',
167
+ bottom: 2,
168
+ right: 2,
169
+ justifyContent: 'center',
170
+ alignItems: 'center',
171
+ elevation: 3,
172
+ borderWidth: 2,
173
+ overflow: 'hidden',
174
+ },
175
+ });
@@ -0,0 +1,273 @@
1
+ import { useNetwork } from '@/context/NetworkContext';
2
+ import { useAppTheme } from '@/context/ThemeContext';
3
+ import { ErrorToast } from '@/services/toast';
4
+ import Haptics from '@mhpdev/react-native-haptics';
5
+ import React, { memo, useRef, useCallback, ReactNode, useMemo } from 'react';
6
+ import {
7
+ Pressable,
8
+ View,
9
+ ActivityIndicator,
10
+ StyleSheet,
11
+ TextStyle,
12
+ ViewStyle,
13
+ StyleProp,
14
+ } from 'react-native';
15
+ import { useTranslation } from 'react-i18next';
16
+ import CustomText from './text/CustomText';
17
+ import { normalize } from '@/utils/normalize';
18
+ import { isHindiLanguage } from '@/utils/hindiText';
19
+ import { isIOS } from '@/constants/device';
20
+ import Icon from './Icon';
21
+ import { IconName } from '@/assets/icons';
22
+ import type { FontWeight, TextVariant } from '@/theme/typography';
23
+
24
+ /* ───────────────── Types ───────────────── */
25
+
26
+ type Variant = 'primary' | 'outline' | 'danger' | 'ghost';
27
+ type Align = 'left' | 'center' | 'right';
28
+ type HapticType = 'light' | 'medium' | 'heavy' | 'soft' | 'rigid';
29
+
30
+ export interface AppButtonProps {
31
+ title?: string;
32
+ onPress?: () => Promise<void> | void;
33
+ onLongPress?: () => void;
34
+
35
+ variant?: Variant;
36
+ overrideVariantColor?: string;
37
+ overrideVariantTextColor?: string;
38
+
39
+ disabled?: boolean;
40
+ loading?: boolean;
41
+ /** Blocks the press while offline and shows a toast (use for API actions). */
42
+ requiresNetwork?: boolean;
43
+
44
+ align?: Align;
45
+ fullWidth?: boolean;
46
+
47
+ leftIcon?: IconName;
48
+ rightIcon?: IconName;
49
+ iconSize?: number;
50
+
51
+ haptic?: HapticType;
52
+
53
+ containerStyle?: StyleProp<ViewStyle>;
54
+ textStyle?: StyleProp<TextStyle>;
55
+ textVariant?: TextVariant;
56
+ textWeight?: FontWeight;
57
+
58
+ backgroundColor?: string;
59
+ borderRadius?: number;
60
+
61
+ children?: ReactNode;
62
+ }
63
+
64
+ const CustomButton = ({
65
+ title,
66
+ onPress,
67
+ onLongPress,
68
+
69
+ variant = 'primary',
70
+ overrideVariantColor,
71
+ overrideVariantTextColor,
72
+
73
+ disabled = false,
74
+ loading = false,
75
+ requiresNetwork = false,
76
+
77
+ align = 'center',
78
+ fullWidth = false,
79
+
80
+ leftIcon,
81
+ rightIcon,
82
+ iconSize = 18,
83
+
84
+ haptic = 'light',
85
+
86
+ backgroundColor,
87
+ borderRadius = 16,
88
+
89
+ containerStyle,
90
+ textStyle,
91
+ textVariant = 'button',
92
+ textWeight = '600',
93
+ children,
94
+ }: AppButtonProps) => {
95
+ const pressLock = useRef(false);
96
+ const { color } = useAppTheme();
97
+ const { t, i18n } = useTranslation();
98
+ const isHindi = isHindiLanguage(i18n.language);
99
+ const { isOffline } = useNetwork();
100
+ const isNetworkBlocked = requiresNetwork && isOffline;
101
+
102
+ const handlePress = useCallback(async () => {
103
+ if (pressLock.current || disabled || loading) return;
104
+
105
+ if (isNetworkBlocked) {
106
+ ErrorToast({
107
+ title: t('network.unavailableTitle'),
108
+ message: t('network.unavailableMessage'),
109
+ });
110
+ return;
111
+ }
112
+
113
+ pressLock.current = true;
114
+ try {
115
+ Haptics.impact(haptic);
116
+ await onPress?.();
117
+ } finally {
118
+ pressLock.current = false;
119
+ }
120
+ }, [isNetworkBlocked, disabled, loading, onPress, haptic, t]);
121
+
122
+ const alignSelf: ViewStyle['alignSelf'] =
123
+ align === 'left' ? 'flex-start' : align === 'right' ? 'flex-end' : 'center';
124
+
125
+ const isIconOnly = !title && !children && !!(leftIcon || rightIcon);
126
+
127
+ const variantButtonStyle = useMemo(
128
+ () => ({
129
+ primary: { backgroundColor: overrideVariantColor || color.primary },
130
+ danger: { backgroundColor: overrideVariantColor || color.danger },
131
+ outline: {
132
+ backgroundColor: 'transparent',
133
+ borderWidth: 1,
134
+ borderColor: overrideVariantColor || color.primary,
135
+ },
136
+ ghost: {
137
+ backgroundColor: overrideVariantColor || 'transparent',
138
+ },
139
+ }),
140
+ [color, overrideVariantColor],
141
+ );
142
+
143
+ const variantTextStyle = useMemo(
144
+ () => ({
145
+ primary: { color: overrideVariantTextColor || color.text_default },
146
+ danger: { color: overrideVariantTextColor || color.text_default },
147
+ outline: { color: overrideVariantTextColor || color.primary },
148
+ ghost: { color: color.primary },
149
+ }),
150
+ [color, overrideVariantTextColor],
151
+ );
152
+
153
+ return (
154
+ <Pressable
155
+ onPress={handlePress}
156
+ onLongPress={onLongPress}
157
+ disabled={disabled || loading}
158
+ accessibilityRole="button"
159
+ accessibilityState={{ disabled: disabled || loading, busy: loading }}
160
+ style={({ pressed }) => [
161
+ buttonStyles.base,
162
+ isHindi && buttonStyles.baseHindi,
163
+ variantButtonStyle[variant],
164
+ fullWidth && buttonStyles.fullWidth,
165
+ disabled && buttonStyles.disabled,
166
+ pressed && isIOS && buttonStyles.pressedIOS,
167
+ pressed && !isIOS && buttonStyles.pressedAndroid,
168
+ { alignSelf },
169
+ backgroundColor && { backgroundColor },
170
+ { borderRadius },
171
+ containerStyle,
172
+ ]}
173
+ android_ripple={{
174
+ color: 'rgba(255,255,255,0.2)',
175
+ borderless: true,
176
+ foreground: true,
177
+ }}
178
+ >
179
+ {isIconOnly ? (
180
+ <Icon name={(leftIcon || rightIcon)!} size={iconSize} />
181
+ ) : (
182
+ <>
183
+ {leftIcon && (
184
+ <View style={fullWidth && buttonStyles.leftIcon}>
185
+ <Icon name={leftIcon} size={iconSize} />
186
+ </View>
187
+ )}
188
+ <View style={buttonStyles.content}>
189
+ {title ? (
190
+ <CustomText
191
+ style={[
192
+ buttonStyles.title,
193
+ loading && buttonStyles.hidden,
194
+ variantTextStyle[variant],
195
+ textStyle,
196
+ ]}
197
+ variant={textVariant}
198
+ weight={textWeight}
199
+ numberOfLines={1}
200
+ >
201
+ {title}
202
+ </CustomText>
203
+ ) : (
204
+ children
205
+ )}
206
+ </View>
207
+ {rightIcon && (
208
+ <View style={fullWidth && buttonStyles.rightIcon}>
209
+ <Icon name={rightIcon} size={iconSize} />
210
+ </View>
211
+ )}
212
+ </>
213
+ )}
214
+
215
+ {loading && (
216
+ <View style={buttonStyles.loader}>
217
+ <ActivityIndicator color={variantTextStyle[variant].color} />
218
+ </View>
219
+ )}
220
+ </Pressable>
221
+ );
222
+ };
223
+
224
+ export default memo(CustomButton);
225
+
226
+ const buttonStyles = StyleSheet.create({
227
+ base: {
228
+ flexDirection: 'row',
229
+ alignItems: 'center',
230
+ justifyContent: 'center',
231
+ overflow: 'hidden',
232
+ padding: 12,
233
+ minHeight: normalize(46),
234
+ gap: 8,
235
+ },
236
+ /** Extra vertical room for Devanagari matras inside overflow:hidden. */
237
+ baseHindi: {
238
+ paddingVertical: 14,
239
+ minHeight: normalize(50),
240
+ },
241
+ fullWidth: {
242
+ width: '100%',
243
+ },
244
+ disabled: {
245
+ opacity: 0.8,
246
+ },
247
+ pressedIOS: {
248
+ opacity: 0.9,
249
+ transform: [{ scale: 0.94 }],
250
+ },
251
+ pressedAndroid: {
252
+ opacity: 0.9,
253
+ transform: [{ scale: 0.96 }],
254
+ },
255
+ content: {
256
+ flexDirection: 'row',
257
+ alignItems: 'center',
258
+ flexShrink: 0,
259
+ },
260
+ title: {
261
+ flexShrink: 0,
262
+ },
263
+ loader: {
264
+ ...StyleSheet.absoluteFill,
265
+ justifyContent: 'center',
266
+ alignItems: 'center',
267
+ },
268
+ hidden: {
269
+ opacity: 0,
270
+ },
271
+ leftIcon: { position: 'absolute', left: 14 },
272
+ rightIcon: { position: 'absolute', right: 14 },
273
+ });
@@ -0,0 +1,86 @@
1
+ import React, {
2
+ forwardRef,
3
+ memo,
4
+ useEffect,
5
+ useImperativeHandle,
6
+ useRef,
7
+ } from 'react';
8
+ import {
9
+ useDocumentPicker,
10
+ type PickedFile,
11
+ } from '@/hooks/useDocumentPicker';
12
+ import ImagePickerSheet from './bottom-sheet/sheets/ImagePickerSheet';
13
+ import { BSRef } from './bottom-sheet/types';
14
+
15
+ export type DocumentPickerRef = {
16
+ open: () => void;
17
+ close: () => void;
18
+ };
19
+
20
+ type SourceType = 'files' | 'camera' | 'both';
21
+
22
+ interface Props {
23
+ source?: SourceType;
24
+ maxSize?: number;
25
+ quality?: number;
26
+ multiple?: boolean;
27
+ onDocumentChange?: (file: PickedFile) => void;
28
+ }
29
+
30
+ const DocumentPicker = forwardRef<DocumentPickerRef, Props>(
31
+ (
32
+ {
33
+ source = 'both',
34
+ maxSize = 1024,
35
+ quality = 85,
36
+ multiple = false,
37
+ onDocumentChange,
38
+ },
39
+ ref,
40
+ ) => {
41
+ const sheetRef = useRef<BSRef>(null);
42
+ const { captureFromCamera, documents, pickFromFiles, resetDocuments } =
43
+ useDocumentPicker({
44
+ maxSize,
45
+ quality,
46
+ multiple,
47
+ });
48
+
49
+ useImperativeHandle(
50
+ ref,
51
+ () => ({
52
+ open: () => {
53
+ if (source === 'both') {
54
+ sheetRef.current?.open();
55
+ } else if (source === 'camera') {
56
+ captureFromCamera();
57
+ } else {
58
+ pickFromFiles();
59
+ }
60
+ },
61
+ close: () => sheetRef.current?.close(),
62
+ }),
63
+ [source, captureFromCamera, pickFromFiles],
64
+ );
65
+
66
+ useEffect(() => {
67
+ if (!documents.length) return;
68
+
69
+ onDocumentChange?.(documents[0]);
70
+ resetDocuments();
71
+ }, [documents, onDocumentChange, resetDocuments]);
72
+
73
+ return (
74
+ <ImagePickerSheet
75
+ ref={sheetRef}
76
+ onCamera={captureFromCamera}
77
+ onGallery={pickFromFiles}
78
+ canDocUpload
79
+ />
80
+ );
81
+ },
82
+ );
83
+
84
+ DocumentPicker.displayName = 'DocumentPicker';
85
+
86
+ export default memo(DocumentPicker);
@@ -0,0 +1,47 @@
1
+ import { useAppTheme } from '@/context/ThemeContext';
2
+ import { useAppSelector } from '@/hooks/useAppSelector';
3
+ import React from 'react';
4
+ import { View, ActivityIndicator, StyleSheet, Modal } from 'react-native';
5
+
6
+ const GlobalLoader = () => {
7
+ const isLoading = useAppSelector(state => state.loader.isLoading);
8
+ const { color } = useAppTheme();
9
+
10
+ return (
11
+ <Modal transparent visible={isLoading} statusBarTranslucent>
12
+ <View style={styles.container}>
13
+ <View
14
+ style={[
15
+ styles.loaderBox,
16
+ { backgroundColor: color.background_secondary },
17
+ ]}
18
+ >
19
+ <ActivityIndicator size="large" color={color.primary} />
20
+ </View>
21
+ </View>
22
+ </Modal>
23
+ );
24
+ };
25
+
26
+ export default GlobalLoader;
27
+
28
+ const styles = StyleSheet.create({
29
+ container: {
30
+ flex: 1,
31
+ backgroundColor: 'rgba(0,0,0,0.5)',
32
+ justifyContent: 'center',
33
+ alignItems: 'center',
34
+ },
35
+ loaderBox: {
36
+ width: 70,
37
+ height: 70,
38
+ borderRadius: 12,
39
+ justifyContent: 'center',
40
+ alignItems: 'center',
41
+ elevation: 5,
42
+ shadowColor: '#000',
43
+ shadowOffset: { width: 0, height: 2 },
44
+ shadowOpacity: 0.25,
45
+ shadowRadius: 4,
46
+ },
47
+ });
@@ -0,0 +1,28 @@
1
+ import { IconName, Icons } from '@/assets/icons';
2
+ import React from 'react';
3
+ import { SvgProps } from 'react-native-svg';
4
+
5
+ export interface IconProps extends SvgProps {
6
+ name: IconName;
7
+ size?: number;
8
+ color?: string;
9
+ }
10
+
11
+ const Icon = ({ name, size = 24, color, ...props }: IconProps) => {
12
+ const Component = Icons[name];
13
+
14
+ if (!Component) {
15
+ return null;
16
+ }
17
+
18
+ return (
19
+ <Component
20
+ width={size}
21
+ height={size}
22
+ {...(color ? { fill: color } : {})}
23
+ {...props}
24
+ />
25
+ );
26
+ };
27
+
28
+ export default Icon;
@@ -0,0 +1,104 @@
1
+ import Haptics from '@mhpdev/react-native-haptics';
2
+ import React, { memo, useCallback, useRef } from 'react';
3
+ import {
4
+ Pressable,
5
+ StyleSheet,
6
+ ViewStyle,
7
+ StyleProp,
8
+ Insets,
9
+ } from 'react-native';
10
+ import { isIOS } from '@/constants/device';
11
+ import Icon from './Icon';
12
+ import { IconName } from '@/assets/icons';
13
+
14
+ type HapticType = 'light' | 'medium' | 'heavy' | 'soft' | 'rigid';
15
+
16
+ export interface PressableIconProps {
17
+ name: IconName;
18
+ size?: number;
19
+ color?: string;
20
+ onPress?: () => Promise<void> | void;
21
+ onLongPress?: () => void;
22
+ disabled?: boolean;
23
+ haptic?: HapticType;
24
+ hitSlop?: number | Insets;
25
+ backgroundColor?: string;
26
+ borderRadius?: number;
27
+ containerStyle?: StyleProp<ViewStyle>;
28
+ accessibilityLabel?: string;
29
+ }
30
+
31
+ const PressableIcon = ({
32
+ name,
33
+ size = 22,
34
+ color,
35
+ onPress,
36
+ onLongPress,
37
+ disabled = false,
38
+ haptic = 'light',
39
+ hitSlop = 8,
40
+ backgroundColor,
41
+ borderRadius,
42
+ containerStyle,
43
+ accessibilityLabel,
44
+ }: PressableIconProps) => {
45
+ const pressLock = useRef(false);
46
+
47
+ const handlePress = useCallback(async () => {
48
+ if (pressLock.current || disabled) return;
49
+
50
+ pressLock.current = true;
51
+ Haptics.impact(haptic);
52
+
53
+ try {
54
+ await onPress?.();
55
+ } finally {
56
+ pressLock.current = false;
57
+ }
58
+ }, [disabled, haptic, onPress]);
59
+
60
+ return (
61
+ <Pressable
62
+ onPress={handlePress}
63
+ onLongPress={onLongPress}
64
+ disabled={disabled}
65
+ hitSlop={hitSlop}
66
+ accessibilityRole="button"
67
+ accessibilityLabel={accessibilityLabel ?? name}
68
+ accessibilityState={{ disabled }}
69
+ android_ripple={{ color: 'transparent' }}
70
+ style={({ pressed }) => [
71
+ styles.base,
72
+ backgroundColor != null && { backgroundColor },
73
+ borderRadius != null && { borderRadius },
74
+ disabled && styles.disabled,
75
+ pressed && isIOS && styles.pressedIOS,
76
+ pressed && !isIOS && styles.pressedAndroid,
77
+ containerStyle,
78
+ ]}
79
+ >
80
+ <Icon name={name} size={size} color={color} />
81
+ </Pressable>
82
+ );
83
+ };
84
+
85
+ export default memo(PressableIcon);
86
+
87
+ const styles = StyleSheet.create({
88
+ base: {
89
+ justifyContent: 'center',
90
+ alignItems: 'center',
91
+ overflow: 'hidden',
92
+ },
93
+ disabled: {
94
+ opacity: 0.5,
95
+ },
96
+ pressedIOS: {
97
+ opacity: 0.7,
98
+ transform: [{ scale: 0.94 }],
99
+ },
100
+ pressedAndroid: {
101
+ opacity: 0.85,
102
+ transform: [{ scale: 0.96 }],
103
+ },
104
+ });