@imksh/create 1.0.31 → 1.0.33
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/README.md +2 -0
- package/package.json +1 -1
- package/src/commands/create.js +2 -0
- package/src/index.js +1 -1
- package/templates/layers/next/javascript/package.json +8 -2
- package/templates/layers/next/typescript/.eslintrc.json +12 -0
- package/templates/layers/next/typescript/package.json +14 -3
- package/templates/layers/next/typescript/src/components/common/Loading.tsx +1 -1
- package/templates/layers/next/typescript/src/components/common/LottieIcon.tsx +2 -2
- package/templates/layers/next/typescript/src/components/common/Table.tsx +4 -4
- package/templates/layers/next/typescript/src/components/modals/ConfirmModal.tsx +2 -1
- package/templates/layers/next/typescript/src/components/ui/Header.tsx +2 -2
- package/templates/layers/next/typescript/src/hooks/usePwaInstall.ts +10 -4
- package/templates/layers/next/typescript/src/services/authService.ts +1 -1
- package/templates/layers/next/typescript/src/store/useAuthStore.ts +24 -9
- package/templates/layers/node/javascript/.env.example +3 -1
- package/templates/layers/node/javascript/package.json +12 -3
- package/templates/layers/node/javascript/src/app.js +2 -1
- package/templates/layers/node/javascript/src/controllers/auth.controller.js +106 -168
- package/templates/layers/node/javascript/src/controllers/push.controller.js +51 -58
- package/templates/layers/node/javascript/src/controllers/upload.controller.js +12 -19
- package/templates/layers/node/javascript/src/middleware/auth.middleware.js +5 -11
- package/templates/layers/node/javascript/src/middleware/errorHandler.js +6 -4
- package/templates/layers/node/javascript/src/routes/auth.route.js +2 -0
- package/templates/layers/node/javascript/src/services/auth.service.js +159 -164
- package/templates/layers/node/javascript/src/utils/ApiError.js +20 -0
- package/templates/layers/node/javascript/src/utils/SuccessResponse.js +15 -0
- package/templates/layers/node/javascript/src/utils/apiResponse.js +4 -0
- package/templates/layers/node/javascript/src/utils/asyncHandler.js +5 -0
- package/templates/layers/node/typescript/.env.example +3 -1
- package/templates/layers/node/typescript/.eslintrc.cjs +28 -0
- package/templates/layers/node/typescript/package.json +16 -2
- package/templates/layers/node/typescript/src/app.ts +3 -2
- package/templates/layers/node/typescript/src/config/db.ts +3 -2
- package/templates/layers/node/typescript/src/config/socket.ts +5 -4
- package/templates/layers/node/typescript/src/controllers/auth.controller.ts +104 -132
- package/templates/layers/node/typescript/src/controllers/push.controller.ts +52 -59
- package/templates/layers/node/typescript/src/controllers/upload.controller.ts +12 -19
- package/templates/layers/node/typescript/src/middleware/auth.middleware.ts +13 -7
- package/templates/layers/node/typescript/src/middleware/errorHandler.ts +18 -5
- package/templates/layers/node/typescript/src/middleware/rateLimiter.ts +2 -2
- package/templates/layers/node/typescript/src/routes/auth.route.ts +2 -0
- package/templates/layers/node/typescript/src/services/auth.service.ts +86 -43
- package/templates/layers/node/typescript/src/types/express.d.ts +5 -3
- package/templates/layers/node/typescript/src/utils/ApiError.ts +25 -0
- package/templates/layers/node/typescript/src/utils/SuccessResponse.ts +17 -0
- package/templates/layers/node/typescript/src/utils/apiResponse.ts +4 -0
- package/templates/layers/node/typescript/src/utils/asyncHandler.ts +13 -0
- package/templates/layers/node/typescript/src/utils/cloudinaryUpload.ts +18 -7
- package/templates/layers/node/typescript/src/utils/expoNotification.ts +1 -1
- package/templates/layers/node/typescript/src/utils/genOtpToken.ts +7 -1
- package/templates/layers/node/typescript/src/utils/jwt.ts +8 -2
- package/templates/layers/node/typescript/src/utils/logger.ts +2 -1
- package/templates/layers/node/typescript/src/utils/pushHelper.ts +13 -9
- package/templates/layers/node-prisma/javascript/.env.example +3 -1
- package/templates/layers/node-prisma/javascript/package.json +11 -2
- package/templates/layers/node-prisma/javascript/src/app.js +2 -1
- package/templates/layers/node-prisma/javascript/src/controllers/auth.controller.js +90 -135
- package/templates/layers/node-prisma/javascript/src/controllers/push.controller.js +64 -76
- package/templates/layers/node-prisma/javascript/src/controllers/upload.controller.js +12 -19
- package/templates/layers/node-prisma/javascript/src/middleware/auth.middleware.js +5 -4
- package/templates/layers/node-prisma/javascript/src/middleware/errorHandler.js +6 -4
- package/templates/layers/node-prisma/javascript/src/routes/auth.route.js +2 -0
- package/templates/layers/node-prisma/javascript/src/services/auth.service.js +145 -122
- package/templates/layers/node-prisma/javascript/src/utils/ApiError.js +20 -0
- package/templates/layers/node-prisma/javascript/src/utils/SuccessResponse.js +15 -0
- package/templates/layers/node-prisma/javascript/src/utils/apiResponse.js +4 -0
- package/templates/layers/node-prisma/javascript/src/utils/asyncHandler.js +5 -0
- package/templates/layers/node-prisma/typescript/.env.example +3 -1
- package/templates/layers/node-prisma/typescript/.eslintrc.cjs +28 -0
- package/templates/layers/node-prisma/typescript/package.json +19 -5
- package/templates/layers/node-prisma/typescript/src/app.ts +3 -2
- package/templates/layers/node-prisma/typescript/src/config/prisma.ts +3 -2
- package/templates/layers/node-prisma/typescript/src/config/socket.ts +5 -4
- package/templates/layers/node-prisma/typescript/src/controllers/auth.controller.ts +89 -105
- package/templates/layers/node-prisma/typescript/src/controllers/push.controller.ts +67 -83
- package/templates/layers/node-prisma/typescript/src/controllers/upload.controller.ts +12 -19
- package/templates/layers/node-prisma/typescript/src/middleware/auth.middleware.ts +9 -13
- package/templates/layers/node-prisma/typescript/src/middleware/errorHandler.ts +18 -5
- package/templates/layers/node-prisma/typescript/src/middleware/rateLimiter.ts +2 -2
- package/templates/layers/node-prisma/typescript/src/routes/auth.route.ts +2 -0
- package/templates/layers/node-prisma/typescript/src/services/auth.service.ts +83 -31
- package/templates/layers/node-prisma/typescript/src/types/express.d.ts +5 -3
- package/templates/layers/node-prisma/typescript/src/utils/ApiError.ts +25 -0
- package/templates/layers/node-prisma/typescript/src/utils/SuccessResponse.ts +17 -0
- package/templates/layers/node-prisma/typescript/src/utils/apiResponse.ts +4 -0
- package/templates/layers/node-prisma/typescript/src/utils/asyncHandler.ts +13 -0
- package/templates/layers/node-prisma/typescript/src/utils/cloudinaryUpload.ts +18 -7
- package/templates/layers/node-prisma/typescript/src/utils/genOtpToken.ts +7 -1
- package/templates/layers/node-prisma/typescript/src/utils/jwt.ts +8 -2
- package/templates/layers/node-prisma/typescript/src/utils/logger.ts +2 -1
- package/templates/layers/node-prisma/typescript/src/utils/pushHelper.ts +10 -6
- package/templates/layers/prisma/javascript/package.json +8 -0
- package/templates/layers/prisma/typescript/package.json +14 -1
- package/templates/layers/prisma/typescript/src/config/db.ts +3 -2
- package/templates/layers/react/javascript/package.json +6 -0
- package/templates/layers/react/typescript/.eslintrc.cjs +20 -0
- package/templates/layers/react/typescript/package.json +11 -2
- package/templates/layers/react/typescript/src/components/common/Table.tsx +4 -4
- package/templates/layers/react/typescript/src/components/ui/Sidebar.tsx +1 -1
- package/templates/layers/react/typescript/src/main.tsx +11 -11
- package/templates/layers/react/typescript/src/services/authService.ts +1 -1
- package/templates/layers/react/typescript/src/store/useAuthStore.ts +24 -9
- package/templates/layers/react-native/base/app.json +9 -22
- package/templates/layers/react-native/base/eslint.config.js +5 -1
- package/templates/layers/react-native/base/package.json +40 -33
- package/templates/layers/react-native/base/src/app/(auth)/edit-profile.tsx +7 -7
- package/templates/layers/react-native/base/src/app/(auth)/login.tsx +31 -7
- package/templates/layers/react-native/base/src/app/(tabs)/_layout.tsx +3 -3
- package/templates/layers/react-native/base/src/app/(tabs)/index.tsx +6 -5
- package/templates/layers/react-native/base/src/app/_layout.tsx +4 -8
- package/templates/layers/react-native/base/src/app/screens/doc-viewer.tsx +378 -0
- package/templates/layers/react-native/base/src/components/common/ConfirmationToast.tsx +58 -40
- package/templates/layers/react-native/base/src/components/common/GoogleAuthButton.tsx +123 -0
- package/templates/layers/react-native/base/src/components/common/LocationLoader.tsx +64 -9
- package/templates/layers/react-native/base/src/components/common/Typography.tsx +54 -19
- package/templates/layers/react-native/base/src/components/ui/BiometricLock.tsx +3 -3
- package/templates/layers/react-native/base/src/components/ui/ClassicTabBar.tsx +15 -12
- package/templates/layers/react-native/base/src/components/ui/CustomTabBar.tsx +90 -91
- package/templates/layers/react-native/base/src/components/ui/Drawer.tsx +344 -0
- package/templates/layers/react-native/base/src/components/ui/Sidebar.tsx +4 -4
- package/templates/layers/react-native/base/src/components/ui/buttons/Button.tsx +29 -6
- package/templates/layers/react-native/base/src/components/ui/data-display/Accordion.tsx +2 -2
- package/templates/layers/react-native/base/src/components/ui/data-display/Badge.tsx +1 -2
- package/templates/layers/react-native/base/src/components/ui/data-display/Image.tsx +3 -3
- package/templates/layers/react-native/base/src/components/ui/data-display/SwipeableRow.tsx +28 -7
- package/templates/layers/react-native/base/src/components/ui/feedback/GestureWrapper.tsx +11 -4
- package/templates/layers/react-native/base/src/components/ui/inputs/DatePicker.tsx +3 -3
- package/templates/layers/react-native/base/src/components/ui/inputs/ImagePickerModal.tsx +45 -19
- package/templates/layers/react-native/base/src/components/ui/inputs/Input.tsx +28 -9
- package/templates/layers/react-native/base/src/components/ui/inputs/SearchablePicker.tsx +199 -0
- package/templates/layers/react-native/base/src/components/ui/inputs/Switch.tsx +7 -7
- package/templates/layers/react-native/base/src/components/ui/inputs/WebLocationPicker.tsx +146 -72
- package/templates/layers/react-native/base/src/config/api.ts +5 -5
- package/templates/layers/react-native/base/src/services/auth.service.ts +3 -1
- package/templates/layers/react-native/base/src/services/permission.service.ts +168 -44
- package/templates/layers/react-native/base/src/services/socket.service.ts +0 -7
- package/templates/layers/react-native/base/src/store/useAuthStore.ts +61 -16
- package/templates/layers/react-native/base/src/store/useNotificationStore.ts +36 -42
- package/templates/layers/react-native/base/src/types/images.d.ts +7 -5
- package/templates/layers/react-native/base/src/utils/env.ts +47 -0
- package/templates/layers/react-native/base/src/utils/fileDownload.ts +206 -0
- package/templates/layers/react-native/base/src/utils/storage.ts +1 -1
- package/templates/presets/production-fullstack/overrides/client/package.json +9 -0
- package/templates/presets/production-fullstack/overrides/mobile/app.json +2 -15
- package/templates/presets/production-fullstack/overrides/mobile/package.json +39 -29
- package/templates/presets/production-fullstack/overrides/mobile/src/app/_layout.tsx +3 -3
- package/templates/presets/production-fullstack/overrides/mobile/src/components/ui/Drawer.tsx +344 -0
- package/templates/presets/production-fullstack/overrides/mobile/src/components/ui/inputs/DatePicker.tsx +3 -3
- package/templates/presets/production-fullstack/overrides/mobile/src/components/ui/inputs/ImagePickerModal.tsx +3 -3
- package/templates/presets/production-fullstack/overrides/mobile/src/services/permission.service.ts +168 -44
- package/templates/presets/production-fullstack/overrides/mobile/src/store/useNotificationStore.ts +16 -0
- package/templates/presets/production-fullstack/overrides/mobile/src/utils/env.ts +47 -0
- package/templates/presets/production-fullstack/overrides/server/package.json +11 -2
- package/templates/layers/react-native/base/src/app/doc-viewer.tsx +0 -193
- package/templates/layers/react-native/base/src/components/ui/BottomModal.tsx +0 -176
- package/templates/presets/production-fullstack/overrides/mobile/src/components/ui/BottomModal.tsx +0 -159
- /package/templates/layers/react-native/base/assets/images/logo/{logoWithBg.png → icon.png} +0 -0
|
@@ -1,59 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "Mobile",
|
|
3
3
|
"main": "expo-router/entry",
|
|
4
4
|
"version": "1.0.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@expo/ui": "~57.0.
|
|
6
|
+
"@expo/ui": "~57.0.22",
|
|
7
7
|
"@expo/vector-icons": "^15.1.1",
|
|
8
8
|
"@react-native-async-storage/async-storage": "2.2.0",
|
|
9
9
|
"@react-native-community/slider": "^5.2.0",
|
|
10
|
+
"@react-native-google-signin/google-signin": "^13.1.0",
|
|
10
11
|
"@react-native-picker/picker": "^2.11.4",
|
|
11
12
|
"@react-navigation/bottom-tabs": "^7.18.10",
|
|
12
|
-
"@tanstack/react-query": "^5.101.4",
|
|
13
13
|
"axios": "^1.18.1",
|
|
14
14
|
"babel-preset-expo": "^57.0.3",
|
|
15
|
-
"dayjs": "^1.11.
|
|
15
|
+
"dayjs": "^1.11.13",
|
|
16
16
|
"drizzle-orm": "^0.45.2",
|
|
17
|
-
"expo": "~57.0.
|
|
18
|
-
"expo-blur": "~57.0.
|
|
17
|
+
"expo": "~57.0.27",
|
|
18
|
+
"expo-blur": "~57.0.3",
|
|
19
19
|
"expo-constants": "~57.0.6",
|
|
20
|
-
"expo-device": "~57.0.
|
|
20
|
+
"expo-device": "~57.0.2",
|
|
21
|
+
"expo-file-system": "~57.0.7",
|
|
21
22
|
"expo-font": "~57.0.1",
|
|
22
|
-
"expo-glass-effect": "~57.0.
|
|
23
|
-
"expo-image": "~57.0.
|
|
24
|
-
"expo-image-picker": "~57.0.
|
|
25
|
-
"expo-linear-gradient": "
|
|
26
|
-
"expo-linking": "~57.0.
|
|
27
|
-
"expo-
|
|
28
|
-
"expo-
|
|
29
|
-
"expo-
|
|
30
|
-
"expo-
|
|
31
|
-
"expo-
|
|
23
|
+
"expo-glass-effect": "~57.0.4",
|
|
24
|
+
"expo-image": "~57.0.5",
|
|
25
|
+
"expo-image-picker": "~57.0.20",
|
|
26
|
+
"expo-linear-gradient": "~57.0.2",
|
|
27
|
+
"expo-linking": "~57.0.12",
|
|
28
|
+
"expo-local-authentication": "~57.0.3",
|
|
29
|
+
"expo-location": "~57.0.20",
|
|
30
|
+
"expo-notifications": "~57.0.22",
|
|
31
|
+
"expo-router": "~57.0.25",
|
|
32
|
+
"expo-sharing": "~57.0.22",
|
|
33
|
+
"expo-splash-screen": "~57.0.9",
|
|
34
|
+
"expo-sqlite": "~57.0.4",
|
|
32
35
|
"expo-status-bar": "~57.0.1",
|
|
33
|
-
"expo-symbols": "~57.0.
|
|
34
|
-
"expo-system-ui": "~57.0.
|
|
35
|
-
"expo-web-browser": "~57.0.
|
|
36
|
-
"lottie-react": "^2.4.1",
|
|
36
|
+
"expo-symbols": "~57.0.3",
|
|
37
|
+
"expo-system-ui": "~57.0.4",
|
|
38
|
+
"expo-web-browser": "~57.0.3",
|
|
37
39
|
"lottie-react-native": "^7.3.8",
|
|
38
40
|
"nativewind": "^4.2.6",
|
|
39
41
|
"prettier-plugin-tailwindcss": "^0.5.14",
|
|
40
42
|
"react": "19.2.3",
|
|
41
43
|
"react-dom": "19.2.3",
|
|
42
|
-
"react-native": "0.86.
|
|
44
|
+
"react-native": "0.86.3",
|
|
45
|
+
"react-native-blob-util": "^0.19.11",
|
|
43
46
|
"react-native-gesture-handler": "~2.32.0",
|
|
44
47
|
"react-native-image-viewing": "^0.2.2",
|
|
45
48
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
46
|
-
"react-native-maps": "1.27.2",
|
|
47
49
|
"react-native-otp-entry": "^1.8.6",
|
|
48
50
|
"react-native-paper": "^5.15.3",
|
|
51
|
+
"react-native-pdf": "^7.0.5",
|
|
49
52
|
"react-native-permissions": "^5.6.0",
|
|
50
|
-
"react-native-reanimated": "
|
|
51
|
-
"react-native-safe-area-context": "
|
|
52
|
-
"react-native-screens": "4.
|
|
53
|
+
"react-native-reanimated": "4.5.1",
|
|
54
|
+
"react-native-safe-area-context": "~5.7.0",
|
|
55
|
+
"react-native-screens": "~4.26.0",
|
|
53
56
|
"react-native-toast-message": "^2.4.0",
|
|
54
57
|
"react-native-web": "~0.21.0",
|
|
55
58
|
"react-native-webview": "13.16.1",
|
|
56
|
-
"react-native-worklets": "0.10.
|
|
59
|
+
"react-native-worklets": "0.10.1",
|
|
57
60
|
"socket.io-client": "^4.8.3",
|
|
58
61
|
"tailwindcss": "^3.4.19",
|
|
59
62
|
"zustand": "^5.0.14"
|
|
@@ -61,9 +64,12 @@
|
|
|
61
64
|
"devDependencies": {
|
|
62
65
|
"@types/react": "~19.2.2",
|
|
63
66
|
"babel-plugin-inline-import": "^3.0.0",
|
|
67
|
+
"dpdm": "^3.14.0",
|
|
64
68
|
"drizzle-kit": "^0.31.10",
|
|
65
69
|
"eslint": "^9.0.0",
|
|
66
|
-
"eslint-config-expo": "~57.0.
|
|
70
|
+
"eslint-config-expo": "~57.0.2",
|
|
71
|
+
"prettier": "^3.4.2",
|
|
72
|
+
"ts-prune": "^0.10.3",
|
|
67
73
|
"typescript": "~6.0.3"
|
|
68
74
|
},
|
|
69
75
|
"scripts": {
|
|
@@ -74,7 +80,11 @@
|
|
|
74
80
|
"ios": "expo run:ios",
|
|
75
81
|
"web": "expo start --web",
|
|
76
82
|
"lint": "expo lint",
|
|
77
|
-
"
|
|
83
|
+
"lint:fix": "expo lint --fix",
|
|
84
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,json}\"",
|
|
85
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,json}\"",
|
|
86
|
+
"circular-check": "dpdm --circular --no-warning --no-tree --exit-code circular:1 \"src/**/*.{ts,tsx}\"",
|
|
87
|
+
"prune:unused": "ts-prune",
|
|
78
88
|
"ts:check": "tsc --noEmit",
|
|
79
89
|
"build": "eas build",
|
|
80
90
|
"build:android": "eas build -p android",
|
|
@@ -63,8 +63,8 @@ export default function RootLayout() {
|
|
|
63
63
|
if (!user && !inAuthGroup) {
|
|
64
64
|
// Redirect to the auth group
|
|
65
65
|
router.replace("/(auth)/login");
|
|
66
|
-
} else if (user && inAuthGroup) {
|
|
67
|
-
// Redirect away from auth
|
|
66
|
+
} else if (user && (inAuthGroup || !segments[0])) {
|
|
67
|
+
// Redirect away from auth or root to main app tabs
|
|
68
68
|
router.replace("/(tabs)");
|
|
69
69
|
}
|
|
70
70
|
}, [user, isCheckingAuth, segments]);
|
|
@@ -94,8 +94,8 @@ export default function RootLayout() {
|
|
|
94
94
|
options={{ headerShown: false, animation: "fade" }}
|
|
95
95
|
/>
|
|
96
96
|
</Stack>
|
|
97
|
-
<Toast />
|
|
98
97
|
</PaperProvider>
|
|
98
|
+
<Toast />
|
|
99
99
|
</GestureHandlerRootView>
|
|
100
100
|
</QueryClientProvider>
|
|
101
101
|
);
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
TouchableWithoutFeedback,
|
|
5
|
+
Dimensions,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
KeyboardAvoidingView,
|
|
8
|
+
Platform,
|
|
9
|
+
BackHandler,
|
|
10
|
+
ViewStyle,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import Animated, {
|
|
13
|
+
useSharedValue,
|
|
14
|
+
useAnimatedStyle,
|
|
15
|
+
withTiming,
|
|
16
|
+
Easing,
|
|
17
|
+
runOnJS,
|
|
18
|
+
} from "react-native-reanimated";
|
|
19
|
+
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
20
|
+
import { Portal } from "react-native-paper";
|
|
21
|
+
import { useColorScheme } from "nativewind";
|
|
22
|
+
import { Colors } from "../../constants/Colors";
|
|
23
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
24
|
+
|
|
25
|
+
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("window");
|
|
26
|
+
|
|
27
|
+
export type DrawerPosition = "top" | "bottom" | "left" | "right";
|
|
28
|
+
|
|
29
|
+
export interface DrawerProps {
|
|
30
|
+
isOpen: boolean;
|
|
31
|
+
onClose: () => void;
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
position?: DrawerPosition;
|
|
34
|
+
sizePercent?: number; // e.g. 0.5 for 50% of the screen height (top/bottom) or width (left/right)
|
|
35
|
+
heightPercent?: number; // backwards compatibility alias for top/bottom
|
|
36
|
+
widthPercent?: number; // backwards compatibility alias for left/right
|
|
37
|
+
showHandle?: boolean;
|
|
38
|
+
zIndex?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default function Drawer({
|
|
42
|
+
isOpen,
|
|
43
|
+
onClose,
|
|
44
|
+
children,
|
|
45
|
+
position = "bottom",
|
|
46
|
+
sizePercent,
|
|
47
|
+
heightPercent,
|
|
48
|
+
widthPercent,
|
|
49
|
+
showHandle = true,
|
|
50
|
+
zIndex = 50,
|
|
51
|
+
}: DrawerProps) {
|
|
52
|
+
const { colorScheme } = useColorScheme();
|
|
53
|
+
const colors = Colors[colorScheme ?? "light"];
|
|
54
|
+
const insets = useSafeAreaInsets();
|
|
55
|
+
|
|
56
|
+
const isVertical = position === "top" || position === "bottom";
|
|
57
|
+
const defaultPercent = isVertical ? 0.5 : 0.75;
|
|
58
|
+
const resolvedPercent =
|
|
59
|
+
sizePercent ??
|
|
60
|
+
(isVertical ? heightPercent : widthPercent) ??
|
|
61
|
+
defaultPercent;
|
|
62
|
+
|
|
63
|
+
const DRAWER_SIZE = isVertical
|
|
64
|
+
? SCREEN_HEIGHT * resolvedPercent
|
|
65
|
+
: SCREEN_WIDTH * resolvedPercent;
|
|
66
|
+
|
|
67
|
+
const getClosedOffset = () => {
|
|
68
|
+
switch (position) {
|
|
69
|
+
case "top":
|
|
70
|
+
case "left":
|
|
71
|
+
return -DRAWER_SIZE;
|
|
72
|
+
case "bottom":
|
|
73
|
+
case "right":
|
|
74
|
+
return DRAWER_SIZE;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const translate = useSharedValue(getClosedOffset());
|
|
79
|
+
const backdropOpacity = useSharedValue(0);
|
|
80
|
+
const [isRendered, setIsRendered] = useState(false);
|
|
81
|
+
|
|
82
|
+
if (isOpen && !isRendered) {
|
|
83
|
+
setIsRendered(true);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const closedOffset = getClosedOffset();
|
|
88
|
+
if (isOpen) {
|
|
89
|
+
translate.value = withTiming(0, {
|
|
90
|
+
duration: 300,
|
|
91
|
+
easing: Easing.out(Easing.ease),
|
|
92
|
+
});
|
|
93
|
+
backdropOpacity.value = withTiming(0.4, { duration: 300 });
|
|
94
|
+
} else {
|
|
95
|
+
translate.value = withTiming(closedOffset, {
|
|
96
|
+
duration: 300,
|
|
97
|
+
easing: Easing.in(Easing.ease),
|
|
98
|
+
});
|
|
99
|
+
backdropOpacity.value = withTiming(0, { duration: 300 }, (finished) => {
|
|
100
|
+
if (finished) {
|
|
101
|
+
runOnJS(setIsRendered)(false);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}, [isOpen, DRAWER_SIZE, position]);
|
|
106
|
+
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (!isOpen) return;
|
|
109
|
+
|
|
110
|
+
const backAction = () => {
|
|
111
|
+
onClose();
|
|
112
|
+
return true;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const backHandler = BackHandler.addEventListener(
|
|
116
|
+
"hardwareBackPress",
|
|
117
|
+
backAction
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return () => backHandler.remove();
|
|
121
|
+
}, [isOpen, onClose]);
|
|
122
|
+
|
|
123
|
+
const panGesture = Gesture.Pan()
|
|
124
|
+
.onUpdate((event) => {
|
|
125
|
+
if (position === "bottom") {
|
|
126
|
+
if (event.translationY > 0) {
|
|
127
|
+
translate.value = event.translationY;
|
|
128
|
+
}
|
|
129
|
+
} else if (position === "top") {
|
|
130
|
+
if (event.translationY < 0) {
|
|
131
|
+
translate.value = event.translationY;
|
|
132
|
+
}
|
|
133
|
+
} else if (position === "left") {
|
|
134
|
+
if (event.translationX < 0) {
|
|
135
|
+
translate.value = event.translationX;
|
|
136
|
+
}
|
|
137
|
+
} else if (position === "right") {
|
|
138
|
+
if (event.translationX > 0) {
|
|
139
|
+
translate.value = event.translationX;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
.onEnd((event) => {
|
|
144
|
+
let shouldClose = false;
|
|
145
|
+
if (position === "bottom") {
|
|
146
|
+
shouldClose =
|
|
147
|
+
event.translationY > DRAWER_SIZE * 0.3 || event.velocityY > 500;
|
|
148
|
+
} else if (position === "top") {
|
|
149
|
+
shouldClose =
|
|
150
|
+
event.translationY < -DRAWER_SIZE * 0.3 || event.velocityY < -500;
|
|
151
|
+
} else if (position === "left") {
|
|
152
|
+
shouldClose =
|
|
153
|
+
event.translationX < -DRAWER_SIZE * 0.3 || event.velocityX < -500;
|
|
154
|
+
} else if (position === "right") {
|
|
155
|
+
shouldClose =
|
|
156
|
+
event.translationX > DRAWER_SIZE * 0.3 || event.velocityX > 500;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (shouldClose) {
|
|
160
|
+
runOnJS(onClose)();
|
|
161
|
+
} else {
|
|
162
|
+
translate.value = withTiming(0, {
|
|
163
|
+
duration: 300,
|
|
164
|
+
easing: Easing.out(Easing.ease),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const drawerAnimatedStyle = useAnimatedStyle(() => {
|
|
170
|
+
if (position === "left" || position === "right") {
|
|
171
|
+
return {
|
|
172
|
+
transform: [{ translateX: translate.value }],
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
transform: [{ translateY: translate.value }],
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const backdropAnimatedStyle = useAnimatedStyle(() => ({
|
|
181
|
+
opacity: backdropOpacity.value,
|
|
182
|
+
}));
|
|
183
|
+
|
|
184
|
+
const getContainerStyle = (): ViewStyle => {
|
|
185
|
+
const baseShadow: ViewStyle = {
|
|
186
|
+
backgroundColor: colors.base100,
|
|
187
|
+
elevation: 24,
|
|
188
|
+
shadowColor: "#000",
|
|
189
|
+
shadowOpacity: 0.15,
|
|
190
|
+
shadowRadius: 15,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
switch (position) {
|
|
194
|
+
case "top":
|
|
195
|
+
return {
|
|
196
|
+
...baseShadow,
|
|
197
|
+
position: "absolute",
|
|
198
|
+
top: 0,
|
|
199
|
+
left: 0,
|
|
200
|
+
right: 0,
|
|
201
|
+
height: DRAWER_SIZE,
|
|
202
|
+
borderBottomLeftRadius: 30,
|
|
203
|
+
borderBottomRightRadius: 30,
|
|
204
|
+
shadowOffset: { width: 0, height: 5 },
|
|
205
|
+
paddingTop: insets.top > 0 ? insets.top : 20,
|
|
206
|
+
};
|
|
207
|
+
case "bottom":
|
|
208
|
+
return {
|
|
209
|
+
...baseShadow,
|
|
210
|
+
position: "absolute",
|
|
211
|
+
bottom: 0,
|
|
212
|
+
left: 0,
|
|
213
|
+
right: 0,
|
|
214
|
+
height: DRAWER_SIZE,
|
|
215
|
+
borderTopLeftRadius: 30,
|
|
216
|
+
borderTopRightRadius: 30,
|
|
217
|
+
shadowOffset: { width: 0, height: -5 },
|
|
218
|
+
paddingBottom: insets.bottom > 0 ? insets.bottom : 20,
|
|
219
|
+
};
|
|
220
|
+
case "left":
|
|
221
|
+
return {
|
|
222
|
+
...baseShadow,
|
|
223
|
+
position: "absolute",
|
|
224
|
+
top: 0,
|
|
225
|
+
bottom: 0,
|
|
226
|
+
left: 0,
|
|
227
|
+
width: DRAWER_SIZE,
|
|
228
|
+
borderTopRightRadius: 30,
|
|
229
|
+
borderBottomRightRadius: 30,
|
|
230
|
+
shadowOffset: { width: 5, height: 0 },
|
|
231
|
+
paddingTop: insets.top > 0 ? insets.top : 20,
|
|
232
|
+
paddingBottom: insets.bottom > 0 ? insets.bottom : 20,
|
|
233
|
+
paddingLeft: insets.left > 0 ? insets.left : 0,
|
|
234
|
+
};
|
|
235
|
+
case "right":
|
|
236
|
+
return {
|
|
237
|
+
...baseShadow,
|
|
238
|
+
position: "absolute",
|
|
239
|
+
top: 0,
|
|
240
|
+
bottom: 0,
|
|
241
|
+
right: 0,
|
|
242
|
+
width: DRAWER_SIZE,
|
|
243
|
+
borderTopLeftRadius: 30,
|
|
244
|
+
borderBottomLeftRadius: 30,
|
|
245
|
+
shadowOffset: { width: -5, height: 0 },
|
|
246
|
+
paddingTop: insets.top > 0 ? insets.top : 20,
|
|
247
|
+
paddingBottom: insets.bottom > 0 ? insets.bottom : 20,
|
|
248
|
+
paddingRight: insets.right > 0 ? insets.right : 0,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
if (!isRendered && !isOpen) return null;
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<Portal>
|
|
257
|
+
<KeyboardAvoidingView
|
|
258
|
+
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
|
259
|
+
style={StyleSheet.absoluteFill}
|
|
260
|
+
pointerEvents="box-none"
|
|
261
|
+
>
|
|
262
|
+
<View style={[StyleSheet.absoluteFill, { zIndex }]}>
|
|
263
|
+
{/* Backdrop Overlay */}
|
|
264
|
+
<TouchableWithoutFeedback onPress={onClose}>
|
|
265
|
+
<Animated.View
|
|
266
|
+
style={[
|
|
267
|
+
StyleSheet.absoluteFill,
|
|
268
|
+
{ backgroundColor: "#000" },
|
|
269
|
+
backdropAnimatedStyle,
|
|
270
|
+
]}
|
|
271
|
+
/>
|
|
272
|
+
</TouchableWithoutFeedback>
|
|
273
|
+
|
|
274
|
+
{/* Sliding Drawer Panel */}
|
|
275
|
+
<Animated.View style={[getContainerStyle(), drawerAnimatedStyle]}>
|
|
276
|
+
{position === "bottom" && (
|
|
277
|
+
<View className="flex-1">
|
|
278
|
+
{showHandle && (
|
|
279
|
+
<GestureDetector gesture={panGesture}>
|
|
280
|
+
<View
|
|
281
|
+
className="items-center pt-4 pb-6 bg-base-100 rounded-t-[30px]"
|
|
282
|
+
style={{ zIndex: 10 }}
|
|
283
|
+
>
|
|
284
|
+
<View className="w-16 h-1.5 rounded-full bg-base-300" />
|
|
285
|
+
</View>
|
|
286
|
+
</GestureDetector>
|
|
287
|
+
)}
|
|
288
|
+
<View className="flex-1 px-6">{children}</View>
|
|
289
|
+
</View>
|
|
290
|
+
)}
|
|
291
|
+
|
|
292
|
+
{position === "top" && (
|
|
293
|
+
<View className="flex-1">
|
|
294
|
+
<View className="flex-1 px-6">{children}</View>
|
|
295
|
+
{showHandle && (
|
|
296
|
+
<GestureDetector gesture={panGesture}>
|
|
297
|
+
<View
|
|
298
|
+
className="items-center pt-4 pb-6 bg-base-100 rounded-b-[30px]"
|
|
299
|
+
style={{ zIndex: 10 }}
|
|
300
|
+
>
|
|
301
|
+
<View className="w-16 h-1.5 rounded-full bg-base-300" />
|
|
302
|
+
</View>
|
|
303
|
+
</GestureDetector>
|
|
304
|
+
)}
|
|
305
|
+
</View>
|
|
306
|
+
)}
|
|
307
|
+
|
|
308
|
+
{position === "left" && (
|
|
309
|
+
<View className="flex-1 flex-row">
|
|
310
|
+
<View className="flex-1 px-6">{children}</View>
|
|
311
|
+
{showHandle && (
|
|
312
|
+
<GestureDetector gesture={panGesture}>
|
|
313
|
+
<View
|
|
314
|
+
className="justify-center items-center px-3 bg-base-100 rounded-r-[30px]"
|
|
315
|
+
style={{ zIndex: 10 }}
|
|
316
|
+
>
|
|
317
|
+
<View className="w-1.5 h-16 rounded-full bg-base-300" />
|
|
318
|
+
</View>
|
|
319
|
+
</GestureDetector>
|
|
320
|
+
)}
|
|
321
|
+
</View>
|
|
322
|
+
)}
|
|
323
|
+
|
|
324
|
+
{position === "right" && (
|
|
325
|
+
<View className="flex-1 flex-row">
|
|
326
|
+
{showHandle && (
|
|
327
|
+
<GestureDetector gesture={panGesture}>
|
|
328
|
+
<View
|
|
329
|
+
className="justify-center items-center px-3 bg-base-100 rounded-l-[30px]"
|
|
330
|
+
style={{ zIndex: 10 }}
|
|
331
|
+
>
|
|
332
|
+
<View className="w-1.5 h-16 rounded-full bg-base-300" />
|
|
333
|
+
</View>
|
|
334
|
+
</GestureDetector>
|
|
335
|
+
)}
|
|
336
|
+
<View className="flex-1 px-6">{children}</View>
|
|
337
|
+
</View>
|
|
338
|
+
)}
|
|
339
|
+
</Animated.View>
|
|
340
|
+
</View>
|
|
341
|
+
</KeyboardAvoidingView>
|
|
342
|
+
</Portal>
|
|
343
|
+
);
|
|
344
|
+
}
|
|
@@ -4,7 +4,7 @@ import { Txt } from "../../common/Typography";
|
|
|
4
4
|
import { Ionicons } from "@expo/vector-icons";
|
|
5
5
|
import { useColorScheme } from "nativewind";
|
|
6
6
|
import { Colors } from "../../../constants/Colors";
|
|
7
|
-
import
|
|
7
|
+
import Drawer from "../Drawer";
|
|
8
8
|
import Button from "../buttons/Button";
|
|
9
9
|
import dayjs from "dayjs";
|
|
10
10
|
|
|
@@ -104,7 +104,7 @@ export default function DatePicker({
|
|
|
104
104
|
<Ionicons name="calendar-outline" size={18} color={colors.primary} />
|
|
105
105
|
</TouchableOpacity>
|
|
106
106
|
|
|
107
|
-
<
|
|
107
|
+
<Drawer isOpen={isOpen} onClose={() => setIsOpen(false)} position="bottom" sizePercent={0.65}>
|
|
108
108
|
<View className="p-4 flex-1">
|
|
109
109
|
<Txt variant="lg" className="font-bold text-center mb-4">
|
|
110
110
|
{label}
|
|
@@ -180,7 +180,7 @@ export default function DatePicker({
|
|
|
180
180
|
<Button label="Close" variant="outline" onPress={() => setIsOpen(false)} className="w-full" />
|
|
181
181
|
</View>
|
|
182
182
|
</View>
|
|
183
|
-
</
|
|
183
|
+
</Drawer>
|
|
184
184
|
</View>
|
|
185
185
|
);
|
|
186
186
|
}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import * as ImagePicker from "expo-image-picker";
|
|
4
4
|
import { Txt } from "@/components/common/Typography";
|
|
5
|
-
import
|
|
5
|
+
import Drawer from "@/components/ui/Drawer";
|
|
6
6
|
import Button from "@/components/ui/buttons/Button";
|
|
7
7
|
|
|
8
8
|
export type ImagePickerSource = "camera" | "gallery" | "both";
|
|
@@ -93,7 +93,7 @@ export default function ImagePickerModal({
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
return (
|
|
96
|
-
<
|
|
96
|
+
<Drawer isOpen={isOpen} onClose={onClose} position="bottom">
|
|
97
97
|
<View className="p-6">
|
|
98
98
|
<Txt variant="lg" className="font-bold mb-1 text-center">
|
|
99
99
|
{title}
|
|
@@ -124,6 +124,6 @@ export default function ImagePickerModal({
|
|
|
124
124
|
)}
|
|
125
125
|
</View>
|
|
126
126
|
</View>
|
|
127
|
-
</
|
|
127
|
+
</Drawer>
|
|
128
128
|
);
|
|
129
129
|
}
|