@ccrf01/react-native-template 0.0.16

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 (233) hide show
  1. package/.github/workflows/npm-publish.yml +28 -0
  2. package/.vscode/settings.json +15 -0
  3. package/README.md +58 -0
  4. package/package.json +16 -0
  5. package/template/.bundle/config +2 -0
  6. package/template/.env.development +1 -0
  7. package/template/.env.production +1 -0
  8. package/template/.eslintrc.js +392 -0
  9. package/template/.java-version +1 -0
  10. package/template/.prettierrc.js +5 -0
  11. package/template/.ruby-version +1 -0
  12. package/template/.watchmanconfig +1 -0
  13. package/template/Gemfile +23 -0
  14. package/template/Gemfile.lock +330 -0
  15. package/template/README.md +97 -0
  16. package/template/ReactotronConfig.js +17 -0
  17. package/template/__tests__/App.test.tsx +13 -0
  18. package/template/_gitignore +75 -0
  19. package/template/_node-version +1 -0
  20. package/template/android/app/build.gradle +162 -0
  21. package/template/android/app/debug.keystore +0 -0
  22. package/template/android/app/proguard-rules.pro +10 -0
  23. package/template/android/app/src/debug/AndroidManifest.xml +9 -0
  24. package/template/android/app/src/main/AndroidManifest.xml +26 -0
  25. package/template/android/app/src/main/java/com/projectname/MainActivity.kt +30 -0
  26. package/template/android/app/src/main/java/com/projectname/MainApplication.kt +27 -0
  27. package/template/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
  28. package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  29. package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  30. package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  31. package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  32. package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  33. package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  34. package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  35. package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  36. package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  37. package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  38. package/template/android/app/src/main/res/values/strings.xml +3 -0
  39. package/template/android/app/src/main/res/values/styles.xml +9 -0
  40. package/template/android/build.gradle +37 -0
  41. package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  42. package/template/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  43. package/template/android/gradle.properties +48 -0
  44. package/template/android/gradlew +251 -0
  45. package/template/android/gradlew.bat +99 -0
  46. package/template/android/keystore/keystore.properties +4 -0
  47. package/template/android/settings.gradle +6 -0
  48. package/template/android/version.properties +2 -0
  49. package/template/app.json +4 -0
  50. package/template/babel.config.js +38 -0
  51. package/template/fastlane/Fastfile +136 -0
  52. package/template/fastlane/Pluginfile +9 -0
  53. package/template/fastlane/README.md +46 -0
  54. package/template/index.js +9 -0
  55. package/template/ios/.xcode.env +11 -0
  56. package/template/ios/Podfile +35 -0
  57. package/template/ios/Podfile.lock +3669 -0
  58. package/template/ios/ProjectName/AppDelegate.swift +48 -0
  59. package/template/ios/ProjectName/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  60. package/template/ios/ProjectName/Images.xcassets/Contents.json +6 -0
  61. package/template/ios/ProjectName/Info.plist +66 -0
  62. package/template/ios/ProjectName/LaunchScreen.storyboard +47 -0
  63. package/template/ios/ProjectName/PrivacyInfo.xcprivacy +47 -0
  64. package/template/ios/ProjectName.xcodeproj/project.pbxproj +482 -0
  65. package/template/ios/ProjectName.xcodeproj/xcshareddata/xcschemes/ProjectName.xcscheme +88 -0
  66. package/template/ios/ProjectName.xcworkspace/contents.xcworkspacedata +10 -0
  67. package/template/jest.config.js +3 -0
  68. package/template/metro.config.js +20 -0
  69. package/template/package-lock.json +17073 -0
  70. package/template/package.json +156 -0
  71. package/template/src/@types/emotion.d.ts +12 -0
  72. package/template/src/@types/env.d.ts +3 -0
  73. package/template/src/@types/redux-persist-transform-immutable.d.ts +1 -0
  74. package/template/src/@types/typing.d.ts +17 -0
  75. package/template/src/AppContainer.tsx +109 -0
  76. package/template/src/assets/images/143.png +0 -0
  77. package/template/src/assets/index.ts +13 -0
  78. package/template/src/components/basic/BackButton/index.tsx +34 -0
  79. package/template/src/components/basic/Body/index.tsx +68 -0
  80. package/template/src/components/basic/Button/index.tsx +181 -0
  81. package/template/src/components/basic/Button/utils.ts +78 -0
  82. package/template/src/components/basic/ButtonGroup/index.tsx +182 -0
  83. package/template/src/components/basic/Card/index.tsx +3 -0
  84. package/template/src/components/basic/Container/index.tsx +38 -0
  85. package/template/src/components/basic/Content/index.tsx +87 -0
  86. package/template/src/components/basic/DropDown/index.tsx +354 -0
  87. package/template/src/components/basic/ExpandableOverlay/index.tsx +113 -0
  88. package/template/src/components/basic/Header/index.tsx +216 -0
  89. package/template/src/components/basic/Header/styles.ts +0 -0
  90. package/template/src/components/basic/Icons/index.tsx +131 -0
  91. package/template/src/components/basic/InputLabel/index.tsx +19 -0
  92. package/template/src/components/basic/LoadingOverlay/index.tsx +68 -0
  93. package/template/src/components/basic/MaterialTextInput/index.tsx +153 -0
  94. package/template/src/components/basic/NumberInput/index.tsx +53 -0
  95. package/template/src/components/basic/Picker/PickerContext.ts +7 -0
  96. package/template/src/components/basic/Picker/PickerHeader.tsx +130 -0
  97. package/template/src/components/basic/Picker/PickerItem.tsx +105 -0
  98. package/template/src/components/basic/Picker/PickerItemsList.tsx +135 -0
  99. package/template/src/components/basic/Picker/PickerPresenter.ts +54 -0
  100. package/template/src/components/basic/Picker/hooks/useImperativePickerHandle.ts +27 -0
  101. package/template/src/components/basic/Picker/hooks/usePickerLabel.ts +74 -0
  102. package/template/src/components/basic/Picker/hooks/usePickerSearch.ts +37 -0
  103. package/template/src/components/basic/Picker/hooks/usePickerSelection.ts +57 -0
  104. package/template/src/components/basic/Picker/index.tsx +284 -0
  105. package/template/src/components/basic/Picker/types.tsx +229 -0
  106. package/template/src/components/basic/PressableOpacity/index.tsx +20 -0
  107. package/template/src/components/basic/RootDialog/Dialog.tsx +246 -0
  108. package/template/src/components/basic/RootDialog/Manager.tsx +110 -0
  109. package/template/src/components/basic/RootDialog/animations/Animation.ts +29 -0
  110. package/template/src/components/basic/RootDialog/animations/FadeAnimation.ts +40 -0
  111. package/template/src/components/basic/RootDialog/animations/ScaleAnimation.ts +37 -0
  112. package/template/src/components/basic/RootDialog/animations/SlideAnimation.ts +89 -0
  113. package/template/src/components/basic/RootDialog/components/Backdrop.tsx +60 -0
  114. package/template/src/components/basic/RootDialog/components/BaseDialog.tsx +564 -0
  115. package/template/src/components/basic/RootDialog/components/BottomDialog.tsx +32 -0
  116. package/template/src/components/basic/RootDialog/components/DialogButton.tsx +87 -0
  117. package/template/src/components/basic/RootDialog/components/DialogContent.tsx +26 -0
  118. package/template/src/components/basic/RootDialog/components/DialogContext.tsx +8 -0
  119. package/template/src/components/basic/RootDialog/components/DialogFooter.tsx +42 -0
  120. package/template/src/components/basic/RootDialog/components/DialogTitle.tsx +53 -0
  121. package/template/src/components/basic/RootDialog/components/DraggableView.tsx +271 -0
  122. package/template/src/components/basic/RootDialog/index.ts +21 -0
  123. package/template/src/components/basic/RootDialog/type.ts +102 -0
  124. package/template/src/components/basic/Text/index.tsx +8 -0
  125. package/template/src/components/basic/index.ts +35 -0
  126. package/template/src/configs/constants/type/APIStatus.type.ts +8 -0
  127. package/template/src/configs/constants/type/Locale.type.ts +7 -0
  128. package/template/src/configs/constants/type/StorageKey.type.ts +7 -0
  129. package/template/src/configs/constants/type/ThemeType.type.ts +6 -0
  130. package/template/src/configs/constants/type/index.ts +11 -0
  131. package/template/src/configs/index.ts +22 -0
  132. package/template/src/contexts/ThemeContext.ts +6 -0
  133. package/template/src/hooks/useAppLoading.ts +26 -0
  134. package/template/src/hooks/useAppState.ts +36 -0
  135. package/template/src/hooks/useArray.ts +47 -0
  136. package/template/src/hooks/useAsync.ts +42 -0
  137. package/template/src/hooks/useAsyncStorage.ts +41 -0
  138. package/template/src/hooks/useBoolean.ts +21 -0
  139. package/template/src/hooks/useBuildTheme.ts +249 -0
  140. package/template/src/hooks/useCountDown.ts +111 -0
  141. package/template/src/hooks/useCounter.ts +27 -0
  142. package/template/src/hooks/useDebounce.ts +25 -0
  143. package/template/src/hooks/useDebouncedValidate.ts +32 -0
  144. package/template/src/hooks/useDebugInformation.ts +38 -0
  145. package/template/src/hooks/useDeviceToken.ts +20 -0
  146. package/template/src/hooks/useEncryptedStorage.ts +41 -0
  147. package/template/src/hooks/useFontFamily.ts +13 -0
  148. package/template/src/hooks/useHttp.ts +18 -0
  149. package/template/src/hooks/useInterval.ts +24 -0
  150. package/template/src/hooks/useIsForeground.ts +17 -0
  151. package/template/src/hooks/useMMKVStorage.ts +0 -0
  152. package/template/src/hooks/usePrevious.ts +12 -0
  153. package/template/src/hooks/useRenderCount.ts +10 -0
  154. package/template/src/hooks/useTheme.ts +17 -0
  155. package/template/src/hooks/useTimeCountDown.ts +91 -0
  156. package/template/src/index.tsx +65 -0
  157. package/template/src/infrastructures/NetClient/AbstractClient.ts +66 -0
  158. package/template/src/infrastructures/NetClient/ApiResponse.ts +16 -0
  159. package/template/src/infrastructures/NetClient/ApisauceClient.ts +76 -0
  160. package/template/src/infrastructures/NetClient/AxiosClient.ts +80 -0
  161. package/template/src/infrastructures/NetClient/FetchNetClient.ts +120 -0
  162. package/template/src/infrastructures/NetClient/config.ts +3 -0
  163. package/template/src/infrastructures/NetClient/interfaces/INetClient.ts +6 -0
  164. package/template/src/infrastructures/Storage/IStorage.ts +7 -0
  165. package/template/src/infrastructures/Storage/MMKVStorage.ts +41 -0
  166. package/template/src/infrastructures/common/Timeout.ts +27 -0
  167. package/template/src/infrastructures/common/colorUtils.ts +82 -0
  168. package/template/src/infrastructures/common/dateUtils.ts +39 -0
  169. package/template/src/infrastructures/common/logger.ts +115 -0
  170. package/template/src/locales/en-US/general.json +26 -0
  171. package/template/src/locales/en-US/index.ts +9 -0
  172. package/template/src/locales/en-US/screens.json +4 -0
  173. package/template/src/locales/en-US/setting.json +3 -0
  174. package/template/src/locales/i18n.ts +109 -0
  175. package/template/src/locales/zh-TW/general.json +26 -0
  176. package/template/src/locales/zh-TW/index.ts +9 -0
  177. package/template/src/locales/zh-TW/screens.json +4 -0
  178. package/template/src/locales/zh-TW/setting.json +3 -0
  179. package/template/src/models/index.ts +5 -0
  180. package/template/src/models/request.model.ts +50 -0
  181. package/template/src/navigators/DrawerNav/DrawerContent.tsx +66 -0
  182. package/template/src/navigators/DrawerNav/DrawerItem.tsx +261 -0
  183. package/template/src/navigators/DrawerNav/index.tsx +39 -0
  184. package/template/src/navigators/DrawerNav/props.ts +12 -0
  185. package/template/src/navigators/DrawerNav/types.ts +8 -0
  186. package/template/src/navigators/MainBottomTabNav/index.tsx +83 -0
  187. package/template/src/navigators/MainBottomTabNav/props.ts +16 -0
  188. package/template/src/navigators/MainBottomTabNav/types.ts +6 -0
  189. package/template/src/navigators/RootStack.tsx +43 -0
  190. package/template/src/navigators/index.tsx +40 -0
  191. package/template/src/navigators/props.ts +14 -0
  192. package/template/src/navigators/types.ts +18 -0
  193. package/template/src/navigators/utils.ts +68 -0
  194. package/template/src/redux/api/api.ts +41 -0
  195. package/template/src/redux/reducers/appSlice.ts +26 -0
  196. package/template/src/redux/reducers/index.ts +21 -0
  197. package/template/src/redux/reducers/nonPersistSlice.ts +51 -0
  198. package/template/src/redux/reducers/settingSlice.ts +48 -0
  199. package/template/src/redux/reducers/themeSlice.ts +55 -0
  200. package/template/src/redux/saga/index.ts +5 -0
  201. package/template/src/redux/saga/settingSaga.ts +21 -0
  202. package/template/src/redux/selectors/app.ts +9 -0
  203. package/template/src/redux/selectors/nonPersist.ts +23 -0
  204. package/template/src/redux/selectors/setting.ts +29 -0
  205. package/template/src/redux/selectors/theme.ts +13 -0
  206. package/template/src/redux/store/index.ts +79 -0
  207. package/template/src/redux/store/types.d.ts +5 -0
  208. package/template/src/screens/Home/index.tsx +146 -0
  209. package/template/src/screens/Settings/components/Item.tsx +45 -0
  210. package/template/src/screens/Settings/index.tsx +97 -0
  211. package/template/src/screens/Splash/index.tsx +53 -0
  212. package/template/src/services/Dialogs.tsx +226 -0
  213. package/template/src/services/PermissionCheck.ts +257 -0
  214. package/template/src/theme/Common.ts +48 -0
  215. package/template/src/theme/Fonts.ts +196 -0
  216. package/template/src/theme/Gutters.ts +63 -0
  217. package/template/src/theme/Icons.ts +28 -0
  218. package/template/src/theme/Images.ts +13 -0
  219. package/template/src/theme/Layout.ts +106 -0
  220. package/template/src/theme/Variables.ts +167 -0
  221. package/template/src/theme/components/Buttons.ts +37 -0
  222. package/template/src/theme/index.ts +8 -0
  223. package/template/src/theme/metrics.ts +57 -0
  224. package/template/src/theme/themes/default_dark/Images.ts +7 -0
  225. package/template/src/theme/themes/default_dark/Variables.ts +84 -0
  226. package/template/src/theme/themes/default_dark/index.ts +2 -0
  227. package/template/src/theme/themes/index.ts +8 -0
  228. package/template/src/theme/types.ts +152 -0
  229. package/template/src/utils/encrypt-helper.ts +118 -0
  230. package/template/src/utils/index.ts +76 -0
  231. package/template/src/utils/sys-info-data.ts +17 -0
  232. package/template/tsconfig.json +44 -0
  233. package/template.config.js +8 -0
@@ -0,0 +1,113 @@
1
+ import React, { forwardRef, PropsWithChildren, useCallback, useImperativeHandle, useState } from 'react'
2
+ import { StyleSheet, TouchableOpacity, TouchableOpacityProps, View } from 'react-native'
3
+ import Modal, { ModalProps } from 'react-native-modal'
4
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
5
+
6
+ import { PressableOpacity } from '@/components/basic'
7
+ import useTheme from '@/hooks/useTheme'
8
+ import { rgbToHex } from '@/infrastructures/common/colorUtils'
9
+ import logger from '@/infrastructures/common/logger'
10
+
11
+ export type ExpandableOverlayMethods = {
12
+ openExpandable: () => void
13
+ closeExpandable: () => void
14
+ toggleExpandable: () => void
15
+ }
16
+ export interface IRenderCustomOverlayProps extends ExpandableOverlayMethods {
17
+ visible: boolean
18
+ }
19
+ export type ExpandableOverlayProps = TouchableOpacityProps &
20
+ {
21
+
22
+ /**
23
+ * The content to render inside the expandable modal/dialog
24
+ */
25
+ expandableContent?: React.ReactElement
26
+ /**
27
+ * Whether to render a modal top bar (relevant only for modal)
28
+ */
29
+ showTopBar?: boolean
30
+ /**
31
+ * A custom overlay to render instead of Modal or Dialog components
32
+ */
33
+ renderCustomOverlay?: (props: IRenderCustomOverlayProps) => React.ReactElement | undefined | null
34
+ /**
35
+ * Disabled opening expandable overlay
36
+ */
37
+ disabled?: boolean
38
+ modalProps?: Partial<Omit<ModalProps, 'children'>>
39
+
40
+ childrenPointEvents?: 'box-none' | 'none' | 'box-only' | 'auto'
41
+ children?: React.ReactElement
42
+ }
43
+
44
+ const ExpandableOverlay = (props: ExpandableOverlayProps, ref: any) => {
45
+ const { Colors } = useTheme()
46
+ const insets = useSafeAreaInsets()
47
+ const {
48
+ children,
49
+ childrenPointEvents = 'none',
50
+ // useDialog,
51
+ disabled,
52
+ // dialogProps,
53
+ expandableContent,
54
+ // topBarProps,
55
+ modalProps,
56
+ onPress,
57
+ renderCustomOverlay,
58
+ showTopBar,
59
+ // customValue,
60
+ testID,
61
+ ...others
62
+ } = props
63
+ const [visible, setExpandableVisible] = useState(false)
64
+ const { style: modalStyle, ...othersModalProps } = modalProps || {}
65
+ const openExpandable = useCallback(() => {
66
+ setExpandableVisible(true)
67
+ onPress?.({} as any)
68
+ }, [onPress])
69
+ const closeExpandable = useCallback(() => {
70
+ setExpandableVisible(false)
71
+ // modalProps?.onDismiss?.()
72
+ }, [])
73
+ const toggleExpandable = useCallback(() => (visible ? closeExpandable() : openExpandable()),
74
+ [visible, openExpandable, closeExpandable])
75
+ useImperativeHandle(ref, () => ({
76
+ openExpandable,
77
+ closeExpandable,
78
+ toggleExpandable,
79
+ }))
80
+
81
+ const modalContainerStyle = {
82
+ margin: 0,
83
+ // paddingBottom: insets.bottom,
84
+ // paddingTop: insets.top,
85
+ }
86
+ const backdrop = rgbToHex(Colors.backdrop, true)
87
+
88
+ const renderModal = () => {
89
+ return (
90
+ <Modal
91
+ testID={`${testID || ''}.overlay`}
92
+ backdropColor={backdrop.hex}
93
+ backdropOpacity={backdrop.alpha}
94
+ isVisible={visible}
95
+ onDismiss={closeExpandable}
96
+ onBackdropPress={closeExpandable}
97
+ {...othersModalProps}
98
+ style={[modalContainerStyle, modalStyle]}
99
+ >
100
+ {expandableContent}
101
+ </Modal>
102
+ )
103
+ }
104
+
105
+ return (
106
+ <PressableOpacity {...others} onPress={openExpandable} disabled={disabled} testID={testID}>
107
+ <View pointerEvents={childrenPointEvents}>{children}</View>
108
+ {renderModal()}
109
+ </PressableOpacity>
110
+ )
111
+ }
112
+
113
+ export default forwardRef<ExpandableOverlayMethods, ExpandableOverlayProps>(ExpandableOverlay)
@@ -0,0 +1,216 @@
1
+ import { StackHeaderProps } from '@react-navigation/stack'
2
+ import React, { useCallback } from 'react'
3
+ import { Animated, StatusBar, View } from 'react-native'
4
+ import { AutoSizeText, ResizeTextMode } from 'react-native-auto-size-text'
5
+ import { Appbar, Text } from 'react-native-paper'
6
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
7
+ import Svg, { Path } from 'react-native-svg'
8
+
9
+ import useFontFamily from '@/hooks/useFontFamily'
10
+ import useTheme from '@/hooks/useTheme'
11
+ import logger from '@/infrastructures/common/logger'
12
+ import { Theme } from '@/theme/types'
13
+ import { normalize } from '@/utils'
14
+
15
+ import BackButton from '../BackButton'
16
+
17
+ // const MORE_ICON = Platform.OS === 'ios' ? 'dots-horizontal' : 'dots-vertical';
18
+
19
+ // const HEADER_HEIGHT = 48
20
+ export type HeaderProps = StackHeaderProps & Partial<{
21
+ backgroundColor: string
22
+ withRoundedSharp?: boolean
23
+ onBackPress?: () => boolean
24
+ }>
25
+ const Header: React.FC<HeaderProps> = ({
26
+ back,
27
+ backgroundColor,
28
+ navigation,
29
+ onBackPress,
30
+ options,
31
+ progress,
32
+ route,
33
+ withRoundedSharp,
34
+ }: HeaderProps) => {
35
+ const { Colors, Fonts, Gutters, Param: { headerHeight } } = useTheme()
36
+ const inset = useSafeAreaInsets()
37
+ const { headerMode, presentation } = options
38
+ const fontFamily = useFontFamily()
39
+
40
+ const path = React.useMemo(
41
+ () =>
42
+ [
43
+ 'M 0 0',
44
+ 'C 0 0 50 0 50 50',
45
+ 'L 50 0',
46
+ 'L 0 0',
47
+ ].join(' '),
48
+ []
49
+ )
50
+
51
+ // const { options } = scene.descriptor
52
+ const navigationName = route.name
53
+ logger.log('navigationName', navigationName)
54
+ const title =
55
+ options.headerTitle !== undefined && typeof options.headerTitle === 'string'
56
+ ? options.headerTitle
57
+ : options.title !== undefined
58
+ ? options.title
59
+ : route.name
60
+ const progressAnimation = Animated.add(progress.current, progress.next || 0)
61
+ const opacity = progressAnimation.interpolate({
62
+ inputRange: [0, 1, 2],
63
+ outputRange: [0, 1, 0],
64
+ })
65
+ const progress2 = Animated.add(progress.current, progress.next || 0)
66
+ const translateY = progress2.interpolate({
67
+ inputRange: [0, 2, 4],
68
+ outputRange: [0, -28, 0],
69
+ })
70
+
71
+ const goBack = useCallback(
72
+ () => {
73
+ navigation.goBack()
74
+ },
75
+ []
76
+ )
77
+
78
+ const { headerLeft, headerRight } = options
79
+
80
+ return (
81
+ <>
82
+ <Animated.View style={{
83
+ opacity,
84
+ // transform: [
85
+ // {
86
+ // translateY: translateY,
87
+ // },
88
+ // ],
89
+ }}
90
+ >
91
+ {/* <StatusBar barStyle={'light-content'}/> */}
92
+ <Appbar
93
+ style={{
94
+ backgroundColor: backgroundColor ? backgroundColor : Colors.primary,
95
+ paddingTop: presentation === 'card' ? inset.top : 0,
96
+ height: headerHeight + (presentation === 'card' ? inset.top : 0),
97
+ }}
98
+ >
99
+ {back || headerLeft ?
100
+ <View
101
+ style={[
102
+ Gutters.smallLPadding,
103
+ // Gutters.smallLMargin,
104
+ { flex: 1, flexDirection: 'row' },
105
+ ]}
106
+ >
107
+ {headerLeft ? headerLeft({}) : <BackButton color={Colors.white} onPress={goBack} />}
108
+ </View> : null
109
+ }
110
+ <View
111
+ style={{
112
+ position: 'absolute',
113
+ left: 0,
114
+ right: 0,
115
+ bottom: 0,
116
+ flexDirection: 'row',
117
+ alignItems: 'center',
118
+ alignContent: 'center',
119
+ justifyContent: 'center',
120
+ height: headerHeight,
121
+ }}
122
+ pointerEvents="box-none"
123
+ >
124
+ <View
125
+ pointerEvents="box-none"
126
+ style={{
127
+ flex: 1,
128
+ width: '100%',
129
+ height: '100%',
130
+ paddingLeft: 50,
131
+ paddingRight: 50,
132
+ justifyContent: 'center',
133
+ alignItems: 'center',
134
+ }}
135
+ >
136
+ {/* <Appbar.Content
137
+ title={title}
138
+ // theme={NavigationTheme}
139
+ style={{
140
+ // position: 'absolute',
141
+ // left: 0,
142
+ // right: 0,
143
+ // bottom: 0,
144
+ flexDirection: 'row',
145
+ alignItems: 'center',
146
+ alignContent: 'center',
147
+ justifyContent: 'center',
148
+ padding: 0,
149
+ margin: 0,
150
+ flex: 1,
151
+ height: headerHeight,
152
+ alignSelf: 'center',
153
+ }}
154
+ titleStyle={[
155
+ Fonts.headerTitle, {
156
+ textAlign: 'center',
157
+ color: Colors.text,
158
+ },
159
+ ]}
160
+ pointerEvents="box-none"
161
+ /> */}
162
+ <AutoSizeText
163
+ fontSize={normalize(26)}
164
+ numberOfLines={1}
165
+ mode={ResizeTextMode.max_lines}
166
+ style={[
167
+ {
168
+ fontFamily,
169
+ textAlign: 'center',
170
+ verticalAlign: 'middle',
171
+ fontWeight: 'bold',
172
+ color: Colors.white,
173
+ },
174
+ ]}
175
+ >
176
+ {title}
177
+ </AutoSizeText>
178
+ </View>
179
+ </View>
180
+ {headerRight ? (
181
+ <View
182
+ style={[
183
+ Gutters.smallPadding,
184
+ // Gutters.smallRMargin,
185
+ {
186
+ flex: 1,
187
+ flexDirection: 'row',
188
+ justifyContent: 'flex-end',
189
+ },
190
+
191
+ ]}
192
+ >
193
+ {headerRight({})}
194
+ </View>
195
+ ) : null}
196
+ </Appbar>
197
+ {withRoundedSharp && (
198
+ <View
199
+ style={{
200
+ position: 'absolute',
201
+ top: (headerHeight + (presentation === 'card' ? inset.top : 0)),
202
+ right: 0,
203
+ }}
204
+ pointerEvents="none"
205
+ >
206
+ <Svg width={50} height={50} viewBox="0 0 50 50">
207
+ <Path fill={backgroundColor ? backgroundColor : Colors.primary} stroke={backgroundColor ? backgroundColor : Colors.primary} d={path} />
208
+ </Svg>
209
+ </View>
210
+ )}
211
+ </Animated.View>
212
+ </>
213
+ )
214
+ }
215
+
216
+ export default Header
File without changes
@@ -0,0 +1,131 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ /* eslint-disable @typescript-eslint/no-duplicate-type-constituents */
3
+ import { AntDesign } from '@react-native-vector-icons/ant-design'
4
+ import { EvilIcons } from '@react-native-vector-icons/evil-icons'
5
+ import { FontAwesome6 } from '@react-native-vector-icons/fontawesome6'
6
+ import { Ionicons } from '@react-native-vector-icons/ionicons'
7
+ import { Lucide } from '@react-native-vector-icons/lucide'
8
+ import { MaterialDesignIcons } from '@react-native-vector-icons/material-design-icons'
9
+ import React from 'react'
10
+ import { StyleProp, StyleSheet, TextStyle, ViewStyle } from 'react-native'
11
+ import { createIconSetFromFontello, createIconSetFromIcoMoon } from 'react-native-vector-icons'
12
+ // import AntDesign from 'react-native-vector-icons/AntDesign'
13
+ // import Entypo from 'react-native-vector-icons/Entypo'
14
+ // import EvilIcons from 'react-native-vector-icons/EvilIcons'
15
+ // import Feather from 'react-native-vector-icons/Feather'
16
+ // import FontAwesome from 'react-native-vector-icons/FontAwesome'
17
+ // import FontAwesome5 from 'react-native-vector-icons/FontAwesome5'
18
+ // import Ionicons from 'react-native-vector-icons/Ionicons'
19
+ // import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
20
+ // import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
21
+ // import Octicons from 'react-native-vector-icons/Octicons'
22
+
23
+ // import fontelloConfig from '@/assets/fonts/config.json'
24
+ // const MyIcon = createIconSetFromFontello(fontelloConfig, 'myicon')
25
+
26
+ const IconType = {
27
+ ANT_DESIGN: 'ANT_DESIGN',
28
+ EVIL_ICONS: 'EVIL_ICONS',
29
+ FONT_AWESOME6: 'FONTAWESOME6',
30
+ IONICONS: 'IONICONS',
31
+ LUCIDE: 'LUCIDE',
32
+ MATERIAL_DESIGN_ICONS: 'MATERIAL_DESIGN_ICONS',
33
+
34
+ // OCTICONS: 'octicons',
35
+ // MY_ICON: 'myicon',
36
+ }
37
+ type IconType = typeof IconType[keyof typeof IconType]
38
+ interface IIconXProps {
39
+ origin: IconType
40
+ name: any
41
+ color?: string
42
+ size?: number
43
+ paddingLeft?: number
44
+ // style?: StyleProp<TextStyle> | undefined
45
+ forTouchable?: boolean
46
+ style?: StyleProp<TextStyle>
47
+ }
48
+
49
+ type IconXType = typeof AntDesign |
50
+ typeof Ionicons |
51
+ typeof MaterialDesignIcons |
52
+ typeof FontAwesome6 |
53
+ typeof Lucide |
54
+ typeof EvilIcons
55
+
56
+ type IPanel<P> = React.FunctionComponent<P> & typeof IconType
57
+
58
+ const IconX: IPanel<IIconXProps> = ({
59
+ color,
60
+ name,
61
+ origin,
62
+ paddingLeft,
63
+ size,
64
+ style = {},
65
+ }: IIconXProps) => {
66
+
67
+ const colorx = color || '#aaaaaa'
68
+ const sizex = size || 26
69
+ const namex = name || 'right'
70
+ const paddingx = paddingLeft || 0
71
+
72
+ let Element: IconXType = Ionicons
73
+
74
+ switch (origin) {
75
+ case IconType.ANT_DESIGN:
76
+ Element = AntDesign
77
+ break
78
+
79
+ case IconType.EVIL_ICONS:
80
+ Element = EvilIcons
81
+ break
82
+
83
+ case IconType.FONT_AWESOME6:
84
+ Element = FontAwesome6
85
+ break
86
+
87
+ case IconType.IONICONS:
88
+ Element = Ionicons
89
+ break
90
+
91
+ case IconType.LUCIDE:
92
+ Element = Lucide
93
+ break
94
+
95
+ case IconType.MATERIAL_DESIGN_ICONS:
96
+ Element = MaterialDesignIcons
97
+ break
98
+
99
+ default:
100
+ Element = Ionicons
101
+ break
102
+ }
103
+
104
+
105
+ /*
106
+ case IconType.MY_ICON:
107
+ Element = MyIcon
108
+ break
109
+ */
110
+
111
+ return (
112
+ <Element
113
+ name={namex}
114
+ size={sizex}
115
+ color={colorx}
116
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
117
+ // @ts-ignore
118
+ style={[{ paddingLeft: paddingx }, style]}
119
+ />
120
+ )
121
+ }
122
+ IconX.ANT_DESIGN = IconType.ANT_DESIGN
123
+ IconX.EVIL_ICONS = IconType.EVIL_ICONS
124
+ IconX.FONT_AWESOME6 = IconType.FONT_AWESOME6
125
+ IconX.IONICONS = IconType.IONICONS
126
+ IconX.LUCIDE = IconType.LUCIDE
127
+ IconX.MATERIAL_DESIGN_ICONS = IconType.MATERIAL_DESIGN_ICONS
128
+ // IconX.MY_ICON = IconType.MY_ICON
129
+
130
+ export default IconX
131
+
@@ -0,0 +1,19 @@
1
+ import React from 'react'
2
+ import { StyleProp, TextStyle, ViewStyle } from 'react-native'
3
+ import { customText, Text } from 'react-native-paper'
4
+
5
+ interface IInputLabelProps {
6
+ // label: string
7
+ children?: React.ReactNode
8
+ style?: StyleProp<TextStyle|ViewStyle> | undefined
9
+ onPress?: () => void
10
+ }
11
+ const InputLabel = ({ children, onPress, style }: IInputLabelProps) => {
12
+ return (
13
+ <Text variant={'bodyMedium'} style={[{ fontWeight: '700' }, style]} onPress={onPress}>
14
+ {children}
15
+ </Text>
16
+ )
17
+ }
18
+
19
+ export default InputLabel
@@ -0,0 +1,68 @@
1
+ import React from 'react'
2
+ import { ActivityIndicator, ColorValue, View } from 'react-native'
3
+ import { Modal, Text } from 'react-native-paper'
4
+ import { useSelector } from 'react-redux'
5
+
6
+ import useTheme from '@/hooks/useTheme'
7
+ import { rgbToHex } from '@/infrastructures/common/colorUtils'
8
+ import { selectLoading } from '@/redux/selectors/nonPersist'
9
+
10
+ interface ILoadingOverlayProps {
11
+ backgroundColor?: ColorValue
12
+ indicatorColor?: ColorValue
13
+ opacity?: number
14
+ zIndex?: number
15
+ textColor?: ColorValue
16
+ wording?: string
17
+ }
18
+
19
+ const LoadingOverlay: React.FC<ILoadingOverlayProps> = ({
20
+ backgroundColor,
21
+ indicatorColor = 'red',
22
+ opacity = 0.5,
23
+ textColor = 'black',
24
+ wording = 'Loading',
25
+ zIndex = 5,
26
+ }: ILoadingOverlayProps) => {
27
+ const loading = useSelector(selectLoading)
28
+ const { Colors, Gutters, Layout } = useTheme()
29
+
30
+ const { alpha, hex: backdropColor } = rgbToHex(Colors.backdrop, true)
31
+
32
+ return (
33
+ loading ? (
34
+ <View style={{
35
+ position: 'absolute',
36
+ top: 0,
37
+ bottom: 0,
38
+ left: 0,
39
+ right: 0,
40
+ backgroundColor: backgroundColor ? backgroundColor : backdropColor,
41
+ opacity: opacity,
42
+ zIndex: zIndex,
43
+ flexDirection: 'column',
44
+ justifyContent: 'center',
45
+ alignItems: 'center',
46
+ }}
47
+ >
48
+ <View
49
+ style={[
50
+ Gutters.smallPadding,
51
+ {
52
+ backgroundColor: 'rgba(20, 20, 20, 0.9)',
53
+ borderRadius: 8,
54
+ borderWidth: 0,
55
+ },
56
+ ]}
57
+ >
58
+ <ActivityIndicator size={'large'} color={indicatorColor} />
59
+ {/* <Text>{wording}</Text> */}
60
+ </View>
61
+ </View>
62
+ ) : (
63
+ null
64
+ )
65
+ )
66
+ }
67
+
68
+ export default LoadingOverlay
@@ -0,0 +1,153 @@
1
+ import React, { forwardRef, useCallback, useImperativeHandle, useState } from 'react'
2
+ import {
3
+ FlatList,
4
+ Platform,
5
+ StyleSheet,
6
+ TextInput as NativeTextInput,
7
+ TextStyle,
8
+ View,
9
+ ViewStyle,
10
+ } from 'react-native'
11
+ import { HelperText, Text, TextInput, TextInputProps, withTheme } from 'react-native-paper'
12
+
13
+ import { images } from '@/assets'
14
+ // import { Props as TextInputProps } from 'react-native-paper/lib/typescript/components/TextInput/TextInput'
15
+ import useImperativePickerHandle from '@/components/basic/Picker/hooks/useImperativePickerHandle'
16
+ import useTheme from '@/hooks/useTheme'
17
+
18
+ type Props = {
19
+ hintText?: string | undefined
20
+ hintTextStyle?: TextStyle
21
+ errorText?: string | undefined
22
+ errorColor?: string
23
+ errorTextStyle?: TextStyle
24
+ showEye?: boolean
25
+ disableErrorText?: boolean
26
+ }
27
+
28
+ export type MaterialTextInputProps = TextInputProps & Props
29
+
30
+ export type TextInputHandles = Pick<
31
+ NativeTextInput,
32
+ 'focus' | 'clear' | 'blur' | 'isFocused' | 'setNativeProps'
33
+ >
34
+
35
+ const MaterialTextInput = forwardRef<TextInputHandles, MaterialTextInputProps>((props: MaterialTextInputProps, ref) => {
36
+ const {
37
+ disableErrorText,
38
+ errorColor = 'rgb(213, 0, 0)',
39
+ errorText,
40
+ errorTextStyle = { fontSize: 12 },
41
+ hintText,
42
+ // underlineColor,
43
+ // activeUnderlineColor,
44
+ // outlineColor,
45
+ // activeOutlineColor,
46
+ hintTextStyle = { fontSize: 12 },
47
+ label,
48
+ mode,
49
+ placeholderTextColor,
50
+ right,
51
+ secureTextEntry,
52
+ showEye = false,
53
+ style,
54
+ theme,
55
+ ...restProps
56
+ } = props
57
+ const { Colors, Common, NavigationTheme } = useTheme()
58
+
59
+ const [visiblePw, setVisiblePw] = useState(false)
60
+ const [secureText, setSecureText] = useState(secureTextEntry)
61
+
62
+ const customPlaceholderTextColor = placeholderTextColor || Colors.outline
63
+ const toggleVisiblePw = () => {
64
+ setVisiblePw(!!!visiblePw)
65
+ setSecureText(visiblePw)
66
+ }
67
+
68
+ const inputRef = React.useRef<NativeTextInput | null>(null)
69
+
70
+ useImperativeHandle(ref, () => ({
71
+ focus: () => inputRef?.current?.focus(),
72
+ clear: () => inputRef.current?.clear(),
73
+ setNativeProps: (args: any) => inputRef.current?.setNativeProps(args),
74
+ isFocused: () => inputRef.current?.isFocused() || false,
75
+ blur: () => inputRef.current?.blur(),
76
+ forceFocus: () => inputRef.current?.focus(),
77
+ }))
78
+
79
+ const renderHelperText = useCallback(() => {
80
+ if (!!errorText && !disableErrorText) {
81
+ return (
82
+ <HelperText
83
+ type="error"
84
+ visible={!!errorText}
85
+ padding={'none'}
86
+ >{errorText}</HelperText>
87
+ )
88
+ } else if (!!hintText && !disableErrorText) {
89
+ return (
90
+ <HelperText
91
+ type="info"
92
+ visible={!!hintText}
93
+ padding={'none'}
94
+ >{hintText}</HelperText>
95
+ )
96
+ } else if (disableErrorText) {
97
+ return null
98
+ }
99
+
100
+ return <HelperText
101
+ type="info"
102
+ visible
103
+ padding={'none'}
104
+ >{' '}</HelperText>
105
+ }, [
106
+ hintText, errorText, errorColor, disableErrorText, hintTextStyle, errorTextStyle,
107
+ ])
108
+
109
+ const contentBackgroundColor = (restProps.contentStyle as ViewStyle)?.backgroundColor
110
+
111
+ return (
112
+ <View>
113
+ {mode === 'flat' && label !== undefined && label !== '' && (
114
+ <Text>
115
+ {label}
116
+ </Text>
117
+ )}
118
+ <TextInput
119
+ ref={inputRef}
120
+ label={mode === 'flat' ? '' : label}
121
+ mode={mode}
122
+ placeholderTextColor={customPlaceholderTextColor}
123
+ {...restProps}
124
+ // underlineColor={errorText ? errorColor : underlineColor}
125
+ // activeUnderlineColor={errorText ? errorColor : activeUnderlineColor}
126
+ // outlineColor={errorText ? errorColor : outlineColor}
127
+ // activeOutlineColor={errorText ? errorColor : activeOutlineColor}
128
+ right={secureTextEntry && showEye ?
129
+ <TextInput.Icon
130
+ icon={visiblePw ? 'eye-off' : 'eye'}
131
+ // icon={images.search}
132
+ onPress={toggleVisiblePw}
133
+ // style={contentBackgroundColor ? { backgroundColor: contentBackgroundColor } : {}}
134
+ /> : (right ? right : null)}
135
+ // right={right ? right : null}
136
+ secureTextEntry={secureText}
137
+ textContentType={secureTextEntry ? 'newPassword' : 'none'}
138
+ theme={Object.assign(NavigationTheme, theme)}
139
+ style={[Common.textInput, style]}
140
+ error={!!errorText}
141
+ />
142
+ {/* {!disableErrorText && (<HelperText */}
143
+ {/* type="error" */}
144
+ {/* visible={!!errorText} */}
145
+ {/* padding={'none'} */}
146
+ {/* >{errorText}</HelperText>)} */}
147
+ {renderHelperText()}
148
+ </View>
149
+ )
150
+ })
151
+ MaterialTextInput.displayName = 'MaterialTextInput'
152
+
153
+ export default React.memo(MaterialTextInput)