@imksh/create 1.0.25 → 1.0.27
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/package.json +1 -1
- package/src/commands/create.js +2 -1
- package/src/index.js +1 -1
- package/src/utils/askTemplate.js +1 -0
- package/templates/mern-react-native/mobile/_gitignore +43 -0
- package/templates/mern-react-native/mobile/package.json +2 -1
- package/templates/mern-react-native/mobile/src/app/(auth)/edit-profile.tsx +11 -15
- package/templates/mern-react-native/mobile/src/app/(tabs)/dashboard.tsx +2 -2
- package/templates/mern-react-native/mobile/src/app/(tabs)/search.tsx +2 -2
- package/templates/mern-react-native/mobile/src/config/sidebar.config.ts +0 -60
- package/templates/mern-react-native/mobile/src/config/tabNavigation.ts +6 -36
- package/templates/mern-react-native/mobile/src/services/notification.service.ts +22 -0
- package/templates/mern-react-native/mobile/src/store/useNotificationStore.ts +158 -33
- package/templates/next/next.config.mjs +1 -0
- package/templates/next/package.json +10 -9
- package/templates/next/postcss.config.js +5 -0
- package/templates/next/src/app/layout.js +1 -0
- package/templates/next/src/app/page.js +1 -1
- package/templates/next/src/components/layout/ProtectedRoute.jsx +3 -3
- package/templates/next/src/index.css +1 -0
- package/templates/next/src/store/useUiStore.js +13 -7
- package/templates/next-ts/.env.example +0 -0
- package/templates/next-ts/AGENTS.md +37 -0
- package/templates/next-ts/CLAUDE.md +1 -0
- package/templates/next-ts/next-env.d.ts +3 -1
- package/templates/next-ts/next.config.mjs +1 -0
- package/templates/next-ts/package.json +13 -12
- package/templates/next-ts/postcss.config.js +5 -0
- package/templates/next-ts/public/logo.png +0 -0
- package/templates/next-ts/src/app/error.tsx +41 -0
- package/templates/next-ts/src/app/layout.tsx +2 -1
- package/templates/next-ts/src/app/not-found.tsx +5 -0
- package/templates/next-ts/src/app/page.tsx +1 -1
- package/templates/next-ts/src/components/layout/ProtectedRoute.tsx +3 -3
- package/templates/next-ts/src/components/ui/Button.tsx +63 -0
- package/templates/next-ts/src/components/ui/Input.tsx +79 -0
- package/templates/next-ts/src/index.css +1 -0
- package/templates/next-ts/src/store/useUiStore.ts +13 -7
- package/templates/next-ts/tsconfig.json +19 -5
- package/templates/production-fullstack/client/_gitignore +24 -0
- package/templates/production-fullstack/client/index.html +14 -0
- package/templates/production-fullstack/client/package.json +47 -0
- package/templates/production-fullstack/client/public/_redirects +1 -0
- package/templates/production-fullstack/client/public/favicon.ico +0 -0
- package/templates/production-fullstack/client/public/favicon.svg +1 -0
- package/templates/production-fullstack/client/public/logo.png +0 -0
- package/templates/production-fullstack/client/public/manifest.json +24 -0
- package/templates/production-fullstack/client/public/sw.js +56 -0
- package/templates/production-fullstack/client/src/App.tsx +68 -0
- package/templates/production-fullstack/client/src/assets/animations/loading.json +1 -0
- package/templates/production-fullstack/client/src/assets/data/navigation.ts +29 -0
- package/templates/production-fullstack/client/src/assets/images/logo.png +0 -0
- package/templates/production-fullstack/client/src/components/layout/ProtectedRoute.tsx +23 -0
- package/templates/production-fullstack/client/src/components/layout/PublicLayout.tsx +13 -0
- package/templates/production-fullstack/client/src/components/layout/SidebarLayout.tsx +37 -0
- package/templates/production-fullstack/client/src/components/shared/Breadcrumbs.tsx +27 -0
- package/templates/production-fullstack/client/src/components/shared/LottieIcon.tsx +36 -0
- package/templates/production-fullstack/client/src/components/shared/NotFound.tsx +78 -0
- package/templates/production-fullstack/client/src/components/shared/PwaInstallPrompt.tsx +72 -0
- package/templates/production-fullstack/client/src/components/shared/SEO.tsx +67 -0
- package/templates/production-fullstack/client/src/components/shared/Scroll.tsx +25 -0
- package/templates/production-fullstack/client/src/components/shared/Unauthorized.tsx +76 -0
- package/templates/production-fullstack/client/src/components/shared/skeletons/common/CardSkeleton.tsx +23 -0
- package/templates/production-fullstack/client/src/components/shared/skeletons/common/DashboardSkeleton.tsx +19 -0
- package/templates/production-fullstack/client/src/components/shared/skeletons/common/ListSkeleton.tsx +24 -0
- package/templates/production-fullstack/client/src/components/shared/skeletons/common/PageSkeleton.tsx +26 -0
- package/templates/production-fullstack/client/src/components/shared/skeletons/common/ProfileSkeleton.tsx +23 -0
- package/templates/production-fullstack/client/src/components/shared/skeletons/common/Skeleton.tsx +18 -0
- package/templates/production-fullstack/client/src/components/shared/skeletons/common/TableSkeleton.tsx +33 -0
- package/templates/production-fullstack/client/src/components/ui/ConfirmModal.tsx +152 -0
- package/templates/production-fullstack/client/src/components/ui/Header.tsx +230 -0
- package/templates/production-fullstack/client/src/components/ui/Loading.tsx +19 -0
- package/templates/production-fullstack/client/src/components/ui/Modal.tsx +106 -0
- package/templates/production-fullstack/client/src/components/ui/SidebarHeader.tsx +34 -0
- package/templates/production-fullstack/client/src/components/ui/Table.tsx +118 -0
- package/templates/production-fullstack/client/src/components/ui/ToggleSwitch.tsx +38 -0
- package/templates/production-fullstack/client/src/components/ui/sidebar.tsx +152 -0
- package/templates/production-fullstack/client/src/config/index.ts +44 -0
- package/templates/production-fullstack/client/src/constants/navigation.ts +14 -0
- package/templates/production-fullstack/client/src/features/auth/api/authService.ts +19 -0
- package/templates/production-fullstack/client/src/features/auth/pages/Login.tsx +233 -0
- package/templates/production-fullstack/client/src/features/auth/store/useAuthStore.ts +143 -0
- package/templates/production-fullstack/client/src/features/core/pages/Home.tsx +150 -0
- package/templates/production-fullstack/client/src/features/core/pages/Profile.tsx +9 -0
- package/templates/production-fullstack/client/src/hooks/useLenis.ts +28 -0
- package/templates/production-fullstack/client/src/hooks/usePwaInstall.ts +45 -0
- package/templates/production-fullstack/client/src/hooks/useWindowSize.ts +25 -0
- package/templates/production-fullstack/client/src/index.css +158 -0
- package/templates/production-fullstack/client/src/lib/axios.ts +22 -0
- package/templates/production-fullstack/client/src/lib/dayjs.ts +12 -0
- package/templates/production-fullstack/client/src/lib/query-client.ts +11 -0
- package/templates/production-fullstack/client/src/lib/socket.ts +6 -0
- package/templates/production-fullstack/client/src/main.tsx +28 -0
- package/templates/production-fullstack/client/src/store/useUiStore.ts +74 -0
- package/templates/production-fullstack/client/src/utils/formatDate.ts +19 -0
- package/templates/production-fullstack/client/src/utils/getInitials.ts +10 -0
- package/templates/production-fullstack/client/src/vite-env.d.ts +1 -0
- package/templates/production-fullstack/client/tsconfig.json +25 -0
- package/templates/production-fullstack/client/tsconfig.node.json +10 -0
- package/templates/production-fullstack/client/vite.config.ts +8 -0
- package/templates/production-fullstack/mobile/LICENSE +21 -0
- package/templates/production-fullstack/mobile/_gitignore +43 -0
- package/templates/production-fullstack/mobile/app.json +84 -0
- package/templates/production-fullstack/mobile/assets/animations/celebrate.json +1 -0
- package/templates/production-fullstack/mobile/assets/animations/infinity.json +1 -0
- package/templates/production-fullstack/mobile/assets/animations/loading.json +1 -0
- package/templates/production-fullstack/mobile/assets/fonts/Inter_Bold.ttf +0 -0
- package/templates/production-fullstack/mobile/assets/fonts/Inter_ExtraBold.ttf +0 -0
- package/templates/production-fullstack/mobile/assets/fonts/Inter_Medium.ttf +0 -0
- package/templates/production-fullstack/mobile/assets/fonts/Inter_Regular.ttf +0 -0
- package/templates/production-fullstack/mobile/assets/fonts/Inter_SemiBold.ttf +0 -0
- package/templates/production-fullstack/mobile/assets/images/logo/logo.png +0 -0
- package/templates/production-fullstack/mobile/assets/images/logo/logo.svg +1 -0
- package/templates/production-fullstack/mobile/assets/images/logo/logoWithBg.png +0 -0
- package/templates/production-fullstack/mobile/babel.config.js +13 -0
- package/templates/production-fullstack/mobile/drizzle.config.ts +8 -0
- package/templates/production-fullstack/mobile/eas.json +24 -0
- package/templates/production-fullstack/mobile/eslint.config.js +10 -0
- package/templates/production-fullstack/mobile/expo-env.d.ts +3 -0
- package/templates/production-fullstack/mobile/metro.config.js +6 -0
- package/templates/production-fullstack/mobile/nativewind-env.d.ts +3 -0
- package/templates/production-fullstack/mobile/package.json +89 -0
- package/templates/production-fullstack/mobile/src/app/(auth)/_layout.tsx +12 -0
- package/templates/production-fullstack/mobile/src/app/(auth)/change-password.tsx +112 -0
- package/templates/production-fullstack/mobile/src/app/(auth)/edit-profile.tsx +160 -0
- package/templates/production-fullstack/mobile/src/app/(auth)/forgot-password.tsx +191 -0
- package/templates/production-fullstack/mobile/src/app/(auth)/login.tsx +253 -0
- package/templates/production-fullstack/mobile/src/app/_layout.tsx +102 -0
- package/templates/production-fullstack/mobile/src/app/global.css +82 -0
- package/templates/production-fullstack/mobile/src/components/common/AnimatedHeader.tsx +328 -0
- package/templates/production-fullstack/mobile/src/components/common/ConfirmationToast.tsx +67 -0
- package/templates/production-fullstack/mobile/src/components/common/Loading.tsx +26 -0
- package/templates/production-fullstack/mobile/src/components/common/LocationLoader.tsx +591 -0
- package/templates/production-fullstack/mobile/src/components/common/ScreenHeader.tsx +68 -0
- package/templates/production-fullstack/mobile/src/components/common/TabHeader.tsx +58 -0
- package/templates/production-fullstack/mobile/src/components/common/Typography.tsx +113 -0
- package/templates/production-fullstack/mobile/src/components/common/Welcome.tsx +55 -0
- package/templates/production-fullstack/mobile/src/components/ui/BottomModal.tsx +159 -0
- package/templates/production-fullstack/mobile/src/components/ui/ClassicTabBar.tsx +129 -0
- package/templates/production-fullstack/mobile/src/components/ui/CustomTabBar.tsx +238 -0
- package/templates/production-fullstack/mobile/src/components/ui/Sidebar.tsx +258 -0
- package/templates/production-fullstack/mobile/src/components/ui/buttons/Button.tsx +180 -0
- package/templates/production-fullstack/mobile/src/components/ui/buttons/ButtonGroup.tsx +32 -0
- package/templates/production-fullstack/mobile/src/components/ui/buttons/FloatingActionButton.tsx +72 -0
- package/templates/production-fullstack/mobile/src/components/ui/buttons/IconButton.tsx +84 -0
- package/templates/production-fullstack/mobile/src/components/ui/data-display/Accordion.tsx +82 -0
- package/templates/production-fullstack/mobile/src/components/ui/data-display/Avatar.tsx +47 -0
- package/templates/production-fullstack/mobile/src/components/ui/data-display/Badge.tsx +104 -0
- package/templates/production-fullstack/mobile/src/components/ui/data-display/Card.tsx +36 -0
- package/templates/production-fullstack/mobile/src/components/ui/data-display/Image.tsx +43 -0
- package/templates/production-fullstack/mobile/src/components/ui/data-display/ImageViewer.tsx +33 -0
- package/templates/production-fullstack/mobile/src/components/ui/data-display/SwipeableRow.tsx +94 -0
- package/templates/production-fullstack/mobile/src/components/ui/feedback/CircularProgress.tsx +38 -0
- package/templates/production-fullstack/mobile/src/components/ui/feedback/GestureWrapper.tsx +114 -0
- package/templates/production-fullstack/mobile/src/components/ui/feedback/ProgressBar.tsx +51 -0
- package/templates/production-fullstack/mobile/src/components/ui/feedback/Skeleton.tsx +84 -0
- package/templates/production-fullstack/mobile/src/components/ui/feedback/Spinner.tsx +50 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/Checkbox.tsx +54 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/DatePicker.tsx +186 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/ImagePickerModal.tsx +129 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/Input.tsx +158 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/LocationPicker.tsx +211 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/OTPInput.tsx +83 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/PasswordInput.tsx +16 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/Radio.tsx +54 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/SearchBar.tsx +53 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/Slider.tsx +49 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/Switch.tsx +75 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/TextArea.tsx +15 -0
- package/templates/production-fullstack/mobile/src/components/ui/inputs/WebLocationPicker.tsx +321 -0
- package/templates/production-fullstack/mobile/src/components/ui/layout/Container.tsx +23 -0
- package/templates/production-fullstack/mobile/src/components/ui/layout/Divider.tsx +20 -0
- package/templates/production-fullstack/mobile/src/components/ui/layout/Grid.tsx +62 -0
- package/templates/production-fullstack/mobile/src/components/ui/layout/KeyboardAvoidingViewWrapper.tsx +16 -0
- package/templates/production-fullstack/mobile/src/components/ui/layout/ScrollContainer.tsx +21 -0
- package/templates/production-fullstack/mobile/src/components/ui/layout/Section.tsx +51 -0
- package/templates/production-fullstack/mobile/src/components/ui/layout/Spacer.tsx +6 -0
- package/templates/production-fullstack/mobile/src/components/ui/layout/Stack.tsx +34 -0
- package/templates/production-fullstack/mobile/src/components/ui/navigation/Pagination.tsx +61 -0
- package/templates/production-fullstack/mobile/src/components/ui/navigation/ProgressStepper.tsx +66 -0
- package/templates/production-fullstack/mobile/src/components/ui/navigation/Tabs.tsx +173 -0
- package/templates/production-fullstack/mobile/src/config/sidebar.config.ts +72 -0
- package/templates/production-fullstack/mobile/src/config/tabNavigation.ts +64 -0
- package/templates/production-fullstack/mobile/src/constants/Colors.ts +71 -0
- package/templates/production-fullstack/mobile/src/db/index.ts +9 -0
- package/templates/production-fullstack/mobile/src/db/schema.ts +14 -0
- package/templates/production-fullstack/mobile/src/features/auth/api/auth.service.ts +35 -0
- package/templates/production-fullstack/mobile/src/features/auth/store/useAuthStore.ts +273 -0
- package/templates/production-fullstack/mobile/src/features/auth/types/auth.type.ts +14 -0
- package/templates/production-fullstack/mobile/src/hooks/useDebounce.ts +17 -0
- package/templates/production-fullstack/mobile/src/lib/axios.ts +27 -0
- package/templates/production-fullstack/mobile/src/lib/query-client.ts +11 -0
- package/templates/production-fullstack/mobile/src/lib/socket.ts +36 -0
- package/templates/production-fullstack/mobile/src/lib/storage.ts +55 -0
- package/templates/production-fullstack/mobile/src/services/permission.service.ts +214 -0
- package/templates/production-fullstack/mobile/src/store/localStore.ts +7 -0
- package/templates/production-fullstack/mobile/src/store/useNotificationStore.ts +53 -0
- package/templates/production-fullstack/mobile/src/types/common.type.ts +6 -0
- package/templates/production-fullstack/mobile/src/types/images.d.ts +24 -0
- package/templates/production-fullstack/mobile/src/utils/toast.ts +26 -0
- package/templates/production-fullstack/mobile/tailwind.config.js +71 -0
- package/templates/production-fullstack/mobile/tsconfig.json +23 -0
- package/templates/production-fullstack/server/.env.example +63 -0
- package/templates/production-fullstack/server/README.md +75 -0
- package/templates/production-fullstack/server/_gitignore +24 -0
- package/templates/production-fullstack/server/eslint.config.js +13 -0
- package/templates/production-fullstack/server/package.json +58 -0
- package/templates/production-fullstack/server/prisma/schema/core/attachment.prisma +14 -0
- package/templates/production-fullstack/server/prisma/schema/core/notification.prisma +18 -0
- package/templates/production-fullstack/server/prisma/schema/core/permission.prisma +26 -0
- package/templates/production-fullstack/server/prisma/schema/core/role.prisma +25 -0
- package/templates/production-fullstack/server/prisma/schema/core/user.prisma +56 -0
- package/templates/production-fullstack/server/prisma/schema/enums/common.prisma +13 -0
- package/templates/production-fullstack/server/prisma/schema/enums/notification.prisma +6 -0
- package/templates/production-fullstack/server/prisma/schema/enums/user.prisma +11 -0
- package/templates/production-fullstack/server/prisma/schema/schema.prisma +7 -0
- package/templates/production-fullstack/server/prisma.config.ts +14 -0
- package/templates/production-fullstack/server/src/app.ts +36 -0
- package/templates/production-fullstack/server/src/common/middlewares/auth.middleware.ts +45 -0
- package/templates/production-fullstack/server/src/common/middlewares/errorHandler.ts +16 -0
- package/templates/production-fullstack/server/src/common/middlewares/multer.ts +20 -0
- package/templates/production-fullstack/server/src/common/middlewares/rateLimiter.ts +53 -0
- package/templates/production-fullstack/server/src/common/services/email.service.ts +28 -0
- package/templates/production-fullstack/server/src/common/services/push.service.ts +65 -0
- package/templates/production-fullstack/server/src/common/services/storage.service.ts +9 -0
- package/templates/production-fullstack/server/src/common/types/express.d.ts +10 -0
- package/templates/production-fullstack/server/src/common/utils/cloudinaryUpload.ts +44 -0
- package/templates/production-fullstack/server/src/common/utils/emailOtp.ts +30 -0
- package/templates/production-fullstack/server/src/common/utils/genOtpToken.ts +22 -0
- package/templates/production-fullstack/server/src/common/utils/generateVapidKeys.ts +12 -0
- package/templates/production-fullstack/server/src/common/utils/jwt.ts +27 -0
- package/templates/production-fullstack/server/src/common/utils/pushHelper.ts +22 -0
- package/templates/production-fullstack/server/src/config/env.ts +2 -0
- package/templates/production-fullstack/server/src/config/logger.ts +58 -0
- package/templates/production-fullstack/server/src/config/prisma.ts +26 -0
- package/templates/production-fullstack/server/src/features/attachments/upload.controller.ts +22 -0
- package/templates/production-fullstack/server/src/features/attachments/upload.routes.ts +11 -0
- package/templates/production-fullstack/server/src/features/auth/auth.controller.ts +124 -0
- package/templates/production-fullstack/server/src/features/auth/auth.routes.ts +22 -0
- package/templates/production-fullstack/server/src/features/auth/auth.service.ts +155 -0
- package/templates/production-fullstack/server/src/features/notifications/push.controller.ts +55 -0
- package/templates/production-fullstack/server/src/features/notifications/push.routes.ts +11 -0
- package/templates/production-fullstack/server/src/index.ts +17 -0
- package/templates/production-fullstack/server/src/routes/index.ts +12 -0
- package/templates/production-fullstack/server/src/sockets/auth.ts +0 -0
- package/templates/production-fullstack/server/src/sockets/connection.ts +31 -0
- package/templates/production-fullstack/server/src/sockets/emitters/assignment.emitter.ts +0 -0
- package/templates/production-fullstack/server/src/sockets/emitters/attendance.emitter.ts +0 -0
- package/templates/production-fullstack/server/src/sockets/emitters/exam.emitter.ts +0 -0
- package/templates/production-fullstack/server/src/sockets/emitters/notification.emitter.ts +17 -0
- package/templates/production-fullstack/server/src/sockets/events.ts +27 -0
- package/templates/production-fullstack/server/src/sockets/handlers/attendance.handler.ts +0 -0
- package/templates/production-fullstack/server/src/sockets/handlers/chat.handler.ts +0 -0
- package/templates/production-fullstack/server/src/sockets/handlers/index.ts +15 -0
- package/templates/production-fullstack/server/src/sockets/handlers/lms.handler.ts +0 -0
- package/templates/production-fullstack/server/src/sockets/handlers/notification.handler.ts +39 -0
- package/templates/production-fullstack/server/src/sockets/index.ts +39 -0
- package/templates/production-fullstack/server/src/sockets/middleware.ts +54 -0
- package/templates/production-fullstack/server/src/sockets/rooms.ts +11 -0
- package/templates/production-fullstack/server/src/sockets/types.ts +32 -0
- package/templates/production-fullstack/server/tsconfig.json +14 -0
- package/templates/react/src/assets/animations/loading.json +1 -0
- package/templates/react-native/_gitignore +43 -0
- package/templates/react-native/package.json +2 -1
- package/templates/react-native/src/app/(auth)/edit-profile.tsx +11 -15
- package/templates/react-native/src/app/(tabs)/dashboard.tsx +2 -2
- package/templates/react-native/src/app/(tabs)/search.tsx +2 -2
- package/templates/react-native/src/config/sidebar.config.ts +0 -60
- package/templates/react-native/src/config/tabNavigation.ts +6 -36
- package/templates/react-native/src/services/notification.service.ts +22 -0
- package/templates/react-native/src/store/useNotificationStore.ts +158 -33
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
TextInput,
|
|
5
|
+
TextInputProps,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
import { useColorScheme } from "nativewind";
|
|
9
|
+
import { Colors } from "../../../constants/Colors";
|
|
10
|
+
import { Ionicons } from "@expo/vector-icons";
|
|
11
|
+
import { Txt } from "../../common/Typography";
|
|
12
|
+
|
|
13
|
+
export interface InputProps extends TextInputProps {
|
|
14
|
+
label?: string;
|
|
15
|
+
error?: string;
|
|
16
|
+
leftIcon?: keyof typeof Ionicons.glyphMap;
|
|
17
|
+
rightIcon?: keyof typeof Ionicons.glyphMap;
|
|
18
|
+
onRightIconPress?: () => void;
|
|
19
|
+
helperText?: string;
|
|
20
|
+
containerStyle?: import("react-native").StyleProp<
|
|
21
|
+
import("react-native").ViewStyle
|
|
22
|
+
>;
|
|
23
|
+
labelOnBorder?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function Input({
|
|
27
|
+
label,
|
|
28
|
+
error,
|
|
29
|
+
leftIcon,
|
|
30
|
+
rightIcon,
|
|
31
|
+
onRightIconPress,
|
|
32
|
+
helperText,
|
|
33
|
+
style,
|
|
34
|
+
containerStyle,
|
|
35
|
+
labelOnBorder = false,
|
|
36
|
+
...props
|
|
37
|
+
}: InputProps) {
|
|
38
|
+
const { colorScheme } = useColorScheme();
|
|
39
|
+
const theme = Colors[colorScheme ?? "light"];
|
|
40
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
41
|
+
|
|
42
|
+
const borderColor = error
|
|
43
|
+
? theme.error
|
|
44
|
+
: isFocused
|
|
45
|
+
? theme.primary
|
|
46
|
+
: theme.base300;
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View className="mb-4 relative">
|
|
50
|
+
{!labelOnBorder && label && (
|
|
51
|
+
<Txt
|
|
52
|
+
color={theme.baseContent}
|
|
53
|
+
weight="semibold"
|
|
54
|
+
style={{ marginBottom: 6 }}
|
|
55
|
+
>
|
|
56
|
+
{label} {error ? "*" : ""}{" "}
|
|
57
|
+
</Txt>
|
|
58
|
+
)}
|
|
59
|
+
|
|
60
|
+
{labelOnBorder && label && (
|
|
61
|
+
<View
|
|
62
|
+
style={{
|
|
63
|
+
position: "absolute",
|
|
64
|
+
top: -6,
|
|
65
|
+
left: 12,
|
|
66
|
+
backgroundColor: theme.base100,
|
|
67
|
+
paddingHorizontal: 6,
|
|
68
|
+
zIndex: 10,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<Txt
|
|
72
|
+
color={
|
|
73
|
+
error ? theme.error : isFocused ? theme.primary : theme.secondary
|
|
74
|
+
}
|
|
75
|
+
variant="xs"
|
|
76
|
+
weight="semibold"
|
|
77
|
+
>
|
|
78
|
+
{label} {error ? "*" : ""}
|
|
79
|
+
</Txt>
|
|
80
|
+
</View>
|
|
81
|
+
)}
|
|
82
|
+
|
|
83
|
+
<View
|
|
84
|
+
style={[
|
|
85
|
+
{
|
|
86
|
+
flexDirection: "row",
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
backgroundColor: theme.base100,
|
|
89
|
+
borderWidth: 1,
|
|
90
|
+
borderColor,
|
|
91
|
+
borderRadius: 12,
|
|
92
|
+
paddingHorizontal: 12,
|
|
93
|
+
height: 52,
|
|
94
|
+
},
|
|
95
|
+
containerStyle,
|
|
96
|
+
]}
|
|
97
|
+
>
|
|
98
|
+
{leftIcon && (
|
|
99
|
+
<Ionicons
|
|
100
|
+
name={leftIcon}
|
|
101
|
+
size={20}
|
|
102
|
+
color={isFocused ? theme.primary : theme.secondary}
|
|
103
|
+
style={{ marginRight: 8 }}
|
|
104
|
+
/>
|
|
105
|
+
)}
|
|
106
|
+
|
|
107
|
+
<TextInput
|
|
108
|
+
style={[
|
|
109
|
+
{
|
|
110
|
+
flex: 1,
|
|
111
|
+
color: theme.baseContent,
|
|
112
|
+
fontSize: 16,
|
|
113
|
+
height: "100%",
|
|
114
|
+
},
|
|
115
|
+
style,
|
|
116
|
+
]}
|
|
117
|
+
placeholderTextColor={theme.secondary}
|
|
118
|
+
onFocus={(e) => {
|
|
119
|
+
setIsFocused(true);
|
|
120
|
+
props.onFocus?.(e);
|
|
121
|
+
}}
|
|
122
|
+
onBlur={(e) => {
|
|
123
|
+
setIsFocused(false);
|
|
124
|
+
props.onBlur?.(e);
|
|
125
|
+
}}
|
|
126
|
+
{...props}
|
|
127
|
+
/>
|
|
128
|
+
|
|
129
|
+
{rightIcon && (
|
|
130
|
+
<TouchableOpacity
|
|
131
|
+
onPress={onRightIconPress}
|
|
132
|
+
disabled={!onRightIconPress}
|
|
133
|
+
>
|
|
134
|
+
<Ionicons
|
|
135
|
+
name={rightIcon}
|
|
136
|
+
size={20}
|
|
137
|
+
color={theme.secondary}
|
|
138
|
+
style={{ marginLeft: 8 }}
|
|
139
|
+
/>
|
|
140
|
+
</TouchableOpacity>
|
|
141
|
+
)}
|
|
142
|
+
</View>
|
|
143
|
+
|
|
144
|
+
{(error || helperText) && (
|
|
145
|
+
<Txt
|
|
146
|
+
style={{
|
|
147
|
+
color: error ? theme.error : theme.secondary,
|
|
148
|
+
fontSize: 12,
|
|
149
|
+
marginTop: 4,
|
|
150
|
+
marginLeft: 4,
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
{error || helperText}
|
|
154
|
+
</Txt>
|
|
155
|
+
)}
|
|
156
|
+
</View>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { View, Modal, TouchableOpacity, ActivityIndicator } from "react-native";
|
|
3
|
+
import MapView, { Region } from "react-native-maps";
|
|
4
|
+
import * as Location from "expo-location";
|
|
5
|
+
import { Ionicons } from "@expo/vector-icons";
|
|
6
|
+
import { useColorScheme } from "nativewind";
|
|
7
|
+
import { Colors } from "../../../constants/Colors";
|
|
8
|
+
import { Txt } from "../../common/Typography";
|
|
9
|
+
import Button from "../buttons/Button";
|
|
10
|
+
|
|
11
|
+
export interface LocationDetails {
|
|
12
|
+
addressLine1: string;
|
|
13
|
+
addressLine2?: string;
|
|
14
|
+
locality: string;
|
|
15
|
+
city: string;
|
|
16
|
+
state: string;
|
|
17
|
+
pinCode: string;
|
|
18
|
+
latitude: number;
|
|
19
|
+
longitude: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface LocationPickerProps {
|
|
23
|
+
onLocationSelected: (details: LocationDetails) => void;
|
|
24
|
+
initialCoordinate?: { latitude: number; longitude: number };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default function LocationPicker({
|
|
28
|
+
onLocationSelected,
|
|
29
|
+
initialCoordinate,
|
|
30
|
+
}: LocationPickerProps) {
|
|
31
|
+
const { colorScheme } = useColorScheme();
|
|
32
|
+
const theme = Colors[colorScheme ?? "light"];
|
|
33
|
+
|
|
34
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
35
|
+
const [loading, setLoading] = useState(false);
|
|
36
|
+
const [region, setRegion] = useState<Region>({
|
|
37
|
+
latitude: initialCoordinate?.latitude || 28.6139,
|
|
38
|
+
longitude: initialCoordinate?.longitude || 77.209,
|
|
39
|
+
latitudeDelta: 0.0922,
|
|
40
|
+
longitudeDelta: 0.0421,
|
|
41
|
+
});
|
|
42
|
+
const [currentCenter, setCurrentCenter] = useState({
|
|
43
|
+
latitude: region.latitude,
|
|
44
|
+
longitude: region.longitude,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (initialCoordinate?.latitude && initialCoordinate?.longitude) {
|
|
49
|
+
|
|
50
|
+
setRegion((r) => ({
|
|
51
|
+
...r,
|
|
52
|
+
latitude: initialCoordinate.latitude,
|
|
53
|
+
longitude: initialCoordinate.longitude,
|
|
54
|
+
}));
|
|
55
|
+
setCurrentCenter(initialCoordinate);
|
|
56
|
+
}
|
|
57
|
+
}, [initialCoordinate]);
|
|
58
|
+
|
|
59
|
+
const requestLocationAndOpenMap = async () => {
|
|
60
|
+
setLoading(true);
|
|
61
|
+
let { status } = await Location.requestForegroundPermissionsAsync();
|
|
62
|
+
if (status !== "granted") {
|
|
63
|
+
setLoading(false);
|
|
64
|
+
setModalVisible(true);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
if (!initialCoordinate?.latitude) {
|
|
70
|
+
let location = await Location.getCurrentPositionAsync({});
|
|
71
|
+
setRegion({
|
|
72
|
+
...region,
|
|
73
|
+
latitude: location.coords.latitude,
|
|
74
|
+
longitude: location.coords.longitude,
|
|
75
|
+
});
|
|
76
|
+
setCurrentCenter({
|
|
77
|
+
latitude: location.coords.latitude,
|
|
78
|
+
longitude: location.coords.longitude,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.warn(e);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
setLoading(false);
|
|
86
|
+
setModalVisible(true);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const handleConfirmLocation = async () => {
|
|
90
|
+
setLoading(true);
|
|
91
|
+
try {
|
|
92
|
+
const [address] = await Location.reverseGeocodeAsync({
|
|
93
|
+
latitude: currentCenter.latitude,
|
|
94
|
+
longitude: currentCenter.longitude,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (address) {
|
|
98
|
+
const details: LocationDetails = {
|
|
99
|
+
addressLine1: address.street || address.name || "",
|
|
100
|
+
locality: address.subregion || address.district || "",
|
|
101
|
+
city: address.city || address.subregion || "",
|
|
102
|
+
state: address.region || "",
|
|
103
|
+
pinCode: address.postalCode || "",
|
|
104
|
+
latitude: currentCenter.latitude,
|
|
105
|
+
longitude: currentCenter.longitude,
|
|
106
|
+
};
|
|
107
|
+
onLocationSelected(details);
|
|
108
|
+
setModalVisible(false);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.warn("Geocoding failed", error);
|
|
112
|
+
}
|
|
113
|
+
setLoading(false);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<>
|
|
118
|
+
<TouchableOpacity
|
|
119
|
+
onPress={requestLocationAndOpenMap}
|
|
120
|
+
className="w-full h-14 bg-base-200 rounded-xl mb-4 flex-row items-center justify-between px-4 border border-base-300"
|
|
121
|
+
>
|
|
122
|
+
<View className="flex-row items-center">
|
|
123
|
+
<Ionicons
|
|
124
|
+
name="map-outline"
|
|
125
|
+
size={24}
|
|
126
|
+
color={theme.primary}
|
|
127
|
+
style={{ marginRight: 12 }}
|
|
128
|
+
/>
|
|
129
|
+
<Txt color={theme.baseContent} weight="semibold">
|
|
130
|
+
{initialCoordinate?.latitude
|
|
131
|
+
? "Update Location on Map"
|
|
132
|
+
: "Pick from Map"}
|
|
133
|
+
</Txt>
|
|
134
|
+
</View>
|
|
135
|
+
{loading && !modalVisible ? (
|
|
136
|
+
<ActivityIndicator color={theme.primary} />
|
|
137
|
+
) : (
|
|
138
|
+
<Ionicons name="chevron-forward" size={20} color={theme.secondary} />
|
|
139
|
+
)}
|
|
140
|
+
</TouchableOpacity>
|
|
141
|
+
|
|
142
|
+
<Modal
|
|
143
|
+
animationType="slide"
|
|
144
|
+
transparent={false}
|
|
145
|
+
visible={modalVisible}
|
|
146
|
+
onRequestClose={() => setModalVisible(false)}
|
|
147
|
+
>
|
|
148
|
+
<View className="flex-1 bg-base-100">
|
|
149
|
+
<View
|
|
150
|
+
className="h-16 flex-row items-center justify-between px-4 border-b border-base-300 pt-4 bg-base-100"
|
|
151
|
+
style={{ zIndex: 10 }}
|
|
152
|
+
>
|
|
153
|
+
<TouchableOpacity
|
|
154
|
+
onPress={() => setModalVisible(false)}
|
|
155
|
+
className="p-2"
|
|
156
|
+
>
|
|
157
|
+
<Ionicons name="close" size={24} color={theme.baseContent} />
|
|
158
|
+
</TouchableOpacity>
|
|
159
|
+
<Txt variant="lg" weight="bold">
|
|
160
|
+
Select Location
|
|
161
|
+
</Txt>
|
|
162
|
+
<View className="w-10" />
|
|
163
|
+
</View>
|
|
164
|
+
|
|
165
|
+
<View className="flex-1 relative">
|
|
166
|
+
<MapView
|
|
167
|
+
style={{ flex: 1 }}
|
|
168
|
+
initialRegion={region}
|
|
169
|
+
showsUserLocation={true}
|
|
170
|
+
onRegionChangeComplete={(r) =>
|
|
171
|
+
setCurrentCenter({
|
|
172
|
+
latitude: r.latitude,
|
|
173
|
+
longitude: r.longitude,
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
/>
|
|
177
|
+
|
|
178
|
+
{/* Center Pin Overlay */}
|
|
179
|
+
<View
|
|
180
|
+
className="absolute top-0 left-0 right-0 bottom-0 items-center justify-center pointer-events-none"
|
|
181
|
+
pointerEvents="none"
|
|
182
|
+
>
|
|
183
|
+
<View
|
|
184
|
+
className="items-center"
|
|
185
|
+
style={{ transform: [{ translateY: -20 }] }}
|
|
186
|
+
>
|
|
187
|
+
<Ionicons name="location" size={40} color={theme.primary} />
|
|
188
|
+
<View className="w-2 h-2 rounded-full bg-black/20 mt-1" />
|
|
189
|
+
</View>
|
|
190
|
+
</View>
|
|
191
|
+
</View>
|
|
192
|
+
|
|
193
|
+
<View className="p-6 bg-base-100 border-t border-base-300 pb-10">
|
|
194
|
+
<Txt
|
|
195
|
+
variant="sm"
|
|
196
|
+
color={theme.secondary}
|
|
197
|
+
className="mb-4 text-center"
|
|
198
|
+
>
|
|
199
|
+
Drag the map to position the pin exactly on your property.
|
|
200
|
+
</Txt>
|
|
201
|
+
<Button
|
|
202
|
+
label="Confirm Location"
|
|
203
|
+
onPress={handleConfirmLocation}
|
|
204
|
+
isLoading={loading}
|
|
205
|
+
/>
|
|
206
|
+
</View>
|
|
207
|
+
</View>
|
|
208
|
+
</Modal>
|
|
209
|
+
</>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { OtpInput } from "react-native-otp-entry";
|
|
4
|
+
import { useColorScheme } from "nativewind";
|
|
5
|
+
import { Colors } from "../../../constants/Colors";
|
|
6
|
+
import { Txt } from "../../common/Typography";
|
|
7
|
+
|
|
8
|
+
export interface OTPProps {
|
|
9
|
+
length?: number;
|
|
10
|
+
onTextChange?: (text: string) => void;
|
|
11
|
+
onFilled?: (text: string) => void;
|
|
12
|
+
label?: string;
|
|
13
|
+
labelOnBorder?:boolean;
|
|
14
|
+
error?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function OTPInput({
|
|
18
|
+
length = 4,
|
|
19
|
+
onTextChange,
|
|
20
|
+
onFilled,
|
|
21
|
+
label,
|
|
22
|
+
error,
|
|
23
|
+
labelOnBorder = false,
|
|
24
|
+
}: OTPProps) {
|
|
25
|
+
const { colorScheme } = useColorScheme();
|
|
26
|
+
const theme = Colors[colorScheme ?? "light"];
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<View className={`mb-4 ${labelOnBorder ? 'relative' : ''}`}>
|
|
30
|
+
{!labelOnBorder && label && (
|
|
31
|
+
<Txt
|
|
32
|
+
color={theme.baseContent}
|
|
33
|
+
weight="semibold"
|
|
34
|
+
style={{ marginBottom: 8 }}
|
|
35
|
+
>
|
|
36
|
+
{label}
|
|
37
|
+
</Txt>
|
|
38
|
+
)}
|
|
39
|
+
|
|
40
|
+
{labelOnBorder && label && (
|
|
41
|
+
<View style={{ position: 'absolute', top: -9, left: 12, backgroundColor: theme.base100, paddingHorizontal: 4, zIndex: 10, elevation: 2 }}>
|
|
42
|
+
<Txt color={error ? theme.error : theme.secondary} variant="xs" weight="semibold">
|
|
43
|
+
{label}
|
|
44
|
+
</Txt>
|
|
45
|
+
</View>
|
|
46
|
+
)}
|
|
47
|
+
|
|
48
|
+
<OtpInput
|
|
49
|
+
numberOfDigits={length}
|
|
50
|
+
onTextChange={onTextChange}
|
|
51
|
+
onFilled={onFilled}
|
|
52
|
+
focusColor={error ? theme.error : theme.primary}
|
|
53
|
+
focusStickBlinkingDuration={500}
|
|
54
|
+
theme={{
|
|
55
|
+
containerStyle: { width: "100%" },
|
|
56
|
+
pinCodeContainerStyle: {
|
|
57
|
+
backgroundColor: theme.base100,
|
|
58
|
+
borderColor: error ? theme.error : theme.base300,
|
|
59
|
+
borderWidth: 1,
|
|
60
|
+
borderRadius: 12,
|
|
61
|
+
width: 56,
|
|
62
|
+
height: 64,
|
|
63
|
+
},
|
|
64
|
+
pinCodeTextStyle: {
|
|
65
|
+
color: theme.baseContent,
|
|
66
|
+
fontSize: 24,
|
|
67
|
+
fontWeight: "700",
|
|
68
|
+
},
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
{error && (
|
|
73
|
+
<Txt
|
|
74
|
+
color={theme.error}
|
|
75
|
+
variant="sm"
|
|
76
|
+
style={{ marginTop: 8, marginLeft: 4 }}
|
|
77
|
+
>
|
|
78
|
+
{error}
|
|
79
|
+
</Txt>
|
|
80
|
+
)}
|
|
81
|
+
</View>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import Input, { InputProps } from "./Input";
|
|
3
|
+
|
|
4
|
+
export default function PasswordInput({ labelOnBorder, ...props }: Omit<InputProps, "rightIcon" | "onRightIconPress" | "secureTextEntry">) {
|
|
5
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<Input
|
|
9
|
+
labelOnBorder={labelOnBorder}
|
|
10
|
+
{...props}
|
|
11
|
+
secureTextEntry={!isVisible}
|
|
12
|
+
rightIcon={isVisible ? "eye-off" : "eye"}
|
|
13
|
+
onRightIconPress={() => setIsVisible(!isVisible)}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TouchableOpacity, View } from "react-native";
|
|
3
|
+
import { useColorScheme } from "nativewind";
|
|
4
|
+
import { Colors } from "../../../constants/Colors";
|
|
5
|
+
import { Txt } from "../../common/Typography";
|
|
6
|
+
|
|
7
|
+
export interface RadioProps {
|
|
8
|
+
checked: boolean;
|
|
9
|
+
onChange: () => void;
|
|
10
|
+
label?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function Radio({
|
|
15
|
+
checked,
|
|
16
|
+
onChange,
|
|
17
|
+
label,
|
|
18
|
+
disabled,
|
|
19
|
+
}: RadioProps) {
|
|
20
|
+
const { colorScheme } = useColorScheme();
|
|
21
|
+
const theme = Colors[colorScheme ?? "light"];
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<TouchableOpacity
|
|
25
|
+
activeOpacity={0.7}
|
|
26
|
+
disabled={disabled}
|
|
27
|
+
onPress={onChange}
|
|
28
|
+
style={{
|
|
29
|
+
flexDirection: "row",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
opacity: disabled ? 0.5 : 1,
|
|
32
|
+
marginBottom: 8,
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<View
|
|
36
|
+
style={{
|
|
37
|
+
width: 24,
|
|
38
|
+
height: 24,
|
|
39
|
+
borderRadius: 12,
|
|
40
|
+
borderWidth: 2,
|
|
41
|
+
borderColor: checked ? theme.primary : theme.base300,
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
justifyContent: "center",
|
|
44
|
+
marginRight: 10,
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{checked && (
|
|
48
|
+
<View style={{ width: 12, height: 12, borderRadius: 6, backgroundColor: theme.primary }} />
|
|
49
|
+
)}
|
|
50
|
+
</View>
|
|
51
|
+
{label && <Txt color={theme.baseContent} variant="base">{label}</Txt>}
|
|
52
|
+
</TouchableOpacity>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Input, { InputProps } from "./Input";
|
|
3
|
+
|
|
4
|
+
export type SearchBarSize = "xs" | "sm" | "base" | "md" | "lg";
|
|
5
|
+
|
|
6
|
+
export interface SearchBarProps extends Omit<InputProps, "leftIcon"> {
|
|
7
|
+
size?: SearchBarSize;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function SearchBar({
|
|
11
|
+
size = "base",
|
|
12
|
+
style,
|
|
13
|
+
containerStyle,
|
|
14
|
+
...props
|
|
15
|
+
}: SearchBarProps) {
|
|
16
|
+
const getSizeStyles = () => {
|
|
17
|
+
switch (size) {
|
|
18
|
+
case "xs":
|
|
19
|
+
return { height: 32, px: 10, fontSize: 12 };
|
|
20
|
+
case "sm":
|
|
21
|
+
return { height: 38, px: 12, fontSize: 13 };
|
|
22
|
+
case "base":
|
|
23
|
+
return { height: 44, px: 14, fontSize: 14 };
|
|
24
|
+
case "md":
|
|
25
|
+
return { height: 50, px: 16, fontSize: 15 };
|
|
26
|
+
case "lg":
|
|
27
|
+
return { height: 56, px: 18, fontSize: 16 };
|
|
28
|
+
default:
|
|
29
|
+
return { height: 44, px: 14, fontSize: 14 };
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const s = getSizeStyles();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Input
|
|
37
|
+
leftIcon="search"
|
|
38
|
+
placeholder="Search..."
|
|
39
|
+
style={[{ fontSize: s.fontSize }, style]}
|
|
40
|
+
containerStyle={[
|
|
41
|
+
{
|
|
42
|
+
borderRadius: 9999,
|
|
43
|
+
height: s.height,
|
|
44
|
+
paddingHorizontal: s.px,
|
|
45
|
+
backgroundColor: "rgba(0,0,0,0.05)",
|
|
46
|
+
borderWidth: 0,
|
|
47
|
+
},
|
|
48
|
+
containerStyle,
|
|
49
|
+
]}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import CommunitySlider from "@react-native-community/slider";
|
|
4
|
+
import { useColorScheme } from "nativewind";
|
|
5
|
+
import { Colors } from "../../../constants/Colors";
|
|
6
|
+
import { Txt } from "../../common/Typography";
|
|
7
|
+
|
|
8
|
+
export interface SliderProps {
|
|
9
|
+
value: number;
|
|
10
|
+
onValueChange: (value: number) => void;
|
|
11
|
+
minimumValue?: number;
|
|
12
|
+
maximumValue?: number;
|
|
13
|
+
step?: number;
|
|
14
|
+
label?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function Slider({
|
|
18
|
+
value,
|
|
19
|
+
onValueChange,
|
|
20
|
+
minimumValue = 0,
|
|
21
|
+
maximumValue = 100,
|
|
22
|
+
step = 1,
|
|
23
|
+
label,
|
|
24
|
+
}: SliderProps) {
|
|
25
|
+
const { colorScheme } = useColorScheme();
|
|
26
|
+
const theme = Colors[colorScheme ?? "light"];
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<View className="mb-4 w-full">
|
|
30
|
+
{label && (
|
|
31
|
+
<View className="flex-row justify-between mb-2">
|
|
32
|
+
<Txt color={theme.baseContent} weight="semibold">{label}</Txt>
|
|
33
|
+
<Txt color={theme.secondary}>{value}</Txt>
|
|
34
|
+
</View>
|
|
35
|
+
)}
|
|
36
|
+
<CommunitySlider
|
|
37
|
+
style={{ width: "100%", height: 40 }}
|
|
38
|
+
minimumValue={minimumValue}
|
|
39
|
+
maximumValue={maximumValue}
|
|
40
|
+
step={step}
|
|
41
|
+
value={value}
|
|
42
|
+
onValueChange={onValueChange}
|
|
43
|
+
minimumTrackTintColor={theme.primary}
|
|
44
|
+
maximumTrackTintColor={theme.base300}
|
|
45
|
+
thumbTintColor={theme.primary}
|
|
46
|
+
/>
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { TouchableOpacity, StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
import Animated, {
|
|
4
|
+
useSharedValue,
|
|
5
|
+
useAnimatedStyle,
|
|
6
|
+
withTiming,
|
|
7
|
+
interpolateColor,
|
|
8
|
+
} from "react-native-reanimated";
|
|
9
|
+
import { useColorScheme } from "nativewind";
|
|
10
|
+
import { Colors } from "../../../constants/Colors";
|
|
11
|
+
import { Txt } from "../../common/Typography";
|
|
12
|
+
|
|
13
|
+
export interface SwitchProps {
|
|
14
|
+
checked: boolean;
|
|
15
|
+
onChange?: (checked: boolean) => void;
|
|
16
|
+
label?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function Switch({
|
|
22
|
+
checked,
|
|
23
|
+
onChange,
|
|
24
|
+
label,
|
|
25
|
+
disabled,
|
|
26
|
+
style,
|
|
27
|
+
}: SwitchProps) {
|
|
28
|
+
const { colorScheme } = useColorScheme();
|
|
29
|
+
const theme = Colors[colorScheme ?? "light"];
|
|
30
|
+
|
|
31
|
+
const progress = useSharedValue(checked ? 1 : 0);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
progress.value = withTiming(checked ? 1 : 0, { duration: 250 });
|
|
35
|
+
}, [checked, progress]);
|
|
36
|
+
|
|
37
|
+
const trackStyle = useAnimatedStyle(() => {
|
|
38
|
+
const backgroundColor = interpolateColor(
|
|
39
|
+
progress.value,
|
|
40
|
+
[0, 1],
|
|
41
|
+
[theme.base300, theme.primary]
|
|
42
|
+
);
|
|
43
|
+
return { backgroundColor };
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const thumbStyle = useAnimatedStyle(() => {
|
|
47
|
+
return {
|
|
48
|
+
transform: [{ translateX: progress.value * 20 }],
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<TouchableOpacity
|
|
54
|
+
activeOpacity={0.8}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
onPress={() => onChange && onChange(!checked)}
|
|
57
|
+
style={[{ flexDirection: "row", alignItems: "center", opacity: disabled ? 0.5 : 1 }, style]}
|
|
58
|
+
>
|
|
59
|
+
<Animated.View
|
|
60
|
+
style={[
|
|
61
|
+
{ width: 44, height: 24, borderRadius: 12, padding: 2, justifyContent: "center" },
|
|
62
|
+
trackStyle,
|
|
63
|
+
]}
|
|
64
|
+
>
|
|
65
|
+
<Animated.View
|
|
66
|
+
style={[
|
|
67
|
+
{ width: 20, height: 20, borderRadius: 10, backgroundColor: "#fff", elevation: 2, shadowColor: "#000", shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.2, shadowRadius: 2 },
|
|
68
|
+
thumbStyle,
|
|
69
|
+
]}
|
|
70
|
+
/>
|
|
71
|
+
</Animated.View>
|
|
72
|
+
{label && <Txt color={theme.baseContent} variant="base" style={{ marginLeft: 10 }}>{label}</Txt>}
|
|
73
|
+
</TouchableOpacity>
|
|
74
|
+
);
|
|
75
|
+
}
|