@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.
- package/.github/workflows/npm-publish.yml +28 -0
- package/.vscode/settings.json +15 -0
- package/README.md +58 -0
- package/package.json +16 -0
- package/template/.bundle/config +2 -0
- package/template/.env.development +1 -0
- package/template/.env.production +1 -0
- package/template/.eslintrc.js +392 -0
- package/template/.java-version +1 -0
- package/template/.prettierrc.js +5 -0
- package/template/.ruby-version +1 -0
- package/template/.watchmanconfig +1 -0
- package/template/Gemfile +23 -0
- package/template/Gemfile.lock +330 -0
- package/template/README.md +97 -0
- package/template/ReactotronConfig.js +17 -0
- package/template/__tests__/App.test.tsx +13 -0
- package/template/_gitignore +75 -0
- package/template/_node-version +1 -0
- package/template/android/app/build.gradle +162 -0
- package/template/android/app/debug.keystore +0 -0
- package/template/android/app/proguard-rules.pro +10 -0
- package/template/android/app/src/debug/AndroidManifest.xml +9 -0
- package/template/android/app/src/main/AndroidManifest.xml +26 -0
- package/template/android/app/src/main/java/com/projectname/MainActivity.kt +30 -0
- package/template/android/app/src/main/java/com/projectname/MainApplication.kt +27 -0
- package/template/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/template/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/template/android/app/src/main/res/values/strings.xml +3 -0
- package/template/android/app/src/main/res/values/styles.xml +9 -0
- package/template/android/build.gradle +37 -0
- package/template/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/template/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/template/android/gradle.properties +48 -0
- package/template/android/gradlew +251 -0
- package/template/android/gradlew.bat +99 -0
- package/template/android/keystore/keystore.properties +4 -0
- package/template/android/settings.gradle +6 -0
- package/template/android/version.properties +2 -0
- package/template/app.json +4 -0
- package/template/babel.config.js +38 -0
- package/template/fastlane/Fastfile +136 -0
- package/template/fastlane/Pluginfile +9 -0
- package/template/fastlane/README.md +46 -0
- package/template/index.js +9 -0
- package/template/ios/.xcode.env +11 -0
- package/template/ios/Podfile +35 -0
- package/template/ios/Podfile.lock +3669 -0
- package/template/ios/ProjectName/AppDelegate.swift +48 -0
- package/template/ios/ProjectName/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/template/ios/ProjectName/Images.xcassets/Contents.json +6 -0
- package/template/ios/ProjectName/Info.plist +66 -0
- package/template/ios/ProjectName/LaunchScreen.storyboard +47 -0
- package/template/ios/ProjectName/PrivacyInfo.xcprivacy +47 -0
- package/template/ios/ProjectName.xcodeproj/project.pbxproj +482 -0
- package/template/ios/ProjectName.xcodeproj/xcshareddata/xcschemes/ProjectName.xcscheme +88 -0
- package/template/ios/ProjectName.xcworkspace/contents.xcworkspacedata +10 -0
- package/template/jest.config.js +3 -0
- package/template/metro.config.js +20 -0
- package/template/package-lock.json +17073 -0
- package/template/package.json +156 -0
- package/template/src/@types/emotion.d.ts +12 -0
- package/template/src/@types/env.d.ts +3 -0
- package/template/src/@types/redux-persist-transform-immutable.d.ts +1 -0
- package/template/src/@types/typing.d.ts +17 -0
- package/template/src/AppContainer.tsx +109 -0
- package/template/src/assets/images/143.png +0 -0
- package/template/src/assets/index.ts +13 -0
- package/template/src/components/basic/BackButton/index.tsx +34 -0
- package/template/src/components/basic/Body/index.tsx +68 -0
- package/template/src/components/basic/Button/index.tsx +181 -0
- package/template/src/components/basic/Button/utils.ts +78 -0
- package/template/src/components/basic/ButtonGroup/index.tsx +182 -0
- package/template/src/components/basic/Card/index.tsx +3 -0
- package/template/src/components/basic/Container/index.tsx +38 -0
- package/template/src/components/basic/Content/index.tsx +87 -0
- package/template/src/components/basic/DropDown/index.tsx +354 -0
- package/template/src/components/basic/ExpandableOverlay/index.tsx +113 -0
- package/template/src/components/basic/Header/index.tsx +216 -0
- package/template/src/components/basic/Header/styles.ts +0 -0
- package/template/src/components/basic/Icons/index.tsx +131 -0
- package/template/src/components/basic/InputLabel/index.tsx +19 -0
- package/template/src/components/basic/LoadingOverlay/index.tsx +68 -0
- package/template/src/components/basic/MaterialTextInput/index.tsx +153 -0
- package/template/src/components/basic/NumberInput/index.tsx +53 -0
- package/template/src/components/basic/Picker/PickerContext.ts +7 -0
- package/template/src/components/basic/Picker/PickerHeader.tsx +130 -0
- package/template/src/components/basic/Picker/PickerItem.tsx +105 -0
- package/template/src/components/basic/Picker/PickerItemsList.tsx +135 -0
- package/template/src/components/basic/Picker/PickerPresenter.ts +54 -0
- package/template/src/components/basic/Picker/hooks/useImperativePickerHandle.ts +27 -0
- package/template/src/components/basic/Picker/hooks/usePickerLabel.ts +74 -0
- package/template/src/components/basic/Picker/hooks/usePickerSearch.ts +37 -0
- package/template/src/components/basic/Picker/hooks/usePickerSelection.ts +57 -0
- package/template/src/components/basic/Picker/index.tsx +284 -0
- package/template/src/components/basic/Picker/types.tsx +229 -0
- package/template/src/components/basic/PressableOpacity/index.tsx +20 -0
- package/template/src/components/basic/RootDialog/Dialog.tsx +246 -0
- package/template/src/components/basic/RootDialog/Manager.tsx +110 -0
- package/template/src/components/basic/RootDialog/animations/Animation.ts +29 -0
- package/template/src/components/basic/RootDialog/animations/FadeAnimation.ts +40 -0
- package/template/src/components/basic/RootDialog/animations/ScaleAnimation.ts +37 -0
- package/template/src/components/basic/RootDialog/animations/SlideAnimation.ts +89 -0
- package/template/src/components/basic/RootDialog/components/Backdrop.tsx +60 -0
- package/template/src/components/basic/RootDialog/components/BaseDialog.tsx +564 -0
- package/template/src/components/basic/RootDialog/components/BottomDialog.tsx +32 -0
- package/template/src/components/basic/RootDialog/components/DialogButton.tsx +87 -0
- package/template/src/components/basic/RootDialog/components/DialogContent.tsx +26 -0
- package/template/src/components/basic/RootDialog/components/DialogContext.tsx +8 -0
- package/template/src/components/basic/RootDialog/components/DialogFooter.tsx +42 -0
- package/template/src/components/basic/RootDialog/components/DialogTitle.tsx +53 -0
- package/template/src/components/basic/RootDialog/components/DraggableView.tsx +271 -0
- package/template/src/components/basic/RootDialog/index.ts +21 -0
- package/template/src/components/basic/RootDialog/type.ts +102 -0
- package/template/src/components/basic/Text/index.tsx +8 -0
- package/template/src/components/basic/index.ts +35 -0
- package/template/src/configs/constants/type/APIStatus.type.ts +8 -0
- package/template/src/configs/constants/type/Locale.type.ts +7 -0
- package/template/src/configs/constants/type/StorageKey.type.ts +7 -0
- package/template/src/configs/constants/type/ThemeType.type.ts +6 -0
- package/template/src/configs/constants/type/index.ts +11 -0
- package/template/src/configs/index.ts +22 -0
- package/template/src/contexts/ThemeContext.ts +6 -0
- package/template/src/hooks/useAppLoading.ts +26 -0
- package/template/src/hooks/useAppState.ts +36 -0
- package/template/src/hooks/useArray.ts +47 -0
- package/template/src/hooks/useAsync.ts +42 -0
- package/template/src/hooks/useAsyncStorage.ts +41 -0
- package/template/src/hooks/useBoolean.ts +21 -0
- package/template/src/hooks/useBuildTheme.ts +249 -0
- package/template/src/hooks/useCountDown.ts +111 -0
- package/template/src/hooks/useCounter.ts +27 -0
- package/template/src/hooks/useDebounce.ts +25 -0
- package/template/src/hooks/useDebouncedValidate.ts +32 -0
- package/template/src/hooks/useDebugInformation.ts +38 -0
- package/template/src/hooks/useDeviceToken.ts +20 -0
- package/template/src/hooks/useEncryptedStorage.ts +41 -0
- package/template/src/hooks/useFontFamily.ts +13 -0
- package/template/src/hooks/useHttp.ts +18 -0
- package/template/src/hooks/useInterval.ts +24 -0
- package/template/src/hooks/useIsForeground.ts +17 -0
- package/template/src/hooks/useMMKVStorage.ts +0 -0
- package/template/src/hooks/usePrevious.ts +12 -0
- package/template/src/hooks/useRenderCount.ts +10 -0
- package/template/src/hooks/useTheme.ts +17 -0
- package/template/src/hooks/useTimeCountDown.ts +91 -0
- package/template/src/index.tsx +65 -0
- package/template/src/infrastructures/NetClient/AbstractClient.ts +66 -0
- package/template/src/infrastructures/NetClient/ApiResponse.ts +16 -0
- package/template/src/infrastructures/NetClient/ApisauceClient.ts +76 -0
- package/template/src/infrastructures/NetClient/AxiosClient.ts +80 -0
- package/template/src/infrastructures/NetClient/FetchNetClient.ts +120 -0
- package/template/src/infrastructures/NetClient/config.ts +3 -0
- package/template/src/infrastructures/NetClient/interfaces/INetClient.ts +6 -0
- package/template/src/infrastructures/Storage/IStorage.ts +7 -0
- package/template/src/infrastructures/Storage/MMKVStorage.ts +41 -0
- package/template/src/infrastructures/common/Timeout.ts +27 -0
- package/template/src/infrastructures/common/colorUtils.ts +82 -0
- package/template/src/infrastructures/common/dateUtils.ts +39 -0
- package/template/src/infrastructures/common/logger.ts +115 -0
- package/template/src/locales/en-US/general.json +26 -0
- package/template/src/locales/en-US/index.ts +9 -0
- package/template/src/locales/en-US/screens.json +4 -0
- package/template/src/locales/en-US/setting.json +3 -0
- package/template/src/locales/i18n.ts +109 -0
- package/template/src/locales/zh-TW/general.json +26 -0
- package/template/src/locales/zh-TW/index.ts +9 -0
- package/template/src/locales/zh-TW/screens.json +4 -0
- package/template/src/locales/zh-TW/setting.json +3 -0
- package/template/src/models/index.ts +5 -0
- package/template/src/models/request.model.ts +50 -0
- package/template/src/navigators/DrawerNav/DrawerContent.tsx +66 -0
- package/template/src/navigators/DrawerNav/DrawerItem.tsx +261 -0
- package/template/src/navigators/DrawerNav/index.tsx +39 -0
- package/template/src/navigators/DrawerNav/props.ts +12 -0
- package/template/src/navigators/DrawerNav/types.ts +8 -0
- package/template/src/navigators/MainBottomTabNav/index.tsx +83 -0
- package/template/src/navigators/MainBottomTabNav/props.ts +16 -0
- package/template/src/navigators/MainBottomTabNav/types.ts +6 -0
- package/template/src/navigators/RootStack.tsx +43 -0
- package/template/src/navigators/index.tsx +40 -0
- package/template/src/navigators/props.ts +14 -0
- package/template/src/navigators/types.ts +18 -0
- package/template/src/navigators/utils.ts +68 -0
- package/template/src/redux/api/api.ts +41 -0
- package/template/src/redux/reducers/appSlice.ts +26 -0
- package/template/src/redux/reducers/index.ts +21 -0
- package/template/src/redux/reducers/nonPersistSlice.ts +51 -0
- package/template/src/redux/reducers/settingSlice.ts +48 -0
- package/template/src/redux/reducers/themeSlice.ts +55 -0
- package/template/src/redux/saga/index.ts +5 -0
- package/template/src/redux/saga/settingSaga.ts +21 -0
- package/template/src/redux/selectors/app.ts +9 -0
- package/template/src/redux/selectors/nonPersist.ts +23 -0
- package/template/src/redux/selectors/setting.ts +29 -0
- package/template/src/redux/selectors/theme.ts +13 -0
- package/template/src/redux/store/index.ts +79 -0
- package/template/src/redux/store/types.d.ts +5 -0
- package/template/src/screens/Home/index.tsx +146 -0
- package/template/src/screens/Settings/components/Item.tsx +45 -0
- package/template/src/screens/Settings/index.tsx +97 -0
- package/template/src/screens/Splash/index.tsx +53 -0
- package/template/src/services/Dialogs.tsx +226 -0
- package/template/src/services/PermissionCheck.ts +257 -0
- package/template/src/theme/Common.ts +48 -0
- package/template/src/theme/Fonts.ts +196 -0
- package/template/src/theme/Gutters.ts +63 -0
- package/template/src/theme/Icons.ts +28 -0
- package/template/src/theme/Images.ts +13 -0
- package/template/src/theme/Layout.ts +106 -0
- package/template/src/theme/Variables.ts +167 -0
- package/template/src/theme/components/Buttons.ts +37 -0
- package/template/src/theme/index.ts +8 -0
- package/template/src/theme/metrics.ts +57 -0
- package/template/src/theme/themes/default_dark/Images.ts +7 -0
- package/template/src/theme/themes/default_dark/Variables.ts +84 -0
- package/template/src/theme/themes/default_dark/index.ts +2 -0
- package/template/src/theme/themes/index.ts +8 -0
- package/template/src/theme/types.ts +152 -0
- package/template/src/utils/encrypt-helper.ts +118 -0
- package/template/src/utils/index.ts +76 -0
- package/template/src/utils/sys-info-data.ts +17 -0
- package/template/tsconfig.json +44 -0
- 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,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
|
+
}
|