@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,84 @@
1
+ import { ThemeNavigationColors } from '@/theme/types'
2
+
3
+ const ownColor = {
4
+ accent: 'rgb(150, 170, 140)', // lighter accent to pop on dark bg
5
+ tintPrimary: '#FF9F45', // warm tint still vibrant
6
+ buttonText: '#FFFFFF', // white text for readability
7
+ iconColor: 'rgb(200, 205, 190)', // lighter icons
8
+ transparent: 'rgba(0,0,0,0)',
9
+ negative: '#2b2b2b', // dark gray background
10
+ onNegative: '#FFFFFF', // white text on dark
11
+ inputBackground: '#1E1E1E', // typical dark input background
12
+ statusBarBackgroundColor: 'rgba(0, 0, 0, .6)',
13
+ topBarBackgroundColor: '#2d1e24', // darker variant of light theme pinkish
14
+ // Bottom Tab
15
+ bottomTabActiveTextColor: '#80CBC4', // teal shade that stands out on dark
16
+ bottomTabInactiveTextColor: '#777777', // muted gray
17
+ homeBottomTabBackgroundColor: '#0d47a1', // darker blue
18
+ rewardsBottomTabBackgroundColor: '#004d40', // darker teal
19
+ storeListBottomTabBackgroundColor: '#37474F', // dark slate
20
+
21
+ itemBackgroundColor: '#1E1A15',
22
+
23
+ grey: '#EBEBEB',
24
+ white: '#FFFFF',
25
+ }
26
+
27
+ const navColors: Partial<ThemeNavigationColors> = {
28
+ // React Navigation colors
29
+ card: 'rgb(18, 18, 18)',
30
+ text: 'rgb(229, 229, 231)',
31
+ border: 'rgb(39, 39, 41)',
32
+ notification: 'rgb(255, 69, 58)',
33
+
34
+ buttonText: 'rgb(226, 227, 220)',
35
+ statusBarBackgroundColor: 'rgba(48,63,159, 0.7)',
36
+
37
+ accent: 'rgb(84, 99, 77)',
38
+
39
+ // react-native-paper MD3 colors
40
+ primary: 'rgb(165, 200, 255)',
41
+ onPrimary: 'rgb(0, 49, 95)',
42
+ primaryContainer: 'rgb(0, 71, 134)',
43
+ onPrimaryContainer: 'rgb(212, 227, 255)',
44
+ secondary: 'rgb(188, 199, 220)',
45
+ onSecondary: 'rgb(39, 49, 65)',
46
+ secondaryContainer: 'rgb(61, 71, 88)',
47
+ onSecondaryContainer: 'rgb(216, 227, 248)',
48
+ tertiary: 'rgb(218, 189, 226)',
49
+ onTertiary: 'rgb(61, 40, 70)',
50
+ tertiaryContainer: 'rgb(85, 63, 93)',
51
+ onTertiaryContainer: 'rgb(247, 216, 255)',
52
+ error: 'rgb(255, 180, 171)',
53
+ onError: 'rgb(105, 0, 5)',
54
+ errorContainer: 'rgb(147, 0, 10)',
55
+ onErrorContainer: 'rgb(255, 180, 171)',
56
+ background: 'rgb(26, 28, 30)',
57
+ onBackground: 'rgb(227, 226, 230)',
58
+ surface: 'rgb(26, 28, 30)',
59
+ onSurface: 'rgb(227, 226, 230)',
60
+ surfaceVariant: 'rgb(67, 71, 78)',
61
+ onSurfaceVariant: 'rgb(195, 198, 207)',
62
+ outline: 'rgb(141, 145, 153)',
63
+ outlineVariant: 'rgb(67, 71, 78)',
64
+ shadow: 'rgb(0, 0, 0)',
65
+ scrim: 'rgb(0, 0, 0)',
66
+ inverseSurface: 'rgb(227, 226, 230)',
67
+ inverseOnSurface: 'rgb(47, 48, 51)',
68
+ inversePrimary: 'rgb(0, 95, 175)',
69
+ elevation: {
70
+ level0: 'transparent',
71
+ level1: 'rgb(33, 37, 41)',
72
+ level2: 'rgb(37, 42, 48)',
73
+ level3: 'rgb(41, 47, 55)',
74
+ level4: 'rgb(43, 49, 57)',
75
+ level5: 'rgb(46, 52, 62)',
76
+ },
77
+ surfaceDisabled: 'rgba(227, 226, 230, 0.12)',
78
+ onSurfaceDisabled: 'rgba(227, 226, 230, 0.38)',
79
+ backdrop: 'rgba(45, 49, 56, 0.4)',
80
+ }
81
+
82
+ const Colors: Partial<ThemeNavigationColors> = Object.assign(navColors, ownColor)
83
+
84
+ export default { Colors }
@@ -0,0 +1,2 @@
1
+ export { default as Images } from './Images'
2
+ export { default as Variables } from './Variables'
@@ -0,0 +1,8 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { Theme } from '@/theme/types'
3
+
4
+ import * as default_dark from './default_dark'
5
+
6
+ type Themes = { [key: string]: Partial<Theme> }
7
+
8
+ export default { default_dark } as Themes
@@ -0,0 +1,152 @@
1
+ import { Theme as NavigationThemeType } from '@react-navigation/native'
2
+ import { ImageStyle, TextStyle, ViewStyle } from 'react-native'
3
+ import { MD3Theme as PaperThemeType } from 'react-native-paper'
4
+
5
+ import { FontAlign, FontType, FontWithSize, MD3FontType } from '@/theme/Fonts'
6
+ import { GutterType } from '@/theme/Gutters'
7
+ import { ILayout } from '@/theme/Layout'
8
+
9
+ import { Colors, ownColor } from './Variables'
10
+
11
+ type Overwrite<T, NewT> = Omit<T, keyof NewT> & NewT
12
+
13
+ type MergeStyleKeys<A, B, C = StyleType> = { [P in
14
+ `${Exclude<keyof A, symbol>}${Exclude<Capitalize<string & keyof B>, symbol>}`
15
+ ]: C; }
16
+
17
+ // declare module '@/theme/types' {
18
+
19
+ export type StyleType = TextStyle & ViewStyle & ImageStyle
20
+
21
+ // export type ThemeColors = typeof Colors[keyof typeof Colors]
22
+
23
+
24
+ // export type ThemeNavigationTheme = {
25
+ // dark: boolean
26
+ // colors: ThemeNavigationColors
27
+ // }
28
+
29
+
30
+ // export type ThemeNavigationColors = {
31
+ // primary: string
32
+ // background: string
33
+ // card: string
34
+ // text: string
35
+ // border: string
36
+ // notification: string
37
+ // }
38
+
39
+ type NavigationColors = NavigationThemeType['colors']
40
+ type PaperColors = PaperThemeType['colors']
41
+ type OwnColors = typeof ownColor
42
+ type TColors = Overwrite<Overwrite<NavigationColors, PaperColors>, OwnColors>
43
+ export type ThemeNavigationColors = TColors // PaperColors & NavigationColors & OwnColors
44
+ export type ThemeNavigationFonts = PaperThemeType['fonts']
45
+
46
+ type TNavigationTheme = Overwrite<NavigationThemeType, PaperThemeType>
47
+ export type ThemeNavigationTheme = TNavigationTheme // NavigationThemeType & PaperThemeType
48
+ export type ThemeNavigationThemeWithOwn = Overwrite<ThemeNavigationTheme, { colors: TColors }> // ThemeNavigationTheme & { colors: OwnColors }
49
+ export type CustomPaperThemeType = Overwrite<PaperThemeType, { colors: TColors }>
50
+
51
+ type MD3FontSizeKey = 'small' | 'medium' | 'large'
52
+ type FontSizeKey = MD3FontSizeKey | 'xlarge' | 'xxlarge'
53
+ export type ThemeFontSize = { [key in FontSizeKey]: number }
54
+ type IconSizeKey = 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'
55
+ export type ThemeIconSize = { [key in IconSizeKey]: number }
56
+ // export type ThemeMetricsSizes = { [key: string]: number | string }
57
+ export type MetricsSizeKey = 'tiny' | 'small' | 'medium' | 'large'
58
+ export type ThemeMetricsSizes = { [key in MetricsSizeKey]: number }
59
+
60
+ export enum FontScale {
61
+ SMALL = 'SMALL',
62
+ MEDIUM = 'MEDIUM',
63
+ LARGE = 'LARGE',
64
+ }
65
+ export type ThemeScaledFontSize = { [key in FontScale]: ThemeFontSize }
66
+ export type ThemeParam = {
67
+ roundness: number
68
+ itemRoundness: number
69
+ animation: {
70
+ scale: number
71
+ }
72
+ headerHeight: number
73
+ }
74
+
75
+ export type ThemeVariables = {
76
+ Colors: ThemeNavigationColors
77
+ // NavigationColors: ThemeNavigationColors
78
+ FontSize: ThemeFontSize
79
+ IconSize: ThemeIconSize
80
+ MetricsSizes: ThemeMetricsSizes
81
+ ScaledFontSize: ThemeScaledFontSize
82
+ Param: ThemeParam
83
+ }
84
+
85
+ type MD3FontSizes = { [key in MD3FontSizeKey]: number }
86
+ export type MD3Fonts = MergeStyleKeys<MD3FontType, MD3FontSizes, TextStyle> & { 'default': TextStyle }
87
+ export type ThemeFonts = MergeStyleKeys<FontWithSize, ThemeFontSize, TextStyle> & MD3Fonts & FontAlign & FontType
88
+ export type ThemeIcon = { [K in keyof ThemeIconSize as `${K}Icon`]: StyleType }
89
+ // export type ThemeLayout = { [key: string]: StyleType }
90
+ export type ThemeLayout<T> = {
91
+ [key in keyof T]: StyleType
92
+ }
93
+ export type ThemeGutters = MergeStyleKeys<ThemeMetricsSizes, GutterType>
94
+
95
+ type ButtonType = 'base' | 'rounded' | 'outline' | 'contentIconOnly' | 'content' // |'outlineRounded'|'baseSecondary'|'roundedSecondary'|'outlineSecondary'|'outlineRoundedSecondary'
96
+ export type ButtonsStyle = { [key in ButtonType]: StyleType }
97
+ export type ThemeCommon = {
98
+ // [key: string]: StyleType
99
+ button: ButtonsStyle
100
+ textInput: StyleType
101
+ }
102
+ export type ThemeImages = { [key: string]: any }
103
+
104
+ export type Theme = {
105
+ Colors: ThemeNavigationColors
106
+ // NavigationColors: ThemeNavigationColors
107
+ FontSize: ThemeFontSize
108
+ MetricsSizes: ThemeMetricsSizes
109
+ IconSize: ThemeIconSize
110
+ Fonts: ThemeFonts
111
+ Icons: ThemeIcon
112
+ Images: ThemeImages
113
+ Layout: ThemeLayout<ILayout>
114
+ Gutters: ThemeGutters
115
+ Common: ThemeCommon
116
+ Variables?: Partial<ThemeVariables>
117
+ NavigationTheme: NavigationThemeType
118
+ PaperTheme: CustomPaperThemeType
119
+ darkMode: boolean
120
+ Param: ThemeParam
121
+ }
122
+ export interface IThemeCommonParams {
123
+ Colors: ThemeNavigationColors
124
+ // NavigationColors: ThemeNavigationColors
125
+ FontSize: ThemeFontSize
126
+ MetricsSizes: ThemeMetricsSizes
127
+ Fonts: ThemeFonts
128
+ Images: ThemeImages
129
+ Layout: ThemeLayout<ILayout>
130
+ Gutters: ThemeGutters
131
+ Variables?: Partial<ThemeVariables>
132
+ Param?: Partial<ThemeParam>
133
+ }
134
+ // }
135
+ const PADDING_VARIATIONS = {
136
+ padding: 'padding',
137
+ paddingL: 'paddingLeft',
138
+ paddingT: 'paddingTop',
139
+ paddingR: 'paddingRight',
140
+ paddingB: 'paddingBottom',
141
+ paddingH: 'paddingHorizontal',
142
+ paddingV: 'paddingVertical',
143
+ } as const
144
+ export type PaddingLiterals = keyof typeof PADDING_VARIATIONS
145
+ export type NativePaddingKeyType = typeof PADDING_VARIATIONS[PaddingLiterals]
146
+
147
+ export type Modifier<T extends string> = Partial<Record<T, boolean>>
148
+ export type PaddingModifiers = Modifier<PaddingLiterals>
149
+
150
+
151
+ export type ContainerModifiers = PaddingModifiers
152
+
@@ -0,0 +1,118 @@
1
+ import { Buffer } from 'buffer'
2
+ // import { AES, CBC, PBKDF2, Pkcs7, WordArray } from 'crypto-es'
3
+ // import * as CryptoJS from 'crypto-js'
4
+ import RNCryptoJS from 'react-native-crypto-js'
5
+ import { encryptRSA, generateRSAKeyPair } from 'rn-encryption'
6
+
7
+ import logger from '@/infrastructures/common/logger'
8
+
9
+ // TODO: get from api
10
+ import { SystemInfo } from './sys-info-data'
11
+
12
+ export class EncryptHelper {
13
+ public static encryptData(data: string): Promise<{
14
+ encryptedData: string
15
+ encryptedAesKey: string
16
+ iv: string
17
+ }> {
18
+ return new Promise<{
19
+ encryptedData: string
20
+ encryptedAesKey: string
21
+ iv: string
22
+ }>((resolve, reject) => {
23
+ const publicKey = SystemInfo.data.secKey || ''
24
+ const pemHeader = '-----BEGIN PUBLIC KEY-----'
25
+ const pemFooter = '-----END PUBLIC KEY-----'
26
+ const pemContents = publicKey.replace(pemHeader, '')
27
+ .replace(pemFooter, '')
28
+ .replace(/\n/g, '')
29
+ // 1. Generate random AES key and IV
30
+ const aesKey = RNCryptoJS.lib.WordArray.random(32) // 256-bit key
31
+ const iv = RNCryptoJS.lib.WordArray.random(16) // 128-bit IV
32
+ // const aesKey = PBKDF2('password', 'salt', { keySize: 256 / 32 })
33
+ // const iv = WordArray.random(128 / 8)
34
+
35
+ // 2. Encrypt data with AES
36
+ const encryptedData = RNCryptoJS.AES.encrypt(data, aesKey, {
37
+ iv: iv,
38
+ mode: RNCryptoJS.mode.CBC,
39
+ padding: RNCryptoJS.pad.Pkcs7,
40
+ }).toString()
41
+
42
+ // logger.log('encryptedData', encryptedData)
43
+ // const encryptedData = AES.encrypt('message', aesKey, { padding: Pkcs7, mode: CBC, iv: iv }).toString()
44
+
45
+ // 3. Encrypt AES key with RSA public key
46
+ // const encryptedAesKey = await this._rsaEncrypt(this._wordArrayToUint8Array(aesKey), publicKey)
47
+ // const encryptedAesKey = await RSA.encrypt(aesKey.toString(RNCryptoJS.enc.Utf8), publicKey)
48
+ const aesKeyString = aesKey.toString(RNCryptoJS.enc.Base64)
49
+ // logger.log('aesKeyString', aesKeyString)
50
+ const encryptedAesKey = encryptRSA(aesKeyString, pemContents)
51
+
52
+ // logger.log('encryptedAesKey', encryptedAesKey)
53
+
54
+ const result = {
55
+ encryptedData,
56
+ encryptedAesKey,
57
+ iv: RNCryptoJS.enc.Base64.stringify(iv),
58
+ }
59
+ resolve(result)
60
+ })
61
+
62
+ }
63
+
64
+ /*
65
+ private static async _rsaEncrypt(data: Uint8Array, publicKeyPem: string): Promise<string> {
66
+ const pemHeader = '-----BEGIN PUBLIC KEY-----'
67
+ const pemFooter = '-----END PUBLIC KEY-----'
68
+ const pemContents = publicKeyPem.replace(pemHeader, '').replace(pemFooter, '')
69
+ .trim()
70
+ const binaryDer = this._base64ToArrayBuffer(pemContents)
71
+ console.log('crypto', crypto)
72
+
73
+ const publicKey = await crypto.subtle.importKey(
74
+ 'spki',
75
+ binaryDer,
76
+ { name: 'RSA-OAEP', hash: 'SHA-256' },
77
+ true,
78
+ ['encrypt'],
79
+ )
80
+
81
+ const encrypted = await crypto.subtle.encrypt(
82
+ { name: 'RSA-OAEP' },
83
+ publicKey,
84
+ Buffer.from(data),
85
+ )
86
+
87
+ return this._arrayBufferToBase64(encrypted)
88
+ }
89
+
90
+ private static _base64ToArrayBuffer(base64: string): ArrayBuffer {
91
+ const binaryString = atob(base64)
92
+ const bytes = new Uint8Array(binaryString.length)
93
+ for (let i = 0; i < binaryString.length; i++) {
94
+ bytes[i] = binaryString.charCodeAt(i)
95
+ }
96
+
97
+ return bytes.buffer
98
+ }
99
+
100
+ private static _arrayBufferToBase64(buffer: ArrayBuffer): string {
101
+ const bytes = new Uint8Array(buffer)
102
+
103
+ return btoa(String.fromCharCode(...bytes))
104
+ }
105
+
106
+ private static _wordArrayToUint8Array(wordArray: RNCryptoJS.lib.WordArray): Uint8Array {
107
+ const words = wordArray.words
108
+ const sigBytes = wordArray.sigBytes
109
+ const u8 = new Uint8Array(sigBytes)
110
+ for (let i = 0; i < sigBytes; i++) {
111
+ // eslint-disable-next-line no-bitwise
112
+ u8[i] = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff
113
+ }
114
+
115
+ return u8
116
+ }
117
+ */
118
+ }
@@ -0,0 +1,76 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ import { Dimensions, PixelRatio, Platform } from 'react-native'
3
+
4
+ import logger from '@/infrastructures/common/logger'
5
+
6
+ const { height: screenHeight, width: screenWidth } = Dimensions.get('screen')
7
+ const dimen = Dimensions.get('window')
8
+ const isIphoneX = (
9
+ Platform.OS === 'ios' &&
10
+ !Platform.isPad &&
11
+ !Platform.isTV &&
12
+ ((dimen.height === 780 || dimen.width === 780)
13
+ || (dimen.height === 812 || dimen.width === 812)
14
+ || (dimen.height === 844 || dimen.width === 844)
15
+ || (dimen.height === 896 || dimen.width === 896)
16
+ || (dimen.height === 926 || dimen.width === 926))
17
+ )
18
+
19
+ const isIOS = Platform.OS === 'ios'
20
+ const { height: windowHeight, width: windowWidth } = dimen
21
+ const scale = windowWidth / 428
22
+
23
+ logger.log('width', { windowWidth, screenWidth })
24
+ logger.log('scale', scale)
25
+
26
+ const isSmallDevice = () => {
27
+ return screenWidth <= 390
28
+ }
29
+
30
+ const normalize = (size: number, maxSize?: number, minSize?: number) => {
31
+ let newSize = size * scale
32
+ const _maxSize = maxSize ? maxSize : size * 1.2
33
+ const _minSize = minSize ? minSize : size * 0.8
34
+ if (newSize > _maxSize) {
35
+ newSize = _maxSize
36
+ }
37
+ if (newSize < _minSize) {
38
+ newSize = _minSize
39
+ }
40
+
41
+ if (Platform.OS === 'ios') {
42
+ return Math.round(PixelRatio.roundToNearestPixel(newSize))
43
+ } else {
44
+ return Math.round(PixelRatio.roundToNearestPixel(newSize)) - 2
45
+ }
46
+ }
47
+
48
+ const cleanUnderscoreProps = (obj: any): any => {
49
+ if (obj) {
50
+ for (const key in obj) {
51
+ if (key.startsWith('_')) {
52
+ delete obj[key]
53
+ } else if (Array.isArray(obj[key])) {
54
+ obj[key].forEach((item: any) => {
55
+ cleanUnderscoreProps(item)
56
+ })
57
+ } else if (obj[key] && typeof obj[key] === 'object') {
58
+ cleanUnderscoreProps(obj[key])
59
+ }
60
+ }
61
+ }
62
+
63
+ return obj
64
+ }
65
+
66
+
67
+ export {
68
+ cleanUnderscoreProps,
69
+ isIOS,
70
+ isIphoneX,
71
+ isSmallDevice,
72
+ normalize,
73
+ screenHeight,
74
+ screenWidth,
75
+ }
76
+
@@ -0,0 +1,17 @@
1
+ export interface ISystemInfoData {
2
+ env?: string
3
+ team?: string
4
+ sessionTimeout?: number
5
+ secKey?: string
6
+ version?: string
7
+ }
8
+
9
+ export class SystemInfo {
10
+ public static data: ISystemInfoData = {
11
+ env: 'PRD',
12
+ team: 'Cms',
13
+ sessionTimeout: 3600,
14
+ secKey: '-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA4o7iA/kr5qFDzfkIJH6k\nONynGjefJESnQk+NFLtxFHmENLDObtCA0+u72pvJ0RCbxyth69aNDQ1mehlRxwc6\nPiQhNOcf2U58Pu98/QzXWixVGa3mWXBDZ5ci511ECUEt3Olh587VPmRk8F0m92dT\nh/fqGARPQ+bvsFWjEptXTbEQ1qlVIjTY1cmwsRrMr+DLA9VSLrFWsmuDMyBR0Gj7\n+yZ0oxAcUFgfvTDwyDgFrpiM4iAQt9OefrTFjcyyZC5zgAjdrqOJCjgnbdE5lgdL\naGIwIKbB1WIVrsFelfTJ15iz73ml/aP9Op/+ylWBpLzPHkROy57NRiii1NSudzeX\n/h9Kb8avynZEyjCgGPqPT0I7OYkaRZER8ylFpShNrXJijZXl97joeUOjOSuQzwAW\nSgt+dSTUr5u4Q8nGe4qD1XhZpwK4rgOkMVMOwfjsTmByERqogypdxKfGhslR6gZG\nmrqI6G15DXFK2E2Zcr0SJhY6Sx2LF1twFdvnD4sarGyjAgMBAAE=\n-----END PUBLIC KEY-----\n',
15
+ version: '1.0.0 (0)',
16
+ } // assigned by core.service.initializr()
17
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "extends": "@react-native/typescript-config",
3
+ "include": [
4
+ "**/*.ts",
5
+ "**/*.tsx"
6
+ ],
7
+ "exclude": [
8
+ "**/node_modules",
9
+ "**/Pods"
10
+ ],
11
+ "compilerOptions": {
12
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
13
+ "types": [
14
+ "jest",
15
+ "react-test-renderer",
16
+ "node"
17
+ ],
18
+ /* Completeness */
19
+ "skipLibCheck": true, /* Skip type checking all .d.ts files. */
20
+ "target": "esnext",
21
+ "lib": [
22
+ "es2019"
23
+ ],
24
+ "jsx": "react-native",
25
+ "typeRoots": [
26
+ "./node_modules/@types",
27
+ "src/@types"
28
+ ],
29
+ "resolveJsonModule": true,
30
+ "allowJs": true,
31
+ "noEmit": true,
32
+ "allowSyntheticDefaultImports": true,
33
+ "esModuleInterop": true,
34
+ "forceConsistentCasingInFileNames": true,
35
+ /* Type Checking */
36
+ "strict": true,
37
+ "baseUrl": ".",
38
+ "paths": {
39
+ "@/*": [
40
+ "src/*"
41
+ ]
42
+ }
43
+ },
44
+ }
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ // Placeholder used to rename and replace in files
3
+ // package.json, index.json, android/, ios/
4
+ placeholderName: "ProjectName",
5
+
6
+ // Directory with template
7
+ templateDir: "./template"
8
+ };