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,30 @@
1
+ import React, { forwardRef, memo, useMemo } from 'react';
2
+ import BottomSheet, { BottomSheetProps } from '@gorhom/bottom-sheet';
3
+ import { useAppTheme } from '@/context/ThemeContext';
4
+
5
+ interface Props extends Partial<Omit<BottomSheetProps, 'snapPoints'>> {
6
+ children: React.ReactNode;
7
+ snapPoints?: string[];
8
+ }
9
+
10
+ const BaseBottomSheet = forwardRef<BottomSheet, Props>(
11
+ ({ children, snapPoints = ['50%'], ...rest }, ref) => {
12
+ const memoSnapPoints = useMemo(() => snapPoints, [snapPoints]);
13
+ const { color } = useAppTheme();
14
+
15
+ return (
16
+ <BottomSheet
17
+ ref={ref}
18
+ snapPoints={memoSnapPoints}
19
+ backgroundStyle={[{ backgroundColor: color.background_secondary }]}
20
+ enablePanDownToClose
21
+ enableDynamicSizing
22
+ {...rest}
23
+ >
24
+ {children}
25
+ </BottomSheet>
26
+ );
27
+ },
28
+ );
29
+
30
+ export default memo(BaseBottomSheet);
@@ -0,0 +1,50 @@
1
+ import React, { forwardRef, memo, useCallback, useMemo } from 'react';
2
+ import {
3
+ BottomSheetBackdrop,
4
+ BottomSheetModal,
5
+ BottomSheetModalProps,
6
+ } from '@gorhom/bottom-sheet';
7
+ import { BottomSheetDefaultBackdropProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetBackdrop/types';
8
+ import { useAppTheme } from '@/context/ThemeContext';
9
+
10
+ interface Props extends Partial<Omit<BottomSheetModalProps, 'snapPoints'>> {
11
+ children: React.ReactNode;
12
+ snapPoints?: string[];
13
+ }
14
+
15
+ const BaseBottomSheetModal = forwardRef<BottomSheetModal, Props>(
16
+ ({ children, snapPoints = ['50%'], ...rest }, ref) => {
17
+ const memoSnapPoints = useMemo(() => snapPoints, [snapPoints]);
18
+ const { color } = useAppTheme();
19
+
20
+ const bottomSheetBackdropRenderer = useCallback(
21
+ (backdropProps: BottomSheetDefaultBackdropProps) => {
22
+ return (
23
+ <BottomSheetBackdrop
24
+ {...backdropProps}
25
+ disappearsOnIndex={-1}
26
+ appearsOnIndex={0}
27
+ pressBehavior={'close'}
28
+ />
29
+ );
30
+ },
31
+ [],
32
+ );
33
+ return (
34
+ <BottomSheetModal
35
+ ref={ref}
36
+ snapPoints={memoSnapPoints}
37
+ backgroundStyle={[{ backgroundColor: color.background_secondary }]}
38
+ enablePanDownToClose
39
+ enableDynamicSizing
40
+ backdropComponent={bottomSheetBackdropRenderer}
41
+ handleIndicatorStyle={{ backgroundColor: color.border }}
42
+ {...rest}
43
+ >
44
+ {children}
45
+ </BottomSheetModal>
46
+ );
47
+ },
48
+ );
49
+
50
+ export default memo(BaseBottomSheetModal);
@@ -0,0 +1,310 @@
1
+ import React, {
2
+ forwardRef,
3
+ useImperativeHandle,
4
+ useCallback,
5
+ useMemo,
6
+ useRef,
7
+ } from 'react';
8
+ import { Pressable, StyleSheet, View } from 'react-native';
9
+ import {
10
+ BottomSheetModal,
11
+ BottomSheetView,
12
+ } from '@gorhom/bottom-sheet';
13
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
14
+ import { useTranslation } from 'react-i18next';
15
+ import type { IconName } from '@/assets/icons';
16
+ import Icon from '@/components/shared/Icon';
17
+ import CustomText from '@/components/shared/text/CustomText';
18
+ import { useAppTheme } from '@/context/ThemeContext';
19
+ import { ColorType, spacing } from '@/theme';
20
+ import { normalize } from '@/utils/normalize';
21
+ import BaseBottomSheetModal from '../BaseBottomSheetModal';
22
+ import { BSRef } from '../types';
23
+
24
+ interface Props {
25
+ onCamera: () => void;
26
+ onGallery: () => void;
27
+ /** When true, uses document-upload copy (images, PDF, etc.). */
28
+ canDocUpload?: boolean;
29
+ }
30
+
31
+ const OPEN_PICKER_DELAY_MS = 300;
32
+
33
+ type SourceOption = {
34
+ id: 'camera' | 'gallery';
35
+ icon: IconName;
36
+ photoLabelKey: 'imagePicker.camera' | 'imagePicker.gallery';
37
+ photoHintKey: 'imagePicker.cameraHint' | 'imagePicker.galleryHint';
38
+ docLabelKey: 'imagePicker.docCamera' | 'imagePicker.docGallery';
39
+ docHintKey: 'imagePicker.docCameraHint' | 'imagePicker.docGalleryHint';
40
+ };
41
+
42
+ const SOURCE_OPTIONS: SourceOption[] = [
43
+ {
44
+ id: 'camera',
45
+ icon: 'claim_upload',
46
+ photoLabelKey: 'imagePicker.camera',
47
+ photoHintKey: 'imagePicker.cameraHint',
48
+ docLabelKey: 'imagePicker.docCamera',
49
+ docHintKey: 'imagePicker.docCameraHint',
50
+ },
51
+ {
52
+ id: 'gallery',
53
+ icon: 'folder',
54
+ photoLabelKey: 'imagePicker.gallery',
55
+ photoHintKey: 'imagePicker.galleryHint',
56
+ docLabelKey: 'imagePicker.docGallery',
57
+ docHintKey: 'imagePicker.docGalleryHint',
58
+ },
59
+ ];
60
+
61
+ const ImagePickerSheet = forwardRef<BSRef, Props>(
62
+ ({ onCamera, onGallery, canDocUpload = false }, ref) => {
63
+ const { t } = useTranslation();
64
+ const insets = useSafeAreaInsets();
65
+ const { color } = useAppTheme();
66
+ const styles = useMemo(() => makeStyles(color), [color]);
67
+ const sheetRef = useRef<BottomSheetModal>(null);
68
+ const pendingActionRef = useRef<(() => void) | null>(null);
69
+
70
+ const titleKey = canDocUpload
71
+ ? 'imagePicker.docTitle'
72
+ : 'imagePicker.title';
73
+ const subtitleKey = canDocUpload
74
+ ? 'imagePicker.docSubtitle'
75
+ : 'imagePicker.subtitle';
76
+
77
+ useImperativeHandle(ref, () => ({
78
+ open: () => sheetRef.current?.present(),
79
+ close: () => sheetRef.current?.dismiss(),
80
+ }));
81
+
82
+ const runAfterClose = useCallback((action: () => void) => {
83
+ pendingActionRef.current = action;
84
+ sheetRef.current?.dismiss();
85
+ }, []);
86
+
87
+ const handleDismiss = useCallback(() => {
88
+ const action = pendingActionRef.current;
89
+ pendingActionRef.current = null;
90
+ if (!action) return;
91
+ setTimeout(action, OPEN_PICKER_DELAY_MS);
92
+ }, []);
93
+
94
+ const handleCamera = useCallback(() => {
95
+ runAfterClose(onCamera);
96
+ }, [onCamera, runAfterClose]);
97
+
98
+ const handleGallery = useCallback(() => {
99
+ runAfterClose(onGallery);
100
+ }, [onGallery, runAfterClose]);
101
+
102
+ const handleCancel = useCallback(() => {
103
+ sheetRef.current?.dismiss();
104
+ }, []);
105
+
106
+ const handleOptionPress = useCallback(
107
+ (id: SourceOption['id']) => {
108
+ if (id === 'camera') {
109
+ handleCamera();
110
+ return;
111
+ }
112
+ handleGallery();
113
+ },
114
+ [handleCamera, handleGallery],
115
+ );
116
+
117
+ return (
118
+ <BaseBottomSheetModal
119
+ ref={sheetRef}
120
+ enableDynamicSizing
121
+ enablePanDownToClose
122
+ onDismiss={handleDismiss}
123
+ backgroundStyle={styles.sheetBackground}
124
+ handleIndicatorStyle={styles.handleIndicator}
125
+ >
126
+ <BottomSheetView
127
+ style={[
128
+ styles.content,
129
+ { paddingBottom: Math.max(insets.bottom, spacing.md) },
130
+ ]}
131
+ >
132
+ <View style={styles.header}>
133
+ <View style={styles.headerTop}>
134
+ <CustomText
135
+ variant="titleSm"
136
+ weight="700"
137
+ textColor={color.text_heading}
138
+ style={styles.title}
139
+ >
140
+ {t(titleKey)}
141
+ </CustomText>
142
+ <Pressable
143
+ onPress={handleCancel}
144
+ hitSlop={12}
145
+ style={({ pressed }) => [
146
+ styles.cancelHit,
147
+ pressed && styles.cancelPressed,
148
+ ]}
149
+ accessibilityRole="button"
150
+ accessibilityLabel={t('common.cancel')}
151
+ >
152
+ <CustomText
153
+ variant="label"
154
+ weight="600"
155
+ textColor={color.danger_strong}
156
+ style={styles.cancelLabel}
157
+ >
158
+ {t('common.cancel')}
159
+ </CustomText>
160
+ </Pressable>
161
+ </View>
162
+ <CustomText
163
+ variant="label"
164
+ weight="400"
165
+ textColor={color.text_secondary}
166
+ style={styles.subtitle}
167
+ >
168
+ {t(subtitleKey)}
169
+ </CustomText>
170
+ </View>
171
+
172
+ <View style={styles.options}>
173
+ {SOURCE_OPTIONS.map(option => {
174
+ const labelKey = canDocUpload
175
+ ? option.docLabelKey
176
+ : option.photoLabelKey;
177
+ const hintKey = canDocUpload
178
+ ? option.docHintKey
179
+ : option.photoHintKey;
180
+
181
+ return (
182
+ <Pressable
183
+ key={option.id}
184
+ onPress={() => handleOptionPress(option.id)}
185
+ style={({ pressed }) => [
186
+ styles.optionCard,
187
+ pressed && styles.optionPressed,
188
+ ]}
189
+ accessibilityRole="button"
190
+ accessibilityLabel={t(labelKey)}
191
+ >
192
+ <View style={styles.optionIconTile}>
193
+ <Icon name={option.icon} width={20} height={20} />
194
+ </View>
195
+ <View style={styles.optionCopy}>
196
+ <CustomText
197
+ variant="label"
198
+ weight="700"
199
+ textColor={color.text_heading}
200
+ style={styles.optionLabel}
201
+ >
202
+ {t(labelKey)}
203
+ </CustomText>
204
+ <CustomText
205
+ variant="caption"
206
+ weight="400"
207
+ textColor={color.text_subtle}
208
+ style={styles.optionHint}
209
+ >
210
+ {t(hintKey)}
211
+ </CustomText>
212
+ </View>
213
+ </Pressable>
214
+ );
215
+ })}
216
+ </View>
217
+ </BottomSheetView>
218
+ </BaseBottomSheetModal>
219
+ );
220
+ },
221
+ );
222
+
223
+ export default React.memo(ImagePickerSheet);
224
+
225
+ const makeStyles = (color: ColorType) =>
226
+ StyleSheet.create({
227
+ sheetBackground: {
228
+ backgroundColor: color.background_primary,
229
+ borderTopLeftRadius: normalize(24),
230
+ borderTopRightRadius: normalize(24),
231
+ },
232
+ handleIndicator: {
233
+ width: normalize(40),
234
+ height: normalize(4),
235
+ borderRadius: 999,
236
+ backgroundColor: color.border,
237
+ },
238
+ content: {
239
+ paddingHorizontal: spacing.md,
240
+ paddingTop: spacing.xs,
241
+ },
242
+ header: {
243
+ marginBottom: spacing.md,
244
+ gap: 6,
245
+ },
246
+ headerTop: {
247
+ flexDirection: 'row',
248
+ alignItems: 'center',
249
+ justifyContent: 'space-between',
250
+ gap: 12,
251
+ },
252
+ title: {
253
+ marginBottom: 0,
254
+ flex: 1,
255
+ },
256
+ cancelHit: {
257
+ paddingVertical: 2,
258
+ paddingLeft: 8,
259
+ },
260
+ cancelLabel: {
261
+ marginBottom: 0,
262
+ },
263
+ cancelPressed: {
264
+ opacity: 0.7,
265
+ },
266
+ subtitle: {
267
+ marginBottom: 0,
268
+ lineHeight: normalize(20),
269
+ },
270
+ options: {
271
+ gap: 10,
272
+ marginBottom: spacing.xs,
273
+ },
274
+ optionCard: {
275
+ flexDirection: 'row',
276
+ alignItems: 'center',
277
+ gap: 12,
278
+ minHeight: normalize(72),
279
+ paddingHorizontal: spacing.md,
280
+ paddingVertical: spacing.sm + 2,
281
+ borderRadius: normalize(16),
282
+ backgroundColor: color.background_soft,
283
+ borderWidth: 1,
284
+ borderColor: color.border,
285
+ overflow: 'hidden',
286
+ },
287
+ optionPressed: {
288
+ opacity: 0.88,
289
+ transform: [{ scale: 0.98 }],
290
+ },
291
+ optionIconTile: {
292
+ width: normalize(44),
293
+ height: normalize(44),
294
+ borderRadius: normalize(14),
295
+ backgroundColor: color.secondary_muted,
296
+ alignItems: 'center',
297
+ justifyContent: 'center',
298
+ },
299
+ optionCopy: {
300
+ flex: 1,
301
+ gap: 2,
302
+ minWidth: 0,
303
+ },
304
+ optionLabel: {
305
+ marginBottom: 0,
306
+ },
307
+ optionHint: {
308
+ marginBottom: 0,
309
+ },
310
+ });
@@ -0,0 +1,4 @@
1
+ export type BSRef = {
2
+ open: () => void;
3
+ close: () => void;
4
+ };
@@ -0,0 +1,139 @@
1
+ import { useState } from 'react';
2
+ import { FormInputProps } from './type';
3
+ import { StyleSheet, View } from 'react-native';
4
+ import Tooltip from 'react-native-walkthrough-tooltip';
5
+ import { Controller, FieldValues } from 'react-hook-form';
6
+ import { FormInputRenderer } from './FormInputRenderer';
7
+ import CustomText from '../text/CustomText';
8
+ import { useAppTheme } from '@/context/ThemeContext';
9
+ import Icon from '../Icon';
10
+ import { isIOS } from '@/constants/device';
11
+ import { FORM_FIELD } from './formFieldStyles';
12
+
13
+ const FormInput = <T extends FieldValues>({
14
+ control,
15
+ name,
16
+ rules,
17
+ label,
18
+ error,
19
+ containerStyle,
20
+ labelStyle,
21
+ labelContainerStyle,
22
+ labelVariant = 'footnote',
23
+ labelWeight = '600',
24
+ isTooltip,
25
+ tooltipMessage,
26
+ variant,
27
+ ...rest
28
+ }: FormInputProps<T>) => {
29
+ const [showTooltip, setShowTooltip] = useState<boolean>(false);
30
+ const { color, icon } = useAppTheme();
31
+
32
+ const handleTooltipPress = () => {
33
+ setShowTooltip(prev => !prev);
34
+ };
35
+
36
+ return (
37
+ <View style={[styles.container, containerStyle]}>
38
+ {label ? (
39
+ <View style={[styles.labelCont, labelContainerStyle]}>
40
+ <CustomText
41
+ style={[styles.label, labelStyle]}
42
+ variant={labelVariant}
43
+ weight={labelWeight}
44
+ textColor={color.text_primary}
45
+ >
46
+ {label}
47
+ </CustomText>
48
+
49
+ {isTooltip ? (
50
+ <Tooltip
51
+ isVisible={showTooltip}
52
+ placement="bottom"
53
+ tooltipStyle={styles.tooltip}
54
+ content={
55
+ <CustomText
56
+ variant="label"
57
+ textColor={color.text_input}
58
+ style={styles.tooltipText}
59
+ >
60
+ {tooltipMessage}
61
+ </CustomText>
62
+ }
63
+ contentStyle={[
64
+ styles.tooltipContent,
65
+ { backgroundColor: color.background_primary },
66
+ ]}
67
+ disableShadow
68
+ closeOnBackgroundInteraction={true}
69
+ closeOnContentInteraction={true}
70
+ childContentSpacing={isIOS ? 0 : -10}
71
+ showChildInTooltip={false}
72
+ onClose={handleTooltipPress}
73
+ backgroundColor="transparent"
74
+ >
75
+ <Icon
76
+ name={icon.tooltip}
77
+ size={15}
78
+ style={styles.tooltipIcon}
79
+ onPress={handleTooltipPress}
80
+ hitSlop={20}
81
+ />
82
+ </Tooltip>
83
+ ) : null}
84
+ </View>
85
+ ) : null}
86
+
87
+ <Controller
88
+ control={control}
89
+ name={name}
90
+ rules={rules}
91
+ render={({ field }) => (
92
+ <FormInputRenderer<T> variant={variant} field={field} {...rest} />
93
+ )}
94
+ />
95
+
96
+ {error ? (
97
+ <CustomText
98
+ variant="footnote"
99
+ weight="500"
100
+ textColor={color.danger}
101
+ style={styles.errorText}
102
+ >
103
+ {error}
104
+ </CustomText>
105
+ ) : null}
106
+ </View>
107
+ );
108
+ };
109
+
110
+ export default FormInput;
111
+
112
+ const styles = StyleSheet.create({
113
+ container: {
114
+ width: '100%',
115
+ marginBottom: 0,
116
+ },
117
+ labelCont: {
118
+ flexDirection: 'row',
119
+ gap: 8,
120
+ alignItems: 'center',
121
+ marginBottom: FORM_FIELD.labelGap,
122
+ },
123
+ label: {
124
+ marginBottom: 0,
125
+ },
126
+ errorText: {
127
+ marginTop: 4,
128
+ marginBottom: 0,
129
+ marginLeft: 6,
130
+ },
131
+ tooltip: {
132
+ backgroundColor: 'transparent',
133
+ },
134
+ tooltipContent: {},
135
+ tooltipIcon: { marginBottom: 8 },
136
+ tooltipText: {
137
+ textAlign: 'center',
138
+ },
139
+ });
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+ import {
3
+ DropdownVariantProps,
4
+ FormInputProps,
5
+ TextInputVariantProps,
6
+ } from './type';
7
+ import TextInputVariant from './variants/TextInputVariant';
8
+ import { ControllerRenderProps, FieldValues } from 'react-hook-form';
9
+ import DropdownVariant from './variants/DropdownVariant';
10
+ import CountryPhoneVariant from './variants/CountryPhoneVariant';
11
+ import ToggleVariant from './variants/ToggleVariant';
12
+ import DateTimeVariant from './variants/DateTimeVariant';
13
+
14
+ type RendererProps<T extends FieldValues> = Omit<
15
+ FormInputProps<T>,
16
+ 'control' | 'name' | 'rules' | 'label' | 'error'
17
+ > & {
18
+ field: ControllerRenderProps<T>;
19
+ };
20
+
21
+ export const FormInputRenderer = <T extends FieldValues>(
22
+ props: RendererProps<T>,
23
+ ) => {
24
+ const { variant, field, ...rest } = props;
25
+
26
+ switch (variant) {
27
+ case 'dropdown': {
28
+ const dropdownProps = rest as DropdownVariantProps;
29
+
30
+ return <DropdownVariant mode="form" field={field} {...dropdownProps} />;
31
+ }
32
+
33
+ case 'country-phone': {
34
+ return (
35
+ <CountryPhoneVariant
36
+ ref={field.ref}
37
+ mode="form"
38
+ field={field}
39
+ {...rest}
40
+ />
41
+ );
42
+ }
43
+
44
+ case 'toggle': {
45
+ return <ToggleVariant mode="form" field={field} {...rest} />;
46
+ }
47
+
48
+ case 'date':
49
+ return (
50
+ <DateTimeVariant
51
+ mode="form"
52
+ field={field}
53
+ dateTimeMode="date"
54
+ {...rest}
55
+ />
56
+ );
57
+
58
+ case 'time':
59
+ return (
60
+ <DateTimeVariant
61
+ mode="form"
62
+ field={field}
63
+ dateTimeMode="time"
64
+ {...rest}
65
+ />
66
+ );
67
+
68
+ // case 'datetime':
69
+ // return <DateField mode="datetime" field={field} {...rest} />;
70
+
71
+ default:
72
+ const textInputProps = rest as TextInputVariantProps;
73
+ return (
74
+ <TextInputVariant
75
+ field={field}
76
+ ref={field.ref}
77
+ mode="form"
78
+ {...textInputProps}
79
+ />
80
+ );
81
+ }
82
+ };