nx-react-native-cli 1.0.10 → 1.0.12
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/lib/index.cjs +17 -17
- package/package.json +2 -2
- package/templates/.eslintrc.json +293 -0
- package/templates/.husky/pre-commit +5 -0
- package/templates/.husky/pre-push +15 -0
- package/templates/.ignorefile +146 -0
- package/templates/.nvmrc +1 -0
- package/templates/.prettierignore +8 -0
- package/templates/.prettierrc +13 -0
- package/templates/.ruby-version +1 -0
- package/templates/.vscode/extensions.json +10 -0
- package/templates/.vscode/settings.json +18 -0
- package/templates/apps/mobile/.env +3 -0
- package/templates/apps/mobile/.env.template +3 -0
- package/templates/apps/mobile/.eslintrc.json +34 -0
- package/templates/apps/mobile/Gemfile +11 -0
- package/templates/apps/mobile/android/app/build.gradle +164 -0
- package/templates/apps/mobile/android/app/src/dev/res/values/strings.xml +3 -0
- package/templates/apps/mobile/android/app/src/production/res/values/strings.xml +3 -0
- package/templates/apps/mobile/android/build.gradle +34 -0
- package/templates/apps/mobile/babel.config.json +14 -0
- package/templates/apps/mobile/fastlane/.env.template +24 -0
- package/templates/apps/mobile/fastlane/Fastfile +303 -0
- package/templates/apps/mobile/fastlane/Matchfile +5 -0
- package/templates/apps/mobile/fastlane/Pluginfile +6 -0
- package/templates/apps/mobile/fastlane/README.md +65 -0
- package/templates/apps/mobile/package.json +77 -0
- package/templates/apps/mobile/project.json +102 -0
- package/templates/apps/mobile/src/app/index.tsx +68 -0
- package/templates/apps/mobile/src/components/atoms/BottomSheet/bottom-sheet.component.tsx +145 -0
- package/templates/apps/mobile/src/components/atoms/BottomSheet/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/Button/button.component.tsx +55 -0
- package/templates/apps/mobile/src/components/atoms/Button/index.ts +2 -0
- package/templates/apps/mobile/src/components/atoms/Button/outlined-button.component.tsx +59 -0
- package/templates/apps/mobile/src/components/atoms/Divider/divider-component.tsx +13 -0
- package/templates/apps/mobile/src/components/atoms/Divider/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/InputLayout/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/InputLayout/input-layout.component.tsx +34 -0
- package/templates/apps/mobile/src/components/atoms/ListLoadingItem/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/ListLoadingItem/list-loading-item.component.tsx +56 -0
- package/templates/apps/mobile/src/components/atoms/Modal/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/Modal/modal.component.tsx +58 -0
- package/templates/apps/mobile/src/components/atoms/ScreenLoader/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/ScreenLoader/screen-loader.component.tsx +17 -0
- package/templates/apps/mobile/src/components/atoms/Skeleton/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/Skeleton/skeleton.component.tsx +42 -0
- package/templates/apps/mobile/src/components/atoms/Text/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/Text/text.component.tsx +23 -0
- package/templates/apps/mobile/src/components/atoms/TextInput/constants.ts +43 -0
- package/templates/apps/mobile/src/components/atoms/TextInput/index.ts +2 -0
- package/templates/apps/mobile/src/components/atoms/TextInput/text-input.component.tsx +137 -0
- package/templates/apps/mobile/src/components/atoms/index.ts +10 -0
- package/templates/apps/mobile/src/components/index.ts +3 -0
- package/templates/apps/mobile/src/components/molecules/BackButton/back-button.component.tsx +58 -0
- package/templates/apps/mobile/src/components/molecules/BackButton/index.ts +1 -0
- package/templates/apps/mobile/src/components/molecules/BottomActionsContainer/BottomActionsContainer.component.tsx +28 -0
- package/templates/apps/mobile/src/components/molecules/BottomActionsContainer/index.ts +1 -0
- package/templates/apps/mobile/src/components/molecules/ScreenContainer/index.ts +1 -0
- package/templates/apps/mobile/src/components/molecules/ScreenContainer/screen-container.component.tsx +100 -0
- package/templates/apps/mobile/src/components/molecules/ScreenHeader/index.ts +1 -0
- package/templates/apps/mobile/src/components/molecules/ScreenHeader/screen-header.component.tsx +71 -0
- package/templates/apps/mobile/src/components/molecules/StorageManager/StorageManager.component.tsx +18 -0
- package/templates/apps/mobile/src/components/molecules/StorageManager/index.ts +1 -0
- package/templates/apps/mobile/src/components/molecules/index.ts +5 -0
- package/templates/apps/mobile/src/components/organisms/index.ts +1 -0
- package/templates/apps/mobile/src/config/index.ts +13 -0
- package/templates/apps/mobile/src/dimens/index.ts +1 -0
- package/templates/apps/mobile/src/env.d.ts +17 -0
- package/templates/apps/mobile/src/hooks/index.ts +9 -0
- package/templates/apps/mobile/src/hooks/useAppState.hook.tsx +20 -0
- package/templates/apps/mobile/src/hooks/useApplicationDimensions.hook.tsx +10 -0
- package/templates/apps/mobile/src/hooks/useDebounce.hook.ts +11 -0
- package/templates/apps/mobile/src/hooks/useGetLayoutHeight.hook.tsx +27 -0
- package/templates/apps/mobile/src/hooks/useGetLayoutWidth.hook.tsx +27 -0
- package/templates/apps/mobile/src/hooks/useNavigation.hook.tsx +8 -0
- package/templates/apps/mobile/src/hooks/useShakeAnimation.hook.tsx +32 -0
- package/templates/apps/mobile/src/hooks/useTextInputChangeFocus.hook.tsx +12 -0
- package/templates/apps/mobile/src/hooks/useThrottle.hook.ts +11 -0
- package/templates/apps/mobile/src/icons/arrow-left.svg +3 -0
- package/templates/apps/mobile/src/icons/checkbox-active.svg +4 -0
- package/templates/apps/mobile/src/icons/checkbox-unactive.svg +4 -0
- package/templates/apps/mobile/src/icons/close.svg +3 -0
- package/templates/apps/mobile/src/icons/download.svg +4 -0
- package/templates/apps/mobile/src/icons/email.svg +10 -0
- package/templates/apps/mobile/src/icons/eye-slash.svg +11 -0
- package/templates/apps/mobile/src/icons/eye.svg +4 -0
- package/templates/apps/mobile/src/icons/gear.svg +4 -0
- package/templates/apps/mobile/src/icons/home.svg +3 -0
- package/templates/apps/mobile/src/icons/index.ts +33 -0
- package/templates/apps/mobile/src/icons/pencil.svg +3 -0
- package/templates/apps/mobile/src/icons/phone.svg +3 -0
- package/templates/apps/mobile/src/icons/user-circle.svg +3 -0
- package/templates/apps/mobile/src/icons/user.svg +4 -0
- package/templates/apps/mobile/src/icons/warning.svg +3 -0
- package/templates/apps/mobile/src/main.tsx +5 -0
- package/templates/apps/mobile/src/routes/index.tsx +65 -0
- package/templates/apps/mobile/src/routes/privateRoutes.tsx +32 -0
- package/templates/apps/mobile/src/routes/publicRoutes.tsx +26 -0
- package/templates/apps/mobile/src/routes/routes.enum.ts +5 -0
- package/templates/apps/mobile/src/routes/screen-options.ts +9 -0
- package/templates/apps/mobile/src/routes/screens.enum.ts +4 -0
- package/templates/apps/mobile/src/screens/HomeScreen/home.screen.tsx +12 -0
- package/templates/apps/mobile/src/screens/LoginScreen/login.screen.tsx +13 -0
- package/templates/apps/mobile/src/stores/index.ts +1 -0
- package/templates/apps/mobile/src/stores/local-storage.store.ts +60 -0
- package/templates/apps/mobile/src/stores/mmkvStorage.ts +19 -0
- package/templates/apps/mobile/src/tailwind/index.ts +24 -0
- package/templates/apps/mobile/src/types/component.type.ts +13 -0
- package/templates/apps/mobile/src/types/index.ts +1 -0
- package/templates/apps/mobile/tailwind.config.js +80 -0
- package/templates/apps/mobile/tsconfig.app.json +11 -0
- package/templates/check-env.sh +44 -0
- package/templates/clean-generated-outputs.sh +32 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mobile",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"android:connect": "adb reverse tcp:8081 tcp:8081",
|
|
7
|
+
"start": "npx nx start mobile --skip-nx-cache",
|
|
8
|
+
"run-ios": "npx nx run-ios mobile --skip-nx-cache --scheme=Dev --simulator='iPhone 13 (A96A9251-28D7-48B1-8F6A-20B6CCB8810B)'",
|
|
9
|
+
"run-android": "npx nx run-android mobile --skip-nx-cache",
|
|
10
|
+
"ensure-symlink": "npx nx ensure-symlink mobile",
|
|
11
|
+
"sync-deps": "npx nx sync-deps mobile",
|
|
12
|
+
"pod-install": "npx nx pod-install mobile",
|
|
13
|
+
"bundle:pod-install": "cd ios && bundle install && bundle exec pod install --repo-update",
|
|
14
|
+
"pre-build": "npm run ensure-symlink && npm run sync-deps && npm run pod-install",
|
|
15
|
+
"list:ios-configurations": "cd ios && xcodebuild -list",
|
|
16
|
+
"list:ios-devices": "xcrun xctrace list devices",
|
|
17
|
+
"xcode": "open ios/AppsMobile.xcworkspace",
|
|
18
|
+
"check-env:mobile": "cd ../.. && npm run check-env:mobile",
|
|
19
|
+
"setup-fastlane": "rbenv local && bundle install && bundle update",
|
|
20
|
+
"deploy-android:dev": "bundle exec fastlane android dev --env development",
|
|
21
|
+
"deploy-ios:dev": "bundle exec fastlane ios dev --env development",
|
|
22
|
+
"ios-certificates": "npm run setup-fastlane && bundle exec fastlane ios certificates --env development"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@gorhom/bottom-sheet": "*",
|
|
26
|
+
"@hookform/resolvers": "*",
|
|
27
|
+
"@react-native-async-storage/async-storage": "*",
|
|
28
|
+
"@react-native-community/datetimepicker": "*",
|
|
29
|
+
"@react-native-community/hooks": "*",
|
|
30
|
+
"@react-native/metro-config": "*",
|
|
31
|
+
"@react-navigation/core": "*",
|
|
32
|
+
"@react-navigation/material-top-tabs": "*",
|
|
33
|
+
"@react-navigation/native-stack": "*",
|
|
34
|
+
"@react-navigation/native": "*",
|
|
35
|
+
"@react-navigation/routers": "*",
|
|
36
|
+
"@react-navigation/stack": "*",
|
|
37
|
+
"@tanstack/query-async-storage-persister": "*",
|
|
38
|
+
"@tanstack/query-core": "*",
|
|
39
|
+
"@tanstack/query-sync-storage-persister": "*",
|
|
40
|
+
"@tanstack/react-query-persist-client": "*",
|
|
41
|
+
"@tanstack/react-query": "*",
|
|
42
|
+
"@testing-library/jest-native": "*",
|
|
43
|
+
"@testing-library/react-native": "*",
|
|
44
|
+
"axios": "*",
|
|
45
|
+
"babel-plugin-module-resolver": "*",
|
|
46
|
+
"dayjs": "*",
|
|
47
|
+
"jotai-optics": "*",
|
|
48
|
+
"jotai": "*",
|
|
49
|
+
"lodash": "*",
|
|
50
|
+
"metro-config": "*",
|
|
51
|
+
"react-hook-form": "*",
|
|
52
|
+
"react-native-dotenv": "*",
|
|
53
|
+
"react-native-fast-image": "*",
|
|
54
|
+
"react-native-gesture-handler": "*",
|
|
55
|
+
"react-native-get-random-values": "*",
|
|
56
|
+
"react-native-keyboard-aware-scroll-view": "*",
|
|
57
|
+
"react-native-mmkv": "*",
|
|
58
|
+
"react-native-modal-datetime-picker": "*",
|
|
59
|
+
"react-native-modal": "*",
|
|
60
|
+
"react-native-pager-view": "*",
|
|
61
|
+
"react-native-reanimated": "*",
|
|
62
|
+
"react-native-safe-area-context": "*",
|
|
63
|
+
"react-native-screens": "*",
|
|
64
|
+
"react-native-simple-toast": "*",
|
|
65
|
+
"react-native-svg-transformer": "*",
|
|
66
|
+
"react-native-svg": "*",
|
|
67
|
+
"react-native-url-polyfill": "*",
|
|
68
|
+
"react-native": "*",
|
|
69
|
+
"react": "*",
|
|
70
|
+
"tailwindcss": "*",
|
|
71
|
+
"twrnc": "*",
|
|
72
|
+
"uuid": "*",
|
|
73
|
+
"zod-validation-error": "*",
|
|
74
|
+
"zod": "*",
|
|
75
|
+
"zustand": "*"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mobile",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "apps/mobile/src",
|
|
5
|
+
"projectType": "application",
|
|
6
|
+
"targets": {
|
|
7
|
+
"check-env": {
|
|
8
|
+
"executor": "nx:run-script",
|
|
9
|
+
"options": {
|
|
10
|
+
"script": "check-env:mobile"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"start": {
|
|
14
|
+
"executor": "@nx/react-native:start",
|
|
15
|
+
"dependsOn": ["check-env", "ensure-symlink", "pod-install"],
|
|
16
|
+
"options": {
|
|
17
|
+
"port": 8081,
|
|
18
|
+
"resetCache": true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"serve": {
|
|
22
|
+
"executor": "nx:run-commands",
|
|
23
|
+
"options": {
|
|
24
|
+
"command": "nx start mobile"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"run-ios": {
|
|
28
|
+
"executor": "@nx/react-native:run-ios",
|
|
29
|
+
"dependsOn": ["ensure-symlink", "pod-install"],
|
|
30
|
+
"options": {}
|
|
31
|
+
},
|
|
32
|
+
"bundle-ios": {
|
|
33
|
+
"executor": "@nx/react-native:bundle",
|
|
34
|
+
"dependsOn": ["ensure-symlink"],
|
|
35
|
+
"outputs": ["{options.bundleOutput}"],
|
|
36
|
+
"options": {
|
|
37
|
+
"entryFile": "src/main.tsx",
|
|
38
|
+
"platform": "ios",
|
|
39
|
+
"bundleOutput": "dist/apps/mobile/ios/main.jsbundle"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"run-android": {
|
|
43
|
+
"executor": "@nx/react-native:run-android",
|
|
44
|
+
"dependsOn": ["ensure-symlink"],
|
|
45
|
+
"options": {}
|
|
46
|
+
},
|
|
47
|
+
"build-android": {
|
|
48
|
+
"executor": "@nx/react-native:build-android",
|
|
49
|
+
"outputs": [
|
|
50
|
+
"{projectRoot}/android/app/build/outputs/bundle",
|
|
51
|
+
"{projectRoot}/android/app/build/outputs/apk"
|
|
52
|
+
],
|
|
53
|
+
"dependsOn": ["ensure-symlink"],
|
|
54
|
+
"options": {}
|
|
55
|
+
},
|
|
56
|
+
"build-ios": {
|
|
57
|
+
"executor": "@nx/react-native:build-ios",
|
|
58
|
+
"outputs": ["{projectRoot}/ios/build/Build"],
|
|
59
|
+
"dependsOn": ["ensure-symlink", "pod-install"],
|
|
60
|
+
"options": {}
|
|
61
|
+
},
|
|
62
|
+
"pod-install": {
|
|
63
|
+
"executor": "nx:run-script",
|
|
64
|
+
"options": {
|
|
65
|
+
"script": "bundle:pod-install"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"bundle-android": {
|
|
69
|
+
"executor": "@nx/react-native:bundle",
|
|
70
|
+
"dependsOn": ["ensure-symlink"],
|
|
71
|
+
"outputs": ["{options.bundleOutput}"],
|
|
72
|
+
"options": {
|
|
73
|
+
"entryFile": "src/main.tsx",
|
|
74
|
+
"platform": "android",
|
|
75
|
+
"bundleOutput": "dist/apps/mobile/android/main.jsbundle"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"sync-deps": {
|
|
79
|
+
"executor": "@nx/react-native:sync-deps",
|
|
80
|
+
"options": {}
|
|
81
|
+
},
|
|
82
|
+
"ensure-symlink": {
|
|
83
|
+
"executor": "@nx/react-native:ensure-symlink",
|
|
84
|
+
"options": {}
|
|
85
|
+
},
|
|
86
|
+
"lint": {
|
|
87
|
+
"executor": "@nx/eslint:lint",
|
|
88
|
+
"outputs": ["{options.outputFile}"],
|
|
89
|
+
"options": {
|
|
90
|
+
"lintFilePatterns": ["apps/mobile/**/*.{ts,tsx,js,jsx}"]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"test": {
|
|
94
|
+
"executor": "@nx/jest:jest",
|
|
95
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
96
|
+
"options": {
|
|
97
|
+
"jestConfig": "apps/mobile/jest.config.ts"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"tags": []
|
|
102
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
+
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister';
|
|
3
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { LogBox } from 'react-native';
|
|
7
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
8
|
+
import 'react-native-get-random-values';
|
|
9
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
10
|
+
import { enableFreeze } from 'react-native-screens';
|
|
11
|
+
import 'react-native-url-polyfill/auto';
|
|
12
|
+
|
|
13
|
+
import { StorageManager } from '../components';
|
|
14
|
+
import ApplicationRoutes from '../routes';
|
|
15
|
+
import { tw } from '../tailwind';
|
|
16
|
+
|
|
17
|
+
LogBox.ignoreLogs(['VirtualizedLists', 'onAnimatedValueUpdate']);
|
|
18
|
+
|
|
19
|
+
enableFreeze(true);
|
|
20
|
+
|
|
21
|
+
const MS_IN_S = 1000;
|
|
22
|
+
const S_IN_A_MIN = 60;
|
|
23
|
+
const MIN_IN_AN_HOUR = 60;
|
|
24
|
+
const HOURS_IN_A_DAY = 24;
|
|
25
|
+
const MS_IN_DAYS = MS_IN_S * S_IN_A_MIN * MIN_IN_AN_HOUR * HOURS_IN_A_DAY;
|
|
26
|
+
|
|
27
|
+
const CACHE_TIME = MS_IN_DAYS * 1;
|
|
28
|
+
const STALE_TIME = MS_IN_S * S_IN_A_MIN * MIN_IN_AN_HOUR; // 5 minutes
|
|
29
|
+
|
|
30
|
+
const queryClient = new QueryClient({
|
|
31
|
+
defaultOptions: {
|
|
32
|
+
queries: {
|
|
33
|
+
staleTime: STALE_TIME,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const persister = createAsyncStoragePersister({
|
|
39
|
+
storage: AsyncStorage,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const persistOptions = { maxAge: CACHE_TIME, persister };
|
|
43
|
+
|
|
44
|
+
function Application(): JSX.Element {
|
|
45
|
+
return (
|
|
46
|
+
<GestureHandlerRootView style={tw`flex-1`}>
|
|
47
|
+
<SafeAreaProvider>
|
|
48
|
+
<PersistQueryClientProvider client={queryClient} persistOptions={persistOptions}>
|
|
49
|
+
<StorageManager>
|
|
50
|
+
<ApplicationRoutes />
|
|
51
|
+
</StorageManager>
|
|
52
|
+
</PersistQueryClientProvider>
|
|
53
|
+
</SafeAreaProvider>
|
|
54
|
+
</GestureHandlerRootView>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
function HeadlessCheck({ isHeadless }: any) {
|
|
60
|
+
if (isHeadless) {
|
|
61
|
+
// App has been launched in the background by iOS, ignore
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return <Application />;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default HeadlessCheck;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/* eslint-disable no-magic-numbers */
|
|
2
|
+
import {
|
|
3
|
+
BottomSheetBackdropProps,
|
|
4
|
+
BottomSheetHandle,
|
|
5
|
+
BottomSheetHandleProps,
|
|
6
|
+
BottomSheetModal,
|
|
7
|
+
BottomSheetScrollView,
|
|
8
|
+
} from '@gorhom/bottom-sheet';
|
|
9
|
+
import React, { FC, ReactNode, RefObject, useCallback, useMemo, useRef } from 'react';
|
|
10
|
+
import { Keyboard, StyleProp, ViewStyle } from 'react-native';
|
|
11
|
+
import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
|
|
12
|
+
import Animated, { Extrapolation, interpolate, useAnimatedStyle } from 'react-native-reanimated';
|
|
13
|
+
|
|
14
|
+
import { tw } from '../../../tailwind';
|
|
15
|
+
import { DefaultComponentProps } from '../../../types';
|
|
16
|
+
|
|
17
|
+
export type BottomSheetProps = DefaultComponentProps & {
|
|
18
|
+
backgroundStyle?: StyleProp<Omit<ViewStyle, 'left' | 'right' | 'position' | 'top' | 'bottom'>>;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
21
|
+
enableDismissOnPressBackdrop?: boolean;
|
|
22
|
+
enableDynamicSizing?: boolean;
|
|
23
|
+
enablePanDownToClose?: boolean;
|
|
24
|
+
handleComponent?: FC<BottomSheetHandleProps> | null;
|
|
25
|
+
onExpand?: () => void;
|
|
26
|
+
sheetRef: RefObject<BottomSheetModal>;
|
|
27
|
+
snapPoints?: string[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const DEFAULT_SNAP_POINTS = ['25%', '50%', '100%'];
|
|
31
|
+
|
|
32
|
+
const CustomBackdrop = ({
|
|
33
|
+
animatedIndex,
|
|
34
|
+
enableDismissOnPressBackdrop = true,
|
|
35
|
+
sheetRef,
|
|
36
|
+
style,
|
|
37
|
+
}: BottomSheetBackdropProps & {
|
|
38
|
+
enableDismissOnPressBackdrop?: boolean;
|
|
39
|
+
sheetRef: RefObject<BottomSheetModal>;
|
|
40
|
+
}) => {
|
|
41
|
+
function handleDismiss() {
|
|
42
|
+
if (enableDismissOnPressBackdrop) {
|
|
43
|
+
sheetRef.current?.close();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const containerAnimatedStyle = useAnimatedStyle(() => {
|
|
48
|
+
const opacity = interpolate(
|
|
49
|
+
animatedIndex.value,
|
|
50
|
+
[-1, 0, 1],
|
|
51
|
+
[0, 0.5, 0.75],
|
|
52
|
+
Extrapolation.CLAMP,
|
|
53
|
+
);
|
|
54
|
+
const pointerEvents = opacity > 0.25 ? 'auto' : 'none';
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
opacity,
|
|
58
|
+
pointerEvents,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// styles
|
|
63
|
+
const containerStyle = useMemo(
|
|
64
|
+
() => [style, tw`bg-black-950/60`, containerAnimatedStyle],
|
|
65
|
+
[style, containerAnimatedStyle],
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Animated.View style={containerStyle}>
|
|
70
|
+
<TouchableWithoutFeedback style={tw`h-full w-full`} onPress={handleDismiss} />
|
|
71
|
+
</Animated.View>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export function BottomSheet(props: BottomSheetProps) {
|
|
76
|
+
const {
|
|
77
|
+
backgroundStyle,
|
|
78
|
+
children,
|
|
79
|
+
contentContainerStyle,
|
|
80
|
+
enableDismissOnPressBackdrop = true,
|
|
81
|
+
enableDynamicSizing = false,
|
|
82
|
+
enablePanDownToClose = true,
|
|
83
|
+
handleComponent = BottomSheetHandle,
|
|
84
|
+
sheetRef,
|
|
85
|
+
snapPoints = DEFAULT_SNAP_POINTS,
|
|
86
|
+
style,
|
|
87
|
+
} = props;
|
|
88
|
+
const points = enableDynamicSizing ? undefined : snapPoints;
|
|
89
|
+
|
|
90
|
+
function renderBackdrop(backdropProps: BottomSheetBackdropProps) {
|
|
91
|
+
return (
|
|
92
|
+
<CustomBackdrop
|
|
93
|
+
{...backdropProps}
|
|
94
|
+
enableDismissOnPressBackdrop={enableDismissOnPressBackdrop}
|
|
95
|
+
sheetRef={sheetRef}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<BottomSheetModal
|
|
102
|
+
ref={sheetRef}
|
|
103
|
+
backdropComponent={renderBackdrop}
|
|
104
|
+
backgroundStyle={[tw`bg-gray-50`, backgroundStyle]}
|
|
105
|
+
enableDynamicSizing={enableDynamicSizing}
|
|
106
|
+
enablePanDownToClose={enablePanDownToClose}
|
|
107
|
+
handleComponent={handleComponent}
|
|
108
|
+
handleIndicatorStyle={tw`bg-gray-50`}
|
|
109
|
+
handleStyle={tw`rounded-tl-xl rounded-tr-xl`}
|
|
110
|
+
keyboardBehavior="interactive"
|
|
111
|
+
snapPoints={points}
|
|
112
|
+
style={[
|
|
113
|
+
tw`rounded-md`,
|
|
114
|
+
{
|
|
115
|
+
elevation: 10,
|
|
116
|
+
},
|
|
117
|
+
style,
|
|
118
|
+
]}
|
|
119
|
+
>
|
|
120
|
+
<BottomSheetScrollView contentContainerStyle={contentContainerStyle}>
|
|
121
|
+
{children}
|
|
122
|
+
</BottomSheetScrollView>
|
|
123
|
+
</BottomSheetModal>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function useBottomSheet() {
|
|
128
|
+
const sheetRef = useRef<BottomSheetModal>(null);
|
|
129
|
+
|
|
130
|
+
const expandSheet = useCallback(() => {
|
|
131
|
+
Keyboard.dismiss();
|
|
132
|
+
sheetRef.current?.present();
|
|
133
|
+
}, []);
|
|
134
|
+
|
|
135
|
+
const closeSheet = useCallback(() => {
|
|
136
|
+
Keyboard.dismiss();
|
|
137
|
+
sheetRef.current?.close();
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
closeSheet,
|
|
142
|
+
expandSheet,
|
|
143
|
+
sheetRef,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bottom-sheet.component';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
StyleProp,
|
|
5
|
+
TextStyle,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
TouchableOpacityProps,
|
|
8
|
+
View,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
|
|
12
|
+
import { colors, disabledInputStyle, tw } from '../../../tailwind';
|
|
13
|
+
import { DefaultComponentProps } from '../../../types/component.type';
|
|
14
|
+
import { Text } from '../Text';
|
|
15
|
+
|
|
16
|
+
type Props = DefaultComponentProps &
|
|
17
|
+
TouchableOpacityProps & {
|
|
18
|
+
buttonStyle?: StyleProp<ViewStyle>;
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
isLoading?: boolean;
|
|
21
|
+
textStyle?: StyleProp<TextStyle>;
|
|
22
|
+
title?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ACTIVE_OPACITY = 0.5;
|
|
26
|
+
|
|
27
|
+
export function Button(props: Props): JSX.Element {
|
|
28
|
+
const {
|
|
29
|
+
activeOpacity = ACTIVE_OPACITY,
|
|
30
|
+
buttonStyle,
|
|
31
|
+
children,
|
|
32
|
+
isDisabled = false,
|
|
33
|
+
isLoading = false,
|
|
34
|
+
style,
|
|
35
|
+
textStyle,
|
|
36
|
+
title = 'Button',
|
|
37
|
+
...rest
|
|
38
|
+
} = props;
|
|
39
|
+
const disabled = isDisabled || isLoading;
|
|
40
|
+
const display = children ?? <Text style={[tw`font-medium text-white`, textStyle]}>{title}</Text>;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<TouchableOpacity activeOpacity={activeOpacity} disabled={disabled} style={[style]} {...rest}>
|
|
44
|
+
<View
|
|
45
|
+
style={[
|
|
46
|
+
tw`bg-primary-700 items-center justify-center rounded-xl p-4`,
|
|
47
|
+
buttonStyle,
|
|
48
|
+
disabledInputStyle(disabled),
|
|
49
|
+
]}
|
|
50
|
+
>
|
|
51
|
+
{isLoading ? <ActivityIndicator color={colors.white} /> : display}
|
|
52
|
+
</View>
|
|
53
|
+
</TouchableOpacity>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
StyleProp,
|
|
5
|
+
TextStyle,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
TouchableOpacityProps,
|
|
8
|
+
View,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
|
|
12
|
+
import { colors, disabledInputStyle, tw } from '../../../tailwind';
|
|
13
|
+
import { DefaultComponentProps } from '../../../types/component.type';
|
|
14
|
+
import { Text } from '../Text';
|
|
15
|
+
|
|
16
|
+
type Props = DefaultComponentProps &
|
|
17
|
+
TouchableOpacityProps & {
|
|
18
|
+
buttonStyle?: StyleProp<ViewStyle>;
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
isLoading?: boolean;
|
|
21
|
+
textStyle?: StyleProp<TextStyle>;
|
|
22
|
+
title?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ACTIVE_OPACITY = 0.5;
|
|
26
|
+
|
|
27
|
+
export function OutlinedButton(props: Props): JSX.Element {
|
|
28
|
+
const {
|
|
29
|
+
activeOpacity = ACTIVE_OPACITY,
|
|
30
|
+
buttonStyle,
|
|
31
|
+
children,
|
|
32
|
+
isDisabled = false,
|
|
33
|
+
isLoading = false,
|
|
34
|
+
style,
|
|
35
|
+
textStyle,
|
|
36
|
+
title = 'Button',
|
|
37
|
+
...rest
|
|
38
|
+
} = props;
|
|
39
|
+
const disabled = isDisabled || isLoading;
|
|
40
|
+
const display = children ? (
|
|
41
|
+
children
|
|
42
|
+
) : (
|
|
43
|
+
<Text style={[tw`text-primary-700 font-medium`, textStyle]}>{title}</Text>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<TouchableOpacity activeOpacity={activeOpacity} disabled={disabled} style={[style]} {...rest}>
|
|
48
|
+
<View
|
|
49
|
+
style={[
|
|
50
|
+
tw`border-primary-700 items-center justify-center rounded-md border-2 bg-white p-4`,
|
|
51
|
+
buttonStyle,
|
|
52
|
+
disabledInputStyle(disabled),
|
|
53
|
+
]}
|
|
54
|
+
>
|
|
55
|
+
{isLoading ? <ActivityIndicator color={colors.primary[100]} /> : display}
|
|
56
|
+
</View>
|
|
57
|
+
</TouchableOpacity>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { tw } from '../../../tailwind';
|
|
5
|
+
import { DefaultComponentProps } from '../../../types';
|
|
6
|
+
|
|
7
|
+
type Props = DefaultComponentProps & {};
|
|
8
|
+
|
|
9
|
+
export function Divider(props: Props) {
|
|
10
|
+
const { style } = props;
|
|
11
|
+
|
|
12
|
+
return <View style={[tw`h-[1px] w-full bg-gray-200`, style]}></View>;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './divider-component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './input-layout.component';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, TextStyle, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { tw } from '../../../tailwind';
|
|
5
|
+
import { DefaultComponentProps } from '../../../types';
|
|
6
|
+
import { Text } from '../Text';
|
|
7
|
+
|
|
8
|
+
type Props = DefaultComponentProps & {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
isRequired?: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
textStyle?: StyleProp<TextStyle>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function InputLayout(props: Props) {
|
|
16
|
+
const { children, error, isRequired, label, style, textStyle } = props;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<View style={[style]}>
|
|
20
|
+
{label && (
|
|
21
|
+
<Text style={[tw`mb-2 text-gray-600`, textStyle]}>
|
|
22
|
+
{label}
|
|
23
|
+
{isRequired && <Text style={tw`text-red-600`}>{isRequired && '*'}</Text>}
|
|
24
|
+
</Text>
|
|
25
|
+
)}
|
|
26
|
+
{children}
|
|
27
|
+
{!!error && (
|
|
28
|
+
<View style={tw`items-end`}>
|
|
29
|
+
<Text style={tw`text-right text-red-500`}>{error}</Text>
|
|
30
|
+
</View>
|
|
31
|
+
)}
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './list-loading-item.component';
|
package/templates/apps/mobile/src/components/atoms/ListLoadingItem/list-loading-item.component.tsx
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { tw } from '../../../tailwind';
|
|
5
|
+
import { DefaultComponentProps } from '../../../types';
|
|
6
|
+
import { Skeleton } from '../Skeleton';
|
|
7
|
+
|
|
8
|
+
type Props = DefaultComponentProps & {
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function ListLoadingItemComponent(props: Props) {
|
|
13
|
+
const { isLoading, style } = props;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<View style={[style]}>
|
|
17
|
+
<View style={[tw`gap-2`, style]}>
|
|
18
|
+
<Skeleton isLoading={isLoading}>
|
|
19
|
+
{isLoading && <View style={tw`h-[100px] w-full`} />}
|
|
20
|
+
</Skeleton>
|
|
21
|
+
<Skeleton isLoading={isLoading}>
|
|
22
|
+
{isLoading && <View style={tw`h-[100px] w-full`} />}
|
|
23
|
+
</Skeleton>
|
|
24
|
+
<Skeleton isLoading={isLoading}>
|
|
25
|
+
{isLoading && <View style={tw`h-[100px] w-full`} />}
|
|
26
|
+
</Skeleton>
|
|
27
|
+
</View>
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function ListLoadingHorizontalItemComponent(props: Props) {
|
|
33
|
+
const { isLoading, style } = props;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<View style={[style]}>
|
|
37
|
+
<View style={[tw`flex-row gap-2`, style]}>
|
|
38
|
+
<Skeleton isLoading={isLoading}>
|
|
39
|
+
{isLoading && <View style={tw`h-[200px] w-[100px]`} />}
|
|
40
|
+
</Skeleton>
|
|
41
|
+
<Skeleton isLoading={isLoading}>
|
|
42
|
+
{isLoading && <View style={tw`h-[200px] w-[100px]`} />}
|
|
43
|
+
</Skeleton>
|
|
44
|
+
<Skeleton isLoading={isLoading}>
|
|
45
|
+
{isLoading && <View style={tw`h-[200px] w-[100px]`} />}
|
|
46
|
+
</Skeleton>
|
|
47
|
+
<Skeleton isLoading={isLoading}>
|
|
48
|
+
{isLoading && <View style={tw`h-[200px] w-[100px]`} />}
|
|
49
|
+
</Skeleton>
|
|
50
|
+
<Skeleton isLoading={isLoading}>
|
|
51
|
+
{isLoading && <View style={tw`h-[200px] w-[100px]`} />}
|
|
52
|
+
</Skeleton>
|
|
53
|
+
</View>
|
|
54
|
+
</View>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './modal.component';
|