Compare commits
1 Commits
tablet
...
matija_cha
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c6ec9eda4 |
@ -1,12 +1,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<queries>
|
||||
<intent>
|
||||
@ -24,7 +22,7 @@
|
||||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
|
||||
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
|
||||
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://u.expo.dev/bdb8c57b-25bb-4d36-b3b8-5b09c5092f52"/>
|
||||
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|locale|layoutDirection" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
|
||||
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 58 KiB |
@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">"Cally "</string>
|
||||
<string name="app_name">Cally - Family Planner</string>
|
||||
<string name="expo_splash_screen_resize_mode" translatable="false">contain</string>
|
||||
<string name="expo_splash_screen_status_bar_translucent" translatable="false">false</string>
|
||||
<string name="expo_system_ui_user_interface_style" translatable="false">light</string>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
rootProject.name = 'Cally '
|
||||
rootProject.name = 'Cally - Family Planner'
|
||||
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
|
||||
18
app.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "Cally ",
|
||||
"name": "Cally - Family Planner",
|
||||
"slug": "cally",
|
||||
"version": "1.0.0",
|
||||
"orientation": "portrait",
|
||||
@ -16,8 +16,7 @@
|
||||
"supportsTablet": true,
|
||||
"bundleIdentifier": "com.cally.app",
|
||||
"googleServicesFile": "./ios/GoogleService-Info.plist",
|
||||
"buildNumber": "60",
|
||||
"usesAppleSignIn": true
|
||||
"buildNumber": "28"
|
||||
},
|
||||
"android": {
|
||||
"adaptiveIcon": {
|
||||
@ -64,18 +63,7 @@
|
||||
"defaultChannel": "default"
|
||||
}
|
||||
],
|
||||
[
|
||||
"expo-calendar",
|
||||
{
|
||||
"calendarPermission": "The app needs to access your calendar."
|
||||
}
|
||||
],
|
||||
[
|
||||
"expo-apple-authentication"
|
||||
],
|
||||
"expo-font",
|
||||
"expo-localization",
|
||||
"./plugins/withPodfile"
|
||||
"expo-font"
|
||||
],
|
||||
"experiments": {
|
||||
"typedRoutes": true
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from "react";
|
||||
import React from "react";
|
||||
import { Drawer } from "expo-router/drawer";
|
||||
import { useSignOut } from "@/hooks/firebase/useSignOut";
|
||||
import {
|
||||
@ -7,7 +7,7 @@ import {
|
||||
DrawerItemList,
|
||||
} from "@react-navigation/drawer";
|
||||
import { Button, View, Text, ButtonSize } from "react-native-ui-lib";
|
||||
import { Dimensions, ImageBackground, StyleSheet } from "react-native";
|
||||
import { StyleSheet } from "react-native";
|
||||
import Feather from "@expo/vector-icons/Feather";
|
||||
import DrawerButton from "@/components/shared/DrawerButton";
|
||||
import {
|
||||
@ -23,57 +23,26 @@ import NavToDosIcon from "@/assets/svgs/NavToDosIcon";
|
||||
import NavBrainDumpIcon from "@/assets/svgs/NavBrainDumpIcon";
|
||||
import NavCalendarIcon from "@/assets/svgs/NavCalendarIcon";
|
||||
import NavSettingsIcon from "@/assets/svgs/NavSettingsIcon";
|
||||
import ViewSwitch from "@/components/pages/(tablet_pages)/ViewSwitch";
|
||||
import { useAtom, useSetAtom } from "jotai";
|
||||
import {
|
||||
isFamilyViewAtom,
|
||||
settingsPageIndex,
|
||||
toDosPageIndex,
|
||||
userSettingsView,
|
||||
} from "@/components/pages/calendar/atoms";
|
||||
import FeedbackNavIcon from "@/assets/svgs/FeedbackNavIcon";
|
||||
import Constants from "expo-constants";
|
||||
import * as Device from "expo-device";
|
||||
import { DeviceType } from "expo-device";
|
||||
|
||||
export default function TabLayout() {
|
||||
const { mutateAsync: signOut } = useSignOut();
|
||||
const setIsFamilyView = useSetAtom(isFamilyViewAtom);
|
||||
const setPageIndex = useSetAtom(settingsPageIndex);
|
||||
const setUserView = useSetAtom(userSettingsView);
|
||||
const setToDosIndex = useSetAtom(toDosPageIndex);
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
initialRouteName={"index"}
|
||||
detachInactiveScreens
|
||||
screenOptions={({ navigation }) => ({
|
||||
screenOptions={{
|
||||
headerShown: true,
|
||||
headerRight: () =>
|
||||
Device.deviceType === DeviceType.TABLET ? (
|
||||
<ViewSwitch navigation={navigation} />
|
||||
) : (
|
||||
<></>
|
||||
),
|
||||
drawerStyle: {
|
||||
width: "90%",
|
||||
backgroundColor: "#f9f8f7",
|
||||
height: "100%",
|
||||
},
|
||||
})}
|
||||
drawerIcon: () => <MenuIcon />,
|
||||
}}
|
||||
drawerContent={(props) => {
|
||||
return (
|
||||
<DrawerContentScrollView {...props} style={{}}>
|
||||
<View centerV marginH-30 marginT-20 marginB-20 row>
|
||||
<ImageBackground
|
||||
source={require("../../assets/images/splash.png")}
|
||||
style={{
|
||||
backgroundColor: "transparent",
|
||||
height: 51.43,
|
||||
aspectRatio: 1,
|
||||
marginRight: 8,
|
||||
}}
|
||||
/>
|
||||
<DrawerContentScrollView {...props} style={{ height: "100%" }}>
|
||||
<View centerH centerV margin-30>
|
||||
<Text style={styles.title}>Welcome to Cally</Text>
|
||||
</View>
|
||||
<View
|
||||
@ -87,41 +56,16 @@ export default function TabLayout() {
|
||||
title={"Calendar"}
|
||||
color="rgb(7, 184, 199)"
|
||||
bgColor={"rgb(231, 248, 250)"}
|
||||
pressFunc={() => {
|
||||
props.navigation.navigate("calendar");
|
||||
setPageIndex(0);
|
||||
setToDosIndex(0);
|
||||
setUserView(true);
|
||||
setIsFamilyView(false);
|
||||
}}
|
||||
pressFunc={() => props.navigation.navigate("calendar")}
|
||||
icon={<NavCalendarIcon />}
|
||||
/>
|
||||
<DrawerButton
|
||||
color="#50be0c"
|
||||
title={"Groceries"}
|
||||
bgColor={"#eef9e7"}
|
||||
pressFunc={() => {
|
||||
props.navigation.navigate("grocery");
|
||||
setPageIndex(0);
|
||||
setToDosIndex(0);
|
||||
setUserView(true);
|
||||
setIsFamilyView(false);
|
||||
}}
|
||||
pressFunc={() => props.navigation.navigate("grocery")}
|
||||
icon={<NavGroceryIcon />}
|
||||
/>
|
||||
<DrawerButton
|
||||
color="#ea156d"
|
||||
title={"Feedback"}
|
||||
bgColor={"#fdedf4"}
|
||||
pressFunc={() => {
|
||||
props.navigation.navigate("feedback");
|
||||
setPageIndex(0);
|
||||
setToDosIndex(0);
|
||||
setUserView(true);
|
||||
setIsFamilyView(false);
|
||||
}}
|
||||
icon={<FeedbackNavIcon />}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flex: 1 }}>
|
||||
{/*<DrawerButton
|
||||
@ -141,39 +85,21 @@ export default function TabLayout() {
|
||||
color="#8005eb"
|
||||
title={"To Do's"}
|
||||
bgColor={"#f3e6fd"}
|
||||
pressFunc={() => {
|
||||
props.navigation.navigate("todos");
|
||||
setPageIndex(0);
|
||||
setToDosIndex(0);
|
||||
setUserView(true);
|
||||
setIsFamilyView(false);
|
||||
}}
|
||||
pressFunc={() => props.navigation.navigate("todos")}
|
||||
icon={<NavToDosIcon />}
|
||||
/>
|
||||
<DrawerButton
|
||||
color="#e0ca03"
|
||||
title={"Brain Dump"}
|
||||
bgColor={"#fffacb"}
|
||||
pressFunc={() => {
|
||||
props.navigation.navigate("brain_dump");
|
||||
setPageIndex(0);
|
||||
setToDosIndex(0);
|
||||
setUserView(true);
|
||||
setIsFamilyView(false);
|
||||
}}
|
||||
pressFunc={() => props.navigation.navigate("brain_dump")}
|
||||
icon={<NavBrainDumpIcon />}
|
||||
/>
|
||||
{/*<DrawerItem label="Logout" onPress={() => signOut()} />*/}
|
||||
</View>
|
||||
</View>
|
||||
<Button
|
||||
onPress={() => {
|
||||
props.navigation.navigate("settings");
|
||||
setPageIndex(0);
|
||||
setToDosIndex(0);
|
||||
setUserView(true);
|
||||
setIsFamilyView(false);
|
||||
}}
|
||||
onPress={() => props.navigation.navigate("settings")}
|
||||
label={"Manage Settings"}
|
||||
labelStyle={styles.label}
|
||||
iconSource={() => (
|
||||
@ -201,9 +127,9 @@ export default function TabLayout() {
|
||||
<Button
|
||||
size={ButtonSize.large}
|
||||
marginH-30
|
||||
marginT-12
|
||||
paddingV-15
|
||||
style={{
|
||||
marginTop: "42%",
|
||||
backgroundColor: "transparent",
|
||||
borderWidth: 1.3,
|
||||
borderColor: "#fd1775",
|
||||
@ -264,13 +190,9 @@ export default function TabLayout() {
|
||||
name="todos"
|
||||
options={{
|
||||
drawerLabel: "To-Do",
|
||||
title: "To-Dos",
|
||||
title: "To-Do's",
|
||||
}}
|
||||
/>
|
||||
<Drawer.Screen
|
||||
name="feedback"
|
||||
options={{ drawerLabel: "Feedback", title: "Feedback" }}
|
||||
/>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
@ -280,7 +202,7 @@ const styles = StyleSheet.create({
|
||||
label: { fontFamily: "Poppins_400Medium", fontSize: 15 },
|
||||
title: {
|
||||
fontSize: 26.13,
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
color: "#262627",
|
||||
},
|
||||
fontFamily: 'Manrope_600SemiBold',
|
||||
color: "#262627"
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,18 +1,14 @@
|
||||
import React from "react";
|
||||
import { CalendarProvider } from "@/contexts/CalendarContext"; // Import the new CalendarPage component
|
||||
import CalendarPage from "@/components/pages/calendar/CalendarPage";
|
||||
import { View } from "react-native-ui-lib";
|
||||
import TabletCalendarPage from "@/components/pages/(tablet_pages)/calendar/TabletCalendarPage";
|
||||
import { DeviceType } from "expo-device";
|
||||
import * as Device from "expo-device";
|
||||
import { SettingsContextProvider } from "@/contexts/SettingsContext";
|
||||
|
||||
export default function Screen() {
|
||||
return (
|
||||
<View style={{ backgroundColor: "white" }}>
|
||||
{Device.deviceType === DeviceType.TABLET ? (
|
||||
<TabletCalendarPage />
|
||||
) : (
|
||||
<SettingsContextProvider>
|
||||
<CalendarProvider>
|
||||
<CalendarPage />
|
||||
)}
|
||||
</View>
|
||||
</CalendarProvider>
|
||||
</SettingsContextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
import {Stack} from "expo-router";
|
||||
|
||||
export default function StackLayout () {
|
||||
return <Stack screenOptions={{headerShown: false}}/>
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
import FeedbackPage from "@/components/pages/feedback/FeedbackPage";
|
||||
import { FeedbackProvider } from "@/contexts/FeedbackContext";
|
||||
import { View } from "react-native-ui-lib";
|
||||
|
||||
export default function Screen() {
|
||||
return (
|
||||
<FeedbackProvider>
|
||||
<View>
|
||||
<FeedbackPage />
|
||||
</View>
|
||||
</FeedbackProvider>
|
||||
);
|
||||
}
|
||||
@ -1,8 +1,11 @@
|
||||
import SettingsPage from "@/components/pages/settings/SettingsPage";
|
||||
import {SettingsContextProvider} from "@/contexts/SettingsContext";
|
||||
import React from "react";
|
||||
|
||||
export default function Screen() {
|
||||
return (
|
||||
<SettingsPage/>
|
||||
<SettingsContextProvider>
|
||||
<SettingsPage/>
|
||||
</SettingsContextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import TabletChoresPage from "@/components/pages/(tablet_pages)/chores/TabletChoresPage";
|
||||
import AddChore from "@/components/pages/todos/AddChore";
|
||||
import ProgressCard from "@/components/pages/todos/ProgressCard";
|
||||
import ToDoItem from "@/components/pages/todos/ToDoItem";
|
||||
@ -9,17 +8,12 @@ import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import { ToDosContextProvider, useToDosContext } from "@/contexts/ToDosContext";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { ScrollView } from "react-native-gesture-handler";
|
||||
import { Button, ButtonSize, View, Text, Constants } from "react-native-ui-lib";
|
||||
import * as Device from "expo-device";
|
||||
import { Button, ButtonSize, View, Text } from "react-native-ui-lib";
|
||||
|
||||
export default function Screen() {
|
||||
return (
|
||||
<ToDosContextProvider>
|
||||
{Device.deviceType === Device.DeviceType.TABLET ? (
|
||||
<TabletChoresPage />
|
||||
) : (
|
||||
<ToDosPage />
|
||||
)}
|
||||
<ToDosPage />
|
||||
</ToDosContextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,246 +0,0 @@
|
||||
import {SafeAreaView} from "react-native-safe-area-context";
|
||||
import {Button, Text, View} from "react-native-ui-lib";
|
||||
import React from "react";
|
||||
import {useCalSync} from "@/hooks/useCalSync";
|
||||
import GoogleIcon from "@/assets/svgs/GoogleIcon";
|
||||
import AppleIcon from "@/assets/svgs/AppleIcon";
|
||||
import OutlookIcon from "@/assets/svgs/OutlookIcon";
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import {StyleSheet} from "react-native";
|
||||
|
||||
export default function Screen() {
|
||||
const {profileData, setRedirectOverride} = useAuthContext()
|
||||
const {handleStartGoogleSignIn, handleAppleSignIn, handleMicrosoftSignIn} = useCalSync()
|
||||
|
||||
const hasSomeCalendarsSynced =
|
||||
!!profileData?.appleAccounts || !!profileData?.microsoftAccounts || !!profileData?.googleAccounts
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{flex: 1}}>
|
||||
<View style={{flex: 1, padding: 21, paddingBottom: 45, paddingTop: "20%", alignItems: "center"}}>
|
||||
<View gap-13 width={"100%"} marginB-20>
|
||||
<Text style={{fontSize: 40, fontFamily: 'Manrope_600SemiBold'}}>
|
||||
Let's get started!
|
||||
</Text>
|
||||
<Text color={"#919191"} style={{fontSize: 20}}>
|
||||
Add your calendar below to sync events to your Cally calendar
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View width={"100%"} gap-1>
|
||||
{!profileData?.googleAccounts && (
|
||||
<Button
|
||||
onPress={() => handleStartGoogleSignIn()}
|
||||
label={"Connect Google account"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<GoogleIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
)}
|
||||
|
||||
{profileData?.googleAccounts
|
||||
? Object.keys(profileData?.googleAccounts)?.map((googleMail) => {
|
||||
const googleToken = profileData?.googleAccounts?.[googleMail]?.accessToken;
|
||||
return (
|
||||
googleToken && (
|
||||
<Button
|
||||
key={googleMail}
|
||||
disabled
|
||||
label={`Connected ${googleMail}`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<GoogleIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
)
|
||||
);
|
||||
})
|
||||
: null}
|
||||
|
||||
{!profileData?.appleAccounts && (
|
||||
<Button
|
||||
onPress={() => handleAppleSignIn()}
|
||||
label={"Connect Apple"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<AppleIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
)}
|
||||
|
||||
{profileData?.appleAccounts
|
||||
? Object.keys(profileData?.appleAccounts)?.map((appleEmail) => {
|
||||
const appleToken = profileData?.appleAccounts?.[appleEmail!];
|
||||
return (
|
||||
appleToken && (
|
||||
<Button
|
||||
key={appleEmail}
|
||||
disabled
|
||||
label={`Connected Apple Calendar`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<AppleIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
)
|
||||
);
|
||||
})
|
||||
: null}
|
||||
|
||||
{!profileData?.microsoftAccounts && (
|
||||
<Button
|
||||
onPress={() => handleMicrosoftSignIn()}
|
||||
label={"Connect Outlook"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<OutlookIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
)}
|
||||
|
||||
{profileData?.microsoftAccounts
|
||||
? Object.keys(profileData?.microsoftAccounts)?.map(
|
||||
(microsoftEmail) => {
|
||||
const microsoftToken =
|
||||
profileData?.microsoftAccounts?.[microsoftEmail];
|
||||
return (
|
||||
microsoftToken && (
|
||||
<Button
|
||||
key={microsoftEmail}
|
||||
|
||||
label={`Connected ${microsoftEmail}`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<OutlookIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
: null}
|
||||
</View>
|
||||
|
||||
<View flexG/>
|
||||
|
||||
<View width={"100%"}>
|
||||
<Button
|
||||
label={hasSomeCalendarsSynced ? "Continue" : "Skip this step"}
|
||||
onPress={() => setRedirectOverride(false)}
|
||||
marginT-50
|
||||
labelStyle={{
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
fontSize: 16,
|
||||
}}
|
||||
style={{height: 50}}
|
||||
backgroundColor="#fd1775"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
addCalBtn: {
|
||||
backgroundColor: "#ffffff",
|
||||
marginBottom: 15,
|
||||
justifyContent: "flex-start",
|
||||
paddingLeft: 25,
|
||||
},
|
||||
backBtn: {
|
||||
backgroundColor: "red",
|
||||
marginLeft: -2,
|
||||
justifyContent: "flex-start",
|
||||
},
|
||||
card: {
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
padding: 20,
|
||||
paddingBottom: 30,
|
||||
marginTop: 20,
|
||||
borderRadius: 12,
|
||||
},
|
||||
noPaddingCard: {
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
marginTop: 20,
|
||||
borderRadius: 12,
|
||||
},
|
||||
colorBox: {
|
||||
aspectRatio: 1,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
width: 51,
|
||||
borderRadius: 12,
|
||||
},
|
||||
checkbox: {
|
||||
borderRadius: 50,
|
||||
},
|
||||
addCalLbl: {
|
||||
fontSize: 16,
|
||||
fontFamily: "PlusJakartaSan_500Medium",
|
||||
flexWrap: "wrap",
|
||||
width: "75%",
|
||||
textAlign: "left",
|
||||
lineHeight: 20,
|
||||
overflow: "visible",
|
||||
},
|
||||
subTitle: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 18,
|
||||
},
|
||||
cardTitle: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
});
|
||||
@ -1,169 +0,0 @@
|
||||
import {SafeAreaView} from "react-native-safe-area-context";
|
||||
import {Button, Colors, Dialog, LoaderScreen, Text, View} from "react-native-ui-lib";
|
||||
import React, {useCallback, useState} from "react";
|
||||
import {useRouter} from "expo-router";
|
||||
import QRIcon from "@/assets/svgs/QRIcon";
|
||||
import {Camera, CameraView} from "expo-camera";
|
||||
import {useLoginWithQrCode} from "@/hooks/firebase/useLoginWithQrCode";
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import debounce from "debounce";
|
||||
|
||||
export default function Screen() {
|
||||
const router = useRouter()
|
||||
const {setRedirectOverride} = useAuthContext()
|
||||
const [hasPermission, setHasPermission] = useState<boolean | null>(null);
|
||||
const [showCameraDialog, setShowCameraDialog] = useState<boolean>(false);
|
||||
|
||||
const {mutateAsync: signInWithQrCode, isLoading} = useLoginWithQrCode();
|
||||
|
||||
const debouncedRouterReplace = useCallback(
|
||||
debounce(() => {
|
||||
router.push("/(unauth)/cal_sync");
|
||||
}, 300),
|
||||
[]
|
||||
);
|
||||
|
||||
const handleQrCodeScanned = async ({data}: { data: string }) => {
|
||||
setShowCameraDialog(false);
|
||||
setRedirectOverride(true);
|
||||
try {
|
||||
await signInWithQrCode({userId: data});
|
||||
debouncedRouterReplace()
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
};
|
||||
|
||||
const getCameraPermissions = async (callback: () => void) => {
|
||||
const {status} = await Camera.requestCameraPermissionsAsync();
|
||||
setHasPermission(status === "granted");
|
||||
if (status === "granted") {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenQrCodeDialog = () => {
|
||||
getCameraPermissions(() => setShowCameraDialog(true));
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{flex: 1}}>
|
||||
<View style={{flex: 1, padding: 21, paddingBottom: 45, paddingTop: "20%", alignItems: "center"}}>
|
||||
<View center>
|
||||
<Text style={{fontSize: 30, fontFamily: 'Manrope_600SemiBold'}}>
|
||||
Get started with Cally
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View width={"100%"} gap-30>
|
||||
<View>
|
||||
<Button
|
||||
label="Scan QR Code"
|
||||
marginT-50
|
||||
labelStyle={{
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
marginLeft: 10
|
||||
}}
|
||||
iconSource={() => <QRIcon color={"#07B8C7"}/>}
|
||||
onPress={handleOpenQrCodeDialog}
|
||||
style={{height: 50}}
|
||||
color={Colors.black}
|
||||
backgroundColor={Colors.white}
|
||||
/>
|
||||
{/* GOOGLE LOGIN HERE */}
|
||||
</View>
|
||||
|
||||
<View row center gap-20>
|
||||
<View flexG style={{backgroundColor: "#E2E2E2", height: 2}}/>
|
||||
<Text style={{fontSize: 16, fontFamily: 'PlusJakartaSans_300Light', color: "#7A7A7A"}}>
|
||||
or
|
||||
</Text>
|
||||
<View flexG style={{backgroundColor: "#E2E2E2", height: 2}}/>
|
||||
</View>
|
||||
|
||||
<View>
|
||||
<Button
|
||||
label="Contine with Email"
|
||||
labelStyle={{
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
marginLeft: 10
|
||||
}}
|
||||
onPress={() => router.push("/(unauth)/sign_up")}
|
||||
style={{height: 50, borderStyle: "solid", borderColor: "#E2E2E2", borderWidth: 2}}
|
||||
color={Colors.black}
|
||||
backgroundColor={"transparent"}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
|
||||
<View flexG/>
|
||||
|
||||
<View row centerH gap-5>
|
||||
<Text style={{
|
||||
fontFamily: "PlusJakartaSans_300Light",
|
||||
fontSize: 16,
|
||||
color: "#484848"
|
||||
}} center>
|
||||
Already have an account?
|
||||
</Text>
|
||||
|
||||
<Button
|
||||
label="Log in"
|
||||
link
|
||||
onPress={() => router.push("/(unauth)/sign_in")}
|
||||
labelStyle={[
|
||||
{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
color: "#919191",
|
||||
},
|
||||
{fontSize: 16, textDecorationLine: "none", color: "#fd1775"},
|
||||
]}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* Legacy, move into separate component */}
|
||||
{/* Camera Dialog */}
|
||||
<Dialog
|
||||
visible={showCameraDialog}
|
||||
onDismiss={() => setShowCameraDialog(false)}
|
||||
bottom
|
||||
width="100%"
|
||||
height="70%"
|
||||
containerStyle={{padding: 15, backgroundColor: "white"}}
|
||||
>
|
||||
<Text center style={{fontSize: 16}} marginB-15>
|
||||
Scan a QR code presented from your family member of provider.
|
||||
</Text>
|
||||
{hasPermission === null ? (
|
||||
<Text>Requesting camera permissions...</Text>
|
||||
) : !hasPermission ? (
|
||||
<Text>No access to camera</Text>
|
||||
) : (
|
||||
<CameraView
|
||||
style={{flex: 1, borderRadius: 15}}
|
||||
onBarcodeScanned={handleQrCodeScanned}
|
||||
barcodeScannerSettings={{
|
||||
barcodeTypes: ["qr"],
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
label="Cancel"
|
||||
onPress={() => setShowCameraDialog(false)}
|
||||
backgroundColor="#fd1775"
|
||||
style={{margin: 10, marginBottom: 30}}
|
||||
/>
|
||||
</Dialog>
|
||||
|
||||
|
||||
{isLoading && (
|
||||
<LoaderScreen overlay message={"Signing in..."} backgroundColor={Colors.white} color={Colors.grey40}/>
|
||||
)}
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
@ -1,44 +1,10 @@
|
||||
import Entry from "@/components/pages/main/Entry";
|
||||
import {SafeAreaView} from "react-native-safe-area-context";
|
||||
import {Button, Image, Text, View} from "react-native-ui-lib";
|
||||
import React from "react";
|
||||
import {useRouter} from "expo-router";
|
||||
|
||||
export default function Screen() {
|
||||
const router = useRouter()
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{flex: 1}}>
|
||||
<View style={{flex: 1, padding: 21, paddingBottom: 45, paddingTop: "20%", alignItems: "center"}}>
|
||||
<View>
|
||||
<Image source={require("../../assets/images/splash.png")}/>
|
||||
</View>
|
||||
|
||||
<View center gap-13>
|
||||
<Text style={{fontSize: 40, fontFamily: 'Manrope_600SemiBold', marginLeft: 5}}>
|
||||
Welcome to Cally
|
||||
</Text>
|
||||
<Text center color={"#919191"} style={{fontSize: 20, maxWidth: 250}}>
|
||||
Lightening Mental Loads,
|
||||
One Family at a Time
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View flexG/>
|
||||
|
||||
<View width={"100%"}>
|
||||
<Button
|
||||
label="Continue"
|
||||
marginT-50
|
||||
labelStyle={{
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
fontSize: 16,
|
||||
}}
|
||||
onPress={() => router.push("/(unauth)/get_started")}
|
||||
style={{height: 50}}
|
||||
backgroundColor="#fd1775"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<SafeAreaView>
|
||||
<Entry/>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
}
|
||||
0
app/(unauth)/onboarding_flow/_layout.tsx
Normal file
@ -1,5 +1,5 @@
|
||||
import Entry from "@/components/pages/main/Entry";
|
||||
|
||||
export default function Screen() {
|
||||
return <Entry />;
|
||||
return <Entry />;
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
import React from "react";
|
||||
import {ResetPasswordPage} from "@/components/pages/main/ResetPasswordPage";
|
||||
|
||||
export default function Screen() {
|
||||
return <ResetPasswordPage/>
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
import SignInPage from "@/components/pages/main/SignInPage";
|
||||
import React from "react";
|
||||
|
||||
export default function Screen() {
|
||||
return <SignInPage/>
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
import React from "react";
|
||||
import SignUpPage from "@/components/pages/main/SignUpPage";
|
||||
|
||||
export default function Screen() {
|
||||
return (
|
||||
<SignUpPage/>
|
||||
)
|
||||
}
|
||||
465
app/_layout.tsx
@ -1,6 +1,170 @@
|
||||
import React, {useEffect} from "react";
|
||||
import {DefaultTheme, ThemeProvider} from "@react-navigation/native";
|
||||
import React, { useEffect } from "react";
|
||||
import { DefaultTheme, ThemeProvider } from "@react-navigation/native";
|
||||
import {
|
||||
useFonts,
|
||||
Manrope_200ExtraLight,
|
||||
Manrope_300Light,
|
||||
Manrope_400Regular,
|
||||
Manrope_500Medium,
|
||||
Manrope_600SemiBold,
|
||||
Manrope_700Bold,
|
||||
Manrope_800ExtraBold,
|
||||
} from "@expo-google-fonts/manrope";
|
||||
import {
|
||||
PlusJakartaSans_200ExtraLight,
|
||||
PlusJakartaSans_300Light,
|
||||
PlusJakartaSans_400Regular,
|
||||
PlusJakartaSans_500Medium,
|
||||
PlusJakartaSans_600SemiBold,
|
||||
PlusJakartaSans_700Bold,
|
||||
PlusJakartaSans_800ExtraBold,
|
||||
PlusJakartaSans_200ExtraLight_Italic,
|
||||
PlusJakartaSans_300Light_Italic,
|
||||
PlusJakartaSans_400Regular_Italic,
|
||||
PlusJakartaSans_500Medium_Italic,
|
||||
PlusJakartaSans_600SemiBold_Italic,
|
||||
PlusJakartaSans_700Bold_Italic,
|
||||
PlusJakartaSans_800ExtraBold_Italic,
|
||||
} from "@expo-google-fonts/plus-jakarta-sans";
|
||||
import {
|
||||
Poppins_100Thin,
|
||||
Poppins_100Thin_Italic,
|
||||
Poppins_200ExtraLight,
|
||||
Poppins_200ExtraLight_Italic,
|
||||
Poppins_300Light,
|
||||
Poppins_300Light_Italic,
|
||||
Poppins_400Regular,
|
||||
Poppins_400Regular_Italic,
|
||||
Poppins_500Medium,
|
||||
Poppins_500Medium_Italic,
|
||||
Poppins_600SemiBold,
|
||||
Poppins_600SemiBold_Italic,
|
||||
Poppins_700Bold,
|
||||
Poppins_700Bold_Italic,
|
||||
Poppins_800ExtraBold,
|
||||
Poppins_800ExtraBold_Italic,
|
||||
Poppins_900Black,
|
||||
Poppins_900Black_Italic,
|
||||
} from "@expo-google-fonts/poppins";
|
||||
import { Stack } from "expo-router";
|
||||
import * as SplashScreen from "expo-splash-screen";
|
||||
import "react-native-reanimated";
|
||||
import { AuthContextProvider } from "@/contexts/AuthContext";
|
||||
import { QueryClient, QueryClientProvider } from "react-query";
|
||||
import {
|
||||
ThemeManager,
|
||||
Typography,
|
||||
Toast,
|
||||
TextProps,
|
||||
} from "react-native-ui-lib";
|
||||
import functions from "@react-native-firebase/functions";
|
||||
import auth from "@react-native-firebase/auth";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
if (__DEV__) {
|
||||
functions().useEmulator("localhost", 5001);
|
||||
firestore().useEmulator("localhost", 5471);
|
||||
auth().useEmulator("http://localhost:9099");
|
||||
}
|
||||
|
||||
type TextStyleBase =
|
||||
| "text10"
|
||||
| "text20"
|
||||
| "text30"
|
||||
| "text40"
|
||||
| "text50"
|
||||
| "text60"
|
||||
| "text70"
|
||||
| "text80"
|
||||
| "text90"
|
||||
| "text100";
|
||||
type TextStyleModifier = "R" | "M" | "BO" | "H" | "BL" | "L";
|
||||
type TextStyle = TextStyleBase | `${TextStyleBase}${TextStyleModifier}`;
|
||||
|
||||
type TextStyleProps = {
|
||||
[K in TextStyle]?: boolean;
|
||||
};
|
||||
|
||||
type ExtendedTextProps = TextProps & TextStyleProps;
|
||||
|
||||
interface FontStyle {
|
||||
fontFamily: string;
|
||||
fontSize: number;
|
||||
}
|
||||
|
||||
const getManropeFontStyle = (style: TextStyle): FontStyle => {
|
||||
let fontFamily: string;
|
||||
let fontSize: number;
|
||||
|
||||
if (style.includes("L") || style.includes("BL"))
|
||||
fontFamily = "Manrope_300Light";
|
||||
else if (style.includes("R")) fontFamily = "Manrope_400Regular";
|
||||
else if (style.includes("M")) fontFamily = "Manrope_500Medium";
|
||||
else if (style.includes("BO") || style.includes("H"))
|
||||
fontFamily = "Manrope_700Bold";
|
||||
else {
|
||||
const baseStyle = style.slice(0, 6) as TextStyleBase;
|
||||
switch (baseStyle) {
|
||||
case "text10":
|
||||
case "text20":
|
||||
fontFamily = "Manrope_700Bold";
|
||||
break;
|
||||
case "text30":
|
||||
case "text40":
|
||||
fontFamily = "Manrope_600SemiBold";
|
||||
break;
|
||||
case "text50":
|
||||
fontFamily = "Manrope_400Regular";
|
||||
break;
|
||||
default:
|
||||
fontFamily = "Manrope_300Light";
|
||||
}
|
||||
}
|
||||
|
||||
switch (style.slice(0, 6) as TextStyleBase) {
|
||||
case "text10":
|
||||
fontSize = 64;
|
||||
break;
|
||||
case "text20":
|
||||
fontSize = 50;
|
||||
break;
|
||||
case "text30":
|
||||
fontSize = 36;
|
||||
break;
|
||||
case "text40":
|
||||
fontSize = 28;
|
||||
break;
|
||||
case "text50":
|
||||
fontSize = 24;
|
||||
break;
|
||||
case "text60":
|
||||
fontSize = 20;
|
||||
break;
|
||||
case "text70":
|
||||
fontSize = 16;
|
||||
break;
|
||||
case "text80":
|
||||
fontSize = 14;
|
||||
break;
|
||||
case "text90":
|
||||
fontSize = 12;
|
||||
break;
|
||||
case "text100":
|
||||
fontSize = 10;
|
||||
break;
|
||||
default:
|
||||
fontSize = 16;
|
||||
}
|
||||
|
||||
return { fontFamily, fontSize };
|
||||
};
|
||||
|
||||
export default function RootLayout() {
|
||||
const [loaded] = useFonts({
|
||||
Manrope_200ExtraLight,
|
||||
Manrope_300Light,
|
||||
Manrope_400Regular,
|
||||
@ -8,25 +172,20 @@ import {
|
||||
Manrope_600SemiBold,
|
||||
Manrope_700Bold,
|
||||
Manrope_800ExtraBold,
|
||||
useFonts,
|
||||
} from "@expo-google-fonts/manrope";
|
||||
import {
|
||||
PlusJakartaSans_200ExtraLight,
|
||||
PlusJakartaSans_200ExtraLight_Italic,
|
||||
PlusJakartaSans_300Light,
|
||||
PlusJakartaSans_300Light_Italic,
|
||||
PlusJakartaSans_400Regular,
|
||||
PlusJakartaSans_400Regular_Italic,
|
||||
PlusJakartaSans_500Medium,
|
||||
PlusJakartaSans_500Medium_Italic,
|
||||
PlusJakartaSans_600SemiBold,
|
||||
PlusJakartaSans_600SemiBold_Italic,
|
||||
PlusJakartaSans_700Bold,
|
||||
PlusJakartaSans_700Bold_Italic,
|
||||
PlusJakartaSans_800ExtraBold,
|
||||
PlusJakartaSans_200ExtraLight_Italic,
|
||||
PlusJakartaSans_300Light_Italic,
|
||||
PlusJakartaSans_400Regular_Italic,
|
||||
PlusJakartaSans_500Medium_Italic,
|
||||
PlusJakartaSans_600SemiBold_Italic,
|
||||
PlusJakartaSans_700Bold_Italic,
|
||||
PlusJakartaSans_800ExtraBold_Italic,
|
||||
} from "@expo-google-fonts/plus-jakarta-sans";
|
||||
import {
|
||||
Poppins_100Thin,
|
||||
Poppins_100Thin_Italic,
|
||||
Poppins_200ExtraLight,
|
||||
@ -45,234 +204,72 @@ import {
|
||||
Poppins_800ExtraBold_Italic,
|
||||
Poppins_900Black,
|
||||
Poppins_900Black_Italic,
|
||||
} from "@expo-google-fonts/poppins";
|
||||
import {Stack} from "expo-router";
|
||||
import * as SplashScreen from "expo-splash-screen";
|
||||
import "react-native-reanimated";
|
||||
import {AuthContextProvider} from "@/contexts/AuthContext";
|
||||
import {QueryClient, QueryClientProvider} from "react-query";
|
||||
import {TextProps, ThemeManager, Toast, Typography,} from "react-native-ui-lib";
|
||||
import {Platform} from 'react-native';
|
||||
import KeyboardManager from 'react-native-keyboard-manager';
|
||||
import {enableScreens} from 'react-native-screens';
|
||||
});
|
||||
|
||||
enableScreens(true)
|
||||
useEffect(() => {
|
||||
if (loaded) {
|
||||
SplashScreen.hideAsync();
|
||||
|
||||
SplashScreen.preventAutoHideAsync();
|
||||
const typographies: Partial<Record<TextStyle, FontStyle>> = {};
|
||||
(
|
||||
[
|
||||
"text10",
|
||||
"text20",
|
||||
"text30",
|
||||
"text40",
|
||||
"text50",
|
||||
"text60",
|
||||
"text70",
|
||||
"text80",
|
||||
"text90",
|
||||
"text100",
|
||||
] as const
|
||||
).forEach((baseStyle) => {
|
||||
typographies[baseStyle] = getManropeFontStyle(baseStyle);
|
||||
(["R", "M", "BO", "H", "BL", "L"] as const).forEach((modifier) => {
|
||||
const style = `${baseStyle}${modifier}` as TextStyle;
|
||||
typographies[style] = getManropeFontStyle(style);
|
||||
});
|
||||
});
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
Typography.loadTypographies(typographies);
|
||||
|
||||
ThemeManager.setComponentTheme(
|
||||
"Text",
|
||||
(props: ExtendedTextProps, context: unknown) => {
|
||||
const textStyle = (
|
||||
Object.keys(props) as Array<keyof ExtendedTextProps>
|
||||
).find((key) => typographies[key as TextStyle]) as
|
||||
| TextStyle
|
||||
| undefined;
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
KeyboardManager.setEnable(true);
|
||||
KeyboardManager.setToolbarPreviousNextButtonEnable(true);
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
// functions().useEmulator("localhost", 5001);
|
||||
// firestore().useEmulator("localhost", 5471);
|
||||
// auth().useEmulator("http://localhost:9099");
|
||||
}
|
||||
|
||||
type TextStyleBase =
|
||||
| "text10"
|
||||
| "text20"
|
||||
| "text30"
|
||||
| "text40"
|
||||
| "text50"
|
||||
| "text60"
|
||||
| "text70"
|
||||
| "text80"
|
||||
| "text90"
|
||||
| "text100";
|
||||
type TextStyleModifier = "R" | "M" | "BO" | "H" | "BL" | "L";
|
||||
type TextStyle = TextStyleBase | `${TextStyleBase}${TextStyleModifier}`;
|
||||
|
||||
type TextStyleProps = {
|
||||
[K in TextStyle]?: boolean;
|
||||
};
|
||||
|
||||
type ExtendedTextProps = TextProps & TextStyleProps;
|
||||
|
||||
interface FontStyle {
|
||||
fontFamily: string;
|
||||
fontSize: number;
|
||||
}
|
||||
|
||||
const getManropeFontStyle = (style: TextStyle): FontStyle => {
|
||||
let fontFamily: string;
|
||||
let fontSize: number;
|
||||
|
||||
if (style.includes("L") || style.includes("BL"))
|
||||
fontFamily = "Manrope_300Light";
|
||||
else if (style.includes("R")) fontFamily = "Manrope_400Regular";
|
||||
else if (style.includes("M")) fontFamily = "Manrope_500Medium";
|
||||
else if (style.includes("BO") || style.includes("H"))
|
||||
fontFamily = "Manrope_700Bold";
|
||||
else {
|
||||
const baseStyle = style.slice(0, 6) as TextStyleBase;
|
||||
switch (baseStyle) {
|
||||
case "text10":
|
||||
case "text20":
|
||||
fontFamily = "Manrope_700Bold";
|
||||
break;
|
||||
case "text30":
|
||||
case "text40":
|
||||
fontFamily = "Manrope_600SemiBold";
|
||||
break;
|
||||
case "text50":
|
||||
fontFamily = "Manrope_400Regular";
|
||||
break;
|
||||
default:
|
||||
fontFamily = "Manrope_300Light";
|
||||
return {
|
||||
style: [
|
||||
Typography.text50,
|
||||
textStyle ? typographies[textStyle] : undefined,
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
}, [loaded]);
|
||||
|
||||
switch (style.slice(0, 6) as TextStyleBase) {
|
||||
case "text10":
|
||||
fontSize = 64;
|
||||
break;
|
||||
case "text20":
|
||||
fontSize = 50;
|
||||
break;
|
||||
case "text30":
|
||||
fontSize = 36;
|
||||
break;
|
||||
case "text40":
|
||||
fontSize = 28;
|
||||
break;
|
||||
case "text50":
|
||||
fontSize = 24;
|
||||
break;
|
||||
case "text60":
|
||||
fontSize = 20;
|
||||
break;
|
||||
case "text70":
|
||||
fontSize = 16;
|
||||
break;
|
||||
case "text80":
|
||||
fontSize = 14;
|
||||
break;
|
||||
case "text90":
|
||||
fontSize = 12;
|
||||
break;
|
||||
case "text100":
|
||||
fontSize = 10;
|
||||
break;
|
||||
default:
|
||||
fontSize = 16;
|
||||
}
|
||||
if (!loaded) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {fontFamily, fontSize};
|
||||
};
|
||||
|
||||
export default function RootLayout() {
|
||||
const [loaded] = useFonts({
|
||||
Manrope_200ExtraLight,
|
||||
Manrope_300Light,
|
||||
Manrope_400Regular,
|
||||
Manrope_500Medium,
|
||||
Manrope_600SemiBold,
|
||||
Manrope_700Bold,
|
||||
Manrope_800ExtraBold,
|
||||
PlusJakartaSans_200ExtraLight,
|
||||
PlusJakartaSans_300Light,
|
||||
PlusJakartaSans_400Regular,
|
||||
PlusJakartaSans_500Medium,
|
||||
PlusJakartaSans_600SemiBold,
|
||||
PlusJakartaSans_700Bold,
|
||||
PlusJakartaSans_800ExtraBold,
|
||||
PlusJakartaSans_200ExtraLight_Italic,
|
||||
PlusJakartaSans_300Light_Italic,
|
||||
PlusJakartaSans_400Regular_Italic,
|
||||
PlusJakartaSans_500Medium_Italic,
|
||||
PlusJakartaSans_600SemiBold_Italic,
|
||||
PlusJakartaSans_700Bold_Italic,
|
||||
PlusJakartaSans_800ExtraBold_Italic,
|
||||
Poppins_100Thin,
|
||||
Poppins_100Thin_Italic,
|
||||
Poppins_200ExtraLight,
|
||||
Poppins_200ExtraLight_Italic,
|
||||
Poppins_300Light,
|
||||
Poppins_300Light_Italic,
|
||||
Poppins_400Regular,
|
||||
Poppins_400Regular_Italic,
|
||||
Poppins_500Medium,
|
||||
Poppins_500Medium_Italic,
|
||||
Poppins_600SemiBold,
|
||||
Poppins_600SemiBold_Italic,
|
||||
Poppins_700Bold,
|
||||
Poppins_700Bold_Italic,
|
||||
Poppins_800ExtraBold,
|
||||
Poppins_800ExtraBold_Italic,
|
||||
Poppins_900Black,
|
||||
Poppins_900Black_Italic,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (loaded) {
|
||||
SplashScreen.hideAsync();
|
||||
|
||||
const typographies: Partial<Record<TextStyle, FontStyle>> = {};
|
||||
(
|
||||
[
|
||||
"text10",
|
||||
"text20",
|
||||
"text30",
|
||||
"text40",
|
||||
"text50",
|
||||
"text60",
|
||||
"text70",
|
||||
"text80",
|
||||
"text90",
|
||||
"text100",
|
||||
] as const
|
||||
).forEach((baseStyle) => {
|
||||
typographies[baseStyle] = getManropeFontStyle(baseStyle);
|
||||
(["R", "M", "BO", "H", "BL", "L"] as const).forEach((modifier) => {
|
||||
const style = `${baseStyle}${modifier}` as TextStyle;
|
||||
typographies[style] = getManropeFontStyle(style);
|
||||
});
|
||||
});
|
||||
|
||||
Typography.loadTypographies(typographies);
|
||||
|
||||
ThemeManager.setComponentTheme(
|
||||
"Text",
|
||||
(props: ExtendedTextProps) => {
|
||||
const textStyle = (
|
||||
Object.keys(props) as Array<keyof ExtendedTextProps>
|
||||
).find((key) => typographies[key as TextStyle]) as
|
||||
| TextStyle
|
||||
| undefined;
|
||||
|
||||
return {
|
||||
style: [
|
||||
Typography.text50,
|
||||
textStyle ? typographies[textStyle] : undefined,
|
||||
],
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
}, [loaded]);
|
||||
|
||||
if (!loaded) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AuthContextProvider>
|
||||
<ThemeProvider value={DefaultTheme}>
|
||||
<Stack>
|
||||
<Stack.Screen name="(auth)" options={{headerShown: false}}/>
|
||||
<Stack.Screen name="(unauth)" options={{headerShown: false}}/>
|
||||
<Stack.Screen name="+not-found"/>
|
||||
</Stack>
|
||||
<Toast/>
|
||||
</ThemeProvider>
|
||||
</AuthContextProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AuthContextProvider>
|
||||
<ThemeProvider value={DefaultTheme}>
|
||||
<Stack>
|
||||
<Stack.Screen name="(auth)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="(unauth)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="+not-found" />
|
||||
</Stack>
|
||||
<Toast />
|
||||
</ThemeProvider>
|
||||
</AuthContextProvider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
BIN
assets/images/splash-clock.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 46 KiB |
@ -1,19 +0,0 @@
|
||||
import * as React from "react"
|
||||
import Svg, { SvgProps, Path } from "react-native-svg"
|
||||
const ArrowRightIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={9}
|
||||
height={15}
|
||||
viewBox="0 0 9 15"
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke="#ACACAC"
|
||||
strokeLinecap="round"
|
||||
strokeWidth={2}
|
||||
d="M1.272 1.803 7.16 7.69a.16.16 0 0 1 0 .226l-5.887 5.887"
|
||||
/>
|
||||
</Svg>
|
||||
)
|
||||
export default ArrowRightIcon
|
||||
@ -4,7 +4,6 @@ const CalendarIcon: React.FC<SvgProps> = (props) => (
|
||||
<Svg
|
||||
width={props.width || 21}
|
||||
height={props.height || 21}
|
||||
viewBox="0 0 21 21"
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
import * as React from "react";
|
||||
import Svg, { SvgProps, Path } from "react-native-svg";
|
||||
const CircledXIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={props.width || 22}
|
||||
height={props.height || 21}
|
||||
viewBox="0 0 22 21"
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke={props.color || "#BBB"}
|
||||
d="M11 20.5c5.523 0 10-4.477 10-10S16.523.5 11 .5 1 4.977 1 10.5s4.477 10 10 10Z"
|
||||
/>
|
||||
<Path
|
||||
stroke={props.color || "#BBB"}
|
||||
strokeLinecap="round"
|
||||
d="m13.75 7.75-5.5 5.5m0-5.5 5.5 5.5"
|
||||
/>
|
||||
</Svg>
|
||||
);
|
||||
export default CircledXIcon;
|
||||
@ -1,20 +0,0 @@
|
||||
import * as React from "react"
|
||||
import Svg, { SvgProps, Path } from "react-native-svg"
|
||||
const ClockOIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={props.height || 22}
|
||||
height={props.height || 22}
|
||||
viewBox="0 0 22 22"
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke={props.color || "#919191"}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M11 5.444V11l1.667 2.778M21 11c0 5.523-4.477 10-10 10S1 16.523 1 11 5.477 1 11 1s10 4.477 10 10Z"
|
||||
/>
|
||||
</Svg>
|
||||
)
|
||||
export default ClockOIcon
|
||||
@ -5,14 +5,13 @@ const CloseXIcon: React.FC<SvgProps> = (props) => (
|
||||
width={15}
|
||||
height={15}
|
||||
fill="none"
|
||||
viewBox="0 0 15 15"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke="#AAA"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={props.strokeWidth || 1.394}
|
||||
strokeWidth={1.394}
|
||||
d="m1.573 1.543 12.544 12.544M1.573 14.087 14.117 1.543"
|
||||
/>
|
||||
</Svg>
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
import * as React from "react";
|
||||
import Svg, { SvgProps, Path } from "react-native-svg";
|
||||
const DropdownIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={props.width || 15}
|
||||
height={props.height || 11}
|
||||
fill="none"
|
||||
viewBox="0 0 15 11"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke={props.color || "#FD1775"}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={props.strokeWidth || 1.393}
|
||||
d="M4.713 1.318h9.056m-9.056 4.18h9.056m-9.056 4.18h9.056M1.23 1.667h.697V.97H1.23v.696Zm0 4.18h.697V5.15H1.23v.696Zm0 4.18h.697V9.33H1.23v.696Z"
|
||||
/>
|
||||
</Svg>
|
||||
);
|
||||
export default DropdownIcon;
|
||||
@ -1,17 +0,0 @@
|
||||
import * as React from "react"
|
||||
import Svg, { SvgProps, Path } from "react-native-svg"
|
||||
const EmailIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={props.width || 20}
|
||||
height={props.height || 16}
|
||||
viewBox="0 0 20 16"
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
fill={props.color || "#fff"}
|
||||
d="M19.948 2.385a2.767 2.767 0 0 0-.76-1.422A2.768 2.768 0 0 0 17.225.15H2.774A2.772 2.772 0 0 0 0 2.925v10.15c0 .389.083.763.23 1.101a2.719 2.719 0 0 0 .774 1.035c.48.398 1.1.638 1.77.638h14.452a2.755 2.755 0 0 0 1.961-.813c.245-.245.447-.537.586-.86v-.002c.147-.338.227-.71.227-1.1V2.925c0-.182-.018-.363-.052-.539ZM1.817 1.967a1.34 1.34 0 0 1 .957-.397h14.452a1.335 1.335 0 0 1 1.079.54l-7.575 6.6a1.11 1.11 0 0 1-1.46 0L1.698 2.107c.034-.048.075-.095.119-.139Zm-.398 11.107V3.575l5.482 4.782-5.479 4.777c-.003-.018-.003-.039-.003-.06Zm15.807 1.355H2.774c-.245 0-.475-.064-.67-.178l5.78-5.037.54.47a2.406 2.406 0 0 0 3.155 0l.54-.47 5.778 5.037a1.338 1.338 0 0 1-.671.178Zm1.355-1.354c0 .02 0 .04-.003.059L13.1 8.36l5.48-4.782v9.497Z"
|
||||
/>
|
||||
</Svg>
|
||||
)
|
||||
export default EmailIcon
|
||||
@ -1,20 +0,0 @@
|
||||
import * as React from "react"
|
||||
import Svg, { SvgProps, Path } from "react-native-svg"
|
||||
const FeedbackNavIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={25}
|
||||
height={25}
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke="#ea156d"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={1.5}
|
||||
d="M10.5 21H4a7.001 7.001 0 0 1 6-6.93m6.498 2.142c-.7-.78-1.867-.989-2.744-.275-.877.713-1 1.906-.311 2.75.388.476 1.312 1.311 2.042 1.948.347.302.52.453.73.515.178.053.387.053.566 0 .21-.061.382-.213.729-.515.73-.637 1.654-1.472 2.043-1.948.688-.844.58-2.044-.312-2.75-.892-.706-2.044-.504-2.743.275ZM15 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z"
|
||||
/>
|
||||
</Svg>
|
||||
)
|
||||
export default FeedbackNavIcon
|
||||
@ -7,8 +7,8 @@ interface MenuIconProps extends SvgProps {
|
||||
|
||||
const MenuIcon: React.FC<MenuIconProps> = (props) => (
|
||||
<Svg
|
||||
width={props.width || 24}
|
||||
height={props.height || 16}
|
||||
width={24}
|
||||
height={16}
|
||||
viewBox="0 0 24 16"
|
||||
fill="none"
|
||||
{...props}
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
import * as React from "react";
|
||||
import Svg, { Path, SvgProps } from "react-native-svg";
|
||||
import * as React from "react"
|
||||
import Svg, { Path, SvgProps } from "react-native-svg"
|
||||
const NavBrainDumpIcon: React.FC<SvgProps> = (props) => (
|
||||
<Svg
|
||||
width={props.width || 22}
|
||||
height={props.height || 28}
|
||||
viewBox="0 0 22 28"
|
||||
width={22}
|
||||
height={28}
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke={props.color || "#F90"}
|
||||
stroke="#F90"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeMiterlimit={10}
|
||||
@ -17,7 +16,7 @@ const NavBrainDumpIcon: React.FC<SvgProps> = (props) => (
|
||||
d="M21.1.859H3.994C2.284.859.976 2.167.976 3.877c0 1.71 1.308 3.019 3.018 3.019H21.1V27.02"
|
||||
/>
|
||||
<Path
|
||||
stroke={props.color || "#F90"}
|
||||
stroke="#F90"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeMiterlimit={10}
|
||||
@ -25,7 +24,7 @@ const NavBrainDumpIcon: React.FC<SvgProps> = (props) => (
|
||||
d="M21.1 27.021H3.994c-1.71 0-3.018-1.308-3.018-3.018V3.878M21.097 3.878H3.991"
|
||||
/>
|
||||
<Path
|
||||
stroke={props.color || "#F90"}
|
||||
stroke="#F90"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeMiterlimit={10}
|
||||
@ -33,5 +32,5 @@ const NavBrainDumpIcon: React.FC<SvgProps> = (props) => (
|
||||
d="M6.007 6.897v12.075l3.019-1.006 3.018 1.006V6.897"
|
||||
/>
|
||||
</Svg>
|
||||
);
|
||||
export default NavBrainDumpIcon;
|
||||
)
|
||||
export default NavBrainDumpIcon
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import * as React from "react";
|
||||
import Svg, { Path, SvgProps } from "react-native-svg";
|
||||
import * as React from "react"
|
||||
import Svg, { Path, SvgProps } from "react-native-svg"
|
||||
const NavCalendarIcon: React.FC<SvgProps> = (props) => (
|
||||
<Svg
|
||||
width={props.width || 28}
|
||||
height={props.height || 28}
|
||||
width={28}
|
||||
height={28}
|
||||
viewBox="0 0 28 28"
|
||||
fill="none"
|
||||
{...props}
|
||||
@ -16,5 +16,5 @@ const NavCalendarIcon: React.FC<SvgProps> = (props) => (
|
||||
d="M1.825 10.075h25.043m-5.565 5.567L7.39 15.64m4.638 5.566H7.39m0-19.478V4.51m13.913-2.782V4.51M6.277 26.77h16.139c1.558 0 2.337 0 2.933-.303.523-.267.949-.692 1.216-1.216.303-.595.303-1.375.303-2.933V8.962c0-1.558 0-2.337-.303-2.933a2.782 2.782 0 0 0-1.216-1.216c-.596-.303-1.375-.303-2.933-.303H6.277c-1.558 0-2.337 0-2.933.303-.523.267-.949.693-1.216 1.216-.303.596-.303 1.375-.303 2.933v13.356c0 1.558 0 2.338.303 2.933.267.523.693.95 1.216 1.216.596.303 1.375.303 2.933.303Z"
|
||||
/>
|
||||
</Svg>
|
||||
);
|
||||
export default NavCalendarIcon;
|
||||
)
|
||||
export default NavCalendarIcon
|
||||
|
||||
@ -2,18 +2,17 @@ import * as React from "react";
|
||||
import Svg, { Path, SvgProps } from "react-native-svg";
|
||||
const NavGroceryIcon: React.FC<SvgProps> = (props) => (
|
||||
<Svg
|
||||
width={props.width || 29}
|
||||
height={props.width || 32}
|
||||
viewBox="0 0 29 32"
|
||||
width={29}
|
||||
height={32}
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
fill={props.color || "#50BE0C"}
|
||||
fill="#50BE0C"
|
||||
d="M27.8 12c-.888-2.27-2.662-4.14-4.983-4.956-2.518-.883-5.143-.382-7.636.307-.047-1.362.068-2.728.262-4.076.11-.761.634-2.335-.668-2.389-1.081-.045-1.084 1.402-1.19 2.14-.203 1.416-.323 2.85-.284 4.281-.599-.1-1.19-.322-1.787-.446a13.485 13.485 0 0 0-2.704-.3c-1.752 0-3.48.465-4.922 1.479C1.09 10.01 0 13.446.046 16.747c.052 3.575 1.263 6.99 3.3 9.905.899 1.288 1.932 2.522 3.21 3.451 1.241.903 2.628 1.325 4.133 1.54.64.093 1.29.096 1.927-.009.557-.09 1.078-.325 1.63-.419.417-.07 1.005.258 1.408.348a6.297 6.297 0 0 0 2.096.107c2.563-.292 4.594-1.449 6.28-3.387 3.71-4.264 5.921-10.791 3.77-16.284Zm-1.69 8.743c-.474 1.663-1.225 3.182-2.195 4.608-.86 1.263-1.855 2.514-3.131 3.377-1.172.79-2.76 1.223-4.173 1.093-.719-.065-1.373-.41-2.087-.478-.8-.076-1.538.352-2.318.459-3.064.416-5.485-1.665-7.146-3.972-2.04-2.831-3.249-6.214-3.134-9.732.106-3.223 1.643-6.55 4.998-7.432 1.678-.44 3.446-.188 5.099.238.715.183 1.454.48 2.196.52.572.066 1.2-.196 1.74-.344 3.233-.89 6.873-1.105 9.124 1.855 2.08 2.732 1.925 6.666 1.027 9.808Z"
|
||||
/>
|
||||
<Path
|
||||
fill={props.color || "#50BE0C"}
|
||||
fill="#50BE0C"
|
||||
d="M12 17.966c-.778.285-1.977.71-2.432 1.454.11-.183.221-.363-.002.002-.222.365-.113.186-.001.003-.668 1.099.272 2.53 1.547 2.347 1.258-.18 1.378-1.419 1.364-2.443a8.822 8.822 0 0 0-.095-1.282c-.043-.264-.157-.164-.382-.08ZM18.096 18.917c-.435-.304-.919-.542-1.405-.752-.118-.05-.698-.375-.832-.297.018-.01.036-.021 0 0-.036.023-.02.012-.001.001-.11.07-.096.609-.104.716a9.003 9.003 0 0 0-.01 1.534c.1 1.117 1.049 2.082 2.228 1.517 1.165-.558 1.095-2.04.124-2.719ZM12.223 3.815C12.343.28 8.347-.271 6.922.432c.371 4.075 3.48 4.164 5.301 3.383Z"
|
||||
/>
|
||||
</Svg>
|
||||
|
||||
@ -3,7 +3,7 @@ import Svg, { Path, SvgProps } from "react-native-svg"
|
||||
const NavToDosIcon: React.FC<SvgProps> = (props) => (
|
||||
<Svg
|
||||
width={props.width || 30}
|
||||
height={props.height || 30}
|
||||
height={props.width || 30}
|
||||
viewBox="0 0 30 30"
|
||||
fill="none"
|
||||
{...props}
|
||||
|
||||
@ -3,8 +3,8 @@ import Svg, { Path, LinearGradient, Stop, SvgProps } from "react-native-svg";
|
||||
|
||||
const OutlookIcon: React.FC<SvgProps> = (props) => (
|
||||
<Svg
|
||||
width={props.width || 34}
|
||||
height={props.height || 34}
|
||||
width={34}
|
||||
height={34}
|
||||
viewBox="0 0 48 48"
|
||||
{...props}
|
||||
>
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
import * as React from "react";
|
||||
import Svg, { SvgProps, Path } from "react-native-svg";
|
||||
const PlusIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={props.width || 14}
|
||||
height={props.height || 15}
|
||||
viewBox="0 0 14 15"
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke="#fff"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={2}
|
||||
d="M1 7.632h12m-6-6v12"
|
||||
/>
|
||||
</Svg>
|
||||
);
|
||||
export default PlusIcon;
|
||||
@ -1,20 +0,0 @@
|
||||
import * as React from "react"
|
||||
import Svg, { SvgProps, Path } from "react-native-svg"
|
||||
const QRIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={props.width || 19}
|
||||
height={props.height || 20}
|
||||
viewBox="0 0 19 20"
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke={props.color || "#fff"}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth={1.764}
|
||||
d="M5.086 10.441h4.41v4.41m-7.93-4.41h-.008m4.418 4.41h-.008m3.536 3.528h-.008m7.946-7.938h-.008m-15.876 4.41H2.88m9.702-4.41h1.764M1.557 18.38h4.41M9.497 1.621v5.292m4.939 11.466h1.587c.494 0 .741 0 .93-.096.166-.085.3-.22.385-.386.097-.188.097-.435.097-.93V15.38c0-.494 0-.74-.097-.93a.882.882 0 0 0-.385-.385c-.189-.096-.436-.096-.93-.096h-1.587c-.494 0-.741 0-.93.096a.881.881 0 0 0-.385.386c-.096.188-.096.435-.096.93v1.587c0 .494 0 .74.096.93.084.166.22.3.385.385.189.096.436.096.93.096Zm0-11.466h1.587c.494 0 .741 0 .93-.096.166-.085.3-.22.385-.385.097-.19.097-.436.097-.93V3.914c0-.494 0-.74-.097-.93a.882.882 0 0 0-.385-.385c-.189-.096-.436-.096-.93-.096h-1.587c-.494 0-.741 0-.93.096a.881.881 0 0 0-.385.386c-.096.188-.096.435-.096.93v1.587c0 .494 0 .74.096.93.084.165.22.3.385.385.189.096.436.096.93.096Zm-11.466 0h1.587c.494 0 .741 0 .93-.096.166-.085.3-.22.385-.385.097-.19.097-.436.097-.93V3.914c0-.494 0-.74-.097-.93a.882.882 0 0 0-.385-.385c-.189-.096-.436-.096-.93-.096H2.97c-.494 0-.741 0-.93.096a.882.882 0 0 0-.385.386c-.096.188-.096.435-.096.93v1.587c0 .494 0 .74.096.93.084.165.22.3.385.385.189.096.436.096.93.096Z"
|
||||
/>
|
||||
</Svg>
|
||||
)
|
||||
export default QRIcon
|
||||
@ -1,18 +0,0 @@
|
||||
import * as React from "react"
|
||||
import Svg, { SvgProps, Path } from "react-native-svg"
|
||||
const RepeatIcon = (props: SvgProps) => (
|
||||
<Svg
|
||||
width={props.height || 13}
|
||||
height={props.height || 13}
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
<Path
|
||||
stroke={props.color || "#858585"}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M1.158 7.197a5.42 5.42 0 0 1 9.58-4.103m0 0V1.099m0 1.995v.037H8.705m3.21 2.71a5.42 5.42 0 0 1-9.444 4.263m0 .001v-.198h2.033m-2.033.198v1.835"
|
||||
/>
|
||||
</Svg>
|
||||
)
|
||||
export default RepeatIcon
|
||||
@ -1,46 +0,0 @@
|
||||
import * as Calendar from 'expo-calendar';
|
||||
|
||||
export async function fetchiPhoneCalendarEvents(familyId, email, startDate, endDate) {
|
||||
try {
|
||||
const {granted} = await Calendar.requestCalendarPermissionsAsync();
|
||||
|
||||
if (!granted) {
|
||||
throw new Error("Calendar permission not granted");
|
||||
}
|
||||
|
||||
const defaultCalendarSource = await Calendar.getDefaultCalendarAsync();
|
||||
|
||||
if (!defaultCalendarSource) {
|
||||
throw new Error("No calendar found");
|
||||
}
|
||||
|
||||
const events = await Calendar.getEventsAsync(
|
||||
[defaultCalendarSource.id],
|
||||
startDate,
|
||||
endDate
|
||||
);
|
||||
|
||||
return events.map((event) => {
|
||||
let isAllDay = event.allDay || false;
|
||||
const startDateTime = new Date(event.startDate);
|
||||
let endDateTime = new Date(event.endDate);
|
||||
|
||||
if (isAllDay) {
|
||||
endDateTime = startDateTime
|
||||
}
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
title: event.title,
|
||||
startDate: startDateTime,
|
||||
endDate: endDateTime,
|
||||
allDay: isAllDay,
|
||||
familyId,
|
||||
email
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error fetching iPhone Calendar events: ", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
export async function fetchGoogleCalendarEvents(token, email, familyId, startDate, endDate) {
|
||||
export async function fetchGoogleCalendarEvents(token, startDate, endDate) {
|
||||
console.log(token);
|
||||
const response = await fetch(
|
||||
`https://www.googleapis.com/calendar/v3/calendars/primary/events?single_events=true&time_min=${startDate}&time_max=${endDate}`,
|
||||
{
|
||||
@ -8,9 +9,8 @@ export async function fetchGoogleCalendarEvents(token, email, familyId, startDat
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
console.log(data);
|
||||
const googleEvents = [];
|
||||
data.items?.forEach((item) => {
|
||||
let isAllDay = false;
|
||||
@ -41,15 +41,13 @@ export async function fetchGoogleCalendarEvents(token, email, familyId, startDat
|
||||
|
||||
const googleEvent = {
|
||||
id: item.id,
|
||||
title: item.summary ?? "",
|
||||
title: item.summary,
|
||||
startDate: startDateTime,
|
||||
endDate: endDateTime,
|
||||
allDay: isAllDay,
|
||||
familyId,
|
||||
email
|
||||
};
|
||||
googleEvents.push(googleEvent);
|
||||
});
|
||||
|
||||
return {googleEvents, success: response.ok};
|
||||
return googleEvents;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export async function fetchMicrosoftCalendarEvents(token, email, familyId, startDate, endDate) {
|
||||
export async function fetchMicrosoftCalendarEvents(token, startDate, endDate) {
|
||||
const response = await fetch(
|
||||
`https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=${startDate}&endDateTime=${endDate}`,
|
||||
{
|
||||
@ -34,8 +34,6 @@ export async function fetchMicrosoftCalendarEvents(token, email, familyId, start
|
||||
startDate: startDateTime,
|
||||
endDate: endDateTime,
|
||||
allDay: item.isAllDay,
|
||||
familyId,
|
||||
email
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
import { Text, TouchableOpacity, View } from "react-native-ui-lib";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { NavigationProp } from "@react-navigation/native";
|
||||
import view from "react-native-ui-lib/src/components/view";
|
||||
|
||||
interface ViewSwitchProps {
|
||||
navigation: NavigationProp<any>; // Adjust according to your navigation structure
|
||||
}
|
||||
|
||||
const ViewSwitch: React.FC<ViewSwitchProps> = ({ navigation }) => {
|
||||
const [pageIndex, setPageIndex] = useState<number>(navigation.getState().index);
|
||||
|
||||
useEffect(() => {
|
||||
setPageIndex(navigation.getState().index);
|
||||
}, [navigation.getState().index])
|
||||
|
||||
return (
|
||||
<View
|
||||
row
|
||||
spread
|
||||
style={{
|
||||
borderRadius: 30,
|
||||
backgroundColor: "#ebebeb",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
// iOS shadow
|
||||
shadowColor: "#000",
|
||||
shadowOffset: { width: 0, height: 0 },
|
||||
shadowOpacity: 0,
|
||||
shadowRadius: 0,
|
||||
// Android shadow (elevation)
|
||||
elevation: 0,
|
||||
}}
|
||||
centerV
|
||||
>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
navigation.navigate("calendar");
|
||||
}}
|
||||
>
|
||||
<View
|
||||
centerV
|
||||
centerH
|
||||
height={54}
|
||||
paddingH-15
|
||||
style={ pageIndex == 1 || pageIndex == 0 ? styles.switchBtnActive : styles.switchBtn}
|
||||
>
|
||||
<Text color={pageIndex == 1 || pageIndex == 0 ? "white" : "black"} style={styles.switchTxt}>
|
||||
Calendar
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
navigation.navigate("todos");
|
||||
}}
|
||||
>
|
||||
<View
|
||||
centerV
|
||||
centerH
|
||||
height={54}
|
||||
paddingH-15
|
||||
style={pageIndex == 6 ? styles.switchBtnActive : styles.switchBtn}
|
||||
>
|
||||
<Text color={pageIndex == 6 ? "white" : "black"} style={styles.switchTxt}>
|
||||
Chores
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default ViewSwitch;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
switchBtnActive: {
|
||||
backgroundColor: "#ea156c",
|
||||
borderRadius: 50,
|
||||
width: 110,
|
||||
},
|
||||
switchBtn: {
|
||||
backgroundColor: "#ebebeb",
|
||||
borderRadius: 50,
|
||||
width: 110,
|
||||
},
|
||||
switchTxt: {
|
||||
fontSize: 16,
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
},
|
||||
});
|
||||
@ -1,29 +0,0 @@
|
||||
import { View, Text } from "react-native-ui-lib";
|
||||
import React, { useEffect } from "react";
|
||||
import * as ScreenOrientation from "expo-screen-orientation";
|
||||
import { InnerCalendar } from "../../calendar/InnerCalendar";
|
||||
import TabletContainer from "../tablet_components/TabletContainer";
|
||||
|
||||
const TabletCalendarPage = () => {
|
||||
const lockScreenOrientation = async () => {
|
||||
await ScreenOrientation.lockAsync(
|
||||
ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
lockScreenOrientation();
|
||||
|
||||
return () => {
|
||||
ScreenOrientation.unlockAsync();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<TabletContainer>
|
||||
<InnerCalendar />
|
||||
</TabletContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default TabletCalendarPage;
|
||||
@ -1,271 +0,0 @@
|
||||
import { View, Text, TouchableOpacity, Icon } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import { useToDosContext } from "@/contexts/ToDosContext";
|
||||
import {
|
||||
addDays,
|
||||
format,
|
||||
isToday,
|
||||
isTomorrow,
|
||||
isWithinInterval,
|
||||
} from "date-fns";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||
import ToDoItem from "../../todos/ToDoItem";
|
||||
import { UserProfile } from "@/hooks/firebase/types/profileTypes";
|
||||
|
||||
const groupToDosByDate = (toDos: IToDo[]) => {
|
||||
let sortedTodos = toDos.sort((a, b) => a.date - b.date);
|
||||
return sortedTodos.reduce(
|
||||
(groups, toDo) => {
|
||||
let dateKey;
|
||||
let subDateKey;
|
||||
|
||||
const isNext7Days = (date: Date) => {
|
||||
const today = new Date();
|
||||
return isWithinInterval(date, { start: today, end: addDays(today, 7) });
|
||||
};
|
||||
|
||||
const isNext30Days = (date: Date) => {
|
||||
const today = new Date();
|
||||
return isWithinInterval(date, {
|
||||
start: today,
|
||||
end: addDays(today, 30),
|
||||
});
|
||||
};
|
||||
|
||||
if (toDo.date === null) {
|
||||
dateKey = "No Date";
|
||||
} else if (isToday(toDo.date)) {
|
||||
dateKey = "Today";
|
||||
} else if (isTomorrow(toDo.date)) {
|
||||
dateKey = "Tomorrow";
|
||||
} else if (isNext7Days(toDo.date)) {
|
||||
dateKey = "Next 7 Days";
|
||||
} else if (isNext30Days(toDo.date)) {
|
||||
dateKey = "Next 30 Days";
|
||||
subDateKey = format(toDo.date, "MMM d");
|
||||
} else {
|
||||
return groups;
|
||||
}
|
||||
|
||||
if (!groups[dateKey]) {
|
||||
groups[dateKey] = {
|
||||
items: [],
|
||||
subgroups: {},
|
||||
};
|
||||
}
|
||||
|
||||
if (dateKey === "Next 30 Days" && subDateKey) {
|
||||
if (!groups[dateKey].subgroups[subDateKey]) {
|
||||
groups[dateKey].subgroups[subDateKey] = [];
|
||||
}
|
||||
groups[dateKey].subgroups[subDateKey].push(toDo);
|
||||
} else {
|
||||
groups[dateKey].items.push(toDo);
|
||||
}
|
||||
|
||||
return groups;
|
||||
},
|
||||
{} as {
|
||||
[key: string]: {
|
||||
items: IToDo[];
|
||||
subgroups: { [key: string]: IToDo[] };
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const filterToDosByUser = (toDos: IToDo[], uid: string | undefined) => {
|
||||
if (!uid) return [];
|
||||
return toDos.filter((todo) =>
|
||||
todo.assignees?.includes(uid)
|
||||
);
|
||||
};
|
||||
|
||||
const SingleUserChoreList = ({ user }: { user: UserProfile }) => {
|
||||
const { toDos } = useToDosContext();
|
||||
const userTodos = filterToDosByUser(toDos, user.uid);
|
||||
const groupedToDos = groupToDosByDate(userTodos);
|
||||
|
||||
const [expandedGroups, setExpandedGroups] = useState<{
|
||||
[key: string]: boolean;
|
||||
}>({});
|
||||
|
||||
const [expandNoDate, setExpandNoDate] = useState<boolean>(true);
|
||||
|
||||
const toggleExpand = (dateKey: string) => {
|
||||
setExpandedGroups((prev) => ({
|
||||
...prev,
|
||||
[dateKey]: !prev[dateKey],
|
||||
}));
|
||||
};
|
||||
|
||||
const noDateToDos = groupedToDos["No Date"]?.items || [];
|
||||
const datedToDos = Object.keys(groupedToDos).filter(
|
||||
(key) => key !== "No Date"
|
||||
);
|
||||
|
||||
const renderTodoGroup = (dateKey: string) => {
|
||||
const isExpanded = expandedGroups[dateKey] || false;
|
||||
|
||||
if (dateKey === "Next 30 Days") {
|
||||
const subgroups = Object.entries(groupedToDos[dateKey].subgroups).sort(
|
||||
([dateA], [dateB]) => {
|
||||
const dateAObj = new Date(dateA);
|
||||
const dateBObj = new Date(dateB);
|
||||
return dateAObj.getTime() - dateBObj.getTime();
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<View key={dateKey}>
|
||||
<TouchableOpacity
|
||||
onPress={() => toggleExpand(dateKey)}
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 0,
|
||||
marginBottom: 4,
|
||||
marginTop: 15,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "Manrope_700Bold",
|
||||
fontSize: 15,
|
||||
color: "#484848",
|
||||
}}
|
||||
>
|
||||
{dateKey}
|
||||
</Text>
|
||||
<AntDesign
|
||||
name={isExpanded ? "caretdown" : "caretright"}
|
||||
size={24}
|
||||
color="#fd1575"
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
|
||||
{isExpanded &&
|
||||
subgroups.map(([subDate, items]) => {
|
||||
const sortedItems = [
|
||||
...items.filter((toDo) => !toDo.done),
|
||||
...items.filter((toDo) => toDo.done),
|
||||
];
|
||||
|
||||
return (
|
||||
<View key={subDate} marginT-15>
|
||||
<View
|
||||
style={{
|
||||
marginBottom: 8,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 14,
|
||||
color: "#919191",
|
||||
}}
|
||||
>
|
||||
{subDate}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{sortedItems.map((item) => (
|
||||
<ToDoItem key={item.id} item={item} is7Days={false} />
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const sortedToDos = [
|
||||
...groupedToDos[dateKey].items.filter((toDo) => !toDo.done),
|
||||
...groupedToDos[dateKey].items.filter((toDo) => toDo.done),
|
||||
];
|
||||
|
||||
return (
|
||||
<View key={dateKey}>
|
||||
<TouchableOpacity
|
||||
onPress={() => toggleExpand(dateKey)}
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 0,
|
||||
marginBottom: 4,
|
||||
marginTop: 15,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "Manrope_700Bold",
|
||||
fontSize: 15,
|
||||
color: "#484848",
|
||||
}}
|
||||
>
|
||||
{dateKey}
|
||||
</Text>
|
||||
<AntDesign
|
||||
name={isExpanded ? "caretdown" : "caretright"}
|
||||
size={24}
|
||||
color="#fd1575"
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
|
||||
{isExpanded &&
|
||||
sortedToDos.map((item) => (
|
||||
<ToDoItem
|
||||
key={item.id}
|
||||
item={item}
|
||||
is7Days={dateKey === "Next 7 Days"}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<View
|
||||
marginB-402
|
||||
marginT-10
|
||||
paddingH-10
|
||||
backgroundColor="#f9f8f7"
|
||||
style={{ minHeight: 800, borderRadius: 9.11 }}
|
||||
width={355}
|
||||
>
|
||||
{noDateToDos.length > 0 && (
|
||||
<View key="No Date">
|
||||
<View row spread paddingH-19 marginB-12>
|
||||
<Text
|
||||
text70
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
Unscheduled
|
||||
</Text>
|
||||
<AntDesign
|
||||
name={expandNoDate ? "caretdown" : "caretright"}
|
||||
size={24}
|
||||
color="#fd1575"
|
||||
onPress={() => {
|
||||
setExpandNoDate(!expandNoDate);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
{expandNoDate &&
|
||||
noDateToDos
|
||||
.sort((a, b) => Number(a.done) - Number(b.done))
|
||||
.map((item) => <ToDoItem key={item.id} item={item} />)}
|
||||
</View>
|
||||
)}
|
||||
|
||||
{datedToDos.map(renderTodoGroup)}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default SingleUserChoreList;
|
||||
@ -1,85 +0,0 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { View, Text } from "react-native-ui-lib";
|
||||
import * as ScreenOrientation from "expo-screen-orientation";
|
||||
import TabletContainer from "../tablet_components/TabletContainer";
|
||||
import ToDosPage from "../../todos/ToDosPage";
|
||||
import ToDosList from "../../todos/ToDosList";
|
||||
import SingleUserChoreList from "./SingleUserChoreList";
|
||||
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
|
||||
import { ImageBackground, StyleSheet } from "react-native";
|
||||
import { colorMap } from "@/constants/colorMap";
|
||||
import { ScrollView } from "react-native-gesture-handler";
|
||||
|
||||
const TabletChoresPage = () => {
|
||||
const { data: users } = useGetFamilyMembers();
|
||||
// Function to lock the screen orientation to landscape
|
||||
const lockScreenOrientation = async () => {
|
||||
await ScreenOrientation.lockAsync(
|
||||
ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
lockScreenOrientation(); // Lock orientation when the component mounts
|
||||
|
||||
return () => {
|
||||
// Optional: Unlock to default when the component unmounts
|
||||
ScreenOrientation.unlockAsync();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<TabletContainer>
|
||||
<ScrollView horizontal>
|
||||
<View row gap-25 padding-25>
|
||||
{users?.map((user, index) => (
|
||||
<View>
|
||||
<View row centerV>
|
||||
{user.pfp ? (
|
||||
<ImageBackground
|
||||
source={{ uri: user.pfp }}
|
||||
style={styles.pfp}
|
||||
borderRadius={13.33}
|
||||
/>
|
||||
) : (
|
||||
<View
|
||||
center
|
||||
style={styles.pfp}
|
||||
backgroundColor={user.eventColor || "#00a8b6"}
|
||||
>
|
||||
<Text color="white">
|
||||
{user.firstName.at(0)}
|
||||
{user.lastName.at(0)}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
<Text style={styles.name} marginL-15>
|
||||
{user.firstName}
|
||||
</Text>
|
||||
<Text style={[styles.name, { color: "#9b9b9b" }]} marginL-5>
|
||||
({user.userType})
|
||||
</Text>
|
||||
</View>
|
||||
<SingleUserChoreList user={user} />
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</TabletContainer>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
pfp: {
|
||||
width: 46.74,
|
||||
aspectRatio: 1,
|
||||
borderRadius: 13.33,
|
||||
},
|
||||
name: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 22.43,
|
||||
color: "#2c2c2c",
|
||||
},
|
||||
});
|
||||
|
||||
export default TabletChoresPage;
|
||||
@ -1,52 +0,0 @@
|
||||
import { View, Text, ViewProps } from "react-native-ui-lib";
|
||||
import React, { ReactNode } from "react";
|
||||
import { Dimensions, StyleSheet } from "react-native";
|
||||
import UsersList from "./UsersList";
|
||||
import { ScrollView } from "react-native-gesture-handler";
|
||||
|
||||
interface TabletContainerProps extends ViewProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
const { width, height } = Dimensions.get("window");
|
||||
|
||||
const TabletContainer: React.FC<TabletContainerProps> = ({
|
||||
children,
|
||||
...props
|
||||
}) => {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View row>
|
||||
<View style={styles.calendarContainer}>{children}</View>
|
||||
<View style={styles.profilesContainer}>
|
||||
<ScrollView>
|
||||
<UsersList />
|
||||
</ScrollView>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: "white",
|
||||
flex: 1,
|
||||
borderTopColor: "#a9a9a9",
|
||||
borderTopWidth: 1,
|
||||
},
|
||||
calendarContainer: {
|
||||
backgroundColor: "white",
|
||||
height: height,
|
||||
width: width * 0.89,
|
||||
},
|
||||
profilesContainer: {
|
||||
width: width * 0.11,
|
||||
height: height,
|
||||
borderLeftWidth: 1,
|
||||
borderLeftColor: "#a9a9a9",
|
||||
backgroundColor: "white",
|
||||
},
|
||||
});
|
||||
|
||||
export default TabletContainer;
|
||||
@ -1,67 +0,0 @@
|
||||
import { View, Text } from "react-native-ui-lib";
|
||||
import React from "react";
|
||||
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
|
||||
import { ImageBackground, StyleSheet } from "react-native";
|
||||
import { colorMap } from "@/constants/colorMap";
|
||||
|
||||
const UsersList = () => {
|
||||
const { data: familyMembers } = useGetFamilyMembers();
|
||||
|
||||
const capitalizeFirstLetter = (str: string) => {
|
||||
if (!str) return '';
|
||||
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
||||
};
|
||||
|
||||
return (
|
||||
<View centerH paddingT-10>
|
||||
{familyMembers?.map((member, index) => (
|
||||
<>
|
||||
{member.pfp ? (
|
||||
<ImageBackground
|
||||
key={index}
|
||||
source={{ uri: member.pfp }}
|
||||
style={styles.pfp}
|
||||
borderRadius={100}
|
||||
/>
|
||||
) : (
|
||||
<View
|
||||
key={index}
|
||||
style={styles.pfp}
|
||||
center
|
||||
backgroundColor={member.eventColor || colorMap.teal}
|
||||
children={
|
||||
<Text color="white">
|
||||
{member.firstName.at(0)}
|
||||
{member.lastName.at(0)}
|
||||
</Text>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<Text style={styles.fName}>{member.firstName}</Text>
|
||||
<Text style={styles.role}>{capitalizeFirstLetter(member.userType)}</Text>
|
||||
</>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
pfp: {
|
||||
aspectRatio: 1,
|
||||
width: 113,
|
||||
borderRadius: 100,
|
||||
marginBottom: 8,
|
||||
},
|
||||
fName: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 18.15,
|
||||
},
|
||||
role: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 12.95,
|
||||
color: "#9b9b9b",
|
||||
marginBottom: 20,
|
||||
},
|
||||
});
|
||||
|
||||
export default UsersList;
|
||||
@ -1,152 +1,101 @@
|
||||
import {Button, Dialog, TextField, TextFieldRef, TouchableOpacity, View,} from "react-native-ui-lib";
|
||||
import React, {useEffect, useRef, useState} from "react";
|
||||
import {PanningDirectionsEnum} from "react-native-ui-lib/src/incubator/panView";
|
||||
import {Dimensions, Platform, StyleSheet} from "react-native";
|
||||
|
||||
import { View, Text, Button, TextField } from "react-native-ui-lib";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Dialog } from "react-native-ui-lib";
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
||||
import CloseXIcon from "@/assets/svgs/CloseXIcon";
|
||||
import { Dimensions, StyleSheet } from "react-native";
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import {useBrainDumpContext} from "@/contexts/DumpContext";
|
||||
import KeyboardManager from "react-native-keyboard-manager";
|
||||
import MenuIcon from "@/assets/svgs/MenuIcon";
|
||||
import { useBrainDumpContext } from "@/contexts/DumpContext";
|
||||
|
||||
interface IAddBrainDumpProps {
|
||||
isVisible: boolean;
|
||||
setIsVisible: (value: boolean) => void;
|
||||
isVisible: boolean;
|
||||
setIsVisible: (value: boolean) => void;
|
||||
}
|
||||
|
||||
const AddBrainDump = ({
|
||||
addBrainDumpProps,
|
||||
}: {
|
||||
addBrainDumpProps: IAddBrainDumpProps;
|
||||
addBrainDumpProps,
|
||||
}: {
|
||||
addBrainDumpProps: IAddBrainDumpProps;
|
||||
}) => {
|
||||
const {addBrainDump} = useBrainDumpContext();
|
||||
const [dumpTitle, setDumpTitle] = useState<string>("");
|
||||
const [dumpDesc, setDumpDesc] = useState<string>("");
|
||||
const {width} = Dimensions.get("screen");
|
||||
|
||||
|
||||
// Refs for the two TextFields
|
||||
const descriptionRef = useRef<TextFieldRef>(null);
|
||||
const titleRef = useRef<TextFieldRef>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setDumpDesc("");
|
||||
setDumpTitle("");
|
||||
}, [addBrainDumpProps.isVisible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (addBrainDumpProps.isVisible) {
|
||||
setTimeout(() => {
|
||||
titleRef?.current?.focus()
|
||||
}, 500)
|
||||
}
|
||||
}, [addBrainDumpProps.isVisible]);
|
||||
const { addBrainDump } = useBrainDumpContext();
|
||||
const [dumpTitle, setDumpTitle] = useState<string>("");
|
||||
const [dumpDesc, setDumpDesc] = useState<string>("");
|
||||
const { width, height } = Dimensions.get("screen");
|
||||
|
||||
useEffect(() => {
|
||||
if (Platform.OS === "ios") KeyboardManager.setEnableAutoToolbar(false);
|
||||
}, []);
|
||||
setDumpDesc("");
|
||||
setDumpTitle("");
|
||||
}, [addBrainDumpProps.isVisible]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
height={"90%"}
|
||||
width={width}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
onDismiss={() => addBrainDumpProps.setIsVisible(false)}
|
||||
containerStyle={styles.dialogContainer}
|
||||
visible={addBrainDumpProps.isVisible}
|
||||
>
|
||||
<View row spread style={styles.topBtns} marginB-20>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
label="Cancel"
|
||||
style={styles.topBtn}
|
||||
onPress={() => {
|
||||
addBrainDumpProps.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
<TouchableOpacity onPress={() => addBrainDumpProps.setIsVisible(false)}>
|
||||
<DropModalIcon style={{marginTop: 15}}/>
|
||||
</TouchableOpacity>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
label="Save"
|
||||
style={styles.topBtn}
|
||||
onPress={() => {
|
||||
addBrainDump({
|
||||
|
||||
id: 99,
|
||||
|
||||
title: dumpTitle.trimEnd().trimStart(),
|
||||
|
||||
description: dumpDesc.trimEnd().trimStart(),
|
||||
|
||||
});
|
||||
addBrainDumpProps.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View marginH-20>
|
||||
<TextField
|
||||
value={dumpTitle}
|
||||
ref={titleRef}
|
||||
placeholder="Set Title"
|
||||
text60R
|
||||
onChangeText={(text) => {
|
||||
setDumpTitle(text);
|
||||
}}
|
||||
onSubmitEditing={() => {
|
||||
// Move focus to the description field
|
||||
descriptionRef.current?.focus();
|
||||
}}
|
||||
style={styles.title}
|
||||
blurOnSubmit={false} // Keep the keyboard open when moving focus
|
||||
returnKeyType="next"
|
||||
/>
|
||||
<View height={2} backgroundColor="#b3b3b3" width={"100%"} marginB-20/>
|
||||
<TextField
|
||||
ref={descriptionRef}
|
||||
value={dumpDesc}
|
||||
placeholder="Write Description"
|
||||
text70
|
||||
onChangeText={(text) => {
|
||||
setDumpDesc(text);
|
||||
}}
|
||||
style={styles.description}
|
||||
multiline
|
||||
numberOfLines={4}
|
||||
maxLength={255}
|
||||
onEndEditing={() => {
|
||||
descriptionRef.current?.blur();
|
||||
}}
|
||||
returnKeyType="done"
|
||||
/>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
height={"90%"}
|
||||
width={width}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
onDismiss={() => addBrainDumpProps.setIsVisible(false)}
|
||||
containerStyle={{
|
||||
borderTopRightRadius: 15,
|
||||
borderTopLeftRadius: 15,
|
||||
backgroundColor: "white",
|
||||
padding: 0,
|
||||
paddingTop: 3,
|
||||
margin: 0,
|
||||
}}
|
||||
visible={addBrainDumpProps.isVisible}
|
||||
>
|
||||
<View row spread style={styles.topBtns} marginB-20>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
label="Cancel"
|
||||
style={styles.topBtn}
|
||||
onPress={() => {
|
||||
addBrainDumpProps.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
<DropModalIcon
|
||||
style={{ marginTop: 15 }}
|
||||
onPress={() => addBrainDumpProps.setIsVisible(false)}
|
||||
/>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
label="Save"
|
||||
style={styles.topBtn}
|
||||
onPress={() => {
|
||||
addBrainDump({ id: 99, title: dumpTitle, description: dumpDesc });
|
||||
addBrainDumpProps.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View marginH-20>
|
||||
<TextField
|
||||
value={dumpTitle}
|
||||
placeholder="Set Title"
|
||||
text60R
|
||||
onChangeText={(text) => {
|
||||
setDumpTitle(text);
|
||||
}}
|
||||
/>
|
||||
<View height={2} backgroundColor="#b3b3b3" width={"100%"} marginB-20 />
|
||||
<TextField
|
||||
value={dumpDesc}
|
||||
placeholder="Write Description"
|
||||
text70
|
||||
onChangeText={(text) => {
|
||||
setDumpDesc(text);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
dialogContainer: {
|
||||
borderTopRightRadius: 15,
|
||||
borderTopLeftRadius: 15,
|
||||
backgroundColor: "white",
|
||||
padding: 0,
|
||||
paddingTop: 3,
|
||||
margin: 0,
|
||||
},
|
||||
topBtns: {},
|
||||
topBtn: {
|
||||
backgroundColor: "white",
|
||||
color: "#05a8b6",
|
||||
},
|
||||
title: {
|
||||
fontSize: 22,
|
||||
fontFamily: "Manrope_500Medium",
|
||||
},
|
||||
description: {
|
||||
fontFamily: "Manrope_400Regular",
|
||||
fontSize: 14,
|
||||
textAlignVertical: "top",
|
||||
},
|
||||
});
|
||||
|
||||
export default AddBrainDump;
|
||||
|
||||
@ -1,82 +0,0 @@
|
||||
import React from "react";
|
||||
import { Dialog, Button, Text, View } from "react-native-ui-lib";
|
||||
import { StyleSheet } from "react-native";
|
||||
|
||||
interface BrainDumpDialogProps {
|
||||
visible: boolean;
|
||||
title: string;
|
||||
onDismiss: () => void;
|
||||
onConfirm: () => void;
|
||||
}
|
||||
|
||||
const BrainDumpDialog: React.FC<BrainDumpDialogProps> = ({
|
||||
visible,
|
||||
title,
|
||||
onDismiss,
|
||||
onConfirm,
|
||||
}) => {
|
||||
return (
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onDismiss={onDismiss}
|
||||
containerStyle={styles.dialog}
|
||||
>
|
||||
<Text center style={styles.title}>
|
||||
Delete Note
|
||||
</Text>
|
||||
<View center>
|
||||
<Text style={styles.text} center>
|
||||
Are you sure you want to delete the {"\n"}
|
||||
<Text style={{ fontSize: 16, fontFamily: "PlusJakartaSans_700Bold" }}>
|
||||
{title}
|
||||
</Text>{" "}
|
||||
Note?
|
||||
</Text>
|
||||
</View>
|
||||
<View row right gap-8>
|
||||
<Button
|
||||
label="Cancel"
|
||||
onPress={onDismiss}
|
||||
style={styles.cancelBtn}
|
||||
color="#999999"
|
||||
labelStyle={{ fontFamily: "Poppins_500Medium", fontSize: 13.53 }}
|
||||
/>
|
||||
<Button
|
||||
label="Yes"
|
||||
onPress={onConfirm}
|
||||
style={styles.confirmBtn}
|
||||
labelStyle={{ fontFamily: "PlusJakartaSans_500Medium" }}
|
||||
/>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
// Empty stylesheet for future styles
|
||||
const styles = StyleSheet.create({
|
||||
confirmBtn: {
|
||||
backgroundColor: "#ea156d",
|
||||
},
|
||||
cancelBtn: {
|
||||
backgroundColor: "white",
|
||||
},
|
||||
dialog: {
|
||||
backgroundColor: "white",
|
||||
paddingHorizontal: 25,
|
||||
paddingTop: 35,
|
||||
paddingBottom: 17,
|
||||
borderRadius: 20,
|
||||
},
|
||||
title: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 22,
|
||||
marginBottom: 20,
|
||||
},
|
||||
text: {
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
marginBottom: 25,
|
||||
},
|
||||
});
|
||||
|
||||
export default BrainDumpDialog;
|
||||
@ -1,120 +1,123 @@
|
||||
import {Dimensions, ScrollView, StyleSheet} from "react-native";
|
||||
import React, {useState} from "react";
|
||||
import {Button, Text, TextField, View} from "react-native-ui-lib";
|
||||
import { Dimensions, ScrollView } from "react-native";
|
||||
import React, { useState } from "react";
|
||||
import { View, Text, Button } from "react-native-ui-lib";
|
||||
import DumpList from "./DumpList";
|
||||
import HeaderTemplate from "@/components/shared/HeaderTemplate";
|
||||
import {Feather, MaterialIcons} from "@expo/vector-icons";
|
||||
import { TextField } from "react-native-ui-lib";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { Feather, MaterialIcons } from "@expo/vector-icons";
|
||||
import { TextInput } from "react-native-gesture-handler";
|
||||
import AddBrainDump from "./AddBrainDump";
|
||||
import LinearGradient from "react-native-linear-gradient";
|
||||
import PlusIcon from "@/assets/svgs/PlusIcon";
|
||||
|
||||
const BrainDumpPage = () => {
|
||||
const [searchText, setSearchText] = useState<string>("");
|
||||
const [isAddVisible, setIsAddVisible] = useState<boolean>(false);
|
||||
const [searchText, setSearchText] = useState<string>("");
|
||||
const [isAddVisible, setIsAddVisible] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<View height={"100%"}>
|
||||
<View>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
return (
|
||||
<View height={"100%"}>
|
||||
<View>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
>
|
||||
<View marginH-25>
|
||||
<HeaderTemplate
|
||||
message={"Welcome to your notes!"}
|
||||
isWelcome={false}
|
||||
children={
|
||||
<Text
|
||||
style={{ fontFamily: "Manrope_400Regular", fontSize: 14 }}
|
||||
>
|
||||
<View marginH-25>
|
||||
<HeaderTemplate
|
||||
message={"Welcome to your notes!"}
|
||||
isWelcome={false}
|
||||
children={
|
||||
<Text
|
||||
style={{fontFamily: "Manrope_400Regular", fontSize: 14}}
|
||||
>
|
||||
Drop your notes on-the-go here, and{"\n"}organize them later.
|
||||
</Text>
|
||||
}
|
||||
/>
|
||||
<View>
|
||||
<View style={styles.searchField} centerV>
|
||||
<TextField
|
||||
value={searchText}
|
||||
onChangeText={(value) => {
|
||||
setSearchText(value);
|
||||
}}
|
||||
leadingAccessory={
|
||||
<Feather
|
||||
name="search"
|
||||
size={24}
|
||||
color="#9b9b9b"
|
||||
style={{paddingRight: 10}}
|
||||
/>
|
||||
}
|
||||
style={{
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
}}
|
||||
placeholder="Search notes..."
|
||||
/>
|
||||
</View>
|
||||
<DumpList searchText={searchText}/>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
<LinearGradient
|
||||
colors={["#f9f8f700", "#f9f8f7"]}
|
||||
locations={[0,1]}
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
height: 120,
|
||||
width: Dimensions.get("screen").width,
|
||||
justifyContent:'center',
|
||||
alignItems:"center"
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
style={{
|
||||
height: 40,
|
||||
position: "relative",
|
||||
width: "90%",
|
||||
bottom: -10,
|
||||
borderRadius: 30,
|
||||
backgroundColor: "#fd1775",
|
||||
}}
|
||||
color="white"
|
||||
enableShadow
|
||||
onPress={() => {
|
||||
setIsAddVisible(true);
|
||||
}}
|
||||
>
|
||||
<View row centerV centerH>
|
||||
<PlusIcon />
|
||||
<Text
|
||||
white
|
||||
style={{fontSize: 16, fontFamily: "Manrope_600SemiBold", marginLeft: 5}}
|
||||
>
|
||||
New
|
||||
</Text>
|
||||
</View>
|
||||
</Button>
|
||||
</LinearGradient>
|
||||
<AddBrainDump
|
||||
addBrainDumpProps={{
|
||||
isVisible: isAddVisible,
|
||||
setIsVisible: setIsAddVisible,
|
||||
}}
|
||||
Drop your notes on-the-go here, and{"\n"}organize them later.
|
||||
</Text>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
<View>
|
||||
<View style={styles.searchField} centerV>
|
||||
<TextField
|
||||
value={searchText}
|
||||
onChangeText={(value) => {
|
||||
setSearchText(value);
|
||||
}}
|
||||
leadingAccessory={
|
||||
<Feather
|
||||
name="search"
|
||||
size={24}
|
||||
color="#9b9b9b"
|
||||
style={{ paddingRight: 10 }}
|
||||
/>
|
||||
}
|
||||
style={{
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
}}
|
||||
placeholder="Search notes..."
|
||||
/>
|
||||
</View>
|
||||
<DumpList searchText={searchText} />
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
<LinearGradient
|
||||
colors={["#f2f2f2", "transparent"]}
|
||||
start={{ x: 0.5, y: 1 }}
|
||||
end={{ x: 0.5, y: 0 }}
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
height: 90,
|
||||
width: Dimensions.get("screen").width,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
style={{
|
||||
height: 40,
|
||||
position: "relative",
|
||||
marginLeft: "auto",
|
||||
width: 20,
|
||||
right: 20,
|
||||
bottom: -10,
|
||||
borderRadius: 30,
|
||||
backgroundColor: "#fd1775",
|
||||
}}
|
||||
color="white"
|
||||
enableShadow
|
||||
onPress={() => {
|
||||
setIsAddVisible(true);
|
||||
}}
|
||||
>
|
||||
<View row centerV centerH>
|
||||
<MaterialIcons name="add" size={22} color={"white"} />
|
||||
<Text
|
||||
white
|
||||
style={{ fontSize: 16, fontFamily: "Manrope_600SemiBold" }}
|
||||
>
|
||||
New
|
||||
</Text>
|
||||
</View>
|
||||
</Button>
|
||||
</LinearGradient>
|
||||
<AddBrainDump
|
||||
addBrainDumpProps={{
|
||||
isVisible: isAddVisible,
|
||||
setIsVisible: setIsAddVisible,
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
searchField: {
|
||||
borderWidth: 0.7,
|
||||
borderColor: "#9b9b9b",
|
||||
borderRadius: 15,
|
||||
height: 42,
|
||||
paddingLeft: 10,
|
||||
marginVertical: 20,
|
||||
},
|
||||
searchField: {
|
||||
borderWidth: 0.7,
|
||||
borderColor: "#9b9b9b",
|
||||
borderRadius: 15,
|
||||
height: 42,
|
||||
paddingLeft: 10,
|
||||
marginVertical: 20,
|
||||
},
|
||||
});
|
||||
|
||||
export default BrainDumpPage;
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import React, {useEffect, useRef, useState} from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
View,
|
||||
Text,
|
||||
TextField,
|
||||
TouchableOpacity, TextFieldRef,
|
||||
TouchableOpacity,
|
||||
} from "react-native-ui-lib";
|
||||
import { Dimensions, StyleSheet } from "react-native";
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
||||
@ -18,7 +18,6 @@ import NavCalendarIcon from "@/assets/svgs/NavCalendarIcon";
|
||||
import NavToDosIcon from "@/assets/svgs/NavToDosIcon";
|
||||
import RemindersIcon from "@/assets/svgs/RemindersIcon";
|
||||
import MenuIcon from "@/assets/svgs/MenuIcon";
|
||||
import BrainDumpDialog from "./BrainDumpDialog";
|
||||
|
||||
const MoveBrainDump = (props: {
|
||||
item: IBrainDump;
|
||||
@ -29,35 +28,12 @@ const MoveBrainDump = (props: {
|
||||
const [description, setDescription] = useState<string>(
|
||||
props.item.description
|
||||
);
|
||||
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
||||
const descriptionRef = useRef<TextFieldRef>(null)
|
||||
|
||||
const { width } = Dimensions.get("screen");
|
||||
|
||||
useEffect(() => {
|
||||
updateBrainDumpItem(props.item.id, { description: description });
|
||||
}, [description]);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.isVisible) {
|
||||
setTimeout(() => {
|
||||
descriptionRef?.current?.focus()
|
||||
}, 500)
|
||||
}
|
||||
}, [props.isVisible]);
|
||||
|
||||
const showConfirmationDialog = () => {
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
const handleDeleteNote = () =>{
|
||||
deleteBrainDump(props.item.id);
|
||||
}
|
||||
|
||||
const hideConfirmationDialog = () => {
|
||||
setModalVisible(false);
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
@ -105,7 +81,8 @@ const MoveBrainDump = (props: {
|
||||
marginL-5
|
||||
iconSource={() => <BinIcon />}
|
||||
onPress={() => {
|
||||
showConfirmationDialog();
|
||||
deleteBrainDump(props.item.id);
|
||||
props.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
@ -124,15 +101,16 @@ const MoveBrainDump = (props: {
|
||||
fieldStyle={{
|
||||
width: "94%",
|
||||
}}
|
||||
style={styles.description}
|
||||
style={{
|
||||
fontFamily: "Manrope_400Regular",
|
||||
fontSize: 14,
|
||||
}}
|
||||
placeholder="Add description"
|
||||
numberOfLines={3}
|
||||
value={description}
|
||||
onChangeText={(value) => {
|
||||
setDescription(value);
|
||||
}}
|
||||
ref={descriptionRef}
|
||||
returnKeyType="default"
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
@ -168,7 +146,6 @@ const MoveBrainDump = (props: {
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<BrainDumpDialog visible={modalVisible} title={props.item.title} onDismiss={hideConfirmationDialog} onConfirm={handleDeleteNote} />
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
@ -215,10 +192,6 @@ const styles = StyleSheet.create({
|
||||
fontSize: 22,
|
||||
fontFamily: "Manrope_500Medium",
|
||||
},
|
||||
description: {
|
||||
fontFamily: "Manrope_400Regular",
|
||||
fontSize: 14,
|
||||
},
|
||||
});
|
||||
|
||||
export default MoveBrainDump;
|
||||
|
||||
@ -1,177 +1,188 @@
|
||||
import React, {useState} from "react";
|
||||
import {MaterialIcons,} from "@expo/vector-icons";
|
||||
import {Button, Card, Dialog, PanningProvider, Text, View,} from "react-native-ui-lib";
|
||||
import {StyleSheet, TouchableOpacity} from "react-native";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
AntDesign,
|
||||
Feather,
|
||||
MaterialCommunityIcons,
|
||||
MaterialIcons,
|
||||
} from "@expo/vector-icons";
|
||||
import {
|
||||
Button,
|
||||
ButtonSize,
|
||||
Card,
|
||||
Dialog,
|
||||
PanningProvider,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import { StyleSheet, TouchableOpacity } from "react-native";
|
||||
import { ManuallyAddEventModal } from "@/components/pages/calendar/ManuallyAddEventModal";
|
||||
import AddChoreDialog from "../todos/AddChoreDialog";
|
||||
import {ToDosContextProvider} from "@/contexts/ToDosContext";
|
||||
import { ToDosContextProvider } from "@/contexts/ToDosContext";
|
||||
import UploadImageDialog from "./UploadImageDialog";
|
||||
import CameraIcon from "@/assets/svgs/CameraIcon";
|
||||
import CalendarIcon from "@/assets/svgs/CalendarIcon";
|
||||
import NavToDosIcon from "@/assets/svgs/NavToDosIcon";
|
||||
import {useSetAtom} from "jotai";
|
||||
import {selectedNewEventDateAtom} from "@/components/pages/calendar/atoms";
|
||||
import PlusIcon from "@/assets/svgs/PlusIcon";
|
||||
|
||||
export const AddEventDialog = () => {
|
||||
const [show, setShow] = useState(false);
|
||||
const [choreDialogVisible, setChoreDialogVisible] = useState<boolean>(false);
|
||||
const [showUploadDialog, setShowUploadDialog] = useState<boolean>(false);
|
||||
const setSelectedNewEndDate = useSetAtom(selectedNewEventDateAtom)
|
||||
const [show, setShow] = useState(false);
|
||||
const [showManualInputModal, setShowManualInputModal] = useState(false);
|
||||
const [choreDialogVisible, setChoreDialogVisible] = useState<boolean>(false);
|
||||
const [showUploadDialog, setShowUploadDialog] = useState<boolean>(false);
|
||||
|
||||
const handleOpenManualInputModal = () => {
|
||||
setShow(false);
|
||||
setTimeout(() => {
|
||||
setSelectedNewEndDate(new Date());
|
||||
}, 500);
|
||||
};
|
||||
const handleOpenManualInputModal = () => {
|
||||
setShow(false);
|
||||
setTimeout(() => {
|
||||
setShowManualInputModal(true);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
const handleScanImageDialog = () => {
|
||||
setShow(false);
|
||||
setTimeout(() => {
|
||||
setShowUploadDialog(true);
|
||||
}, 100);
|
||||
};
|
||||
const handleScanImageDialog = () => {
|
||||
setShow(false);
|
||||
setTimeout(() => {
|
||||
setShowUploadDialog(true);
|
||||
}, 100);
|
||||
};
|
||||
|
||||
return (
|
||||
<ToDosContextProvider>
|
||||
<>
|
||||
<Button
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 20,
|
||||
right: 20,
|
||||
height: 40,
|
||||
borderRadius: 30,
|
||||
backgroundColor: "#fd1775",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
color="white"
|
||||
enableShadow
|
||||
onPress={() => setShow(true)}
|
||||
>
|
||||
<View row centerV centerH>
|
||||
<PlusIcon />
|
||||
<Text white style={{fontSize: 16, fontFamily: 'Manrope_600SemiBold', marginLeft: 5}}>
|
||||
New
|
||||
</Text>
|
||||
</View>
|
||||
</Button>
|
||||
return (
|
||||
<ToDosContextProvider>
|
||||
<>
|
||||
<Button
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 20,
|
||||
right: 20,
|
||||
height: 40,
|
||||
borderRadius: 30,
|
||||
backgroundColor: "#fd1775",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
color="white"
|
||||
enableShadow
|
||||
onPress={() => setShow(true)}
|
||||
>
|
||||
<View row centerV centerH>
|
||||
<MaterialIcons name="add" size={22} color={"white"} />
|
||||
<Text white style={{ fontSize: 16, fontFamily: 'Manrope_600SemiBold' }}>
|
||||
New
|
||||
</Text>
|
||||
</View>
|
||||
</Button>
|
||||
|
||||
<Dialog
|
||||
visible={show}
|
||||
onDismiss={() => setShow(false)}
|
||||
panDirection={PanningProvider.Directions.DOWN}
|
||||
center
|
||||
>
|
||||
<Card style={styles.dialogCard}>
|
||||
<Text text60 style={styles.modalTitle}>
|
||||
Create a new event
|
||||
</Text>
|
||||
<Dialog
|
||||
visible={show}
|
||||
onDismiss={() => setShow(false)}
|
||||
panDirection={PanningProvider.Directions.DOWN}
|
||||
center
|
||||
>
|
||||
<Card style={styles.dialogCard}>
|
||||
<Text text60 style={styles.modalTitle}>
|
||||
Create a new event
|
||||
</Text>
|
||||
|
||||
<View
|
||||
style={{marginTop: 20, alignItems: "center", width: "100%"}}
|
||||
>
|
||||
<Button
|
||||
disabled
|
||||
style={{
|
||||
marginBottom: 10,
|
||||
// backgroundColor: "#ea156c",
|
||||
justifyContent: "center",
|
||||
width: "100%",
|
||||
paddingVertical: 13,
|
||||
opacity: 0.5
|
||||
}}
|
||||
label="Scan Image"
|
||||
labelStyle={styles.btnLabel}
|
||||
onPress={handleScanImageDialog}
|
||||
iconSource={() => (
|
||||
<CameraIcon color="white" style={styles.btnIcon}/>
|
||||
)}
|
||||
/>
|
||||
<View
|
||||
style={{ marginTop: 20, alignItems: "center", width: "100%" }}
|
||||
>
|
||||
<Button
|
||||
style={{
|
||||
marginBottom: 10,
|
||||
backgroundColor: "#ea156c",
|
||||
justifyContent: "center",
|
||||
width: "100%",
|
||||
paddingVertical: 13,
|
||||
}}
|
||||
label="Scan Image"
|
||||
labelStyle={styles.btnLabel}
|
||||
onPress={handleScanImageDialog}
|
||||
iconSource={() => (
|
||||
<CameraIcon color="white" style={styles.btnIcon} />
|
||||
)}
|
||||
/>
|
||||
|
||||
<Button
|
||||
style={{
|
||||
marginBottom: 10,
|
||||
backgroundColor: "#e28800",
|
||||
justifyContent: "center",
|
||||
width: "100%",
|
||||
paddingVertical: 13,
|
||||
}}
|
||||
label="Create Event"
|
||||
labelStyle={styles.btnLabel}
|
||||
onPress={handleOpenManualInputModal}
|
||||
iconSource={() => (
|
||||
<CalendarIcon color={"white"} style={styles.btnIcon}/>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
style={{
|
||||
marginBottom: 10,
|
||||
backgroundColor: "#e28800",
|
||||
justifyContent: "center",
|
||||
width: "100%",
|
||||
paddingVertical: 13,
|
||||
}}
|
||||
label="Create Event"
|
||||
labelStyle={styles.btnLabel}
|
||||
onPress={handleOpenManualInputModal}
|
||||
iconSource={() => (
|
||||
<CalendarIcon color={"white"} style={styles.btnIcon} />
|
||||
)}
|
||||
/>
|
||||
|
||||
<Button
|
||||
disabled
|
||||
style={{
|
||||
marginBottom: 10,
|
||||
// backgroundColor: "#05a8b6",
|
||||
justifyContent: "center",
|
||||
width: "100%",
|
||||
paddingVertical: 13,
|
||||
opacity: 0.5
|
||||
}}
|
||||
label="Add To Do"
|
||||
labelStyle={styles.btnLabel}
|
||||
onPress={() => setChoreDialogVisible(true)}
|
||||
iconSource={() => (
|
||||
<NavToDosIcon
|
||||
color={"white"}
|
||||
width={23}
|
||||
style={styles.btnIcon}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</View>
|
||||
<Button
|
||||
style={{
|
||||
marginBottom: 10,
|
||||
backgroundColor: "#05a8b6",
|
||||
justifyContent: "center",
|
||||
width: "100%",
|
||||
paddingVertical: 13,
|
||||
}}
|
||||
label="Add To Do"
|
||||
labelStyle={styles.btnLabel}
|
||||
onPress={() => setChoreDialogVisible(true)}
|
||||
iconSource={() => (
|
||||
<NavToDosIcon
|
||||
color={"white"}
|
||||
width={23}
|
||||
style={styles.btnIcon}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<TouchableOpacity onPress={() => setShow(false)}>
|
||||
<Text style={styles.bottomText} text70>
|
||||
Go back to calendar
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</Card>
|
||||
</Dialog>
|
||||
<AddChoreDialog
|
||||
isVisible={choreDialogVisible}
|
||||
setIsVisible={setChoreDialogVisible}
|
||||
/>
|
||||
<UploadImageDialog
|
||||
show={showUploadDialog}
|
||||
setShow={setShowUploadDialog}
|
||||
/>
|
||||
</>
|
||||
</ToDosContextProvider>
|
||||
);
|
||||
<TouchableOpacity onPress={() => setShow(false)}>
|
||||
<Text style={styles.bottomText} text70>
|
||||
Go back to calendar
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</Card>
|
||||
</Dialog>
|
||||
<AddChoreDialog
|
||||
isVisible={choreDialogVisible}
|
||||
setIsVisible={setChoreDialogVisible}
|
||||
/>
|
||||
<ManuallyAddEventModal
|
||||
show={showManualInputModal}
|
||||
close={() => setShowManualInputModal(false)}
|
||||
/>
|
||||
<UploadImageDialog
|
||||
show={showUploadDialog}
|
||||
setShow={setShowUploadDialog}
|
||||
/>
|
||||
</>
|
||||
</ToDosContextProvider>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
modalTitle: {
|
||||
fontSize: 22,
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
marginBottom: 16,
|
||||
},
|
||||
bottomText: {
|
||||
marginTop: 20,
|
||||
color: "#999999",
|
||||
fontSize: 13.53,
|
||||
fontFamily: "Poppins_500Medium",
|
||||
},
|
||||
dialogCard: {
|
||||
paddingHorizontal: 40,
|
||||
paddingTop: 35,
|
||||
paddingBottom: 20,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
borderRadius: 20,
|
||||
},
|
||||
btnLabel: {
|
||||
fontSize: 15,
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
},
|
||||
btnIcon: {marginRight: 10},
|
||||
modalTitle: {
|
||||
fontSize: 22,
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
marginBottom: 16,
|
||||
},
|
||||
bottomText: {
|
||||
marginTop: 20,
|
||||
color: "#999999",
|
||||
fontSize: 13.53,
|
||||
fontFamily: "Poppins_500Medium",
|
||||
},
|
||||
dialogCard: {
|
||||
paddingHorizontal: 40,
|
||||
paddingTop: 35,
|
||||
paddingBottom: 20,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
borderRadius: 20,
|
||||
},
|
||||
btnLabel: {
|
||||
fontSize: 15,
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
},
|
||||
btnIcon: { marginRight: 10 },
|
||||
});
|
||||
|
||||
@ -1,130 +0,0 @@
|
||||
import React, { memo } from "react";
|
||||
import {
|
||||
Button,
|
||||
Picker,
|
||||
PickerModes,
|
||||
SegmentedControl,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import { MaterialIcons } from "@expo/vector-icons";
|
||||
import { modeMap, months } from "./constants";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { useAtom } from "jotai";
|
||||
import { modeAtom, selectedDateAtom } from "@/components/pages/calendar/atoms";
|
||||
import { format, isSameDay } from "date-fns";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
|
||||
export const CalendarHeader = memo(() => {
|
||||
const [selectedDate, setSelectedDate] = useAtom(selectedDateAtom);
|
||||
const [mode, setMode] = useAtom(modeAtom);
|
||||
const { profileData } = useAuthContext();
|
||||
|
||||
const handleSegmentChange = (index: number) => {
|
||||
const selectedMode = modeMap.get(index);
|
||||
if (selectedMode) {
|
||||
setTimeout(() => {
|
||||
setMode(selectedMode as "day" | "week" | "month");
|
||||
}, 150);
|
||||
}
|
||||
};
|
||||
|
||||
const handleMonthChange = (month: string) => {
|
||||
const currentDay = selectedDate.getDate();
|
||||
const currentYear = selectedDate.getFullYear();
|
||||
const newMonthIndex = months.indexOf(month);
|
||||
|
||||
const updatedDate = new Date(currentYear, newMonthIndex, currentDay);
|
||||
setSelectedDate(updatedDate);
|
||||
};
|
||||
|
||||
const isSelectedDateToday = isSameDay(selectedDate, new Date());
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 8,
|
||||
borderRadius: 20,
|
||||
borderBottomLeftRadius: 0,
|
||||
borderBottomRightRadius: 0,
|
||||
backgroundColor: "white",
|
||||
marginBottom: 10,
|
||||
}}
|
||||
>
|
||||
<View row centerV gap-3>
|
||||
<Text style={{ fontFamily: "Manrope_500Medium", fontSize: 17 }}>
|
||||
{selectedDate.getFullYear()}
|
||||
</Text>
|
||||
<Picker
|
||||
value={months[selectedDate.getMonth()]}
|
||||
placeholder={"Select Month"}
|
||||
style={{ fontFamily: "Manrope_500Medium", fontSize: 17, width: 85 }}
|
||||
mode={PickerModes.SINGLE}
|
||||
onChange={(itemValue) => handleMonthChange(itemValue as string)}
|
||||
trailingAccessory={<MaterialIcons name={"keyboard-arrow-down"} />}
|
||||
topBarProps={{
|
||||
title: selectedDate.getFullYear().toString(),
|
||||
titleStyle: { fontFamily: "Manrope_500Medium", fontSize: 17 },
|
||||
}}
|
||||
>
|
||||
{months.map((month) => (
|
||||
<Picker.Item key={month} label={month} value={month} />
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
|
||||
<View row centerV>
|
||||
{!isSelectedDateToday && (
|
||||
<Button
|
||||
size={"xSmall"}
|
||||
marginR-0
|
||||
avoidInnerPadding
|
||||
style={{
|
||||
borderRadius: 50,
|
||||
backgroundColor: "white",
|
||||
borderWidth: 0.7,
|
||||
borderColor: "#dadce0",
|
||||
height: 30,
|
||||
paddingHorizontal: 10,
|
||||
}}
|
||||
labelStyle={{
|
||||
fontSize: 12,
|
||||
color: "black",
|
||||
fontFamily: "Manrope_500Medium",
|
||||
}}
|
||||
label={format(new Date(), "dd/MM/yyyy")}
|
||||
onPress={() => {
|
||||
setSelectedDate(new Date());
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
<View>
|
||||
<SegmentedControl
|
||||
segments={[{ label: "D" }, { label: "W" }, { label: "M" }]}
|
||||
backgroundColor="#ececec"
|
||||
inactiveColor="#919191"
|
||||
activeBackgroundColor="#ea156c"
|
||||
activeColor="white"
|
||||
outlineColor="white"
|
||||
outlineWidth={3}
|
||||
segmentLabelStyle={styles.segmentslblStyle}
|
||||
onChangeIndex={handleSegmentChange}
|
||||
initialIndex={mode === "day" ? 0 : mode === "week" ? 1 : 2}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
segmentslblStyle: {
|
||||
fontSize: 12,
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
},
|
||||
});
|
||||
@ -1,21 +1,204 @@
|
||||
import React from "react";
|
||||
import {View,} from "react-native-ui-lib";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { LayoutChangeEvent, StyleSheet } from "react-native";
|
||||
import { Calendar } from "react-native-big-calendar";
|
||||
import {
|
||||
Picker,
|
||||
PickerModes,
|
||||
SegmentedControl,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import { MaterialIcons } from "@expo/vector-icons";
|
||||
import { AddEventDialog } from "@/components/pages/calendar/AddEventDialog";
|
||||
import HeaderTemplate from "@/components/shared/HeaderTemplate";
|
||||
import {InnerCalendar} from "@/components/pages/calendar/InnerCalendar";
|
||||
import CalendarViewSwitch from "@/components/pages/calendar/CalendarViewSwitch";
|
||||
import { ManuallyAddEventModal } from "@/components/pages/calendar/ManuallyAddEventModal";
|
||||
import { CalendarEvent } from "@/contexts/CalendarContext";
|
||||
import { useSettingsContext } from "@/contexts/SettingsContext";
|
||||
import EditEventDialog from "./EditEventDialog";
|
||||
import { useGetEvents } from "@/hooks/firebase/useGetEvents";
|
||||
import { Text } from "react-native-ui-lib";
|
||||
|
||||
const modeMap = new Map([
|
||||
[0, "day"],
|
||||
[1, "week"],
|
||||
[2, "month"],
|
||||
]);
|
||||
|
||||
const months = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
];
|
||||
|
||||
export default function CalendarPage() {
|
||||
return (
|
||||
const { calendarColor } = useSettingsContext();
|
||||
const [editVisible, setEditVisible] = useState<boolean>(false);
|
||||
const [eventForEdit, setEventForEdit] = useState<CalendarEvent>();
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
segmentslblStyle: {
|
||||
fontSize: 12,
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
},
|
||||
calHeader: {
|
||||
borderWidth: 0,
|
||||
},
|
||||
dayModeHeader: {
|
||||
alignSelf: "flex-start",
|
||||
justifyContent: "space-between",
|
||||
alignContent: "center",
|
||||
width: 38,
|
||||
right: 42,
|
||||
},
|
||||
});
|
||||
|
||||
const [isFamilyView, setIsFamilyView] = useState<boolean>(false);
|
||||
const [calendarHeight, setCalendarHeight] = useState(0);
|
||||
const [mode, setMode] = useState<"week" | "month" | "day">("week");
|
||||
const [selectedDate, setSelectedDate] = useState<Date>(new Date());
|
||||
const [selectedNewEventDate, setSelectedNewEndDate] = useState<
|
||||
Date | undefined
|
||||
>(undefined);
|
||||
|
||||
const calendarContainerRef = useRef(null);
|
||||
const { data: events } = useGetEvents(isFamilyView);
|
||||
|
||||
const onLayout = (event: LayoutChangeEvent) => {
|
||||
const { height } = event.nativeEvent.layout;
|
||||
setCalendarHeight(height);
|
||||
};
|
||||
|
||||
const handleSegmentChange = (index: number) => {
|
||||
const selectedMode = modeMap.get(index);
|
||||
if (selectedMode) {
|
||||
setMode(selectedMode as "day" | "week" | "month");
|
||||
}
|
||||
};
|
||||
|
||||
const handleMonthChange = (month: string) => {
|
||||
const currentDay = selectedDate.getDate();
|
||||
const currentYear = selectedDate.getFullYear();
|
||||
|
||||
const newMonthIndex = months.indexOf(month);
|
||||
|
||||
const updatedDate = new Date(currentYear, newMonthIndex, currentDay);
|
||||
|
||||
setSelectedDate(updatedDate);
|
||||
};
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{ flex: 1, height: "100%", padding: 10 }}
|
||||
paddingH-22
|
||||
paddingT-0
|
||||
>
|
||||
<HeaderTemplate
|
||||
message={"Let's get your week started!"}
|
||||
isWelcome={true}
|
||||
/>
|
||||
|
||||
<View
|
||||
style={{ flex: 1, backgroundColor: "#fff", borderRadius: 30 }}
|
||||
ref={calendarContainerRef}
|
||||
onLayout={onLayout}
|
||||
>
|
||||
<View
|
||||
style={{flex: 1, height: "100%", padding: 10}}
|
||||
paddingH-22
|
||||
paddingT-0
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 8,
|
||||
borderRadius: 20,
|
||||
borderBottomLeftRadius: 0,
|
||||
borderBottomRightRadius: 0,
|
||||
backgroundColor: "white",
|
||||
marginBottom: 10,
|
||||
}}
|
||||
>
|
||||
<HeaderTemplate
|
||||
message={"Let's get your week started!"}
|
||||
isWelcome
|
||||
isCalendar={true}
|
||||
<View row centerV gap-3>
|
||||
<Text style={{ fontFamily: "Manrope_500Medium", fontSize: 17 }}>
|
||||
{selectedDate.getFullYear()}
|
||||
</Text>
|
||||
<Picker
|
||||
value={months[selectedDate.getMonth()]} // Get the month from the date
|
||||
placeholder={"Select Month"}
|
||||
style={{ fontFamily: "Manrope_500Medium", fontSize: 17 }}
|
||||
mode={PickerModes.SINGLE}
|
||||
onChange={(itemValue) => handleMonthChange(itemValue as string)}
|
||||
trailingAccessory={<MaterialIcons name={"keyboard-arrow-down"} />}
|
||||
topBarProps={{
|
||||
title: selectedDate.getFullYear().toString(),
|
||||
titleStyle: { fontFamily: "Manrope_500Medium", fontSize: 17 },
|
||||
}}
|
||||
>
|
||||
{months.map((month) => (
|
||||
<Picker.Item key={month} label={month} value={month} />
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
|
||||
<View>
|
||||
<SegmentedControl
|
||||
segments={[{ label: "D" }, { label: "W" }, { label: "M" }]}
|
||||
backgroundColor="#ececec"
|
||||
inactiveColor="#919191"
|
||||
activeBackgroundColor="#ea156c"
|
||||
activeColor="white"
|
||||
outlineColor="white"
|
||||
outlineWidth={3}
|
||||
segmentLabelStyle={styles.segmentslblStyle}
|
||||
onChangeIndex={handleSegmentChange}
|
||||
initialIndex={mode === "day" ? 0 : mode === "week" ? 1 : 2}
|
||||
/>
|
||||
<InnerCalendar/>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
{calendarHeight > 0 && (
|
||||
<Calendar
|
||||
bodyContainerStyle={styles.calHeader}
|
||||
mode={mode}
|
||||
events={isFamilyView ? events ?? [] : events ?? []}
|
||||
eventCellStyle={(event) => ({ backgroundColor: event.eventColor })}
|
||||
onPressEvent={(event) => {
|
||||
setEditVisible(true);
|
||||
setEventForEdit(event);
|
||||
}}
|
||||
height={calendarHeight}
|
||||
activeDate={selectedDate}
|
||||
date={selectedDate}
|
||||
onPressCell={setSelectedNewEndDate}
|
||||
headerContentStyle={mode === "day" ? styles.dayModeHeader : {}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
<CalendarViewSwitch viewSwitch={setIsFamilyView} />
|
||||
<AddEventDialog />
|
||||
{eventForEdit && (
|
||||
<EditEventDialog
|
||||
isVisible={editVisible}
|
||||
setIsVisible={() => {
|
||||
setEditVisible(!editVisible);
|
||||
}}
|
||||
event={eventForEdit}
|
||||
/>
|
||||
)}
|
||||
|
||||
<ManuallyAddEventModal
|
||||
key={`${selectedNewEventDate}`}
|
||||
initialDate={selectedNewEventDate}
|
||||
show={!!selectedNewEventDate}
|
||||
close={() => setSelectedNewEndDate(undefined)}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import { Text, TouchableOpacity, View } from "react-native-ui-lib";
|
||||
import React from "react";
|
||||
import { View, Text, Button, TouchableOpacity } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import { MaterialIcons } from "@expo/vector-icons";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { useAtom } from "jotai";
|
||||
import { isFamilyViewAtom } from "@/components/pages/calendar/atoms";
|
||||
|
||||
const CalendarViewSwitch = () => {
|
||||
const [isFamilyView, setIsFamilyView] = useAtom(isFamilyViewAtom);
|
||||
interface ICalendarViewProps {
|
||||
viewSwitch: (value: boolean) => void;
|
||||
}
|
||||
const CalendarViewSwitch = (calendarViewProps: ICalendarViewProps) => {
|
||||
const [calView, setCalView] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<View
|
||||
@ -31,7 +33,8 @@ const CalendarViewSwitch = () => {
|
||||
>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
setIsFamilyView(true);
|
||||
setCalView(true);
|
||||
calendarViewProps.viewSwitch(true);
|
||||
}}
|
||||
>
|
||||
<View
|
||||
@ -39,12 +42,9 @@ const CalendarViewSwitch = () => {
|
||||
centerH
|
||||
height={40}
|
||||
paddingH-15
|
||||
style={isFamilyView ? styles.switchBtnActive : styles.switchBtn}
|
||||
style={calView ? styles.switchBtnActive : styles.switchBtn}
|
||||
>
|
||||
<Text
|
||||
color={isFamilyView ? "white" : "#a1a1a1"}
|
||||
style={styles.switchTxt}
|
||||
>
|
||||
<Text color={calView ? "white" : "#a1a1a1"} style={styles.switchTxt}>
|
||||
Family View
|
||||
</Text>
|
||||
</View>
|
||||
@ -52,7 +52,8 @@ const CalendarViewSwitch = () => {
|
||||
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
setIsFamilyView(false);
|
||||
setCalView(false);
|
||||
calendarViewProps.viewSwitch(false);
|
||||
}}
|
||||
>
|
||||
<View
|
||||
@ -60,12 +61,9 @@ const CalendarViewSwitch = () => {
|
||||
centerH
|
||||
height={40}
|
||||
paddingH-15
|
||||
style={!isFamilyView ? styles.switchBtnActive : styles.switchBtn}
|
||||
style={!calView ? styles.switchBtnActive : styles.switchBtn}
|
||||
>
|
||||
<Text
|
||||
color={!isFamilyView ? "white" : "#a1a1a1"}
|
||||
style={styles.switchTxt}
|
||||
>
|
||||
<Text color={!calView ? "white" : "#a1a1a1"} style={styles.switchTxt}>
|
||||
My View
|
||||
</Text>
|
||||
</View>
|
||||
@ -85,8 +83,8 @@ const styles = StyleSheet.create({
|
||||
backgroundColor: "white",
|
||||
borderRadius: 50,
|
||||
},
|
||||
switchTxt: {
|
||||
switchTxt:{
|
||||
fontSize: 16,
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
},
|
||||
fontFamily: 'Manrope_600SemiBold'
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,81 +0,0 @@
|
||||
import React from "react";
|
||||
import { Dialog, Button, Text, View } from "react-native-ui-lib";
|
||||
import { StyleSheet } from "react-native";
|
||||
|
||||
interface DeleteEventDialogProps {
|
||||
visible: boolean;
|
||||
title: string;
|
||||
onDismiss: () => void;
|
||||
onConfirm: () => void;
|
||||
}
|
||||
|
||||
const DeleteEventDialog: React.FC<DeleteEventDialogProps> = ({
|
||||
visible,
|
||||
title,
|
||||
onDismiss,
|
||||
onConfirm,
|
||||
}) => {
|
||||
return (
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onDismiss={onDismiss}
|
||||
containerStyle={styles.dialog}
|
||||
>
|
||||
<Text center style={styles.title}>
|
||||
Delete Event
|
||||
</Text>
|
||||
<View center>
|
||||
<Text style={styles.text} center>
|
||||
Are you sure you want to delete the event:{" "}
|
||||
<Text style={{ fontSize: 16, fontFamily: "PlusJakartaSans_700Bold" }}>
|
||||
{title}
|
||||
</Text>{" "}
|
||||
</Text>
|
||||
</View>
|
||||
<View row right gap-8>
|
||||
<Button
|
||||
label="Cancel"
|
||||
onPress={onDismiss}
|
||||
style={styles.cancelBtn}
|
||||
color="#999999"
|
||||
labelStyle={{ fontFamily: "Poppins_500Medium", fontSize: 13.53 }}
|
||||
/>
|
||||
<Button
|
||||
label="Yes"
|
||||
onPress={onConfirm}
|
||||
style={styles.confirmBtn}
|
||||
labelStyle={{ fontFamily: "PlusJakartaSans_500Medium" }}
|
||||
/>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
// Empty stylesheet for future styles
|
||||
const styles = StyleSheet.create({
|
||||
confirmBtn: {
|
||||
backgroundColor: "#ea156d",
|
||||
},
|
||||
cancelBtn: {
|
||||
backgroundColor: "white",
|
||||
},
|
||||
dialog: {
|
||||
backgroundColor: "white",
|
||||
paddingHorizontal: 25,
|
||||
paddingTop: 35,
|
||||
paddingBottom: 17,
|
||||
borderRadius: 20,
|
||||
},
|
||||
title: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 22,
|
||||
marginBottom: 20,
|
||||
},
|
||||
text: {
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
marginBottom: 25,
|
||||
},
|
||||
});
|
||||
|
||||
export default DeleteEventDialog;
|
||||
312
components/pages/calendar/EditEventDialog.tsx
Normal file
@ -0,0 +1,312 @@
|
||||
import { View, Text, Button, Switch } from "react-native-ui-lib";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Feather, AntDesign, Ionicons } from "@expo/vector-icons";
|
||||
import {
|
||||
Dialog,
|
||||
TextField,
|
||||
DateTimePicker,
|
||||
Picker,
|
||||
ButtonSize,
|
||||
} from "react-native-ui-lib";
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
||||
import { StyleSheet } from "react-native";
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import { CalendarEvent } from "@/contexts/CalendarContext";
|
||||
import ClockIcon from "@/assets/svgs/ClockIcon";
|
||||
import LockIcon from "@/assets/svgs/LockIcon";
|
||||
import MenuIcon from "@/assets/svgs/MenuIcon";
|
||||
import { useUpdateEvent } from "@/hooks/firebase/useUpdateEvent";
|
||||
|
||||
interface IEditEventDialog {
|
||||
event: CalendarEvent;
|
||||
isVisible: boolean;
|
||||
setIsVisible: (value: boolean) => void;
|
||||
}
|
||||
const EditEventDialog = (editEventProps: IEditEventDialog) => {
|
||||
const [event, setEvent] = useState<CalendarEvent>(editEventProps.event);
|
||||
|
||||
const { mutateAsync: updateEvent } = useUpdateEvent();
|
||||
|
||||
useEffect(() => {
|
||||
setEvent(editEventProps.event);
|
||||
}, [editEventProps.isVisible]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
height={"90%"}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
onDismiss={() => editEventProps.setIsVisible(false)}
|
||||
containerStyle={{
|
||||
borderRadius: 10,
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
alignSelf: "stretch",
|
||||
padding: 0,
|
||||
paddingTop: 4,
|
||||
margin: 0,
|
||||
}}
|
||||
visible={editEventProps.isVisible}
|
||||
>
|
||||
<View row spread>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
style={styles.topBtn}
|
||||
label="Cancel"
|
||||
onPress={() => {
|
||||
editEventProps.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
<View marginT-12>
|
||||
<DropModalIcon
|
||||
onPress={() => {
|
||||
editEventProps.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
style={styles.topBtn}
|
||||
label="Save"
|
||||
onPress={() => {
|
||||
try {
|
||||
if (event.id) {
|
||||
updateEvent(event).then(() => editEventProps.setIsVisible(false));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<TextField
|
||||
placeholder="Edit event title"
|
||||
value={event.title}
|
||||
onChangeText={(text) => {
|
||||
setEvent((prevEvent) => ({
|
||||
...prevEvent,
|
||||
title: text,
|
||||
}));
|
||||
}}
|
||||
placeholderTextColor="#2d2d30"
|
||||
text60R
|
||||
marginT-15
|
||||
marginL-30
|
||||
/>
|
||||
<View style={styles.divider} marginT-8 />
|
||||
|
||||
<View row spread marginB-10 marginL-30 centerV>
|
||||
<View row>
|
||||
<AntDesign name="clockcircleo" size={24} color="#919191" />
|
||||
<Text text70 marginL-10>
|
||||
All day
|
||||
</Text>
|
||||
</View>
|
||||
<View right marginR-30>
|
||||
<Switch
|
||||
onColor={"#ea156c"}
|
||||
offColor={"#e1e1e2"}
|
||||
marginL-10
|
||||
value={event.allDay}
|
||||
onValueChange={(value) =>
|
||||
setEvent((prev) => ({ ...prev, allDay: value }))
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View marginL-30 centerV>
|
||||
<View row marginB-10 spread>
|
||||
<View row centerV>
|
||||
<Feather name="calendar" size={25} color="#919191" />
|
||||
<DateTimePicker
|
||||
value={event.start}
|
||||
text70
|
||||
marginL-8
|
||||
maximumDate={event.end}
|
||||
onChange={(date) => {
|
||||
setEvent((prev) => ({ ...prev, start: date }));
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<DateTimePicker
|
||||
text70
|
||||
value={event.start}
|
||||
onChange={(date) => {
|
||||
setEvent((prev) => ({ ...prev, start: date }));
|
||||
}}
|
||||
maximumDate={event.end}
|
||||
dateTimeFormatter={(date, mode) => date.toLocaleTimeString("en-us",
|
||||
{ hour: "numeric",
|
||||
minute: "numeric"
|
||||
})}
|
||||
mode="time"
|
||||
marginR-30
|
||||
/>
|
||||
</View>
|
||||
|
||||
{!event.allDay && (
|
||||
<View row marginB-10 spread>
|
||||
<View row centerV>
|
||||
<Feather name="calendar" size={25} color="#919191" />
|
||||
<DateTimePicker
|
||||
value={event.end}
|
||||
minimumDate={event.start}
|
||||
text70
|
||||
marginL-8
|
||||
onChange={(date) => {
|
||||
setEvent((prev) => ({ ...prev, end: date }));
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<DateTimePicker
|
||||
text70
|
||||
value={event.end}
|
||||
minimumDate={event.start}
|
||||
onChange={(date) => {
|
||||
setEvent((prev) => ({ ...prev, end: date }));
|
||||
}}
|
||||
dateTimeFormatter={(date, mode) => date.toLocaleTimeString("en-us",
|
||||
{ hour: "numeric",
|
||||
minute: "numeric"
|
||||
})}
|
||||
mode="time"
|
||||
marginR-30
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
|
||||
<View marginH-30 marginB-10 row centerV>
|
||||
<Ionicons name="person-circle-outline" size={28} color="#919191" />
|
||||
<Text text70R marginL-10>
|
||||
Assignees
|
||||
</Text>
|
||||
<Button
|
||||
size={ButtonSize.small}
|
||||
paddingH-8
|
||||
iconSource={() => (
|
||||
<Ionicons name="add-outline" size={20} color="#ea156c" />
|
||||
)}
|
||||
style={{
|
||||
marginLeft: "auto",
|
||||
borderRadius: 8,
|
||||
backgroundColor: "#ffe8f1",
|
||||
borderColor: "#ea156c",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
color="#ea156c"
|
||||
label="Assign"
|
||||
/>
|
||||
</View>
|
||||
<View row marginH-13 marginT-13>
|
||||
<View
|
||||
marginL-30
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 50,
|
||||
backgroundColor: "red",
|
||||
borderRadius: 50,
|
||||
}}
|
||||
/>
|
||||
<View
|
||||
marginL-30
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 50,
|
||||
backgroundColor: "red",
|
||||
borderRadius: 50,
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<View marginH-30 marginB-0 row spread centerV>
|
||||
<View row centerV>
|
||||
<ClockIcon />
|
||||
<Text text70 marginL-10>
|
||||
Reminder
|
||||
</Text>
|
||||
</View>
|
||||
<View>
|
||||
<Button
|
||||
size={ButtonSize.small}
|
||||
paddingH-8
|
||||
iconSource={() => (
|
||||
<Ionicons name="add-outline" size={20} color="#ea156c" />
|
||||
)}
|
||||
style={{
|
||||
marginLeft: "auto",
|
||||
borderRadius: 8,
|
||||
backgroundColor: "#ffe8f1",
|
||||
borderColor: "#ea156c",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
color="#ea156c"
|
||||
label="Set Reminder"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<View marginH-30 marginB-0 row spread centerV>
|
||||
<View row>
|
||||
<LockIcon />
|
||||
<Text text70 marginL-10>
|
||||
Mark as Private
|
||||
</Text>
|
||||
</View>
|
||||
<View>
|
||||
<Switch
|
||||
onColor={"#ea156c"}
|
||||
offColor={"#e1e1e2"}
|
||||
marginL-10
|
||||
value={event.private}
|
||||
onValueChange={(value) =>
|
||||
setEvent((prev) => ({ ...prev, private: value }))
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<View marginH-30 marginB-0 row spread centerV>
|
||||
<View row centerV>
|
||||
<MenuIcon />
|
||||
<Text text70 marginL-10>
|
||||
Add Details
|
||||
</Text>
|
||||
</View>
|
||||
<View></View>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default EditEventDialog;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
divider: { height: 1, backgroundColor: "#e4e4e4", marginVertical: 15 },
|
||||
gradient: {
|
||||
height: "25%",
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
width: "100%",
|
||||
},
|
||||
buttonContainer: {
|
||||
position: "absolute",
|
||||
bottom: 25,
|
||||
width: "100%",
|
||||
},
|
||||
button: {
|
||||
backgroundColor: "rgb(253, 23, 117)",
|
||||
paddingVertical: 20,
|
||||
},
|
||||
topBtn: {
|
||||
backgroundColor: "white",
|
||||
color: "#05a8b6",
|
||||
},
|
||||
rotateSwitch: {
|
||||
marginLeft: 35,
|
||||
marginBottom: 10,
|
||||
marginTop: 25,
|
||||
},
|
||||
});
|
||||
@ -1,337 +0,0 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Calendar } from "react-native-big-calendar";
|
||||
import { ActivityIndicator, StyleSheet, View, ViewStyle } from "react-native";
|
||||
import { useGetEvents } from "@/hooks/firebase/useGetEvents";
|
||||
import { useAtom, useSetAtom } from "jotai";
|
||||
import {
|
||||
editVisibleAtom,
|
||||
eventForEditAtom,
|
||||
isAllDayAtom,
|
||||
modeAtom,
|
||||
selectedDateAtom,
|
||||
selectedNewEventDateAtom,
|
||||
} from "@/components/pages/calendar/atoms";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import { CalendarEvent } from "@/components/pages/calendar/interfaces";
|
||||
import { Text } from "react-native-ui-lib";
|
||||
import { addDays, compareAsc, isWithinInterval, subDays } from "date-fns";
|
||||
|
||||
interface EventCalendarProps {
|
||||
calendarHeight: number;
|
||||
// WAS USED FOR SCROLLABLE CALENDARS, PERFORMANCE WAS NOT OPTIMAL
|
||||
calendarWidth: number;
|
||||
}
|
||||
|
||||
const getTotalMinutes = () => {
|
||||
const date = new Date();
|
||||
return Math.abs(date.getUTCHours() * 60 + date.getUTCMinutes() - 200);
|
||||
};
|
||||
|
||||
export const EventCalendar: React.FC<EventCalendarProps> = React.memo(
|
||||
({ calendarHeight }) => {
|
||||
const { data: events, isLoading } = useGetEvents();
|
||||
const { profileData } = useAuthContext();
|
||||
const [selectedDate, setSelectedDate] = useAtom(selectedDateAtom);
|
||||
const [mode, setMode] = useAtom(modeAtom);
|
||||
|
||||
const setEditVisible = useSetAtom(editVisibleAtom);
|
||||
const [isAllDay, setIsAllDay] = useAtom(isAllDayAtom);
|
||||
const setEventForEdit = useSetAtom(eventForEditAtom);
|
||||
const setSelectedNewEndDate = useSetAtom(selectedNewEventDateAtom);
|
||||
|
||||
const [offsetMinutes, setOffsetMinutes] = useState(getTotalMinutes());
|
||||
|
||||
const todaysDate = new Date();
|
||||
|
||||
const handlePressEvent = useCallback(
|
||||
(event: CalendarEvent) => {
|
||||
if (mode === "day" || mode === "week") {
|
||||
setEditVisible(true);
|
||||
console.log({ event });
|
||||
setEventForEdit(event);
|
||||
} else {
|
||||
setMode("day");
|
||||
setSelectedDate(event.start);
|
||||
}
|
||||
},
|
||||
[setEditVisible, setEventForEdit, mode]
|
||||
);
|
||||
|
||||
const handlePressCell = useCallback(
|
||||
(date: Date) => {
|
||||
if (mode === "day" || mode === "week") {
|
||||
setSelectedNewEndDate(date);
|
||||
} else {
|
||||
setMode("day");
|
||||
setSelectedDate(date);
|
||||
}
|
||||
},
|
||||
[mode, setSelectedNewEndDate, setSelectedDate]
|
||||
);
|
||||
|
||||
const handlePressDayHeader = useCallback(
|
||||
(date: Date) => {
|
||||
setIsAllDay(true);
|
||||
console.log(isAllDay);
|
||||
setSelectedNewEndDate(date);
|
||||
setEditVisible(true);
|
||||
},
|
||||
[setSelectedNewEndDate]
|
||||
);
|
||||
|
||||
const handleSwipeEnd = useCallback(
|
||||
(date: Date) => {
|
||||
setSelectedDate(date);
|
||||
},
|
||||
[setSelectedDate]
|
||||
);
|
||||
|
||||
const memoizedEventCellStyle = useCallback(
|
||||
(event: CalendarEvent) => ({ backgroundColor: event.eventColor }),
|
||||
[]
|
||||
);
|
||||
|
||||
const memoizedWeekStartsOn = useMemo(
|
||||
() => (profileData?.firstDayOfWeek === "Mondays" ? 1 : 0),
|
||||
[profileData]
|
||||
);
|
||||
|
||||
console.log({
|
||||
memoizedWeekStartsOn,
|
||||
profileData: profileData?.firstDayOfWeek,
|
||||
});
|
||||
|
||||
const isSameDate = useCallback((date1: Date, date2: Date) => {
|
||||
return (
|
||||
date1.getDate() === date2.getDate() &&
|
||||
date1.getMonth() === date2.getMonth() &&
|
||||
date1.getFullYear() === date2.getFullYear()
|
||||
);
|
||||
}, []);
|
||||
|
||||
const dayHeaderColor = useMemo(() => {
|
||||
return isSameDate(todaysDate, selectedDate) ? "white" : "#4d4d4d";
|
||||
}, [selectedDate, mode]);
|
||||
|
||||
const dateStyle = useMemo(() => {
|
||||
if (mode === "week") return undefined;
|
||||
return isSameDate(todaysDate, selectedDate) && mode === "day"
|
||||
? styles.dayHeader
|
||||
: styles.otherDayHeader;
|
||||
}, [selectedDate, mode]);
|
||||
|
||||
const memoizedHeaderContentStyle = useMemo(() => {
|
||||
if (mode === "day") {
|
||||
return styles.dayModeHeader;
|
||||
} else if (mode === "week") {
|
||||
return styles.weekModeHeader;
|
||||
} else if (mode === "month") {
|
||||
return styles.monthModeHeader;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}, [mode]);
|
||||
|
||||
const { enrichedEvents, filteredEvents } = useMemo(() => {
|
||||
const startTime = Date.now(); // Start timer
|
||||
|
||||
const startOffset = mode === "month" ? 40 : mode === "week" ? 10 : 1;
|
||||
const endOffset = mode === "month" ? 40 : mode === "week" ? 10 : 1;
|
||||
|
||||
const filteredEvents =
|
||||
events?.filter(
|
||||
(event) =>
|
||||
event.start &&
|
||||
event.end &&
|
||||
isWithinInterval(event.start, {
|
||||
start: subDays(selectedDate, startOffset),
|
||||
end: addDays(selectedDate, endOffset),
|
||||
}) &&
|
||||
isWithinInterval(event.end, {
|
||||
start: subDays(selectedDate, startOffset),
|
||||
end: addDays(selectedDate, endOffset),
|
||||
})
|
||||
) ?? [];
|
||||
|
||||
const enrichedEvents = filteredEvents.reduce((acc, event) => {
|
||||
const dateKey = event.start.toISOString().split("T")[0];
|
||||
acc[dateKey] = acc[dateKey] || [];
|
||||
acc[dateKey].push({
|
||||
...event,
|
||||
overlapPosition: false,
|
||||
overlapCount: 0,
|
||||
});
|
||||
|
||||
acc[dateKey].sort((a, b) => compareAsc(a.start, b.start));
|
||||
|
||||
return acc;
|
||||
}, {} as Record<string, CalendarEvent[]>);
|
||||
|
||||
const endTime = Date.now();
|
||||
console.log(
|
||||
"memoizedEvents computation time:",
|
||||
endTime - startTime,
|
||||
"ms"
|
||||
);
|
||||
|
||||
return { enrichedEvents, filteredEvents };
|
||||
}, [events, selectedDate, mode]);
|
||||
|
||||
const renderCustomDateForMonth = (date: Date) => {
|
||||
const circleStyle = useMemo<ViewStyle>(
|
||||
() => ({
|
||||
width: 30,
|
||||
height: 30,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
borderRadius: 15,
|
||||
}),
|
||||
[]
|
||||
);
|
||||
|
||||
const defaultStyle = useMemo<ViewStyle>(
|
||||
() => ({
|
||||
...circleStyle,
|
||||
}),
|
||||
[circleStyle]
|
||||
);
|
||||
|
||||
const currentDateStyle = useMemo<ViewStyle>(
|
||||
() => ({
|
||||
...circleStyle,
|
||||
backgroundColor: "#4184f2",
|
||||
}),
|
||||
[circleStyle]
|
||||
);
|
||||
|
||||
const renderDate = useCallback(
|
||||
(date: Date) => {
|
||||
const isCurrentDate = isSameDate(todaysDate, date);
|
||||
const appliedStyle = isCurrentDate ? currentDateStyle : defaultStyle;
|
||||
|
||||
return (
|
||||
<View style={{ alignItems: "center" }}>
|
||||
<View style={appliedStyle}>
|
||||
<Text style={{ color: isCurrentDate ? "white" : "black" }}>
|
||||
{date.getDate()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
},
|
||||
[todaysDate, currentDateStyle, defaultStyle] // dependencies
|
||||
);
|
||||
|
||||
return renderDate(date);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setOffsetMinutes(getTotalMinutes());
|
||||
}, [events, mode]);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<View style={styles.loadingContainer}>
|
||||
<ActivityIndicator size="large" color="#0000ff" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
// console.log(enrichedEvents, filteredEvents)
|
||||
|
||||
return (
|
||||
<Calendar
|
||||
bodyContainerStyle={styles.calHeader}
|
||||
swipeEnabled
|
||||
mode={mode}
|
||||
enableEnrichedEvents={true}
|
||||
sortedMonthView
|
||||
// enrichedEventsByDate={enrichedEvents}
|
||||
events={filteredEvents}
|
||||
// eventCellStyle={memoizedEventCellStyle}
|
||||
onPressEvent={handlePressEvent}
|
||||
weekStartsOn={memoizedWeekStartsOn}
|
||||
height={calendarHeight}
|
||||
activeDate={todaysDate}
|
||||
date={selectedDate}
|
||||
onPressCell={handlePressCell}
|
||||
headerContentStyle={memoizedHeaderContentStyle}
|
||||
onSwipeEnd={handleSwipeEnd}
|
||||
scrollOffsetMinutes={offsetMinutes}
|
||||
theme={{
|
||||
palette: {
|
||||
nowIndicator: profileData?.eventColor || "#fd1575",
|
||||
gray: {
|
||||
"100": "#e8eaed",
|
||||
"200": "#e8eaed",
|
||||
"500": "#b7b7b7",
|
||||
"800": "#919191",
|
||||
},
|
||||
},
|
||||
typography: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
sm: { fontFamily: "Manrope_600SemiBold", fontSize: 15 },
|
||||
xl: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
},
|
||||
moreLabel: {},
|
||||
xs: { fontSize: 10 },
|
||||
},
|
||||
}}
|
||||
dayHeaderStyle={dateStyle}
|
||||
dayHeaderHighlightColor={"white"}
|
||||
showAdjacentMonths
|
||||
hourStyle={styles.hourStyle}
|
||||
onPressDateHeader={handlePressDayHeader}
|
||||
ampm
|
||||
// renderCustomDateForMonth={renderCustomDateForMonth}
|
||||
/>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
segmentslblStyle: {
|
||||
fontSize: 12,
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
},
|
||||
calHeader: {
|
||||
borderWidth: 0,
|
||||
},
|
||||
dayModeHeader: {
|
||||
alignSelf: "flex-start",
|
||||
justifyContent: "space-between",
|
||||
alignContent: "center",
|
||||
width: 38,
|
||||
right: 42,
|
||||
height: 13,
|
||||
},
|
||||
weekModeHeader: {},
|
||||
monthModeHeader: {},
|
||||
loadingContainer: {
|
||||
flex: 1,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
dayHeader: {
|
||||
backgroundColor: "#4184f2",
|
||||
aspectRatio: 1,
|
||||
borderRadius: 100,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
otherDayHeader: {
|
||||
backgroundColor: "transparent",
|
||||
color: "#919191",
|
||||
aspectRatio: 1,
|
||||
borderRadius: 100,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
hourStyle: {
|
||||
color: "#5f6368",
|
||||
fontSize: 12,
|
||||
fontFamily: "Manrope_500Medium",
|
||||
},
|
||||
});
|
||||
@ -1,42 +0,0 @@
|
||||
import {View} from "react-native-ui-lib";
|
||||
import React, {useRef, useState} from "react";
|
||||
import {LayoutChangeEvent} from "react-native";
|
||||
import CalendarViewSwitch from "@/components/pages/calendar/CalendarViewSwitch";
|
||||
import {AddEventDialog} from "@/components/pages/calendar/AddEventDialog";
|
||||
import {ManuallyAddEventModal} from "@/components/pages/calendar/ManuallyAddEventModal";
|
||||
import {CalendarHeader} from "@/components/pages/calendar/CalendarHeader";
|
||||
import {EventCalendar} from "@/components/pages/calendar/EventCalendar";
|
||||
|
||||
export const InnerCalendar = () => {
|
||||
const [calendarHeight, setCalendarHeight] = useState(0);
|
||||
const [calendarWidth, setCalendarWidth] = useState(0);
|
||||
const calendarContainerRef = useRef(null);
|
||||
|
||||
const onLayout = (event: LayoutChangeEvent) => {
|
||||
const {height, width} = event.nativeEvent.layout;
|
||||
setCalendarHeight(height);
|
||||
setCalendarWidth(width);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<View
|
||||
style={{flex: 1, backgroundColor: "#fff", borderRadius: 30, marginBottom: 60, overflow: "hidden"}}
|
||||
ref={calendarContainerRef}
|
||||
onLayout={onLayout}
|
||||
>
|
||||
<CalendarHeader/>
|
||||
{calendarHeight > 0 && (
|
||||
<EventCalendar
|
||||
calendarHeight={calendarHeight}
|
||||
calendarWidth={calendarWidth}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
<CalendarViewSwitch/>
|
||||
|
||||
<AddEventDialog/>
|
||||
<ManuallyAddEventModal/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import {
|
||||
Avatar,
|
||||
Button,
|
||||
ButtonSize,
|
||||
Colors,
|
||||
@ -6,39 +7,35 @@ import {
|
||||
LoaderScreen,
|
||||
Modal,
|
||||
Picker,
|
||||
PickerModes,
|
||||
Switch,
|
||||
Text,
|
||||
TextField,
|
||||
TextFieldRef,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import { ScrollView } from "react-native-gesture-handler";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { AntDesign, Feather, Ionicons } from "@expo/vector-icons";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
AntDesign,
|
||||
Feather,
|
||||
Ionicons,
|
||||
MaterialIcons,
|
||||
} from "@expo/vector-icons";
|
||||
import { PickerMultiValue } from "react-native-ui-lib/src/components/picker/types";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import { useCreateEvent } from "@/hooks/firebase/useCreateEvent";
|
||||
import { EventData } from "@/hooks/firebase/types/eventData";
|
||||
import { addHours } from "date-fns";
|
||||
import { addHours, setDate } from "date-fns";
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { CalendarEvent, useCalendarContext } from "@/contexts/CalendarContext";
|
||||
import { repeatOptions } from "@/contexts/ToDosContext";
|
||||
import { ImageBackground, StyleSheet } from "react-native";
|
||||
import ClockIcon from "@/assets/svgs/ClockIcon";
|
||||
import LockIcon from "@/assets/svgs/LockIcon";
|
||||
import MenuIcon from "@/assets/svgs/MenuIcon";
|
||||
import CameraIcon from "@/assets/svgs/CameraIcon";
|
||||
import AssigneesDisplay from "@/components/shared/AssigneesDisplay";
|
||||
import { useAtom, useAtomValue } from "jotai";
|
||||
import {
|
||||
eventForEditAtom,
|
||||
selectedNewEventDateAtom,
|
||||
isAllDayAtom,
|
||||
} from "@/components/pages/calendar/atoms";
|
||||
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
|
||||
import BinIcon from "@/assets/svgs/BinIcon";
|
||||
import DeleteEventDialog from "./DeleteEventDialog";
|
||||
import { useDeleteEvent } from "@/hooks/firebase/useDeleteEvent";
|
||||
|
||||
const daysOfWeek = [
|
||||
{ label: "Monday", value: "monday" },
|
||||
@ -50,157 +47,42 @@ const daysOfWeek = [
|
||||
{ label: "Sunday", value: "sunday" },
|
||||
];
|
||||
|
||||
export const ManuallyAddEventModal = () => {
|
||||
export const ManuallyAddEventModal = ({
|
||||
show,
|
||||
close,
|
||||
initialDate,
|
||||
}: {
|
||||
show: boolean;
|
||||
close: () => void;
|
||||
initialDate?: Date;
|
||||
}) => {
|
||||
const { addEvent } = useCalendarContext();
|
||||
const { user } = useAuthContext();
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
const [selectedNewEventDate, setSelectedNewEndDate] = useAtom(
|
||||
selectedNewEventDateAtom
|
||||
);
|
||||
const [editEvent, setEditEvent] = useAtom(eventForEditAtom);
|
||||
const [allDayAtom, setAllDayAtom] = useAtom(isAllDayAtom);
|
||||
const [deleteModalVisible, setDeleteModalVisible] = useState<boolean>(false);
|
||||
const { mutateAsync: deleteEvent, isLoading: isDeleting } = useDeleteEvent();
|
||||
|
||||
const { show, close, initialDate } = {
|
||||
show: !!selectedNewEventDate || !!editEvent,
|
||||
close: () => {
|
||||
setDeleteModalVisible(false);
|
||||
setSelectedNewEndDate(undefined);
|
||||
setEditEvent(undefined);
|
||||
},
|
||||
initialDate: selectedNewEventDate || editEvent?.start,
|
||||
};
|
||||
|
||||
const detailsRef = useRef<TextFieldRef>(null);
|
||||
|
||||
const [title, setTitle] = useState<string>(editEvent?.title || "");
|
||||
const [details, setDetails] = useState<string>(editEvent?.notes || "");
|
||||
const [isAllDay, setIsAllDay] = useState(editEvent?.allDay || false);
|
||||
const [isPrivate, setIsPrivate] = useState<boolean>(
|
||||
editEvent?.private || false
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(allDayAtom);
|
||||
return () => {
|
||||
setAllDayAtom(false);
|
||||
};
|
||||
}, []);
|
||||
const [title, setTitle] = useState<string>("");
|
||||
|
||||
const [isAllDay, setIsAllDay] = useState(false);
|
||||
const [isPrivate, setIsPrivate] = useState<boolean>(false);
|
||||
const [startTime, setStartTime] = useState(() => {
|
||||
const date = initialDate ?? new Date();
|
||||
if (
|
||||
date.getMinutes() > 0 ||
|
||||
date.getSeconds() > 0 ||
|
||||
date.getMilliseconds() > 0
|
||||
) {
|
||||
date.setHours(date.getHours() + 1);
|
||||
}
|
||||
date.setMinutes(0);
|
||||
date.setSeconds(0);
|
||||
date.setMilliseconds(0);
|
||||
date.setSeconds(0, 0);
|
||||
return date;
|
||||
});
|
||||
|
||||
const [endTime, setEndTime] = useState(() => {
|
||||
if (editEvent?.end) {
|
||||
const date = new Date(editEvent.end);
|
||||
date.setSeconds(0, 0);
|
||||
return date;
|
||||
}
|
||||
|
||||
const baseDate = editEvent?.end ?? initialDate ?? new Date();
|
||||
const date = new Date(baseDate);
|
||||
|
||||
if (
|
||||
date.getMinutes() > 0 ||
|
||||
date.getSeconds() > 0 ||
|
||||
date.getMilliseconds() > 0
|
||||
) {
|
||||
date.setHours(date.getHours() + 1);
|
||||
}
|
||||
date.setMinutes(0);
|
||||
date.setSeconds(0);
|
||||
date.setMilliseconds(0);
|
||||
|
||||
date.setHours(date.getHours() + 1);
|
||||
const date = initialDate
|
||||
? addHours(initialDate, 1)
|
||||
: addHours(new Date(), 1);
|
||||
date.setSeconds(0, 0);
|
||||
return date;
|
||||
});
|
||||
|
||||
const [startDate, setStartDate] = useState(initialDate ?? new Date());
|
||||
const [endDate, setEndDate] = useState(
|
||||
editEvent?.end ?? initialDate ?? new Date()
|
||||
);
|
||||
const [selectedAttendees, setSelectedAttendees] = useState<string[]>(
|
||||
editEvent?.participants ?? []
|
||||
);
|
||||
const [endDate, setEndDate] = useState(initialDate ?? new Date());
|
||||
|
||||
const [repeatInterval, setRepeatInterval] = useState<PickerMultiValue>([]);
|
||||
|
||||
const {
|
||||
mutateAsync: createEvent,
|
||||
isLoading: isAdding,
|
||||
isError,
|
||||
} = useCreateEvent();
|
||||
const { data: members } = useGetFamilyMembers(true);
|
||||
const titleRef = useRef<TextFieldRef>(null);
|
||||
|
||||
const isLoading = isDeleting || isAdding;
|
||||
|
||||
useEffect(() => {
|
||||
setTitle(editEvent?.title || "");
|
||||
setDetails(editEvent?.notes || "");
|
||||
setIsAllDay(editEvent?.allDay || false);
|
||||
setIsPrivate(editEvent?.private || false);
|
||||
|
||||
setStartTime(() => {
|
||||
const date = new Date(initialDate ?? new Date());
|
||||
const minutes = date.getMinutes();
|
||||
date.setMinutes(0, 0, 0);
|
||||
if (minutes >= 30) {
|
||||
date.setHours(date.getHours() + 1);
|
||||
}
|
||||
return date;
|
||||
});
|
||||
|
||||
setEndTime(() => {
|
||||
if (editEvent?.end) {
|
||||
const date = new Date(editEvent.end);
|
||||
date.setSeconds(0, 0);
|
||||
return date;
|
||||
}
|
||||
|
||||
const baseDate = editEvent?.end ?? initialDate ?? new Date();
|
||||
const date = new Date(baseDate);
|
||||
|
||||
if (
|
||||
date.getMinutes() > 0 ||
|
||||
date.getSeconds() > 0 ||
|
||||
date.getMilliseconds() > 0
|
||||
) {
|
||||
date.setHours(date.getHours() + 1);
|
||||
}
|
||||
date.setMinutes(0);
|
||||
date.setSeconds(0);
|
||||
date.setMilliseconds(0);
|
||||
|
||||
date.setHours(date.getHours() + 1);
|
||||
return date;
|
||||
});
|
||||
|
||||
setStartDate(initialDate ?? new Date());
|
||||
setEndDate(editEvent?.end ?? initialDate ?? new Date());
|
||||
setSelectedAttendees(editEvent?.participants ?? []);
|
||||
setRepeatInterval([]);
|
||||
}, [editEvent, selectedNewEventDate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (show && !editEvent) {
|
||||
setTimeout(() => {
|
||||
titleRef?.current?.focus();
|
||||
}, 500);
|
||||
}
|
||||
}, [selectedNewEventDate]);
|
||||
|
||||
if (!show) return null;
|
||||
const { mutateAsync: createEvent, isLoading, isError } = useCreateEvent();
|
||||
|
||||
const formatDateTime = (date?: Date | string) => {
|
||||
if (!date) return undefined;
|
||||
@ -211,19 +93,6 @@ export const ManuallyAddEventModal = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const showDeleteEventModal = () => {
|
||||
setDeleteModalVisible(true);
|
||||
};
|
||||
|
||||
const handleDeleteEvent = async () => {
|
||||
await deleteEvent({ eventId: `${editEvent?.id}` });
|
||||
close();
|
||||
};
|
||||
|
||||
const hideDeleteEventModal = () => {
|
||||
setDeleteModalVisible(false);
|
||||
};
|
||||
|
||||
const combineDateAndTime = (date: Date, time: Date): Date => {
|
||||
const combined = new Date(date);
|
||||
combined.setHours(time.getHours());
|
||||
@ -250,14 +119,9 @@ export const ManuallyAddEventModal = () => {
|
||||
startDate: finalStartDate,
|
||||
endDate: finalEndDate,
|
||||
allDay: isAllDay,
|
||||
attendees: selectedAttendees,
|
||||
notes: details,
|
||||
};
|
||||
|
||||
if (editEvent?.id) eventData.id = editEvent?.id;
|
||||
|
||||
await createEvent(eventData);
|
||||
setEditEvent(undefined);
|
||||
|
||||
close();
|
||||
};
|
||||
@ -302,10 +166,7 @@ export const ManuallyAddEventModal = () => {
|
||||
onRequestClose={close}
|
||||
transparent={false}
|
||||
>
|
||||
<LoaderScreen
|
||||
message={isDeleting ? "Deleting event..." : "Saving event..."}
|
||||
color={Colors.grey40}
|
||||
/>
|
||||
<LoaderScreen message={"Saving event..."} color={Colors.grey40} />
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@ -327,39 +188,6 @@ export const ManuallyAddEventModal = () => {
|
||||
paddingRight: insets.right, // Safe area inset for right
|
||||
}}
|
||||
>
|
||||
{/*{editEvent ? (*/}
|
||||
{/* <>*/}
|
||||
{/* <View center paddingT-8>*/}
|
||||
{/* <TouchableOpacity onPress={close}>*/}
|
||||
{/* <DropModalIcon />*/}
|
||||
{/* </TouchableOpacity>*/}
|
||||
{/* </View>*/}
|
||||
{/* <View row spread paddingH-10 paddingB-15>*/}
|
||||
{/* <Button*/}
|
||||
{/* color="#05a8b6"*/}
|
||||
{/* style={styles.topBtn}*/}
|
||||
{/* iconSource={() => <CloseXIcon />}*/}
|
||||
{/* onPress={close}*/}
|
||||
{/* />*/}
|
||||
{/* <View row>*/}
|
||||
{/* <Button*/}
|
||||
{/* style={styles.topBtn}*/}
|
||||
{/* marginR-10*/}
|
||||
{/* iconSource={() => <PenIcon />}*/}
|
||||
{/* onPress={handleSave}*/}
|
||||
{/* />*/}
|
||||
{/* <Button*/}
|
||||
{/* style={styles.topBtn}*/}
|
||||
{/* marginL-5*/}
|
||||
{/* iconSource={() => <BinIcon />}*/}
|
||||
{/* onPress={() => {*/}
|
||||
{/* showDeleteEventModal();*/}
|
||||
{/* }}*/}
|
||||
{/* />*/}
|
||||
{/* </View>*/}
|
||||
{/* </View>*/}
|
||||
{/* </>*/}
|
||||
{/*) : (*/}
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
@ -379,37 +207,23 @@ export const ManuallyAddEventModal = () => {
|
||||
Cancel
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
<View row center>
|
||||
<DropModalIcon onPress={close} />
|
||||
</View>
|
||||
<View flexS row gap-10>
|
||||
<TouchableOpacity onPress={handleSave}>
|
||||
<Text
|
||||
style={{
|
||||
color: "#05a8b6",
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
}}
|
||||
text70
|
||||
>
|
||||
Save
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
{editEvent && (
|
||||
<Button
|
||||
style={styles.topBtn}
|
||||
marginL-5
|
||||
iconSource={() => <BinIcon />}
|
||||
onPress={showDeleteEventModal}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
<DropModalIcon onPress={close} />
|
||||
<TouchableOpacity onPress={handleSave}>
|
||||
<Text
|
||||
style={{
|
||||
color: "#05a8b6",
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
}}
|
||||
text70
|
||||
>
|
||||
Save
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
{/*)}*/}
|
||||
<ScrollView style={{ minHeight: "85%" }}>
|
||||
<ScrollView>
|
||||
<TextField
|
||||
placeholder="Add event title"
|
||||
ref={titleRef}
|
||||
value={title}
|
||||
onChangeText={(text) => {
|
||||
setTitle(text);
|
||||
@ -418,7 +232,6 @@ export const ManuallyAddEventModal = () => {
|
||||
style={{ fontFamily: "Manrope_500Medium", fontSize: 22 }}
|
||||
paddingT-15
|
||||
paddingL-30
|
||||
returnKeyType="next"
|
||||
/>
|
||||
<View style={styles.divider} marginT-8 />
|
||||
<View marginL-30 centerV>
|
||||
@ -453,7 +266,7 @@ export const ManuallyAddEventModal = () => {
|
||||
onChange={(date) => {
|
||||
setStartDate(date);
|
||||
}}
|
||||
//maximumDate={endDate}
|
||||
maximumDate={endDate}
|
||||
style={{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
@ -463,11 +276,8 @@ export const ManuallyAddEventModal = () => {
|
||||
</View>
|
||||
<DateTimePicker
|
||||
value={startTime}
|
||||
onChange={(time) => {
|
||||
if (time <= endTime) {
|
||||
setStartTime(time);
|
||||
}
|
||||
}}
|
||||
onChange={(date) => setStartTime(date)}
|
||||
maximumDate={endTime}
|
||||
minuteInterval={5}
|
||||
dateTimeFormatter={(date, mode) =>
|
||||
date.toLocaleTimeString("en-us", {
|
||||
@ -504,11 +314,7 @@ export const ManuallyAddEventModal = () => {
|
||||
</View>
|
||||
<DateTimePicker
|
||||
value={endTime}
|
||||
onChange={(time) => {
|
||||
if (time >= endTime) {
|
||||
setEndTime(time);
|
||||
}
|
||||
}}
|
||||
onChange={(date) => setEndTime(date)}
|
||||
minimumDate={startTime}
|
||||
minuteInterval={5}
|
||||
dateTimeFormatter={(date, mode) =>
|
||||
@ -538,54 +344,27 @@ export const ManuallyAddEventModal = () => {
|
||||
>
|
||||
Attendees
|
||||
</Text>
|
||||
<View flex-1 />
|
||||
<Picker
|
||||
value={selectedAttendees}
|
||||
onChange={(value) =>
|
||||
setSelectedAttendees((value as string[]) ?? [])
|
||||
}
|
||||
style={{ marginLeft: "auto" }}
|
||||
mode={PickerModes.MULTI}
|
||||
renderInput={() => (
|
||||
<Button
|
||||
size={ButtonSize.small}
|
||||
paddingH-8
|
||||
iconSource={() => (
|
||||
<Ionicons name="add-outline" size={20} color="#ea156c" />
|
||||
)}
|
||||
style={{
|
||||
marginLeft: "auto",
|
||||
borderRadius: 8,
|
||||
backgroundColor: "#ffe8f1",
|
||||
borderColor: "#ea156c",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
color="#ea156c"
|
||||
label="Add"
|
||||
labelStyle={{
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 14,
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
size={ButtonSize.small}
|
||||
paddingH-8
|
||||
iconSource={() => (
|
||||
<Ionicons name="add-outline" size={20} color="#ea156c" />
|
||||
)}
|
||||
>
|
||||
{members?.map((member) => (
|
||||
<Picker.Item
|
||||
key={member?.uid}
|
||||
value={member?.uid!}
|
||||
label={member?.firstName + " " + member?.lastName}
|
||||
/>
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
|
||||
<View marginL-35>
|
||||
<AssigneesDisplay
|
||||
setSelectedAttendees={setSelectedAttendees}
|
||||
selectedAttendees={selectedAttendees}
|
||||
style={{
|
||||
marginLeft: "auto",
|
||||
borderRadius: 8,
|
||||
backgroundColor: "#ffe8f1",
|
||||
borderColor: "#ea156c",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
color="#ea156c"
|
||||
label="Add"
|
||||
labelStyle={{ fontFamily: "Manrope_600SemiBold", fontSize: 14 }}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View marginL-35>
|
||||
<AssigneesDisplay />
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<View marginH-30 marginB-0 row spread centerV>
|
||||
<View row centerV>
|
||||
@ -622,15 +401,14 @@ export const ManuallyAddEventModal = () => {
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<View marginH-30 marginB-0 row spread centerV>
|
||||
<View row center>
|
||||
<View row>
|
||||
<LockIcon />
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
}}
|
||||
marginL-12
|
||||
center
|
||||
marginL-10
|
||||
>
|
||||
Mark as Private
|
||||
</Text>
|
||||
@ -646,38 +424,25 @@ export const ManuallyAddEventModal = () => {
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<View marginH-30 marginB-0 spread centerV flex-1>
|
||||
<TouchableOpacity onPress={() => detailsRef?.current?.focus()}>
|
||||
<View row centerV>
|
||||
<MenuIcon />
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
}}
|
||||
marginL-10
|
||||
>
|
||||
Add Details
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
<TextField
|
||||
value={details}
|
||||
onChangeText={setDetails}
|
||||
ref={detailsRef}
|
||||
maxLength={2000}
|
||||
multiline
|
||||
numberOfLines={10}
|
||||
marginT-10
|
||||
style={{ flex: 1, minHeight: 180 }}
|
||||
/>
|
||||
<View marginH-30 marginB-0 row spread centerV>
|
||||
<View row centerV>
|
||||
<MenuIcon />
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
}}
|
||||
marginL-10
|
||||
>
|
||||
Add Details
|
||||
</Text>
|
||||
</View>
|
||||
<View></View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
<Button
|
||||
disabled
|
||||
marginH-30
|
||||
marginB-30
|
||||
marginB-15
|
||||
label="Create event from image"
|
||||
text70
|
||||
style={{ height: 47 }}
|
||||
@ -690,14 +455,6 @@ export const ManuallyAddEventModal = () => {
|
||||
)}
|
||||
/>
|
||||
</View>
|
||||
{editEvent && (
|
||||
<DeleteEventDialog
|
||||
visible={deleteModalVisible}
|
||||
title={editEvent?.title}
|
||||
onDismiss={hideDeleteEventModal}
|
||||
onConfirm={handleDeleteEvent}
|
||||
/>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
import { atom } from "jotai";
|
||||
import { CalendarEvent } from "@/components/pages/calendar/interfaces";
|
||||
|
||||
export const editVisibleAtom = atom<boolean>(false);
|
||||
export const isAllDayAtom = atom<boolean>(false);
|
||||
export const eventForEditAtom = atom<CalendarEvent | undefined>(undefined);
|
||||
export const isFamilyViewAtom = atom<boolean>(false);
|
||||
export const modeAtom = atom<"week" | "month" | "day">("week");
|
||||
export const selectedDateAtom = atom<Date>(new Date());
|
||||
export const selectedNewEventDateAtom = atom<Date | undefined>(undefined);
|
||||
export const settingsPageIndex = atom<number>(0);
|
||||
export const userSettingsView = atom<boolean>(true);
|
||||
export const toDosPageIndex = atom<number>(0);
|
||||
@ -1,20 +0,0 @@
|
||||
export const modeMap = new Map([
|
||||
[0, "day"],
|
||||
[1, "week"],
|
||||
[2, "month"],
|
||||
]);
|
||||
|
||||
export const months = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
];
|
||||
@ -1,16 +0,0 @@
|
||||
export interface CalendarEvent {
|
||||
id?: number | string; // Unique identifier for the event
|
||||
user?: string;
|
||||
title: string; // Event title or name
|
||||
description?: string; // Optional description for the event
|
||||
start: Date; // Start date and time of the event
|
||||
end: Date; // End date and time of the event
|
||||
location?: string; // Optional event location
|
||||
allDay?: boolean; // Specifies if the event lasts all day
|
||||
eventColor?: string; // Optional color to represent the event
|
||||
participants?: string[]; // Optional list of participants or attendees
|
||||
private?: boolean;
|
||||
notes?: string,
|
||||
overlapPosition?: number
|
||||
overlapCount?: number
|
||||
}
|
||||
@ -1,157 +0,0 @@
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
TextField,
|
||||
TextFieldRef,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
||||
import { Dimensions, Platform, StyleSheet } from "react-native";
|
||||
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import { useBrainDumpContext } from "@/contexts/DumpContext";
|
||||
import KeyboardManager from "react-native-keyboard-manager";
|
||||
import { useFeedbackContext } from "@/contexts/FeedbackContext";
|
||||
|
||||
interface IAddFeedbackProps {
|
||||
isVisible: boolean;
|
||||
setIsVisible: (value: boolean) => void;
|
||||
}
|
||||
|
||||
const AddFeedback = ({
|
||||
addFeedbackProps,
|
||||
}: {
|
||||
addFeedbackProps: IAddFeedbackProps;
|
||||
}) => {
|
||||
const { addFeedback } = useFeedbackContext();
|
||||
const [feedback, setFeedback] = useState<string>("");
|
||||
const [feedbackTitle, setFeedbackTitle] = useState<string>("");
|
||||
const { width } = Dimensions.get("screen");
|
||||
|
||||
const descriptionRef = useRef<TextFieldRef>(null);
|
||||
const titleRef = useRef<TextFieldRef>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setFeedback("");
|
||||
}, [addFeedbackProps.isVisible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (addFeedbackProps.isVisible) {
|
||||
setTimeout(() => {
|
||||
titleRef?.current?.focus();
|
||||
}, 500);
|
||||
}
|
||||
}, [addFeedbackProps.isVisible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (Platform.OS === "ios") KeyboardManager.setEnableAutoToolbar(false);
|
||||
|
||||
setFeedbackTitle("");
|
||||
setFeedback("");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
height={"90%"}
|
||||
width={width}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
onDismiss={() => addFeedbackProps.setIsVisible(false)}
|
||||
containerStyle={styles.dialogContainer}
|
||||
visible={addFeedbackProps.isVisible}
|
||||
>
|
||||
<View row spread style={styles.topBtns} marginB-20>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
label="Cancel"
|
||||
style={styles.topBtn}
|
||||
onPress={() => {
|
||||
addFeedbackProps.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
<TouchableOpacity onPress={() => addFeedbackProps.setIsVisible(false)}>
|
||||
<DropModalIcon style={{ marginTop: 15 }} />
|
||||
</TouchableOpacity>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
label="Save"
|
||||
style={styles.topBtn}
|
||||
onPress={() => {
|
||||
addFeedback({
|
||||
id: 99,
|
||||
|
||||
title: feedbackTitle.trimEnd().trimStart(),
|
||||
|
||||
text: feedback.trimEnd().trimStart(),
|
||||
});
|
||||
addFeedbackProps.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View marginH-20>
|
||||
<TextField
|
||||
value={feedbackTitle}
|
||||
ref={titleRef}
|
||||
placeholder="Set Title"
|
||||
text60R
|
||||
onChangeText={(text) => {
|
||||
setFeedbackTitle(text);
|
||||
}}
|
||||
onSubmitEditing={() => {
|
||||
descriptionRef.current?.focus();
|
||||
}}
|
||||
style={styles.title}
|
||||
blurOnSubmit={false}
|
||||
returnKeyType="next"
|
||||
/>
|
||||
<View height={2} backgroundColor="#b3b3b3" width={"100%"} marginB-20 />
|
||||
<TextField
|
||||
ref={descriptionRef}
|
||||
value={feedback}
|
||||
placeholder="Write Description"
|
||||
text70
|
||||
onChangeText={(text) => {
|
||||
setFeedback(text);
|
||||
}}
|
||||
style={styles.description}
|
||||
multiline
|
||||
numberOfLines={4}
|
||||
maxLength={255}
|
||||
onEndEditing={() => {
|
||||
descriptionRef.current?.blur();
|
||||
}}
|
||||
returnKeyType="done"
|
||||
/>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
dialogContainer: {
|
||||
borderTopRightRadius: 15,
|
||||
borderTopLeftRadius: 15,
|
||||
backgroundColor: "white",
|
||||
padding: 0,
|
||||
paddingTop: 3,
|
||||
margin: 0,
|
||||
},
|
||||
topBtns: {},
|
||||
topBtn: {
|
||||
backgroundColor: "white",
|
||||
color: "#05a8b6",
|
||||
},
|
||||
title: {
|
||||
fontSize: 22,
|
||||
fontFamily: "Manrope_500Medium",
|
||||
},
|
||||
description: {
|
||||
fontFamily: "Manrope_400Regular",
|
||||
fontSize: 14,
|
||||
textAlignVertical: "top",
|
||||
},
|
||||
});
|
||||
|
||||
export default AddFeedback;
|
||||
@ -1,196 +0,0 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
View,
|
||||
Text,
|
||||
TextField,
|
||||
TouchableOpacity,
|
||||
TextFieldRef,
|
||||
} from "react-native-ui-lib";
|
||||
import { Dimensions, StyleSheet } from "react-native";
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
||||
import PenIcon from "@/assets/svgs/PenIcon";
|
||||
import BinIcon from "@/assets/svgs/BinIcon";
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import CloseXIcon from "@/assets/svgs/CloseXIcon";
|
||||
import NavCalendarIcon from "@/assets/svgs/NavCalendarIcon";
|
||||
import NavToDosIcon from "@/assets/svgs/NavToDosIcon";
|
||||
import RemindersIcon from "@/assets/svgs/RemindersIcon";
|
||||
import MenuIcon from "@/assets/svgs/MenuIcon";
|
||||
import { IFeedback, useFeedbackContext } from "@/contexts/FeedbackContext";
|
||||
import FeedbackDialog from "./FeedbackDialog";
|
||||
|
||||
const EditFeedback = (props: {
|
||||
item: IFeedback;
|
||||
isVisible: boolean;
|
||||
setIsVisible: (value: boolean) => void;
|
||||
}) => {
|
||||
const { updateFeedback, deleteFeedback } = useFeedbackContext();
|
||||
const [text, setText] = useState<string>(props.item.text);
|
||||
const [modalVisible, setModalVisible] = useState<boolean>(false);
|
||||
const textRef = useRef<TextFieldRef>(null);
|
||||
|
||||
const { width } = Dimensions.get("screen");
|
||||
|
||||
useEffect(() => {
|
||||
setText(props.item.text);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.isVisible) {
|
||||
setTimeout(() => {
|
||||
textRef?.current?.focus();
|
||||
}, 500);
|
||||
}
|
||||
}, [props.isVisible]);
|
||||
|
||||
const showConfirmationDialog = () => {
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
const handleDeleteNote = () => {
|
||||
deleteFeedback(props.item.id);
|
||||
};
|
||||
|
||||
const hideConfirmationDialog = () => {
|
||||
setModalVisible(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
height={"90%"}
|
||||
width={width}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
onDismiss={() => props.setIsVisible(false)}
|
||||
containerStyle={{
|
||||
borderRadius: 15,
|
||||
borderBottomLeftRadius: 0,
|
||||
borderBottomRightRadius: 0,
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
alignSelf: "stretch",
|
||||
padding: 10,
|
||||
paddingTop: 3,
|
||||
margin: 0,
|
||||
}}
|
||||
visible={props.isVisible}
|
||||
>
|
||||
<View center paddingT-8>
|
||||
<TouchableOpacity onPress={() => props.setIsVisible(false)}>
|
||||
<DropModalIcon />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<View row spread paddingH-10 paddingB-15>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
style={styles.topBtn}
|
||||
iconSource={() => <CloseXIcon />}
|
||||
onPress={() => {
|
||||
props.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
<View row>
|
||||
<Button
|
||||
style={styles.topBtn}
|
||||
marginR-10
|
||||
iconSource={() => <PenIcon />}
|
||||
onPress={() => {
|
||||
console.log("selview");
|
||||
updateFeedback(props.item.id, { text: text });
|
||||
props.setIsVisible(false);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
style={styles.topBtn}
|
||||
marginL-5
|
||||
iconSource={() => <BinIcon />}
|
||||
onPress={() => {
|
||||
showConfirmationDialog();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View centerH>
|
||||
<Text style={styles.title}>{props.item.title} </Text>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<View row gap-5 paddingR-20>
|
||||
<View paddingT-8 marginR-5>
|
||||
<MenuIcon width={20} height={12} />
|
||||
</View>
|
||||
<TextField
|
||||
textAlignVertical="top"
|
||||
multiline
|
||||
style={styles.description}
|
||||
placeholder="Add description"
|
||||
numberOfLines={3}
|
||||
value={text}
|
||||
onChangeText={(value) => {
|
||||
setText(value);
|
||||
}}
|
||||
ref={textRef}
|
||||
returnKeyType="done"
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<FeedbackDialog
|
||||
visible={modalVisible}
|
||||
title={props.item.title}
|
||||
onDismiss={hideConfirmationDialog}
|
||||
onConfirm={handleDeleteNote}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
divider: { height: 1, backgroundColor: "#e4e4e4", marginVertical: 15 },
|
||||
gradient: {
|
||||
height: "25%",
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
width: "100%",
|
||||
},
|
||||
buttonContainer: {
|
||||
position: "absolute",
|
||||
bottom: 25,
|
||||
width: "100%",
|
||||
},
|
||||
button: {
|
||||
backgroundColor: "rgb(253, 23, 117)",
|
||||
paddingVertical: 20,
|
||||
},
|
||||
topBtn: {
|
||||
backgroundColor: "white",
|
||||
color: "#05a8b6",
|
||||
marginTop: -3,
|
||||
},
|
||||
rotateSwitch: {
|
||||
marginLeft: 35,
|
||||
marginBottom: 10,
|
||||
marginTop: 25,
|
||||
},
|
||||
optionsReg: {
|
||||
fontSize: 16,
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
},
|
||||
optionsBold: {
|
||||
fontSize: 16,
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
},
|
||||
optionsIcon: {
|
||||
marginRight: 10,
|
||||
},
|
||||
title: {
|
||||
fontSize: 22,
|
||||
fontFamily: "Manrope_500Medium",
|
||||
},
|
||||
description: {
|
||||
fontFamily: "Manrope_400Regular",
|
||||
fontSize: 14,
|
||||
},
|
||||
});
|
||||
|
||||
export default EditFeedback;
|
||||
@ -1,50 +0,0 @@
|
||||
import { View, Text } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
TouchableWithoutFeedback,
|
||||
} from "react-native-gesture-handler";
|
||||
import { IFeedback } from "@/contexts/FeedbackContext";
|
||||
import EditFeedback from "./EditFeedback";
|
||||
|
||||
const Feedback = (props: { item: IFeedback }) => {
|
||||
const [isVisible, setIsVisible] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<View>
|
||||
<TouchableWithoutFeedback onPress={() => setIsVisible(true)}>
|
||||
<View
|
||||
backgroundColor="white"
|
||||
marginV-5
|
||||
paddingH-13
|
||||
paddingV-10
|
||||
style={{ borderRadius: 15, elevation: 2 }}
|
||||
>
|
||||
<Text
|
||||
text70B
|
||||
style={{ fontSize: 15, fontFamily: "Manrope_600SemiBold" }}
|
||||
marginB-8
|
||||
>
|
||||
{props.item.title}
|
||||
</Text>
|
||||
<Text
|
||||
text70
|
||||
style={{
|
||||
fontSize: 13,
|
||||
fontFamily: "Manrope_400Regular",
|
||||
color: "#5c5c5c",
|
||||
}}
|
||||
>
|
||||
{props.item.text}
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
<EditFeedback
|
||||
item={props.item}
|
||||
isVisible={isVisible}
|
||||
setIsVisible={setIsVisible}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default Feedback;
|
||||
@ -1,81 +0,0 @@
|
||||
import React from "react";
|
||||
import { Dialog, Button, Text, View } from "react-native-ui-lib";
|
||||
import { StyleSheet } from "react-native";
|
||||
|
||||
interface FeedbackDialogProps {
|
||||
visible: boolean;
|
||||
title: string;
|
||||
onDismiss: () => void;
|
||||
onConfirm: () => void;
|
||||
}
|
||||
|
||||
const FeedbackDialog: React.FC<FeedbackDialogProps> = ({
|
||||
visible,
|
||||
title,
|
||||
onDismiss,
|
||||
onConfirm,
|
||||
}) => {
|
||||
return (
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onDismiss={onDismiss}
|
||||
containerStyle={styles.dialog}
|
||||
>
|
||||
<Text center style={styles.title}>
|
||||
Delete Note
|
||||
</Text>
|
||||
<View center>
|
||||
<Text style={styles.text} center>
|
||||
Are you sure you want to delete this feedback? {"\n\n"}
|
||||
<Text style={{ fontSize: 16, fontFamily: "PlusJakartaSans_700Bold" }}>
|
||||
{title}
|
||||
</Text>
|
||||
</Text>
|
||||
</View>
|
||||
<View row right gap-8>
|
||||
<Button
|
||||
label="Cancel"
|
||||
onPress={onDismiss}
|
||||
style={styles.cancelBtn}
|
||||
color="#999999"
|
||||
labelStyle={{ fontFamily: "Poppins_500Medium", fontSize: 13.53 }}
|
||||
/>
|
||||
<Button
|
||||
label="Yes"
|
||||
onPress={onConfirm}
|
||||
style={styles.confirmBtn}
|
||||
labelStyle={{ fontFamily: "PlusJakartaSans_500Medium" }}
|
||||
/>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
// Empty stylesheet for future styles
|
||||
const styles = StyleSheet.create({
|
||||
confirmBtn: {
|
||||
backgroundColor: "#ea156d",
|
||||
},
|
||||
cancelBtn: {
|
||||
backgroundColor: "white",
|
||||
},
|
||||
dialog: {
|
||||
backgroundColor: "white",
|
||||
paddingHorizontal: 25,
|
||||
paddingTop: 35,
|
||||
paddingBottom: 17,
|
||||
borderRadius: 20,
|
||||
},
|
||||
title: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 22,
|
||||
marginBottom: 20,
|
||||
},
|
||||
text: {
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
marginBottom: 25,
|
||||
},
|
||||
});
|
||||
|
||||
export default FeedbackDialog;
|
||||
@ -1,35 +0,0 @@
|
||||
import { View } from "react-native-ui-lib";
|
||||
import React from "react";
|
||||
import { FlatList } from "react-native";
|
||||
import { useFeedbackContext } from "@/contexts/FeedbackContext";
|
||||
import Feedback from "./Feedback";
|
||||
|
||||
const FeedbackList = (props: { searchText: string }) => {
|
||||
const { feedbacks } = useFeedbackContext();
|
||||
|
||||
const filteredBrainDumps =
|
||||
props.searchText.trim() === ""
|
||||
? feedbacks
|
||||
: feedbacks.filter(
|
||||
(item) =>
|
||||
item.title.toLowerCase().includes(props.searchText.toLowerCase()) ||
|
||||
item.text
|
||||
.toLowerCase()
|
||||
.includes(props.searchText.toLowerCase())
|
||||
);
|
||||
|
||||
return (
|
||||
<View marginB-70>
|
||||
<FlatList
|
||||
style={{ zIndex: -1 }}
|
||||
data={filteredBrainDumps}
|
||||
keyExtractor={(item) => item.title}
|
||||
renderItem={({ item }) => (
|
||||
<Feedback key={item.title} item={item} />
|
||||
)}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default FeedbackList;
|
||||
@ -1,120 +0,0 @@
|
||||
import {Dimensions, ScrollView, StyleSheet} from "react-native";
|
||||
import React, {useState} from "react";
|
||||
import {Button, Text, TextField, View} from "react-native-ui-lib";
|
||||
import HeaderTemplate from "@/components/shared/HeaderTemplate";
|
||||
import {Feather, MaterialIcons} from "@expo/vector-icons";
|
||||
import LinearGradient from "react-native-linear-gradient";
|
||||
import PlusIcon from "@/assets/svgs/PlusIcon";
|
||||
import AddFeedback from "./AddFeedback";
|
||||
import FeedbackList from "./FeedbackList";
|
||||
|
||||
const FeedbackPage = () => {
|
||||
const [searchText, setSearchText] = useState<string>("");
|
||||
const [isAddVisible, setIsAddVisible] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<View height={"100%"}>
|
||||
<View>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
>
|
||||
<View marginH-25>
|
||||
<HeaderTemplate
|
||||
message={"Welcome to your Feedback!"}
|
||||
isWelcome={false}
|
||||
children={
|
||||
<Text
|
||||
style={{fontFamily: "Manrope_400Regular", fontSize: 14}}
|
||||
>
|
||||
Drop your feedback here, and{"\n"}organize it later.
|
||||
</Text>
|
||||
}
|
||||
/>
|
||||
<View>
|
||||
<View style={styles.searchField} centerV>
|
||||
<TextField
|
||||
value={searchText}
|
||||
onChangeText={(value) => {
|
||||
setSearchText(value);
|
||||
}}
|
||||
leadingAccessory={
|
||||
<Feather
|
||||
name="search"
|
||||
size={24}
|
||||
color="#9b9b9b"
|
||||
style={{paddingRight: 10}}
|
||||
/>
|
||||
}
|
||||
style={{
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
}}
|
||||
placeholder="Search your feedbacks..."
|
||||
/>
|
||||
</View>
|
||||
<FeedbackList searchText={searchText}/>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
<LinearGradient
|
||||
colors={["#f9f8f700", "#f9f8f7"]}
|
||||
locations={[0,1]}
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
height: 120,
|
||||
width: Dimensions.get("screen").width,
|
||||
justifyContent:'center',
|
||||
alignItems:"center"
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
style={{
|
||||
height: 40,
|
||||
position: "relative",
|
||||
width: "90%",
|
||||
bottom: -10,
|
||||
borderRadius: 30,
|
||||
backgroundColor: "#fd1775",
|
||||
}}
|
||||
color="white"
|
||||
enableShadow
|
||||
onPress={() => {
|
||||
setIsAddVisible(true);
|
||||
}}
|
||||
>
|
||||
<View row centerV centerH>
|
||||
<PlusIcon />
|
||||
<Text
|
||||
white
|
||||
style={{fontSize: 16, fontFamily: "Manrope_600SemiBold", marginLeft: 5}}
|
||||
>
|
||||
New
|
||||
</Text>
|
||||
</View>
|
||||
</Button>
|
||||
</LinearGradient>
|
||||
<AddFeedback
|
||||
addFeedbackProps={{
|
||||
isVisible: isAddVisible,
|
||||
setIsVisible: setIsAddVisible,
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
searchField: {
|
||||
borderWidth: 0.7,
|
||||
borderColor: "#9b9b9b",
|
||||
borderRadius: 15,
|
||||
height: 42,
|
||||
paddingLeft: 10,
|
||||
marginVertical: 20,
|
||||
},
|
||||
});
|
||||
|
||||
export default FeedbackPage;
|
||||
@ -1,88 +1,96 @@
|
||||
import {Dimensions, StyleSheet} from "react-native";
|
||||
import React from "react";
|
||||
import {Button, View,} from "react-native-ui-lib";
|
||||
import {useGroceryContext} from "@/contexts/GroceryContext";
|
||||
import {FontAwesome6} from "@expo/vector-icons";
|
||||
import PlusIcon from "@/assets/svgs/PlusIcon";
|
||||
|
||||
const { width } = Dimensions.get("screen");
|
||||
|
||||
import { StyleSheet } from "react-native";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Colors,
|
||||
Dialog,
|
||||
Drawer,
|
||||
Text,
|
||||
View,
|
||||
PanningProvider,
|
||||
} from "react-native-ui-lib";
|
||||
import { useGroceryContext } from "@/contexts/GroceryContext";
|
||||
import { FontAwesome6 } from "@expo/vector-icons";
|
||||
interface AddGroceryItemProps {
|
||||
visible: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
const AddGroceryItem = () => {
|
||||
const {setIsAddingGrocery} = useGroceryContext();
|
||||
const { isAddingGrocery, setIsAddingGrocery } = useGroceryContext();
|
||||
const [visible, setVisible] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<View
|
||||
row
|
||||
spread
|
||||
paddingH-20
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 15,
|
||||
width: "100%",
|
||||
height: 53.26,
|
||||
}}
|
||||
>
|
||||
<View style={styles.btnContainer} row>
|
||||
<Button
|
||||
color="white"
|
||||
backgroundColor="#fd1775"
|
||||
label="Add item"
|
||||
text70L
|
||||
iconSource={() => <PlusIcon />}
|
||||
style={styles.finishShopBtn}
|
||||
labelStyle={styles.addBtnLbl}
|
||||
enableShadow
|
||||
onPress={() => {
|
||||
setIsAddingGrocery(true);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
const handleShowDialog = () => {
|
||||
setVisible(true);
|
||||
};
|
||||
const handleHideDialog = () => {
|
||||
setVisible(false);
|
||||
};
|
||||
return (
|
||||
<View
|
||||
row
|
||||
spread
|
||||
paddingH-25
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 20,
|
||||
width: "100%",
|
||||
height: 60,
|
||||
}}
|
||||
>
|
||||
<View style={styles.btnContainer} row>
|
||||
<Button
|
||||
color="white"
|
||||
backgroundColor="#fd1775"
|
||||
label="Add item"
|
||||
text70L
|
||||
iconSource={() => <FontAwesome6 name="add" size={18} color="white" />}
|
||||
style={styles.finishShopBtn}
|
||||
labelStyle={styles.addBtnLbl}
|
||||
enableShadow
|
||||
onPress={() => {
|
||||
setIsAddingGrocery(true);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddGroceryItem;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
paddingVertical: 10,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "space-between",
|
||||
},
|
||||
inner: {
|
||||
paddingHorizontal: 20,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
fontWeight: "400",
|
||||
textAlign: "center",
|
||||
},
|
||||
divider: {
|
||||
width: "100%",
|
||||
height: 1,
|
||||
backgroundColor: "#E0E0E0",
|
||||
marginVertical: 10,
|
||||
},
|
||||
btnContainer: {
|
||||
position:"absolute",
|
||||
bottom: 30,
|
||||
width: width,
|
||||
padding: 20,
|
||||
paddingBottom: 0,
|
||||
justifyContent: "center",
|
||||
alignItems:"center",
|
||||
zIndex: 10,
|
||||
},
|
||||
finishShopBtn: {
|
||||
width: "100%",
|
||||
height: 53.26,
|
||||
},
|
||||
shoppingBtn: {
|
||||
flex: 1,
|
||||
marginHorizontal: 3,
|
||||
},
|
||||
addBtnLbl: {fontFamily: "Manrope_500Medium", fontSize: 17, marginLeft: 5},
|
||||
container: {
|
||||
paddingVertical: 10,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "space-between",
|
||||
},
|
||||
inner: {
|
||||
paddingHorizontal: 20,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
},
|
||||
title: {
|
||||
fontSize: 20,
|
||||
fontWeight: "400",
|
||||
textAlign: "center",
|
||||
},
|
||||
divider: {
|
||||
width: "100%",
|
||||
height: 1,
|
||||
backgroundColor: "#E0E0E0",
|
||||
marginVertical: 10,
|
||||
},
|
||||
btnContainer: {
|
||||
width: "100%",
|
||||
justifyContent: "center",
|
||||
},
|
||||
finishShopBtn: {
|
||||
width: "100%",
|
||||
},
|
||||
shoppingBtn: {
|
||||
flex: 1,
|
||||
marginHorizontal: 3,
|
||||
},
|
||||
addBtnLbl: { fontFamily: "Manrope_500Medium", fontSize: 17, marginLeft: 5 },
|
||||
});
|
||||
|
||||
@ -23,7 +23,7 @@ const CategoryDropdown = (props: {
|
||||
padding: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{fontFamily: "Manrope_400Regular"}}>{category}</Text>
|
||||
<Text>{category}</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
|
||||
@ -1,204 +1,72 @@
|
||||
import { Text, TextField, TextFieldRef, View } from "react-native-ui-lib";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import { GroceryCategory, useGroceryContext } from "@/contexts/GroceryContext";
|
||||
import { Dropdown } from "react-native-element-dropdown";
|
||||
import CloseXIcon from "@/assets/svgs/CloseXIcon";
|
||||
import { findNodeHandle, StyleSheet, UIManager } from "react-native";
|
||||
import DropdownIcon from "@/assets/svgs/DropdownIcon";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import {Text, View} from "react-native";
|
||||
import React, {useEffect, useRef} from "react";
|
||||
import {TextField, TextFieldRef} from "react-native-ui-lib";
|
||||
import {GroceryCategory, useGroceryContext,} from "@/contexts/GroceryContext";
|
||||
|
||||
interface IEditGrocery {
|
||||
id?: string;
|
||||
title: string;
|
||||
category: GroceryCategory;
|
||||
setTitle: (value: string) => void;
|
||||
setCategory?: (category: GroceryCategory) => void;
|
||||
setSubmit?: (value: boolean) => void;
|
||||
closeEdit?: () => void;
|
||||
handleEditSubmit?: Function;
|
||||
id?: string;
|
||||
title: string;
|
||||
category: GroceryCategory;
|
||||
setTitle: (value: string) => void;
|
||||
setCategory?: (category: GroceryCategory) => void;
|
||||
setSubmit?: (value: boolean) => void;
|
||||
closeEdit?: (value: boolean) => void;
|
||||
handleEditSubmit?: Function
|
||||
}
|
||||
|
||||
const EditGroceryItem = ({
|
||||
editGrocery,
|
||||
onInputFocus,
|
||||
}: {
|
||||
editGrocery: IEditGrocery;
|
||||
onInputFocus: (y: number) => void;
|
||||
}) => {
|
||||
const { fuzzyMatchGroceryCategory } = useGroceryContext();
|
||||
const inputRef = useRef<TextFieldRef>(null);
|
||||
const containerRef = useRef(null);
|
||||
const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
||||
const {fuzzyMatchGroceryCategory} = useGroceryContext();
|
||||
const inputRef = useRef<TextFieldRef>(null);
|
||||
|
||||
const handleFocus = () => {
|
||||
if (containerRef.current) {
|
||||
const handle = findNodeHandle(containerRef.current);
|
||||
if (handle) {
|
||||
UIManager.measure(
|
||||
handle,
|
||||
(
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
height: number,
|
||||
pageX: number,
|
||||
pageY: number
|
||||
) => {
|
||||
onInputFocus(pageY);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
if (editGrocery.setCategory)
|
||||
editGrocery.setCategory(fuzzyMatchGroceryCategory(editGrocery.title));
|
||||
}, [editGrocery.title]);
|
||||
|
||||
const groceryCategoryOptions = Object.values(GroceryCategory).map(
|
||||
(category) => ({
|
||||
label: category,
|
||||
value: category,
|
||||
})
|
||||
);
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
inputRef.current.focus(); // Focus on the TextField
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleSubmit = () => {
|
||||
inputRef?.current?.blur();
|
||||
console.log("CALLLLLL");
|
||||
if (editGrocery.setSubmit) {
|
||||
editGrocery.setSubmit(true);
|
||||
}
|
||||
if (editGrocery.handleEditSubmit) {
|
||||
editGrocery.handleEditSubmit({
|
||||
id: editGrocery.id,
|
||||
title: editGrocery.title,
|
||||
category: editGrocery.category,
|
||||
});
|
||||
}
|
||||
if (editGrocery.closeEdit) {
|
||||
editGrocery.closeEdit();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
inputRef.current.focus();
|
||||
}
|
||||
|
||||
console.log(editGrocery.category);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View
|
||||
ref={containerRef}
|
||||
style={{
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
borderRadius: 25,
|
||||
paddingHorizontal: 13,
|
||||
paddingVertical: 10,
|
||||
marginTop: 0,
|
||||
}}
|
||||
>
|
||||
<View row spread centerV>
|
||||
<TextField
|
||||
text70T
|
||||
ref={inputRef}
|
||||
onFocus={handleFocus}
|
||||
placeholder="Grocery"
|
||||
value={editGrocery.title}
|
||||
onSubmitEditing={handleSubmit}
|
||||
numberOfLines={1}
|
||||
returnKeyType="done"
|
||||
onChangeText={(value) => {
|
||||
editGrocery.setTitle(value);
|
||||
let groceryCategory = fuzzyMatchGroceryCategory(value);
|
||||
if (editGrocery.setCategory) {
|
||||
editGrocery.setCategory(groceryCategory);
|
||||
}
|
||||
}}
|
||||
maxLength={25}
|
||||
/>
|
||||
<View row centerV>
|
||||
<AntDesign
|
||||
name="check"
|
||||
size={24}
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
color: "green",
|
||||
marginRight: 15,
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
borderRadius: 25,
|
||||
padding: 15,
|
||||
marginTop: 10
|
||||
}}
|
||||
onPress={handleSubmit}
|
||||
/>
|
||||
<CloseXIcon
|
||||
onPress={() => {
|
||||
if (editGrocery.closeEdit) {
|
||||
editGrocery.closeEdit();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
>
|
||||
<TextField
|
||||
text70T
|
||||
style={{fontWeight: "400"}}
|
||||
ref={inputRef}
|
||||
placeholder="Grocery"
|
||||
value={editGrocery.title}
|
||||
onChangeText={(value) => {
|
||||
editGrocery.setTitle(value);
|
||||
}}
|
||||
onSubmitEditing={() => {
|
||||
if (editGrocery.setSubmit) {
|
||||
editGrocery.setSubmit(true);
|
||||
}
|
||||
if (editGrocery.setCategory) {
|
||||
editGrocery.setCategory(fuzzyMatchGroceryCategory(editGrocery.title));
|
||||
}
|
||||
if (editGrocery.handleEditSubmit) {
|
||||
editGrocery.handleEditSubmit({id: editGrocery.id, title: editGrocery.title, category: editGrocery.category});
|
||||
}
|
||||
if (editGrocery.closeEdit) {
|
||||
editGrocery.closeEdit(false);
|
||||
}
|
||||
}}
|
||||
maxLength={25}
|
||||
/>
|
||||
<Text>{editGrocery.category}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<Dropdown
|
||||
style={{ marginTop: 15 }}
|
||||
data={groceryCategoryOptions}
|
||||
placeholder="Select grocery category"
|
||||
placeholderStyle={{
|
||||
color: "#a2a2a2",
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 13.2,
|
||||
}}
|
||||
labelField="label"
|
||||
valueField="value"
|
||||
value={editGrocery.category}
|
||||
iconColor="white"
|
||||
activeColor={"#fd1775"}
|
||||
containerStyle={styles.dropdownStyle}
|
||||
itemTextStyle={styles.itemText}
|
||||
itemContainerStyle={styles.itemStyle}
|
||||
selectedTextStyle={styles.selectedText}
|
||||
renderLeftIcon={() => (
|
||||
<DropdownIcon
|
||||
style={{ marginRight: 8 }}
|
||||
color={
|
||||
editGrocery.category == GroceryCategory.None
|
||||
? "#7b7b7b"
|
||||
: "#fd1775"
|
||||
}
|
||||
/>
|
||||
)}
|
||||
renderItem={(item) => {
|
||||
return (
|
||||
<View height={36.02} centerV>
|
||||
<Text style={styles.itemText}>{item.label}</Text>
|
||||
</View>
|
||||
);
|
||||
}}
|
||||
onChange={(item) => {
|
||||
if (editGrocery.handleEditSubmit) {
|
||||
editGrocery.handleEditSubmit({
|
||||
id: editGrocery.id,
|
||||
category: item.value,
|
||||
});
|
||||
if (editGrocery.closeEdit) editGrocery.closeEdit();
|
||||
} else {
|
||||
if (editGrocery.setCategory) {
|
||||
editGrocery.setCategory(item.value);
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
itemText: {
|
||||
fontFamily: "Manrope_400Regular",
|
||||
fontSize: 15.42,
|
||||
paddingLeft: 15,
|
||||
},
|
||||
selectedText: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 13.2,
|
||||
color: "#fd1775",
|
||||
},
|
||||
dropdownStyle: { borderRadius: 6.61, height: 115.34, width: 187 },
|
||||
itemStyle: { padding: 0, margin: 0 },
|
||||
});
|
||||
|
||||
export default EditGroceryItem;
|
||||
|
||||
@ -8,33 +8,24 @@ import { ImageBackground, StyleSheet } from "react-native";
|
||||
import { IGrocery } from "@/hooks/firebase/types/groceryData";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import { UserProfile } from "@/hooks/firebase/types/profileTypes";
|
||||
import { ProfileType, useAuthContext } from "@/contexts/AuthContext";
|
||||
|
||||
const GroceryItem = ({
|
||||
item,
|
||||
handleItemApproved,
|
||||
onInputFocus,
|
||||
}: {
|
||||
item: IGrocery;
|
||||
handleItemApproved: (id: string, changes: Partial<IGrocery>) => void;
|
||||
onInputFocus: (y: number) => void;
|
||||
}) => {
|
||||
const { updateGroceryItem } = useGroceryContext();
|
||||
const { profileData } = useAuthContext();
|
||||
const isParent = profileData?.userType === ProfileType.PARENT;
|
||||
|
||||
const [openFreqEdit, setOpenFreqEdit] = useState<boolean>(false);
|
||||
const [isEditingTitle, setIsEditingTitle] = useState<boolean>(false);
|
||||
const [newTitle, setNewTitle] = useState<string>(item.title ?? "");
|
||||
const [newTitle, setNewTitle] = useState<string>("");
|
||||
const [category, setCategory] = useState<GroceryCategory>(
|
||||
item.category ?? GroceryCategory.None
|
||||
GroceryCategory.None
|
||||
);
|
||||
const [itemCreator, setItemCreator] = useState<UserProfile>(null);
|
||||
|
||||
const closeEdit = () => {
|
||||
setIsEditingTitle(false);
|
||||
};
|
||||
|
||||
const handleTitleChange = (newTitle: string) => {
|
||||
updateGroceryItem({ id: item?.id, title: newTitle });
|
||||
};
|
||||
@ -44,7 +35,8 @@ const GroceryItem = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log(item);
|
||||
setNewTitle(item.title);
|
||||
|
||||
getItemCreator(item?.creatorId);
|
||||
}, []);
|
||||
|
||||
@ -61,23 +53,14 @@ const GroceryItem = ({
|
||||
}
|
||||
};
|
||||
|
||||
const getInitials = (firstName: string, lastName: string) => {
|
||||
return `${firstName.charAt(0)}${lastName.charAt(0)}`;
|
||||
};
|
||||
|
||||
return (
|
||||
<View
|
||||
key={item.id}
|
||||
style={{
|
||||
borderRadius: 17,
|
||||
marginVertical: 5,
|
||||
paddingHorizontal: isEditingTitle ? 0 : 13,
|
||||
paddingVertical: isEditingTitle ? 0 : 10,
|
||||
height: 44.64,
|
||||
backgroundColor: item.bought ? "#cbcbcb" : "white",
|
||||
}}
|
||||
style={{ borderRadius: 17, marginVertical: 5 }}
|
||||
backgroundColor="white"
|
||||
centerV
|
||||
paddingH-13
|
||||
paddingV-10
|
||||
>
|
||||
<View row spread>
|
||||
<EditGroceryFrequency
|
||||
@ -88,92 +71,58 @@ const GroceryItem = ({
|
||||
setOpenFreqEdit(false);
|
||||
}}
|
||||
/>
|
||||
{isEditingTitle ? (
|
||||
<EditGroceryItem
|
||||
editGrocery={{
|
||||
id: item.id,
|
||||
title: newTitle,
|
||||
category: category,
|
||||
setTitle: setNewTitle,
|
||||
setCategory: setCategory,
|
||||
closeEdit: closeEdit,
|
||||
handleEditSubmit: updateGroceryItem,
|
||||
}}
|
||||
onInputFocus={onInputFocus}
|
||||
/>
|
||||
) : (
|
||||
{!isEditingTitle ? (
|
||||
<View>
|
||||
{isParent ? (
|
||||
<TouchableOpacity onPress={() => setIsEditingTitle(true)}>
|
||||
<Text
|
||||
text70T
|
||||
black
|
||||
style={[
|
||||
styles.title,
|
||||
{
|
||||
textDecorationLine: item.bought ? "line-through" : "none",
|
||||
},
|
||||
]}
|
||||
>
|
||||
{item.title}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
) : (
|
||||
<Text
|
||||
text70T
|
||||
black
|
||||
style={[styles.title, { color: item.bought ? "red" : "black" }]}
|
||||
>
|
||||
<TouchableOpacity onPress={() => setIsEditingTitle(true)}>
|
||||
<Text text70T black style={styles.title}>
|
||||
{item.title}
|
||||
</Text>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
) : (
|
||||
<EditGroceryItem
|
||||
editGrocery={{
|
||||
id: item.id,
|
||||
title: newTitle,
|
||||
category: category,
|
||||
setTitle: setNewTitle,
|
||||
setCategory: setCategory,
|
||||
closeEdit: setIsEditingTitle,
|
||||
handleEditSubmit: updateGroceryItem
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!item.approved ? (
|
||||
<View row centerV marginB-10>
|
||||
{isParent && (
|
||||
<>
|
||||
<AntDesign
|
||||
name="check"
|
||||
size={24}
|
||||
style={{
|
||||
color: "green",
|
||||
marginRight: 15,
|
||||
}}
|
||||
onPress={
|
||||
isParent
|
||||
? () => handleItemApproved(item.id, { approved: true })
|
||||
: null
|
||||
}
|
||||
/>
|
||||
<AntDesign
|
||||
name="close"
|
||||
size={24}
|
||||
style={{ color: "red" }}
|
||||
onPress={
|
||||
isParent
|
||||
? () => handleItemApproved(item.id, { approved: false })
|
||||
: null
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<AntDesign
|
||||
name="check"
|
||||
size={24}
|
||||
style={{
|
||||
color: item.approved ? "green" : "#aaaaaa",
|
||||
marginRight: 15,
|
||||
}}
|
||||
onPress={() => {
|
||||
handleItemApproved(item.id, { approved: true });
|
||||
}}
|
||||
/>
|
||||
<AntDesign
|
||||
name="close"
|
||||
size={24}
|
||||
style={{ color: item.approved ? "#aaaaaa" : "red" }}
|
||||
onPress={() => {
|
||||
handleItemApproved(item.id, { approved: false });
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
!isEditingTitle &&
|
||||
isParent && (
|
||||
<Checkbox
|
||||
value={item.bought}
|
||||
containerStyle={[styles.checkbox, { borderRadius: 50 }]}
|
||||
style={styles.checked}
|
||||
borderRadius={50}
|
||||
color="#fd1575"
|
||||
hitSlop={20}
|
||||
onValueChange={() =>
|
||||
updateGroceryItem({ id: item.id, bought: !item.bought })
|
||||
}
|
||||
/>
|
||||
)
|
||||
<Checkbox
|
||||
value={item.bought}
|
||||
containerStyle={styles.checkbox}
|
||||
hitSlop={20}
|
||||
onValueChange={() =>
|
||||
updateGroceryItem({ id: item.id, bought: !item.bought })
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
{!item.approved && (
|
||||
@ -182,49 +131,17 @@ const GroceryItem = ({
|
||||
<View height={0.7} backgroundColor="#e7e7e7" width={"98%"} />
|
||||
</View>
|
||||
<View paddingL-0 paddingT-12 flexS row centerV>
|
||||
{profileData?.pfp ? (
|
||||
<ImageBackground
|
||||
source={require("../../../assets/images/child-picture.png")}
|
||||
style={{
|
||||
height: 24.64,
|
||||
aspectRatio: 1,
|
||||
borderRadius: 22,
|
||||
overflow: "hidden",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<View
|
||||
style={{
|
||||
position: "relative",
|
||||
width: 24.64,
|
||||
aspectRatio: 1,
|
||||
marginRight: 4,
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#ccc",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
borderRadius: 100, // Circular shape
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: "#fff",
|
||||
fontSize: 12,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{itemCreator
|
||||
? getInitials(itemCreator.firstName, itemCreator.lastName)
|
||||
: ""}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
<ImageBackground
|
||||
style={{
|
||||
width: 22.36,
|
||||
aspectRatio: 1,
|
||||
borderRadius: 50,
|
||||
backgroundColor: "red",
|
||||
marginRight: 10,
|
||||
overflow: 'hidden'
|
||||
}}
|
||||
source={require('../../../assets/images/child-picture.png')}
|
||||
/>
|
||||
<Text color="#858585" style={styles.authorTxt}>
|
||||
Requested by {itemCreator?.firstName}
|
||||
</Text>
|
||||
@ -249,9 +166,6 @@ const styles = StyleSheet.create({
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
checked: {
|
||||
borderRadius: 50,
|
||||
},
|
||||
});
|
||||
|
||||
export default GroceryItem;
|
||||
|
||||
@ -1,298 +1,298 @@
|
||||
import {FlatList, StyleSheet} from "react-native";
|
||||
import React, {useEffect, useState} from "react";
|
||||
import {Text, TouchableOpacity, View} from "react-native-ui-lib";
|
||||
import { FlatList, StyleSheet } from "react-native";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Button, Text, TouchableOpacity, View } from "react-native-ui-lib";
|
||||
import GroceryItem from "./GroceryItem";
|
||||
import {GroceryCategory, GroceryFrequency, useGroceryContext,} from "@/contexts/GroceryContext";
|
||||
import {
|
||||
GroceryCategory,
|
||||
GroceryFrequency,
|
||||
useGroceryContext,
|
||||
} from "@/contexts/GroceryContext";
|
||||
import HeaderTemplate from "@/components/shared/HeaderTemplate";
|
||||
import {AntDesign} from "@expo/vector-icons";
|
||||
import { AntDesign, MaterialIcons } from "@expo/vector-icons";
|
||||
import EditGroceryItem from "./EditGroceryItem";
|
||||
import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
|
||||
import {IGrocery} from "@/hooks/firebase/types/groceryData";
|
||||
import { ProfileType, useAuthContext } from "@/contexts/AuthContext";
|
||||
import { IGrocery } from "@/hooks/firebase/types/groceryData";
|
||||
import AddPersonIcon from "@/assets/svgs/AddPersonIcon";
|
||||
|
||||
const GroceryList = ({onInputFocus}: {onInputFocus: (y: number) => void}) => {
|
||||
const {
|
||||
groceries,
|
||||
updateGroceryItem,
|
||||
isAddingGrocery,
|
||||
setIsAddingGrocery,
|
||||
addGrocery,
|
||||
} = useGroceryContext();
|
||||
const {profileData} = useAuthContext();
|
||||
const [approvedGroceries, setapprovedGroceries] = useState<IGrocery[]>(
|
||||
groceries?.filter((item) => item.approved)
|
||||
);
|
||||
const [pendingGroceries, setPendingGroceries] = useState<IGrocery[]>(
|
||||
groceries?.filter((item) => !item.approved)
|
||||
);
|
||||
const [category, setCategory] = useState<GroceryCategory>(
|
||||
GroceryCategory.None
|
||||
);
|
||||
const GroceryList = () => {
|
||||
const {
|
||||
groceries,
|
||||
updateGroceryItem,
|
||||
isAddingGrocery,
|
||||
setIsAddingGrocery,
|
||||
addGrocery,
|
||||
} = useGroceryContext();
|
||||
const { profileData } = useAuthContext();
|
||||
const [approvedGroceries, setapprovedGroceries] = useState<IGrocery[]>(
|
||||
groceries?.filter((item) => item.approved === true)
|
||||
);
|
||||
const [pendingGroceries, setPendingGroceries] = useState<IGrocery[]>(
|
||||
groceries?.filter((item) => item.approved !== true)
|
||||
);
|
||||
const [category, setCategory] = useState<GroceryCategory>(
|
||||
GroceryCategory.Bakery
|
||||
);
|
||||
const [title, setTitle] = useState<string>("");
|
||||
const [submit, setSubmitted] = useState<boolean>(false);
|
||||
|
||||
const [title, setTitle] = useState<string>("");
|
||||
const [submit, setSubmitted] = useState<boolean>(false);
|
||||
const [pendingVisible, setPendingVisible] = useState<boolean>(true);
|
||||
const [approvedVisible, setApprovedVisible] = useState<boolean>(true);
|
||||
|
||||
const [pendingVisible, setPendingVisible] = useState<boolean>(true);
|
||||
const [approvedVisible, setApprovedVisible] = useState<boolean>(true);
|
||||
// Group approved groceries by category
|
||||
const approvedGroceriesByCategory = approvedGroceries?.reduce(
|
||||
(groups: any, item: IGrocery) => {
|
||||
const category = item.category || "Uncategorized";
|
||||
if (!groups[category]) {
|
||||
groups[category] = [];
|
||||
}
|
||||
groups[category].push(item);
|
||||
return groups;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
// Group approved groceries by category
|
||||
const approvedGroceriesByCategory = approvedGroceries?.reduce(
|
||||
(groups: any, item: IGrocery) => {
|
||||
const category = item.category || "Uncategorized";
|
||||
if (!groups[category]) {
|
||||
groups[category] = [];
|
||||
}
|
||||
groups[category].push(item);
|
||||
return groups;
|
||||
},
|
||||
{}
|
||||
);
|
||||
useEffect(() => {
|
||||
if (submit) {
|
||||
if (title?.length > 2 && title?.length <= 25) {
|
||||
addGrocery({
|
||||
id: "",
|
||||
title: title,
|
||||
category: category,
|
||||
approved: profileData?.userType === ProfileType.PARENT,
|
||||
recurring: false,
|
||||
frequency: GroceryFrequency.Never,
|
||||
bought: false,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (submit) {
|
||||
if (title?.length > 2 && title?.length <= 25) {
|
||||
addGrocery({
|
||||
id: "",
|
||||
title: title,
|
||||
category: category,
|
||||
approved: profileData?.userType === ProfileType.PARENT,
|
||||
recurring: false,
|
||||
frequency: GroceryFrequency.Never,
|
||||
bought: false,
|
||||
});
|
||||
setIsAddingGrocery(false);
|
||||
setSubmitted(false);
|
||||
setTitle("");
|
||||
}
|
||||
}
|
||||
}, [submit]);
|
||||
|
||||
setIsAddingGrocery(false);
|
||||
setSubmitted(false);
|
||||
setTitle("");
|
||||
}
|
||||
}
|
||||
}, [submit]);
|
||||
useEffect(() => {
|
||||
/**/
|
||||
}, [category]);
|
||||
|
||||
useEffect(() => {
|
||||
setapprovedGroceries(groceries?.filter((item) => item.approved));
|
||||
setPendingGroceries(groceries?.filter((item) => !item.approved));
|
||||
}, [groceries]);
|
||||
useEffect(() => {
|
||||
setapprovedGroceries(groceries?.filter((item) => item.approved === true));
|
||||
setPendingGroceries(groceries?.filter((item) => item.approved !== true));
|
||||
}, [groceries]);
|
||||
|
||||
return (
|
||||
<View marginH-20 marginB-45>
|
||||
<HeaderTemplate
|
||||
message={"Welcome to your grocery list"}
|
||||
isWelcome={false}
|
||||
isGroceries={true}
|
||||
>
|
||||
<View row centerV>
|
||||
<View
|
||||
backgroundColor="#e2eed8"
|
||||
paddingH-15
|
||||
paddingV-8
|
||||
marginR-5
|
||||
centerV
|
||||
style={{borderRadius: 50}}
|
||||
>
|
||||
<Text text70BL color="#46a80a" style={styles.counterText}>
|
||||
{approvedGroceries?.length} list{" "}
|
||||
{approvedGroceries?.length === 1 ? (
|
||||
<Text text70BL color="#46a80a" style={styles.counterText}>
|
||||
item
|
||||
</Text>
|
||||
) : (
|
||||
<Text text70BL color="#46a80a" style={styles.counterText}>
|
||||
items
|
||||
</Text>
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
backgroundColor="#faead2"
|
||||
padding-8
|
||||
paddingH-12
|
||||
marginR-15
|
||||
style={{borderRadius: 50}}
|
||||
>
|
||||
<Text text70 style={styles.counterText} color="#e28800">
|
||||
{pendingGroceries?.length} pending
|
||||
</Text>
|
||||
</View>
|
||||
<TouchableOpacity>
|
||||
<AddPersonIcon width={24}/>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</HeaderTemplate>
|
||||
|
||||
{/* Pending Approval Section */}
|
||||
<View row spread marginT-40 marginB-10 centerV>
|
||||
<View row centerV>
|
||||
<Text style={styles.subHeader}>Pending Approval</Text>
|
||||
{pendingVisible && (
|
||||
<AntDesign
|
||||
name="down"
|
||||
size={17}
|
||||
style={styles.dropIcon}
|
||||
color="#9f9f9f"
|
||||
onPress={() => {
|
||||
setPendingVisible(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!pendingVisible && (
|
||||
<AntDesign
|
||||
name="right"
|
||||
size={15}
|
||||
style={styles.dropIcon}
|
||||
color="#9f9f9f"
|
||||
onPress={() => {
|
||||
setPendingVisible(true);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
<View
|
||||
centerV
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 35,
|
||||
backgroundColor: "#faead2",
|
||||
borderRadius: 50,
|
||||
}}
|
||||
>
|
||||
<Text style={styles.counterNr} center color="#e28800">
|
||||
{pendingGroceries?.length.toString()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
{pendingGroceries?.length > 0
|
||||
? pendingVisible && (
|
||||
<FlatList
|
||||
data={pendingGroceries}
|
||||
renderItem={({item}) => (
|
||||
<GroceryItem
|
||||
item={item}
|
||||
handleItemApproved={(id, changes) =>
|
||||
updateGroceryItem({...changes, id: id})
|
||||
}
|
||||
onInputFocus={onInputFocus}
|
||||
/>
|
||||
)}
|
||||
keyExtractor={(item) => item.id.toString()}
|
||||
/>
|
||||
)
|
||||
: pendingVisible && (
|
||||
<Text style={styles.noItemTxt}>No items pending approval.</Text>
|
||||
)}
|
||||
|
||||
{/* Approved Section */}
|
||||
<View row spread marginT-40 marginB-0 centerV>
|
||||
<View row centerV>
|
||||
<Text style={styles.subHeader}>Shopping List</Text>
|
||||
{approvedVisible && (
|
||||
<AntDesign
|
||||
name="down"
|
||||
size={17}
|
||||
style={styles.dropIcon}
|
||||
color="#9f9f9f"
|
||||
onPress={() => {
|
||||
setApprovedVisible(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!approvedVisible && (
|
||||
<AntDesign
|
||||
name="right"
|
||||
size={15}
|
||||
style={styles.dropIcon}
|
||||
color="#9f9f9f"
|
||||
onPress={() => {
|
||||
setApprovedVisible(true);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
<View
|
||||
centerV
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 35,
|
||||
backgroundColor: "#e2eed8",
|
||||
borderRadius: 50,
|
||||
}}
|
||||
>
|
||||
<Text style={styles.counterNr} center color="#46a80a">
|
||||
{approvedGroceries?.length.toString()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
{isAddingGrocery && (
|
||||
<View style={{marginTop: 8}}>
|
||||
<EditGroceryItem
|
||||
editGrocery={{
|
||||
title: title,
|
||||
setCategory: setCategory,
|
||||
category: category,
|
||||
setTitle: setTitle,
|
||||
setSubmit: setSubmitted,
|
||||
closeEdit: () => setIsAddingGrocery(false)
|
||||
}}
|
||||
onInputFocus={onInputFocus}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* Render Approved Groceries Grouped by Category */}
|
||||
{approvedGroceries?.length > 0
|
||||
? approvedVisible && (
|
||||
<FlatList
|
||||
data={Object.keys(approvedGroceriesByCategory)}
|
||||
renderItem={({item: category}) => (
|
||||
<View key={category}>
|
||||
{/* Render Category Header */}
|
||||
<Text text80M style={{marginTop: 10}} color="#666">
|
||||
{category}
|
||||
</Text>
|
||||
{/* Render Grocery Items for this Category */}
|
||||
{approvedGroceriesByCategory[category].map(
|
||||
(grocery: IGrocery) => (
|
||||
<GroceryItem
|
||||
key={grocery.id}
|
||||
item={grocery}
|
||||
handleItemApproved={(id, changes) =>
|
||||
updateGroceryItem({...changes, id: id})
|
||||
}
|
||||
onInputFocus={onInputFocus}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
keyExtractor={(category) => category}
|
||||
/>
|
||||
)
|
||||
: approvedVisible && (
|
||||
<Text style={styles.noItemTxt}>No approved items.</Text>
|
||||
)}
|
||||
return (
|
||||
<View marginH-20 marginB-20>
|
||||
<HeaderTemplate
|
||||
message={"Welcome to your grocery list"}
|
||||
isWelcome={false}
|
||||
>
|
||||
<View row centerV>
|
||||
<View
|
||||
backgroundColor="#e2eed8"
|
||||
paddingH-15
|
||||
paddingV-8
|
||||
marginR-5
|
||||
centerV
|
||||
style={{ borderRadius: 50 }}
|
||||
>
|
||||
<Text text70BL color="#46a80a" style={styles.counterText}>
|
||||
{approvedGroceries?.length} list{" "}
|
||||
{approvedGroceries?.length === 1 ? (
|
||||
<Text text70BL color="#46a80a" style={styles.counterText}>
|
||||
item
|
||||
</Text>
|
||||
) : (
|
||||
<Text text70BL color="#46a80a" style={styles.counterText}>
|
||||
items
|
||||
</Text>
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
backgroundColor="#faead2"
|
||||
padding-8
|
||||
paddingH-12
|
||||
marginR-15
|
||||
style={{ borderRadius: 50 }}
|
||||
>
|
||||
<Text text70 style={styles.counterText} color="#e28800">
|
||||
{pendingGroceries?.length} pending
|
||||
</Text>
|
||||
</View>
|
||||
<TouchableOpacity>
|
||||
<AddPersonIcon width={24}/>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
</HeaderTemplate>
|
||||
|
||||
{/* Pending Approval Section */}
|
||||
<View row spread marginT-40 marginB-10 centerV>
|
||||
<View row centerV>
|
||||
<Text style={styles.subHeader}>Pending Approval</Text>
|
||||
{pendingVisible && (
|
||||
<AntDesign
|
||||
name="down"
|
||||
size={17}
|
||||
style={styles.dropIcon}
|
||||
color="#9f9f9f"
|
||||
onPress={() => {
|
||||
setPendingVisible(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!pendingVisible && (
|
||||
<AntDesign
|
||||
name="right"
|
||||
size={15}
|
||||
style={styles.dropIcon}
|
||||
color="#9f9f9f"
|
||||
onPress={() => {
|
||||
setPendingVisible(true);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
<View
|
||||
centerV
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 35,
|
||||
backgroundColor: "#faead2",
|
||||
borderRadius: 50,
|
||||
}}
|
||||
>
|
||||
<Text style={styles.counterNr} center color="#e28800">
|
||||
{pendingGroceries?.length.toString()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
{pendingGroceries?.length > 0
|
||||
? pendingVisible && (
|
||||
<FlatList
|
||||
data={pendingGroceries}
|
||||
renderItem={({ item }) => (
|
||||
<GroceryItem
|
||||
item={item}
|
||||
handleItemApproved={(id, changes) =>
|
||||
updateGroceryItem({ ...changes, id: id })
|
||||
}
|
||||
/>
|
||||
)}
|
||||
keyExtractor={(item) => item.id.toString()}
|
||||
/>
|
||||
)
|
||||
: pendingVisible && (
|
||||
<Text style={styles.noItemTxt}>No items pending approval.</Text>
|
||||
)}
|
||||
|
||||
{/* Approved Section */}
|
||||
<View row spread marginT-40 marginB-0 centerV>
|
||||
<View row centerV>
|
||||
<Text style={styles.subHeader}>Shopping List</Text>
|
||||
{approvedVisible && (
|
||||
<AntDesign
|
||||
name="down"
|
||||
size={17}
|
||||
style={styles.dropIcon}
|
||||
color="#9f9f9f"
|
||||
onPress={() => {
|
||||
setApprovedVisible(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!approvedVisible && (
|
||||
<AntDesign
|
||||
name="right"
|
||||
size={15}
|
||||
style={styles.dropIcon}
|
||||
color="#9f9f9f"
|
||||
onPress={() => {
|
||||
setApprovedVisible(true);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
<View
|
||||
centerV
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 35,
|
||||
backgroundColor: "#e2eed8",
|
||||
borderRadius: 50,
|
||||
}}
|
||||
>
|
||||
<Text style={styles.counterNr} center color="#46a80a">
|
||||
{approvedGroceries?.length.toString()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
{isAddingGrocery && (
|
||||
<EditGroceryItem
|
||||
editGrocery={{
|
||||
title: title,
|
||||
setCategory: setCategory,
|
||||
category: category,
|
||||
setTitle: setTitle,
|
||||
setSubmit: setSubmitted,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Render Approved Groceries Grouped by Category */}
|
||||
{approvedGroceries?.length > 0
|
||||
? approvedVisible && (
|
||||
<FlatList
|
||||
data={Object.keys(approvedGroceriesByCategory)}
|
||||
renderItem={({ item: category }) => (
|
||||
<View key={category}>
|
||||
{/* Render Category Header */}
|
||||
<Text text80M style={{ marginTop: 10 }} color="#666">
|
||||
{category}
|
||||
</Text>
|
||||
{/* Render Grocery Items for this Category */}
|
||||
{approvedGroceriesByCategory[category].map(
|
||||
(grocery: IGrocery) => (
|
||||
<GroceryItem
|
||||
key={grocery.id}
|
||||
item={grocery}
|
||||
handleItemApproved={(id, changes) =>
|
||||
updateGroceryItem({ ...changes, id: id })
|
||||
}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
keyExtractor={(category) => category}
|
||||
/>
|
||||
)
|
||||
: approvedVisible && (
|
||||
<Text style={styles.noItemTxt}>No approved items.</Text>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
dropIcon: {
|
||||
marginHorizontal: 10,
|
||||
},
|
||||
noItemTxt: {
|
||||
fontFamily: "Manrope_400Regular",
|
||||
fontSize: 14,
|
||||
},
|
||||
counterText: {
|
||||
fontSize: 14,
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
},
|
||||
subHeader: {
|
||||
fontSize: 15,
|
||||
fontFamily: "Manrope_700Bold",
|
||||
},
|
||||
counterNr: {
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
fontSize: 14
|
||||
}
|
||||
dropIcon: {
|
||||
marginHorizontal: 10,
|
||||
},
|
||||
noItemTxt: {
|
||||
fontFamily: "Manrope_400Regular",
|
||||
fontSize: 14,
|
||||
},
|
||||
counterText: {
|
||||
fontSize: 14,
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
},
|
||||
subHeader: {
|
||||
fontSize: 15,
|
||||
fontFamily: "Manrope_700Bold",
|
||||
},
|
||||
counterNr: {
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
fontSize: 14
|
||||
}
|
||||
});
|
||||
|
||||
export default GroceryList;
|
||||
|
||||
@ -1,79 +1,38 @@
|
||||
import { Dimensions, ScrollView, Keyboard, Platform } from "react-native";
|
||||
import { Text, ScrollView } from "react-native";
|
||||
import { View } from "react-native-ui-lib";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import AddGroceryItem from "./AddGroceryItem";
|
||||
import GroceryList from "./GroceryList";
|
||||
import { useGroceryContext } from "@/contexts/GroceryContext";
|
||||
|
||||
const GroceryWrapper = () => {
|
||||
const { isAddingGrocery } = useGroceryContext();
|
||||
const scrollViewRef = useRef<ScrollView>(null);
|
||||
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const keyboardWillShowListener = Keyboard.addListener(
|
||||
Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow',
|
||||
(e) => {
|
||||
setKeyboardHeight(e.endCoordinates.height);
|
||||
}
|
||||
);
|
||||
|
||||
const keyboardWillHideListener = Keyboard.addListener(
|
||||
Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide',
|
||||
() => {
|
||||
setKeyboardHeight(0);
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
keyboardWillShowListener.remove();
|
||||
keyboardWillHideListener.remove();
|
||||
};
|
||||
}, []);
|
||||
const scrollViewRef = useRef<ScrollView>(null); // Reference to the ScrollView
|
||||
|
||||
useEffect(() => {
|
||||
if (isAddingGrocery && scrollViewRef.current) {
|
||||
scrollViewRef.current.scrollTo({
|
||||
y: 400,
|
||||
y: 400, // Adjust this value to scroll a bit down (100 is an example)
|
||||
animated: true,
|
||||
});
|
||||
}
|
||||
}, [isAddingGrocery]);
|
||||
|
||||
const handleInputFocus = (y: number) => {
|
||||
if (scrollViewRef.current) {
|
||||
// Get the window height
|
||||
const windowHeight = Dimensions.get('window').height;
|
||||
// Calculate the space we want to leave at the top
|
||||
const topSpacing = 20;
|
||||
|
||||
// Calculate the target scroll position:
|
||||
// y (position of input) - topSpacing (space we want at top)
|
||||
// if keyboard is shown, we need to account for its height
|
||||
const scrollPosition = Math.max(0, y - topSpacing);
|
||||
|
||||
scrollViewRef.current.scrollTo({
|
||||
y: scrollPosition,
|
||||
animated: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
ref={scrollViewRef}
|
||||
automaticallyAdjustKeyboardInsets={true}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<View marginB-60>
|
||||
<GroceryList onInputFocus={handleInputFocus} />
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View height={"100%"} paddingT-15 paddingH-15>
|
||||
<View height={"100%"}>
|
||||
<ScrollView
|
||||
ref={scrollViewRef} // Assign the ref to the ScrollView
|
||||
automaticallyAdjustKeyboardInsets={true}
|
||||
>
|
||||
<View marginB-70>
|
||||
<GroceryList />
|
||||
</View>
|
||||
</ScrollView>
|
||||
{!isAddingGrocery && <AddGroceryItem />}
|
||||
</>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default GroceryWrapper;
|
||||
export default GroceryWrapper;
|
||||
|
||||
@ -8,7 +8,7 @@ const Entry = () => {
|
||||
const [tab, setTab] = useState<"register" | "login" | "reset-password">("login");
|
||||
|
||||
return (
|
||||
<View style={{height:"100%"}}>
|
||||
<View>
|
||||
{tab === "register" && <SignUpPage setTab={setTab}/>}
|
||||
{tab === "login" && <SignInPage setTab={setTab}/>}
|
||||
{tab === "reset-password" && <ResetPasswordPage setTab={setTab}/>}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import {Button, Text, TextField, View} from "react-native-ui-lib";
|
||||
import {Button, ButtonSize, Text, TextField, View} from "react-native-ui-lib";
|
||||
import React, {useState} from "react";
|
||||
import {useSignIn} from "@/hooks/firebase/useSignIn";
|
||||
import {StyleSheet} from "react-native";
|
||||
import {useResetPassword} from "@/hooks/firebase/useResetPassword";
|
||||
import {isLoading} from "expo-font";
|
||||
|
||||
export const ResetPasswordPage = () => {
|
||||
export const ResetPasswordPage = ({setTab}: { setTab: React.Dispatch<React.SetStateAction<"register" | "login" | "reset-password">> }) => {
|
||||
const [email, setEmail] = useState<string>("");
|
||||
|
||||
const {mutateAsync: resetPassword, error, isError, isLoading} = useResetPassword();
|
||||
|
||||
@ -1,193 +1,170 @@
|
||||
import {
|
||||
Button,
|
||||
ButtonSize,
|
||||
Colors,
|
||||
KeyboardAwareScrollView,
|
||||
LoaderScreen,
|
||||
Text,
|
||||
TextField,
|
||||
TextFieldRef,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { useSignIn } from "@/hooks/firebase/useSignIn";
|
||||
import { KeyboardAvoidingView, Platform, StyleSheet } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import KeyboardManager from "react-native-keyboard-manager";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { useRouter } from "expo-router";
|
||||
import {Button, ButtonSize, Dialog, Text, TextField, View} from "react-native-ui-lib";
|
||||
import React, {useEffect, useState} from "react";
|
||||
import {useSignIn} from "@/hooks/firebase/useSignIn";
|
||||
import {StyleSheet} from "react-native";
|
||||
import Toast from 'react-native-toast-message';
|
||||
import {useLoginWithQrCode} from "@/hooks/firebase/useLoginWithQrCode";
|
||||
import {Camera, CameraView} from 'expo-camera';
|
||||
import {BarCodeScanner} from "expo-barcode-scanner";
|
||||
|
||||
if (Platform.OS === "ios") KeyboardManager.setEnableAutoToolbar(true);
|
||||
const SignInPage = ({setTab}: { setTab: React.Dispatch<React.SetStateAction<"register" | "login" | "reset-password">> }) => {
|
||||
const [email, setEmail] = useState<string>("");
|
||||
const [password, setPassword] = useState<string>("");
|
||||
const [hasPermission, setHasPermission] = useState<boolean | null>(null);
|
||||
const [scanned, setScanned] = useState<boolean>(false);
|
||||
const [showCameraDialog, setShowCameraDialog] = useState<boolean>(false);
|
||||
|
||||
const SignInPage = () => {
|
||||
const [email, setEmail] = useState<string>("");
|
||||
const [password, setPassword] = useState<string>("");
|
||||
const passwordRef = useRef<TextFieldRef>(null);
|
||||
const {mutateAsync: signIn, error, isError} = useSignIn();
|
||||
const {mutateAsync: signInWithQrCode} = useLoginWithQrCode()
|
||||
|
||||
const { mutateAsync: signIn, error, isError, isLoading } = useSignIn();
|
||||
const handleSignIn = async () => {
|
||||
await signIn({email, password});
|
||||
if(!isError) {
|
||||
Toast.show({
|
||||
type: "success",
|
||||
text1: "Login successful!"
|
||||
});
|
||||
} else {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Error logging in",
|
||||
text2: `${error}`
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const router = useRouter();
|
||||
const handleQrCodeScanned = async ({ data }: { data: string }) => {
|
||||
setShowCameraDialog(false);
|
||||
try {
|
||||
await signInWithQrCode({ userId: data });
|
||||
Toast.show({
|
||||
type: "success",
|
||||
text1: "Login successful with QR code!"
|
||||
});
|
||||
} catch (err) {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Error logging in with QR code",
|
||||
text2: `${err}`
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleSignIn = async () => {
|
||||
await signIn({ email, password });
|
||||
if (!isError) {
|
||||
Toast.show({
|
||||
type: "success",
|
||||
text1: "Login successful!",
|
||||
});
|
||||
} else {
|
||||
Toast.show({
|
||||
type: "error",
|
||||
text1: "Error logging in",
|
||||
text2: `${error}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
const getCameraPermissions = async (callback: () => void) => {
|
||||
const { status } = await Camera.requestCameraPermissionsAsync();
|
||||
setHasPermission(status === 'granted');
|
||||
if(status === 'granted') {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ flex: 1 }}>
|
||||
<KeyboardAwareScrollView
|
||||
contentContainerStyle={{ flexGrow: 1 }}
|
||||
enableOnAndroid
|
||||
>
|
||||
<View
|
||||
style={{ flex: 1, padding: 21, paddingBottom: 45, paddingTop: "20%" }}
|
||||
>
|
||||
<View gap-13 width={"100%"} marginB-20>
|
||||
<Text style={{ fontSize: 40, fontFamily: "Manrope_600SemiBold" }}>
|
||||
Jump back into Cally
|
||||
</Text>
|
||||
<Text color={"#919191"} style={{ fontSize: 20 }}>
|
||||
Please enter your details.
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<KeyboardAvoidingView
|
||||
style={{ width: "100%" }}
|
||||
contentContainerStyle={{ justifyContent: "center" }}
|
||||
keyboardVerticalOffset={50}
|
||||
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
||||
>
|
||||
return (
|
||||
<View padding-10 centerV height={"100%"}>
|
||||
<TextField
|
||||
placeholder="Email"
|
||||
keyboardType={"email-address"}
|
||||
returnKeyType={"next"}
|
||||
textContentType={"emailAddress"}
|
||||
defaultValue={email}
|
||||
onChangeText={setEmail}
|
||||
style={styles.textfield}
|
||||
autoComplete={"email"}
|
||||
autoCorrect={false}
|
||||
onSubmitEditing={() => {
|
||||
// Move focus to the description field
|
||||
passwordRef.current?.focus();
|
||||
}}
|
||||
placeholder="Email"
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
style={styles.textfield}
|
||||
/>
|
||||
<TextField
|
||||
ref={passwordRef}
|
||||
placeholder="Password"
|
||||
textContentType={"oneTimeCode"}
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
secureTextEntry
|
||||
style={styles.textfield}
|
||||
autoCorrect={false}
|
||||
placeholder="Password"
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
secureTextEntry
|
||||
style={styles.textfield}
|
||||
/>
|
||||
</KeyboardAvoidingView>
|
||||
|
||||
<View flexG />
|
||||
|
||||
<Button
|
||||
label="Log in"
|
||||
marginT-50
|
||||
labelStyle={{
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
fontSize: 16,
|
||||
}}
|
||||
onPress={handleSignIn}
|
||||
style={{ marginBottom: 20, height: 50 }}
|
||||
backgroundColor="#fd1775"
|
||||
/>
|
||||
|
||||
{isError && (
|
||||
<Text center style={{ marginBottom: 20 }}>{`${
|
||||
error?.toString()?.split("]")?.[1]
|
||||
}`}</Text>
|
||||
)}
|
||||
|
||||
<View row centerH marginB-5 gap-5>
|
||||
<Text style={styles.jakartaLight}>Don't have an account?</Text>
|
||||
<Button
|
||||
onPress={() => router.replace("/(unauth)/sign_up")}
|
||||
label="Sign Up"
|
||||
labelStyle={[
|
||||
styles.jakartaMedium,
|
||||
{ textDecorationLine: "none", color: "#fd1575" },
|
||||
]}
|
||||
link
|
||||
size={ButtonSize.xSmall}
|
||||
padding-0
|
||||
margin-0
|
||||
text70
|
||||
left
|
||||
color="#fd1775"
|
||||
label="Login"
|
||||
onPress={handleSignIn}
|
||||
style={{marginBottom: 20}}
|
||||
backgroundColor="#fd1775"
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/*<View row centerH marginB-5 gap-5>*/}
|
||||
{/* <Text text70>Forgot your password?</Text>*/}
|
||||
{/* <Button*/}
|
||||
{/* onPress={() => router.replace("/(unauth)/sign_up")}*/}
|
||||
{/* label="Reset password"*/}
|
||||
{/* labelStyle={[*/}
|
||||
{/* styles.jakartaMedium,*/}
|
||||
{/* {textDecorationLine: "none", color: "#fd1575"},*/}
|
||||
{/* ]}*/}
|
||||
{/* link*/}
|
||||
{/* size={ButtonSize.xSmall}*/}
|
||||
{/* padding-0*/}
|
||||
{/* margin-0*/}
|
||||
{/* text70*/}
|
||||
{/* left*/}
|
||||
{/* avoidInnerPadding*/}
|
||||
{/* color="#fd1775"*/}
|
||||
{/* />*/}
|
||||
{/*</View>*/}
|
||||
|
||||
{isLoading && (
|
||||
<LoaderScreen
|
||||
overlay
|
||||
message={"Signing in..."}
|
||||
backgroundColor={Colors.white}
|
||||
color={Colors.grey40}
|
||||
<Button
|
||||
label="Login with a QR Code"
|
||||
onPress={() => {
|
||||
getCameraPermissions(() => setShowCameraDialog(true));
|
||||
}
|
||||
}
|
||||
style={{marginBottom: 20}}
|
||||
backgroundColor="#fd1775"
|
||||
/>
|
||||
)}
|
||||
{isError && <Text center style={{marginBottom: 20}}>{`${error}`}</Text>}
|
||||
|
||||
<View row centerH marginB-5 gap-5>
|
||||
<Text text70>
|
||||
Don't have an account?
|
||||
</Text>
|
||||
<Button
|
||||
onPress={() => setTab("register")}
|
||||
label="Sign Up"
|
||||
link
|
||||
size={ButtonSize.xSmall}
|
||||
padding-0
|
||||
margin-0
|
||||
text70
|
||||
left
|
||||
color="#fd1775"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View row centerH marginB-5 gap-5>
|
||||
<Text text70>
|
||||
Forgot your password?
|
||||
</Text>
|
||||
<Button
|
||||
onPress={() => setTab("reset-password")}
|
||||
label="Reset password"
|
||||
link
|
||||
size={ButtonSize.xSmall}
|
||||
padding-0
|
||||
margin-0
|
||||
text70
|
||||
left
|
||||
color="#fd1775"
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/* Camera Dialog */}
|
||||
<Dialog
|
||||
visible={showCameraDialog}
|
||||
onDismiss={() => setShowCameraDialog(false)}
|
||||
bottom
|
||||
width="100%"
|
||||
height="70%"
|
||||
containerStyle={{ padding: 0 }}
|
||||
>
|
||||
{hasPermission === null ? (
|
||||
<Text>Requesting camera permissions...</Text>
|
||||
) : !hasPermission ? (
|
||||
<Text>No access to camera</Text>
|
||||
) : (
|
||||
<CameraView
|
||||
style={{ flex: 1 }}
|
||||
onBarcodeScanned={handleQrCodeScanned}
|
||||
barcodeScannerSettings={{
|
||||
barcodeTypes: ["qr"],
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
label="Cancel"
|
||||
onPress={() => setShowCameraDialog(false)}
|
||||
backgroundColor="#fd1775"
|
||||
style={{ margin: 10 }}
|
||||
/>
|
||||
</Dialog>
|
||||
</View>
|
||||
</KeyboardAwareScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
textfield: {
|
||||
backgroundColor: "white",
|
||||
marginVertical: 10,
|
||||
padding: 30,
|
||||
height: 45,
|
||||
borderRadius: 50,
|
||||
fontFamily: "PlusJakartaSans_300Light",
|
||||
},
|
||||
jakartaLight: {
|
||||
fontFamily: "PlusJakartaSans_300Light",
|
||||
fontSize: 16,
|
||||
color: "#484848",
|
||||
},
|
||||
jakartaMedium: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
color: "#919191",
|
||||
textDecorationLine: "underline",
|
||||
},
|
||||
textfield: {
|
||||
backgroundColor: "white",
|
||||
marginVertical: 10,
|
||||
padding: 30,
|
||||
height: 45,
|
||||
borderRadius: 50,
|
||||
},
|
||||
});
|
||||
|
||||
export default SignInPage;
|
||||
|
||||
@ -1,27 +1,19 @@
|
||||
import React, { useRef, useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
ButtonSize,
|
||||
Checkbox,
|
||||
Colors,
|
||||
KeyboardAwareScrollView,
|
||||
LoaderScreen,
|
||||
Text,
|
||||
TextField,
|
||||
TextFieldRef,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import { useSignUp } from "@/hooks/firebase/useSignUp";
|
||||
import { KeyboardAvoidingView, Platform, StyleSheet } from "react-native";
|
||||
import { ProfileType } from "@/contexts/AuthContext";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import KeyboardManager from "react-native-keyboard-manager";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { useRouter } from "expo-router";
|
||||
|
||||
if (Platform.OS === "ios") KeyboardManager.setEnableAutoToolbar(true);
|
||||
|
||||
const SignUpPage = () => {
|
||||
const SignUpPage = ({setTab}: { setTab: React.Dispatch<React.SetStateAction<"register" | "login" | "reset-password">> }) => {
|
||||
const [email, setEmail] = useState<string>("");
|
||||
const [firstName, setFirstName] = useState<string>("");
|
||||
const [lastName, setLastName] = useState<string>("");
|
||||
@ -30,212 +22,116 @@ const SignUpPage = () => {
|
||||
const [isPasswordVisible, setIsPasswordVisible] = useState<boolean>(false);
|
||||
const [allowFaceID, setAllowFaceID] = useState<boolean>(false);
|
||||
const [acceptTerms, setAcceptTerms] = useState<boolean>(false);
|
||||
const { mutateAsync: signUp, isLoading } = useSignUp();
|
||||
|
||||
const lnameRef = useRef<TextFieldRef>(null);
|
||||
const emailRef = useRef<TextFieldRef>(null);
|
||||
const passwordRef = useRef<TextFieldRef>(null);
|
||||
|
||||
const router = useRouter();
|
||||
const { mutateAsync: signUp } = useSignUp();
|
||||
|
||||
const handleSignUp = async () => {
|
||||
await signUp({ email, password, firstName, lastName });
|
||||
router.replace("/(unauth)/cal_sync");
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ flex: 1 }}>
|
||||
<KeyboardAwareScrollView
|
||||
contentContainerStyle={{ flexGrow: 1 }}
|
||||
enableOnAndroid
|
||||
>
|
||||
<View
|
||||
style={{ flex: 1, padding: 21, paddingBottom: 45, paddingTop: "20%" }}
|
||||
>
|
||||
<View gap-13 width={"100%"} marginB-20>
|
||||
<Text style={{ fontSize: 40, fontFamily: "Manrope_600SemiBold" }}>
|
||||
Get started with Cally
|
||||
<View padding-10 height={"100%"} flexG>
|
||||
<Text text30 center>
|
||||
Get started with Cally
|
||||
</Text>
|
||||
<Text center>Please enter your details.</Text>
|
||||
<TextField
|
||||
marginT-60
|
||||
placeholder="First name"
|
||||
value={firstName}
|
||||
onChangeText={setFirstName}
|
||||
style={styles.textfield}
|
||||
/>
|
||||
<TextField
|
||||
placeholder="Last name"
|
||||
value={lastName}
|
||||
onChangeText={setLastName}
|
||||
style={styles.textfield}
|
||||
/>
|
||||
<TextField
|
||||
placeholder="Email"
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
style={styles.textfield}
|
||||
/>
|
||||
<TextField
|
||||
placeholder="Password"
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
secureTextEntry={!isPasswordVisible}
|
||||
style={styles.textfield}
|
||||
trailingAccessory={
|
||||
<TouchableOpacity
|
||||
onPress={() => setIsPasswordVisible(!isPasswordVisible)}
|
||||
>
|
||||
<AntDesign
|
||||
name={isPasswordVisible ? "eye" : "eyeo"}
|
||||
size={24}
|
||||
color="gray"
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
}
|
||||
/>
|
||||
<View gap-10 marginH-10>
|
||||
<View row centerV>
|
||||
<Checkbox
|
||||
value={allowFaceID}
|
||||
onValueChange={(value) => {
|
||||
setAllowFaceID(value);
|
||||
}}
|
||||
/>
|
||||
<Text text90R marginL-10>
|
||||
Allow FaceID for login in future
|
||||
</Text>
|
||||
</View>
|
||||
<View row centerV>
|
||||
<Checkbox
|
||||
value={acceptTerms}
|
||||
onValueChange={(value) => setAcceptTerms(value)}
|
||||
/>
|
||||
<View row>
|
||||
<Text text90R marginL-10>
|
||||
I accept the
|
||||
</Text>
|
||||
<Text color={"#919191"} style={{ fontSize: 20 }}>
|
||||
Please enter your details.
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<KeyboardAvoidingView style={{ width: "100%" }}>
|
||||
<TextField
|
||||
marginT-30
|
||||
autoFocus
|
||||
placeholder="First name"
|
||||
value={firstName}
|
||||
onChangeText={setFirstName}
|
||||
style={styles.textfield}
|
||||
onSubmitEditing={() => {
|
||||
lnameRef.current?.focus();
|
||||
}}
|
||||
blurOnSubmit={false}
|
||||
accessibilityLabel="First name input"
|
||||
accessibilityHint="Enter your first name"
|
||||
accessible
|
||||
returnKeyType="next"
|
||||
textContentType="givenName"
|
||||
importantForAccessibility="yes"
|
||||
/>
|
||||
<TextField
|
||||
ref={lnameRef}
|
||||
placeholder="Last name"
|
||||
value={lastName}
|
||||
onChangeText={setLastName}
|
||||
style={styles.textfield}
|
||||
onSubmitEditing={() => {
|
||||
emailRef.current?.focus();
|
||||
}}
|
||||
blurOnSubmit={false}
|
||||
accessibilityLabel="Last name input"
|
||||
accessibilityHint="Enter your last name"
|
||||
accessible
|
||||
returnKeyType="next"
|
||||
textContentType="familyName"
|
||||
importantForAccessibility="yes"
|
||||
/>
|
||||
<TextField
|
||||
placeholder="Email"
|
||||
keyboardType={"email-address"}
|
||||
returnKeyType={"next"}
|
||||
textContentType={"emailAddress"}
|
||||
defaultValue={email}
|
||||
onChangeText={setEmail}
|
||||
style={styles.textfield}
|
||||
autoComplete={"email"}
|
||||
autoCorrect={false}
|
||||
ref={emailRef}
|
||||
onSubmitEditing={() => {
|
||||
passwordRef.current?.focus();
|
||||
}}
|
||||
/>
|
||||
|
||||
<View
|
||||
centerV
|
||||
style={[styles.textfield, { padding: 0, paddingHorizontal: 30 }]}
|
||||
>
|
||||
<TextField
|
||||
ref={passwordRef}
|
||||
placeholder="Password"
|
||||
style={styles.jakartaLight}
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
secureTextEntry={!isPasswordVisible}
|
||||
trailingAccessory={
|
||||
<TouchableOpacity
|
||||
onPress={() => setIsPasswordVisible(!isPasswordVisible)}
|
||||
>
|
||||
<AntDesign
|
||||
name={isPasswordVisible ? "eye" : "eyeo"}
|
||||
size={24}
|
||||
color="gray"
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
|
||||
<View gap-5 marginT-15>
|
||||
<View row centerV>
|
||||
<Checkbox
|
||||
style={[styles.check]}
|
||||
color="#919191"
|
||||
value={allowFaceID}
|
||||
onValueChange={(value) => {
|
||||
setAllowFaceID(value);
|
||||
}}
|
||||
/>
|
||||
<Text style={styles.jakartaLight} marginL-10>
|
||||
Allow FaceID for login in future
|
||||
<TouchableOpacity>
|
||||
<Text text90 style={{ textDecorationLine: "underline" }}>
|
||||
{" "}
|
||||
terms and conditions
|
||||
</Text>
|
||||
</View>
|
||||
<View row centerV>
|
||||
<Checkbox
|
||||
style={styles.check}
|
||||
color="#919191"
|
||||
value={acceptTerms}
|
||||
onValueChange={(value) => setAcceptTerms(value)}
|
||||
/>
|
||||
<View row style={{ flexWrap: "wrap", marginLeft: 10 }}>
|
||||
<Text style={styles.jakartaLight}>I accept the</Text>
|
||||
<TouchableOpacity>
|
||||
<Text text90 style={styles.jakartaMedium}>
|
||||
{" "}
|
||||
terms and conditions
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
<Text style={styles.jakartaLight}> and </Text>
|
||||
<TouchableOpacity>
|
||||
<Text text90 style={styles.jakartaMedium}>
|
||||
{" "}
|
||||
privacy policy
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View flexG style={{ minHeight: 50 }} />
|
||||
|
||||
<View>
|
||||
<Button
|
||||
label="Register"
|
||||
disabled={!acceptTerms}
|
||||
labelStyle={{
|
||||
fontFamily: "PlusJakartaSans_600SemiBold",
|
||||
fontSize: 16,
|
||||
}}
|
||||
onPress={handleSignUp}
|
||||
backgroundColor={"#fd1775"}
|
||||
style={{ marginBottom: 0, height: 50 }}
|
||||
/>
|
||||
<View row centerH marginT-10 marginB-2 gap-5>
|
||||
<Text
|
||||
style={[
|
||||
styles.jakartaLight,
|
||||
{ fontSize: 16, color: "#484848" },
|
||||
]}
|
||||
center
|
||||
>
|
||||
Already have an account?
|
||||
</TouchableOpacity>
|
||||
<Text text90R> and </Text>
|
||||
<TouchableOpacity>
|
||||
<Text text90 style={{ textDecorationLine: "underline" }}>
|
||||
{" "}
|
||||
privacy policy
|
||||
</Text>
|
||||
|
||||
<Button
|
||||
label="Log in"
|
||||
labelStyle={[
|
||||
styles.jakartaMedium,
|
||||
{
|
||||
fontSize: 16,
|
||||
textDecorationLine: "none",
|
||||
color: "#fd1775",
|
||||
},
|
||||
]}
|
||||
flexS
|
||||
margin-0
|
||||
link
|
||||
color="#fd1775"
|
||||
size={ButtonSize.small}
|
||||
text70
|
||||
onPress={() => router.replace("/(unauth)/sign_in")}
|
||||
/>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</KeyboardAwareScrollView>
|
||||
|
||||
{isLoading && (
|
||||
<LoaderScreen
|
||||
overlay
|
||||
message={"Signing up..."}
|
||||
backgroundColor={Colors.white}
|
||||
color={Colors.grey40}
|
||||
</View>
|
||||
<View style={styles.bottomView}>
|
||||
<Button
|
||||
label="Register"
|
||||
onPress={handleSignUp}
|
||||
style={{ marginBottom: 10, backgroundColor: "#fd1775" }}
|
||||
/>
|
||||
)}
|
||||
</SafeAreaView>
|
||||
<View row centerH marginT-10 marginB-5 gap-5>
|
||||
<Text text70 center>
|
||||
Already have an account?
|
||||
</Text>
|
||||
|
||||
<Button
|
||||
label="Sign In"
|
||||
flexS
|
||||
margin-0
|
||||
link
|
||||
color="#fd1775"
|
||||
size={ButtonSize.small}
|
||||
text70
|
||||
onPress={() => setTab("login")}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
@ -244,33 +140,11 @@ export default SignUpPage;
|
||||
const styles = StyleSheet.create({
|
||||
textfield: {
|
||||
backgroundColor: "white",
|
||||
marginVertical: 8,
|
||||
marginVertical: 10,
|
||||
padding: 30,
|
||||
height: 44,
|
||||
height: 45,
|
||||
borderRadius: 50,
|
||||
fontFamily: "PlusJakartaSans_300Light",
|
||||
fontSize: 13,
|
||||
color: "#919191",
|
||||
},
|
||||
jakartaLight: {
|
||||
fontFamily: "PlusJakartaSans_300Light",
|
||||
fontSize: 13,
|
||||
color: "#919191",
|
||||
},
|
||||
jakartaMedium: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 13,
|
||||
color: "#919191",
|
||||
textDecorationLine: "underline",
|
||||
},
|
||||
title: { fontFamily: "Manrope_600SemiBold", fontSize: 34, marginTop: 50 },
|
||||
subtitle: { fontFamily: "PlusJakartaSans_400Regular", fontSize: 16 },
|
||||
check: {
|
||||
borderRadius: 3,
|
||||
aspectRatio: 1,
|
||||
width: 18,
|
||||
color: "#919191",
|
||||
borderColor: "#919191",
|
||||
borderWidth: 1,
|
||||
},
|
||||
//mora da se izmeni kako treba
|
||||
bottomView: { marginTop: 150 },
|
||||
});
|
||||
|
||||
@ -1,471 +1,433 @@
|
||||
import {Ionicons} from "@expo/vector-icons";
|
||||
import React, {useCallback, useState} from "react";
|
||||
import {Button, Checkbox, Text, View} from "react-native-ui-lib";
|
||||
import {ActivityIndicator, ScrollView, StyleSheet} from "react-native";
|
||||
import {TouchableOpacity} from "react-native-gesture-handler";
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import {useUpdateUserData} from "@/hooks/firebase/useUpdateUserData";
|
||||
import { AntDesign, Ionicons } from "@expo/vector-icons";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import { Button, Checkbox, Text, View } from "react-native-ui-lib";
|
||||
import { ScrollView, StyleSheet } from "react-native";
|
||||
import { colorMap } from "@/contexts/SettingsContext";
|
||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||
import { fetchGoogleCalendarEvents } from "@/calendar-integration/google-calendar-utils";
|
||||
import { fetchMicrosoftCalendarEvents } from "@/calendar-integration/microsoft-calendar-utils";
|
||||
import { useCreateEventFromProvider } from "@/hooks/firebase/useCreateEvent";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import { useUpdateUserData } from "@/hooks/firebase/useUpdateUserData";
|
||||
import debounce from "debounce";
|
||||
import AppleIcon from "@/assets/svgs/AppleIcon";
|
||||
import GoogleIcon from "@/assets/svgs/GoogleIcon";
|
||||
import OutlookIcon from "@/assets/svgs/OutlookIcon";
|
||||
import ExpoLocalization from "expo-localization/src/ExpoLocalization";
|
||||
import {useSetAtom} from "jotai";
|
||||
import {settingsPageIndex} from "../calendar/atoms";
|
||||
import CalendarSettingsDialog from "./calendar_components/CalendarSettingsDialog";
|
||||
import {useClearTokens} from "@/hooks/firebase/useClearTokens";
|
||||
import {useCalSync} from "@/hooks/useCalSync";
|
||||
import Feather from "@expo/vector-icons/Feather";
|
||||
import * as AuthSession from "expo-auth-session";
|
||||
import * as Google from "expo-auth-session/providers/google";
|
||||
import * as WebBrowser from "expo-web-browser";
|
||||
|
||||
const googleConfig = {
|
||||
androidClientId:
|
||||
"406146460310-2u67ab2nbhu23trp8auho1fq4om29fc0.apps.googleusercontent.com",
|
||||
iosClientId:
|
||||
"406146460310-2u67ab2nbhu23trp8auho1fq4om29fc0.apps.googleusercontent.com",
|
||||
webClientId:
|
||||
"406146460310-2u67ab2nbhu23trp8auho1fq4om29fc0.apps.googleusercontent.com",
|
||||
scopes: [
|
||||
"email",
|
||||
"profile",
|
||||
"https://www.googleapis.com/auth/calendar.events.owned",
|
||||
],
|
||||
};
|
||||
|
||||
const CalendarSettingsPage = () => {
|
||||
const {profileData} = useAuthContext();
|
||||
const setPageIndex = useSetAtom(settingsPageIndex);
|
||||
const microsoftConfig = {
|
||||
clientId: "13c79071-1066-40a9-9f71-b8c4b138b4af", // Replace with your Microsoft client ID
|
||||
redirectUri: AuthSession.makeRedirectUri({ path: "settings" }), // Generate redirect URI automatically for Expo
|
||||
scopes: [
|
||||
"openid",
|
||||
"profile",
|
||||
"email",
|
||||
"offline_access",
|
||||
"Calendars.ReadWrite", // Scope for reading calendar events
|
||||
],
|
||||
authorizationEndpoint:
|
||||
"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
||||
tokenEndpoint: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
|
||||
};
|
||||
|
||||
const [firstDayOfWeek, setFirstDayOfWeek] = useState<string>(
|
||||
profileData?.firstDayOfWeek ??
|
||||
ExpoLocalization.getCalendars()[0].firstWeekday === 1
|
||||
? "Mondays"
|
||||
: "Sundays"
|
||||
);
|
||||
const [isModalVisible, setModalVisible] = useState<boolean>(false);
|
||||
const [selectedService, setSelectedService] = useState<
|
||||
"google" | "outlook" | "apple"
|
||||
>("google");
|
||||
const [selectedEmail, setSelectedEmail] = useState<string>("");
|
||||
const CalendarSettingsPage = (props: {
|
||||
setSelectedPage: (page: number) => void;
|
||||
}) => {
|
||||
const [startDate, setStartDate] = useState<boolean>(false);
|
||||
const { profileData } = useAuthContext();
|
||||
|
||||
const showConfirmationDialog = (
|
||||
serviceName: "google" | "outlook" | "apple",
|
||||
email: string
|
||||
) => {
|
||||
setSelectedService(serviceName);
|
||||
setSelectedEmail(email);
|
||||
setModalVisible(true);
|
||||
};
|
||||
const [selectedColor, setSelectedColor] = useState<string>(
|
||||
profileData?.eventColor ?? colorMap.pink
|
||||
);
|
||||
const [previousSelectedColor, setPreviousSelectedColor] = useState<string>(
|
||||
profileData?.eventColor ?? colorMap.pink
|
||||
);
|
||||
|
||||
const handleConfirm = async () => {
|
||||
await clearToken({email: selectedEmail, provider: selectedService});
|
||||
setModalVisible(false);
|
||||
};
|
||||
const { mutateAsync: createEventFromProvider } = useCreateEventFromProvider();
|
||||
const { mutateAsync: updateUserData } = useUpdateUserData();
|
||||
|
||||
const handleCancel = () => {
|
||||
setModalVisible(false);
|
||||
};
|
||||
WebBrowser.maybeCompleteAuthSession();
|
||||
const [request, response, promptAsync] = Google.useAuthRequest(googleConfig);
|
||||
|
||||
const {mutateAsync: updateUserData} = useUpdateUserData();
|
||||
const {mutateAsync: clearToken} = useClearTokens();
|
||||
useEffect(() => {
|
||||
signInWithGoogle();
|
||||
}, [response]);
|
||||
|
||||
const {
|
||||
isSyncingGoogle,
|
||||
isSyncingOutlook,
|
||||
isConnectedToGoogle,
|
||||
isConnectedToMicrosoft,
|
||||
isConnectedToApple,
|
||||
handleAppleSignIn,
|
||||
isSyncingApple,
|
||||
handleMicrosoftSignIn,
|
||||
fetchAndSaveOutlookEvents,
|
||||
fetchAndSaveGoogleEvents,
|
||||
handleStartGoogleSignIn,
|
||||
fetchAndSaveAppleEvents
|
||||
} = useCalSync()
|
||||
|
||||
const debouncedUpdateFirstDayOfWeek = useCallback(
|
||||
debounce(async (firstDayOfWeek: string) => {
|
||||
try {
|
||||
await updateUserData({
|
||||
newUserData: {
|
||||
firstDayOfWeek,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to update first day of week:", error);
|
||||
}
|
||||
}, 500),
|
||||
[]
|
||||
const fetchAndSaveGoogleEvents = () => {
|
||||
console.log("fetch");
|
||||
const timeMin = new Date(new Date().setHours(0, 0, 0, 0));
|
||||
const timeMax = new Date(
|
||||
new Date(new Date().setHours(0, 0, 0, 0)).setDate(timeMin.getDate() + 30)
|
||||
);
|
||||
|
||||
const handleChangeFirstDayOfWeek = (firstDayOfWeek: string) => {
|
||||
setFirstDayOfWeek(firstDayOfWeek);
|
||||
debouncedUpdateFirstDayOfWeek(firstDayOfWeek);
|
||||
};
|
||||
fetchGoogleCalendarEvents(
|
||||
profileData?.googleToken,
|
||||
timeMin.toISOString().slice(0, -5) + "Z",
|
||||
timeMax.toISOString().slice(0, -5) + "Z"
|
||||
).then((response) => {
|
||||
response?.forEach((item) => saveData(item));
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<ScrollView>
|
||||
<TouchableOpacity onPress={() => setPageIndex(0)}>
|
||||
<View row marginT-20 marginB-20 marginL-20 centerV>
|
||||
<Ionicons
|
||||
name="chevron-back"
|
||||
size={14}
|
||||
color="#979797"
|
||||
style={{paddingBottom: 3}}
|
||||
/>
|
||||
<Text
|
||||
style={{fontFamily: "Poppins_400Regular", fontSize: 14.71}}
|
||||
color="#979797"
|
||||
>
|
||||
Return to main settings
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<View marginH-30 marginB-30>
|
||||
<Text style={styles.subTitle}>Calendar settings</Text>
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.cardTitle}>Weekly Start Date</Text>
|
||||
<View row marginV-5 marginT-20>
|
||||
<Checkbox
|
||||
value={firstDayOfWeek === "Sundays"}
|
||||
style={styles.checkbox}
|
||||
color="#ea156d"
|
||||
onValueChange={() => handleChangeFirstDayOfWeek("Sundays")}
|
||||
/>
|
||||
<View row marginL-8>
|
||||
<Text text70>Sundays</Text>
|
||||
<Text text70 color="gray">
|
||||
{" "}
|
||||
(default)
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View row marginV-5>
|
||||
<Checkbox
|
||||
value={firstDayOfWeek === "Mondays"}
|
||||
style={styles.checkbox}
|
||||
color="#ea156d"
|
||||
onValueChange={() => handleChangeFirstDayOfWeek("Mondays")}
|
||||
/>
|
||||
<Text text70 marginL-8>
|
||||
Mondays
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<Text style={styles.subTitle} marginT-30 marginB-25>
|
||||
Add Calendar
|
||||
</Text>
|
||||
async function saveData(item: any) {
|
||||
await createEventFromProvider(item);
|
||||
}
|
||||
|
||||
<Button
|
||||
onPress={() => handleStartGoogleSignIn()}
|
||||
label={profileData?.googleAccounts ? "Connect another Google account" : "Connect Google account"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<GoogleIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
const fetchAndSaveMicrosoftEvents = () => {
|
||||
const startDateTime = new Date(new Date().setHours(0, 0, 0, 0));
|
||||
const endDateTime = new Date(
|
||||
new Date(new Date().setHours(0, 0, 0, 0)).setDate(
|
||||
startDateTime.getDate() + 30
|
||||
)
|
||||
);
|
||||
|
||||
{!profileData?.appleAccounts && (
|
||||
<Button
|
||||
onPress={() => handleAppleSignIn()}
|
||||
label={"Connect Apple"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<AppleIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
)}
|
||||
fetchMicrosoftCalendarEvents(
|
||||
profileData?.microsoftToken,
|
||||
startDateTime.toISOString().slice(0, -5) + "Z",
|
||||
endDateTime.toISOString().slice(0, -5) + "Z"
|
||||
).then((response) => {
|
||||
console.log(response);
|
||||
response?.forEach((item) => saveData(item));
|
||||
});
|
||||
};
|
||||
|
||||
<Button
|
||||
onPress={() => handleMicrosoftSignIn()}
|
||||
label={profileData?.microsoftAccounts ? "Connect another Outlook account" : "Connect Outlook"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2,
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<OutlookIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
const signInWithGoogle = async () => {
|
||||
try {
|
||||
// Attempt to retrieve user information from AsyncStorage
|
||||
if (response?.type === "success") {
|
||||
console.log(response.authentication);
|
||||
await updateUserData({
|
||||
newUserData: { googleToken: response.authentication?.accessToken },
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
// Handle any errors that occur during AsyncStorage retrieval or other operations
|
||||
console.error("Error retrieving user data from AsyncStorage:", error);
|
||||
}
|
||||
};
|
||||
|
||||
{(isConnectedToGoogle ||
|
||||
isConnectedToMicrosoft ||
|
||||
isConnectedToApple) && (
|
||||
<>
|
||||
<Text style={styles.subTitle} marginT-30 marginB-20>
|
||||
Connected Calendars
|
||||
</Text>
|
||||
const handleMicrosoftSignIn = async () => {
|
||||
try {
|
||||
console.log("Starting Microsoft sign-in...");
|
||||
|
||||
<View style={[styles.noPaddingCard, {marginBottom: 100}]}>
|
||||
<View style={{marginTop: 20}}>
|
||||
{profileData?.googleAccounts &&
|
||||
Object.keys(profileData?.googleAccounts)?.map(
|
||||
(googleEmail) => {
|
||||
const googleToken =
|
||||
profileData?.googleAccounts?.[googleEmail]?.accessToken;
|
||||
return (
|
||||
googleToken && (
|
||||
<View row paddingR-5 center>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#ffffff",
|
||||
marginBottom: 15,
|
||||
paddingLeft: 15,
|
||||
}}
|
||||
color="black"
|
||||
text70BL
|
||||
row
|
||||
centerV
|
||||
width="100%"
|
||||
spread
|
||||
>
|
||||
{isSyncingGoogle ? (
|
||||
<View marginR-5>
|
||||
<ActivityIndicator/>
|
||||
</View>
|
||||
) : (
|
||||
<View marginR-5>
|
||||
<Button
|
||||
style={{backgroundColor: "#ffffff"}}
|
||||
color="black"
|
||||
onPress={() =>
|
||||
fetchAndSaveGoogleEvents({
|
||||
token: googleToken,
|
||||
email: googleEmail,
|
||||
})
|
||||
}
|
||||
iconSource={() => <Ionicons
|
||||
name={"refresh"}
|
||||
size={20}
|
||||
color={"#000000"}
|
||||
/>}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<View marginR-5>
|
||||
<GoogleIcon/>
|
||||
</View>
|
||||
<Text style={styles.addCalLbl}>
|
||||
{googleEmail}
|
||||
</Text>
|
||||
<Button
|
||||
style={{backgroundColor: "#ffffff", marginRight: 5}}
|
||||
color="black"
|
||||
onPress={
|
||||
() => showConfirmationDialog("google", googleEmail)
|
||||
}
|
||||
iconSource={() => <Feather name="x" size={24} />}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
);
|
||||
}
|
||||
)}
|
||||
const authRequest = new AuthSession.AuthRequest({
|
||||
clientId: microsoftConfig.clientId,
|
||||
scopes: microsoftConfig.scopes,
|
||||
redirectUri: microsoftConfig.redirectUri,
|
||||
responseType: AuthSession.ResponseType.Code,
|
||||
usePKCE: true, // Enable PKCE
|
||||
});
|
||||
|
||||
{profileData?.appleAccounts &&
|
||||
Object.keys(profileData?.appleAccounts)?.map((appleEmail) => {
|
||||
console.log(profileData?.appleAccounts)
|
||||
console.log("Auth request created:", authRequest);
|
||||
|
||||
const appleToken = profileData?.appleAccounts?.[appleEmail];
|
||||
return (
|
||||
appleToken && (
|
||||
<View row paddingR-5 center>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#ffffff",
|
||||
marginBottom: 15,
|
||||
paddingLeft: 15,
|
||||
}}
|
||||
color="black"
|
||||
text70BL
|
||||
row
|
||||
centerV
|
||||
width="100%"
|
||||
spread
|
||||
>
|
||||
<View marginR-5>
|
||||
<AppleIcon/>
|
||||
</View>
|
||||
<Text style={styles.addCalLbl}>
|
||||
{appleEmail}
|
||||
</Text>
|
||||
{isSyncingApple ? (
|
||||
<View marginR-5>
|
||||
<ActivityIndicator/>
|
||||
</View>
|
||||
) : (
|
||||
<View marginR-5>
|
||||
<Button
|
||||
style={{backgroundColor: "#ffffff"}}
|
||||
color="black"
|
||||
onPress={() =>
|
||||
fetchAndSaveAppleEvents({
|
||||
email: appleEmail,
|
||||
token: appleToken,
|
||||
})
|
||||
}
|
||||
iconSource={() => <Ionicons
|
||||
name={"refresh"}
|
||||
size={20}
|
||||
color={"#000000"}
|
||||
/>}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<Button
|
||||
style={{backgroundColor: "#ffffff", marginRight: 5}}
|
||||
color="black"
|
||||
onPress={() => showConfirmationDialog("apple", appleEmail)}
|
||||
iconSource={() => <Feather name="x" size={24} />}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
);
|
||||
})}
|
||||
const authResult = await authRequest.promptAsync({
|
||||
authorizationEndpoint: microsoftConfig.authorizationEndpoint,
|
||||
});
|
||||
|
||||
{profileData?.microsoftAccounts &&
|
||||
Object.keys(profileData?.microsoftAccounts)?.map(
|
||||
(microsoftEmail) => {
|
||||
const microsoftToken =
|
||||
profileData?.microsoftAccounts?.[microsoftEmail];
|
||||
return (
|
||||
microsoftToken && (
|
||||
<View row paddingR-5 center>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#ffffff",
|
||||
marginBottom: 15,
|
||||
paddingLeft: 15,
|
||||
}}
|
||||
color="black"
|
||||
text70BL
|
||||
row
|
||||
centerV
|
||||
width="100%"
|
||||
spread
|
||||
>
|
||||
{isSyncingOutlook ? (
|
||||
<View marginR-5>
|
||||
<ActivityIndicator/>
|
||||
</View>
|
||||
) : (
|
||||
<View marginR-5>
|
||||
<Button
|
||||
style={{backgroundColor: "#ffffff"}}
|
||||
color="black"
|
||||
onPress={() =>
|
||||
fetchAndSaveOutlookEvents({
|
||||
token: microsoftToken,
|
||||
email: microsoftEmail,
|
||||
})
|
||||
}
|
||||
iconSource={() => <Ionicons
|
||||
name={"refresh"}
|
||||
size={20}
|
||||
color={"#000000"}
|
||||
/>}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<View marginR-5>
|
||||
<OutlookIcon/>
|
||||
</View>
|
||||
<Text style={styles.addCalLbl}>
|
||||
{microsoftEmail}
|
||||
</Text>
|
||||
<Button
|
||||
style={{backgroundColor: "#ffffff", marginRight: 5}}
|
||||
color="black"
|
||||
onPress={
|
||||
() => showConfirmationDialog("outlook", microsoftEmail)
|
||||
}
|
||||
iconSource={() => <Feather name="x" size={24} />}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
);
|
||||
}
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
<CalendarSettingsDialog
|
||||
visible={isModalVisible}
|
||||
serviceName={selectedService}
|
||||
email={selectedEmail}
|
||||
onDismiss={handleCancel}
|
||||
onConfirm={handleConfirm}
|
||||
console.log("Auth result:", authResult);
|
||||
|
||||
if (authResult.type === "success" && authResult.params?.code) {
|
||||
const code = authResult.params.code;
|
||||
console.log("Authorization code received:", code);
|
||||
|
||||
// Exchange authorization code for tokens
|
||||
const tokenResponse = await fetch(microsoftConfig.tokenEndpoint, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: `client_id=${
|
||||
microsoftConfig.clientId
|
||||
}&redirect_uri=${encodeURIComponent(
|
||||
microsoftConfig.redirectUri
|
||||
)}&grant_type=authorization_code&code=${code}&code_verifier=${
|
||||
authRequest.codeVerifier
|
||||
}&scope=${encodeURIComponent(
|
||||
"https://graph.microsoft.com/Calendars.ReadWrite offline_access"
|
||||
)}`,
|
||||
});
|
||||
|
||||
console.log("Token response status:", tokenResponse.status);
|
||||
|
||||
if (!tokenResponse.ok) {
|
||||
console.error("Token exchange failed:", await tokenResponse.text());
|
||||
return;
|
||||
}
|
||||
|
||||
const tokenData = await tokenResponse.json();
|
||||
console.log("Token data received:", tokenData);
|
||||
|
||||
if (tokenData?.id_token) {
|
||||
console.log("ID token received, updating user data...");
|
||||
await updateUserData({
|
||||
newUserData: { microsoftToken: tokenData.access_token },
|
||||
});
|
||||
console.log("User data updated successfully.");
|
||||
}
|
||||
} else {
|
||||
console.warn("Authentication was not successful:", authResult);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error during Microsoft sign-in:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const debouncedUpdateUserData = useCallback(
|
||||
debounce(async (color: string) => {
|
||||
try {
|
||||
await updateUserData({
|
||||
newUserData: {
|
||||
eventColor: color,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to update color:", error);
|
||||
setSelectedColor(previousSelectedColor);
|
||||
}
|
||||
}, 500),
|
||||
[]
|
||||
);
|
||||
|
||||
const handleChangeColor = (color: string) => {
|
||||
setPreviousSelectedColor(selectedColor);
|
||||
setSelectedColor(color);
|
||||
debouncedUpdateUserData(color);
|
||||
};
|
||||
|
||||
return (
|
||||
<ScrollView>
|
||||
<View marginH-30>
|
||||
<TouchableOpacity onPress={() => props.setSelectedPage(0)}>
|
||||
<View row marginT-20 marginB-35 centerV>
|
||||
<Ionicons
|
||||
name="chevron-back"
|
||||
size={14}
|
||||
color="#979797"
|
||||
style={{ paddingBottom: 3 }}
|
||||
/>
|
||||
</ScrollView>
|
||||
);
|
||||
<Text
|
||||
style={{ fontFamily: "Poppins_400Regular", fontSize: 14.71 }}
|
||||
color="#979797"
|
||||
>
|
||||
Return to main settings
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<Text style={styles.subTitle}>Calendar settings</Text>
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.cardTitle} marginB-14>
|
||||
Event Color Preference
|
||||
</Text>
|
||||
<View row spread>
|
||||
<TouchableOpacity onPress={() => handleChangeColor(colorMap.pink)}>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.pink}>
|
||||
{selectedColor == colorMap.pink && (
|
||||
<AntDesign name="check" size={30} color="white" />
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
onPress={() => handleChangeColor(colorMap.orange)}
|
||||
>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.orange}>
|
||||
{selectedColor == colorMap.orange && (
|
||||
<AntDesign name="check" size={30} color="white" />
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => handleChangeColor(colorMap.green)}>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.green}>
|
||||
{selectedColor == colorMap.green && (
|
||||
<AntDesign name="check" size={30} color="white" />
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => handleChangeColor(colorMap.teal)}>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.teal}>
|
||||
{selectedColor == colorMap.teal && (
|
||||
<AntDesign name="check" size={30} color="white" />
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
onPress={() => handleChangeColor(colorMap.purple)}
|
||||
>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.purple}>
|
||||
{selectedColor == colorMap.purple && (
|
||||
<AntDesign name="check" size={30} color="white" />
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.cardTitle}>Weekly Start Date</Text>
|
||||
<View row marginV-5 marginT-20>
|
||||
<Checkbox
|
||||
value={startDate}
|
||||
style={styles.checkbox}
|
||||
color="#ea156d"
|
||||
onValueChange={() => setStartDate(true)}
|
||||
/>
|
||||
<View row marginL-8>
|
||||
<Text text70>Sundays</Text>
|
||||
<Text text70 color="gray">
|
||||
{" "}
|
||||
(default)
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View row marginV-5>
|
||||
<Checkbox
|
||||
value={!startDate}
|
||||
style={styles.checkbox}
|
||||
color="#ea156d"
|
||||
onValueChange={() => setStartDate(false)}
|
||||
/>
|
||||
<Text text70 marginL-8>
|
||||
Mondays
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<Text style={styles.subTitle} marginT-30 marginB-25>
|
||||
Add Calendar
|
||||
</Text>
|
||||
|
||||
<Button
|
||||
onPress={() => promptAsync()}
|
||||
label="Connect Google"
|
||||
labelStyle={styles.addCalLbl}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<GoogleIcon />
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
<Button
|
||||
label="Connect Apple"
|
||||
labelStyle={styles.addCalLbl}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<AppleIcon />
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
<Button
|
||||
onPress={handleMicrosoftSignIn}
|
||||
label="Connect Outlook"
|
||||
labelStyle={styles.addCalLbl}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<OutlookIcon />
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
|
||||
<Text style={styles.subTitle} marginT-30 marginB-20>
|
||||
Connected Calendars
|
||||
</Text>
|
||||
<View style={styles.card}>
|
||||
<View style={{ marginTop: 20 }}>
|
||||
<Button
|
||||
onPress={fetchAndSaveGoogleEvents}
|
||||
label="Sync Google"
|
||||
labelStyle={styles.addCalLbl}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<GoogleIcon />
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
<Button
|
||||
onPress={fetchAndSaveMicrosoftEvents}
|
||||
label="Sync Outlook"
|
||||
labelStyle={styles.addCalLbl}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<OutlookIcon />
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
addCalBtn: {
|
||||
backgroundColor: "#ffffff",
|
||||
marginBottom: 15,
|
||||
justifyContent: "flex-start",
|
||||
paddingLeft: 25,
|
||||
},
|
||||
backBtn: {
|
||||
backgroundColor: "red",
|
||||
marginLeft: -2,
|
||||
justifyContent: "flex-start",
|
||||
},
|
||||
card: {
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
padding: 20,
|
||||
paddingBottom: 30,
|
||||
marginTop: 20,
|
||||
borderRadius: 12,
|
||||
},
|
||||
noPaddingCard: {
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
marginTop: 20,
|
||||
borderRadius: 12,
|
||||
},
|
||||
colorBox: {
|
||||
aspectRatio: 1,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
width: 51,
|
||||
borderRadius: 12,
|
||||
},
|
||||
checkbox: {
|
||||
borderRadius: 50,
|
||||
},
|
||||
addCalLbl: {
|
||||
fontSize: 16,
|
||||
fontFamily: "PlusJakartaSan_500Medium",
|
||||
flexWrap: "wrap",
|
||||
width: "70%",
|
||||
textAlign: "left",
|
||||
lineHeight: 20,
|
||||
overflow: "hidden",
|
||||
},
|
||||
subTitle: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 18,
|
||||
},
|
||||
cardTitle: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
addCalBtn: {
|
||||
backgroundColor: "#ffffff",
|
||||
marginBottom: 15,
|
||||
justifyContent: "flex-start",
|
||||
paddingLeft: 25,
|
||||
},
|
||||
backBtn: {
|
||||
backgroundColor: "red",
|
||||
marginLeft: -2,
|
||||
justifyContent: "flex-start",
|
||||
},
|
||||
card: {
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
padding: 20,
|
||||
paddingBottom: 30,
|
||||
marginTop: 20,
|
||||
borderRadius: 12,
|
||||
},
|
||||
colorBox: {
|
||||
aspectRatio: 1,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
width: 51,
|
||||
borderRadius: 12,
|
||||
},
|
||||
checkbox: {
|
||||
borderRadius: 50,
|
||||
},
|
||||
addCalLbl: {
|
||||
fontSize: 16,
|
||||
fontFamily: "PlusJakartaSan_500Medium",
|
||||
},
|
||||
subTitle: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 18,
|
||||
},
|
||||
cardTitle: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
});
|
||||
|
||||
export default CalendarSettingsPage;
|
||||
|
||||
@ -4,32 +4,30 @@ import { Ionicons } from "@expo/vector-icons";
|
||||
import { ToDosContextProvider } from "@/contexts/ToDosContext";
|
||||
import ToDosList from "../todos/ToDosList";
|
||||
import { ScrollView } from "react-native-gesture-handler";
|
||||
import { settingsPageIndex } from "../calendar/atoms";
|
||||
import { useAtom } from "jotai";
|
||||
|
||||
const ChoreRewardSettings = () => {
|
||||
const [pageIndex, setPageIndex] = useAtom(settingsPageIndex);
|
||||
|
||||
const ChoreRewardSettings = (props: {
|
||||
setSelectedPage: (page: number) => void;
|
||||
}) => {
|
||||
return (
|
||||
<ToDosContextProvider>
|
||||
<TouchableOpacity onPress={() => setPageIndex(0)}>
|
||||
<View row marginT-20 marginB-20 marginL-20 centerV>
|
||||
<Ionicons
|
||||
name="chevron-back"
|
||||
size={14}
|
||||
color="#979797"
|
||||
style={{ paddingBottom: 3 }}
|
||||
/>
|
||||
<Text
|
||||
style={{ fontFamily: "Poppins_400Regular", fontSize: 14.71 }}
|
||||
color="#979797"
|
||||
>
|
||||
Return to main settings
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<View marginH-20>
|
||||
<View marginT-10 marginH-20>
|
||||
<ScrollView>
|
||||
<TouchableOpacity onPress={() => props.setSelectedPage(0)}>
|
||||
<View row marginT-20 marginB-35 centerV>
|
||||
<Ionicons
|
||||
name="chevron-back"
|
||||
size={14}
|
||||
color="#979797"
|
||||
style={{ paddingBottom: 3 }}
|
||||
/>
|
||||
<Text
|
||||
style={{ fontFamily: "Poppins_400Regular", fontSize: 14.71 }}
|
||||
color="#979797"
|
||||
>
|
||||
Return to main settings
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<Text text60R marginB-20>
|
||||
Chore Reward Settings
|
||||
</Text>
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
import { Button, Text, View } from "react-native-ui-lib";
|
||||
import { View, Text, Button } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import {Linking, StyleSheet} from "react-native";
|
||||
import { Octicons } from "@expo/vector-icons";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { Entypo, Ionicons, Octicons } from "@expo/vector-icons";
|
||||
import CalendarSettingsPage from "./CalendarSettingsPage";
|
||||
import ChoreRewardSettings from "./ChoreRewardSettings";
|
||||
import UserSettings from "./UserSettings";
|
||||
import { AuthContextProvider } from "@/contexts/AuthContext";
|
||||
import ProfileIcon from "@/assets/svgs/ProfileIcon";
|
||||
import CalendarIcon from "@/assets/svgs/CalendarIcon";
|
||||
import PrivacyPolicyIcon from "@/assets/svgs/PrivacyPolicyIcon";
|
||||
import ArrowRightIcon from "@/assets/svgs/ArrowRightIcon";
|
||||
import { ProfileType, useAuthContext } from "@/contexts/AuthContext";
|
||||
import { settingsPageIndex } from "../calendar/atoms";
|
||||
import { useAtom } from "jotai";
|
||||
|
||||
const pageIndex = {
|
||||
main: 0,
|
||||
@ -20,109 +17,74 @@ const pageIndex = {
|
||||
chore: 3,
|
||||
policy: 4,
|
||||
};
|
||||
|
||||
const PRIVACY_POLICY_URL = 'https://callyapp.com';
|
||||
|
||||
|
||||
const SettingsPage = () => {
|
||||
const { profileData } = useAuthContext();
|
||||
const [pageIndex, setPageIndex] = useAtom(settingsPageIndex);
|
||||
const isntParent = profileData?.userType !== ProfileType.PARENT;
|
||||
|
||||
const openPrivacyPolicy = async () => {
|
||||
const supported = await Linking.canOpenURL(PRIVACY_POLICY_URL);
|
||||
if (supported) {
|
||||
await Linking.openURL(PRIVACY_POLICY_URL);
|
||||
} else {
|
||||
console.log("Don't know how to open this URL:", PRIVACY_POLICY_URL);
|
||||
}
|
||||
};
|
||||
|
||||
const [selectedPage, setSelectedPage] = useState<number>(0);
|
||||
return (
|
||||
<View flexG>
|
||||
{pageIndex == 0 && (
|
||||
<View flexG centerH marginH-30 marginT-30>
|
||||
<Button
|
||||
disabled={isntParent}
|
||||
backgroundColor="white"
|
||||
style={styles.mainBtn}
|
||||
children={
|
||||
<View row centerV width={"100%"}>
|
||||
<ProfileIcon style={{ marginRight: 10 }} color="#07b9c8" />
|
||||
<Text
|
||||
style={[
|
||||
styles.label,
|
||||
isntParent ? styles.disabledText : { color: "#07b9c8" },
|
||||
]}
|
||||
>
|
||||
Manage My Profile
|
||||
</Text>
|
||||
<ArrowRightIcon style={{ marginLeft: "auto" }} />
|
||||
</View>
|
||||
}
|
||||
onPress={() => setPageIndex(1)}
|
||||
/>
|
||||
<Button
|
||||
disabled={isntParent}
|
||||
backgroundColor="white"
|
||||
style={styles.mainBtn}
|
||||
children={
|
||||
<View row centerV width={"100%"}>
|
||||
<CalendarIcon style={{ marginRight: 10 }} />
|
||||
<Text
|
||||
style={[
|
||||
styles.label,
|
||||
isntParent ? styles.disabledText : { color: "#FD1775" },
|
||||
]}
|
||||
>
|
||||
Calendar Settings
|
||||
</Text>
|
||||
<ArrowRightIcon style={{ marginLeft: "auto" }} />
|
||||
</View>
|
||||
}
|
||||
onPress={() => {
|
||||
setPageIndex(2);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
disabled
|
||||
// disabled={isntParent}
|
||||
backgroundColor="white"
|
||||
style={styles.mainBtn}
|
||||
children={
|
||||
<View row centerV width={"100%"}>
|
||||
<View flexG>
|
||||
{selectedPage == 0 && (
|
||||
<View flexG centerH marginH-30 marginT-30>
|
||||
<Button
|
||||
backgroundColor="white"
|
||||
style={styles.mainBtn}
|
||||
label="Manage My Profile"
|
||||
labelStyle={styles.label}
|
||||
color="#07b8c7"
|
||||
iconSource={() => (
|
||||
<ProfileIcon style={{marginRight: 10}} color="#07b9c8" />
|
||||
)}
|
||||
onPress={() => setSelectedPage(pageIndex.user)}
|
||||
/>
|
||||
<Button
|
||||
backgroundColor="white"
|
||||
style={styles.mainBtn}
|
||||
label="Calendar Settings"
|
||||
labelStyle={styles.label}
|
||||
color="#fd1775"
|
||||
iconSource={() => (
|
||||
<CalendarIcon style={{marginRight: 10}}/>
|
||||
)}
|
||||
onPress={() => {
|
||||
setSelectedPage(pageIndex.calendar);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
backgroundColor="white"
|
||||
style={styles.mainBtn}
|
||||
label="To-Do Reward Settings"
|
||||
labelStyle={styles.label}
|
||||
color="#ff9900"
|
||||
iconSource={() => (
|
||||
<Octicons
|
||||
name="gear"
|
||||
size={24}
|
||||
color="#ff9900"
|
||||
style={{ marginRight: 10 }}
|
||||
/>
|
||||
<Text style={[styles.label, true ? styles.disabledText : {color: "#ff9900"}]}>
|
||||
To-Do Reward Settings
|
||||
</Text>
|
||||
<ArrowRightIcon style={{ marginLeft: "auto" }} />
|
||||
</View>
|
||||
}
|
||||
onPress={() => setPageIndex(3)}
|
||||
/>
|
||||
<Button
|
||||
backgroundColor="white"
|
||||
style={styles.mainBtn}
|
||||
onPress={openPrivacyPolicy}
|
||||
children={
|
||||
<View row centerV width={"100%"}>
|
||||
<PrivacyPolicyIcon style={{ marginRight: 10 }} />
|
||||
<Text style={[styles.label]} color={"#6C645B"}>Cally Privacy Policy</Text>
|
||||
<ArrowRightIcon style={{ marginLeft: "auto" }} />
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
{pageIndex == 2 && <CalendarSettingsPage />}
|
||||
{pageIndex == 3 && <ChoreRewardSettings />}
|
||||
{pageIndex == 1 && <UserSettings />}
|
||||
</View>
|
||||
)}
|
||||
onPress={() => setSelectedPage(pageIndex.chore)}
|
||||
/>
|
||||
<Button
|
||||
backgroundColor="white"
|
||||
style={styles.mainBtn}
|
||||
label="Cally Privacy Policy"
|
||||
labelStyle={styles.label}
|
||||
iconSource={() => (
|
||||
<PrivacyPolicyIcon style={{marginRight: 10}}/>
|
||||
)}
|
||||
color="#6c645b"
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
{selectedPage == pageIndex.calendar && (
|
||||
<CalendarSettingsPage setSelectedPage={setSelectedPage} />
|
||||
)}
|
||||
{selectedPage == pageIndex.chore && (
|
||||
<ChoreRewardSettings setSelectedPage={setSelectedPage} />
|
||||
)}
|
||||
{selectedPage == pageIndex.user && (
|
||||
<UserSettings setSelectedPage={setSelectedPage} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
@ -130,17 +92,14 @@ export default SettingsPage;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
mainBtn: {
|
||||
width: 311,
|
||||
width: "100%",
|
||||
justifyContent: "flex-start",
|
||||
marginBottom: 20,
|
||||
height: 57.61,
|
||||
height: 60,
|
||||
},
|
||||
label: {
|
||||
label:{
|
||||
fontFamily: "Poppins_400Regular",
|
||||
fontSize: 14.71,
|
||||
textAlignVertical: "center",
|
||||
},
|
||||
disabledText: {
|
||||
color: "#A9A9A9", // Example of a gray color for disabled text
|
||||
},
|
||||
textAlignVertical: 'center'
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,131 +1,99 @@
|
||||
import {FloatingButton, Text, TouchableOpacity, View,} from "react-native-ui-lib";
|
||||
import React, {useState} from "react";
|
||||
import {Ionicons} from "@expo/vector-icons";
|
||||
import {ScrollView, StyleSheet} from "react-native";
|
||||
import { Text, TouchableOpacity, View } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { ScrollView, StyleSheet } from "react-native";
|
||||
import MyProfile from "./user_settings_views/MyProfile";
|
||||
import MyGroup from "./user_settings_views/MyGroup";
|
||||
import {useAtom, useSetAtom} from "jotai";
|
||||
import {settingsPageIndex, userSettingsView} from "../calendar/atoms";
|
||||
import PlusIcon from "@/assets/svgs/PlusIcon";
|
||||
|
||||
const UserSettings = () => {
|
||||
const setPageIndex = useSetAtom(settingsPageIndex);
|
||||
const [userView, setUserView] = useAtom(userSettingsView);
|
||||
const [onNewUserClick, setOnNewUserClick] = useState<(boolean)>(false);
|
||||
|
||||
return (
|
||||
<View flexG>
|
||||
<ScrollView style={{paddingBottom: 20, minHeight: "100%"}}>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
setPageIndex(0);
|
||||
setUserView(true);
|
||||
}}
|
||||
const UserSettings = (props: { setSelectedPage: (page: number) => void }) => {
|
||||
const [selectedView, setSelectedView] = useState<boolean>(true);
|
||||
return (
|
||||
<View flexG>
|
||||
<ScrollView style={{ paddingBottom: 20, minHeight: "100%" }}>
|
||||
<TouchableOpacity onPress={() => props.setSelectedPage(0)}>
|
||||
<View row marginT-20 marginB-35 centerV>
|
||||
<Ionicons name="chevron-back" size={14} color="#979797" style={{paddingBottom: 3}} />
|
||||
<Text
|
||||
style={{ fontFamily: "Poppins_400Regular", fontSize: 14.71 }}
|
||||
color="#979797"
|
||||
>
|
||||
Return to main settings
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<View marginH-20 flexG style={{ minHeight: "90%" }}>
|
||||
<Text text60R marginB-25>
|
||||
User Management
|
||||
</Text>
|
||||
<View style={styles.buttonSwitch} spread row>
|
||||
<TouchableOpacity
|
||||
onPress={() => setSelectedView(true)}
|
||||
centerV
|
||||
centerH
|
||||
style={selectedView == true ? styles.btnSelected : styles.btnNot}
|
||||
>
|
||||
<View>
|
||||
<Text
|
||||
style={styles.btnTxt}
|
||||
color={selectedView ? "white" : "black"}
|
||||
>
|
||||
<View row marginT-20 marginB-20 marginL-20 centerV>
|
||||
<Ionicons
|
||||
name="chevron-back"
|
||||
size={14}
|
||||
color="#979797"
|
||||
style={{paddingBottom: 3}}
|
||||
/>
|
||||
<Text
|
||||
style={{fontFamily: "Poppins_400Regular", fontSize: 14.71}}
|
||||
color="#979797"
|
||||
>
|
||||
Return to main settings
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<View marginH-26 flexG style={{minHeight: "90%"}}>
|
||||
<Text text60R marginB-25>
|
||||
User Management
|
||||
</Text>
|
||||
<View style={styles.buttonSwitch} spread row>
|
||||
<TouchableOpacity
|
||||
onPress={() => setUserView(true)}
|
||||
centerV
|
||||
centerH
|
||||
style={userView == true ? styles.btnSelected : styles.btnNot}
|
||||
>
|
||||
<View>
|
||||
<Text
|
||||
style={styles.btnTxt}
|
||||
color={userView ? "white" : "black"}
|
||||
>
|
||||
My Profile
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
onPress={() => setUserView(false)}
|
||||
centerV
|
||||
centerH
|
||||
style={userView == false ? styles.btnSelected : styles.btnNot}
|
||||
>
|
||||
<View>
|
||||
<Text
|
||||
style={styles.btnTxt}
|
||||
color={!userView ? "white" : "black"}
|
||||
>
|
||||
My Group
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
{userView && <MyProfile/>}
|
||||
{!userView && <MyGroup onNewUserClick={onNewUserClick} setOnNewUserClick={setOnNewUserClick}/>}
|
||||
</View>
|
||||
</ScrollView>
|
||||
{!userView && (
|
||||
<FloatingButton
|
||||
fullWidth
|
||||
hideBackgroundOverlay
|
||||
visible
|
||||
button={{
|
||||
label: " Add a user device",
|
||||
iconSource: () => <PlusIcon height={13} width={14}/>,
|
||||
onPress: () => setOnNewUserClick(true),
|
||||
style: styles.bottomButton,
|
||||
labelStyle: {fontFamily: "Manrope_600SemiBold", fontSize: 15},
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
My Profile
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
onPress={() => setSelectedView(false)}
|
||||
centerV
|
||||
centerH
|
||||
style={selectedView == false ? styles.btnSelected : styles.btnNot}
|
||||
>
|
||||
<View>
|
||||
<Text
|
||||
style={styles.btnTxt}
|
||||
color={!selectedView ? "white" : "black"}
|
||||
>
|
||||
My Group
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
{selectedView && <MyProfile />}
|
||||
{!selectedView && <MyGroup />}
|
||||
</View>
|
||||
);
|
||||
</ScrollView>
|
||||
|
||||
{!selectedView && (
|
||||
<View>
|
||||
<Text>selview</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
bottomButton: {
|
||||
position: "absolute",
|
||||
bottom: 15,
|
||||
marginHorizontal: 28,
|
||||
width: 337,
|
||||
backgroundColor: "#e8156c",
|
||||
height: 53.26,
|
||||
},
|
||||
buttonSwitch: {
|
||||
borderRadius: 50,
|
||||
width: "100%",
|
||||
backgroundColor: "#ebebeb",
|
||||
height: 45,
|
||||
},
|
||||
btnSelected: {
|
||||
backgroundColor: "#05a8b6",
|
||||
height: "100%",
|
||||
width: "50%",
|
||||
borderRadius: 50,
|
||||
},
|
||||
btnTxt: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
btnNot: {
|
||||
height: "100%",
|
||||
width: "50%",
|
||||
borderRadius: 50,
|
||||
},
|
||||
title: {fontFamily: "Manrope_600SemiBold", fontSize: 18},
|
||||
buttonSwitch: {
|
||||
borderRadius: 50,
|
||||
width: "100%",
|
||||
backgroundColor: "#ebebeb",
|
||||
height: 45,
|
||||
},
|
||||
btnSelected: {
|
||||
backgroundColor: "#05a8b6",
|
||||
height: "100%",
|
||||
width: "50%",
|
||||
borderRadius: 50,
|
||||
},
|
||||
btnTxt: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
btnNot: {
|
||||
height: "100%",
|
||||
width: "50%",
|
||||
borderRadius: 50,
|
||||
},
|
||||
title: { fontFamily: "Manrope_600SemiBold", fontSize: 18 },
|
||||
});
|
||||
|
||||
export default UserSettings;
|
||||
|
||||
@ -1,86 +0,0 @@
|
||||
import React from "react";
|
||||
import { Dialog, Button, Text, View } from "react-native-ui-lib";
|
||||
import { StyleSheet } from "react-native";
|
||||
|
||||
interface ConfirmationDialogProps {
|
||||
visible: boolean;
|
||||
serviceName: "google" | "outlook" | "apple";
|
||||
email: string;
|
||||
onDismiss: () => void;
|
||||
onConfirm: () => void;
|
||||
}
|
||||
|
||||
const CalendarSettingsDialog: React.FC<ConfirmationDialogProps> = ({
|
||||
visible,
|
||||
serviceName,
|
||||
email,
|
||||
onDismiss,
|
||||
onConfirm,
|
||||
}) => {
|
||||
return (
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onDismiss={onDismiss}
|
||||
containerStyle={styles.dialog}
|
||||
>
|
||||
<Text center style={styles.title}>
|
||||
Disconnect {serviceName}
|
||||
</Text>
|
||||
<View center>
|
||||
<Text style={styles.text} center>
|
||||
Are you sure you want to disconnect this {"\n"}
|
||||
<Text style={{ fontSize: 16, fontFamily: "PlusJakartaSans_700Bold" }}>
|
||||
{serviceName}
|
||||
</Text>{" "}
|
||||
calendar
|
||||
{"\n"}
|
||||
for {email}?
|
||||
</Text>
|
||||
</View>
|
||||
<View row right gap-8>
|
||||
<Button
|
||||
label="Cancel"
|
||||
onPress={onDismiss}
|
||||
style={styles.cancelBtn}
|
||||
color="#999999"
|
||||
labelStyle={{ fontFamily: "Poppins_500Medium", fontSize: 13.53 }}
|
||||
/>
|
||||
<Button
|
||||
label="Yes"
|
||||
onPress={onConfirm}
|
||||
style={styles.confirmBtn}
|
||||
labelStyle={{ fontFamily: "PlusJakartaSans_500Medium" }}
|
||||
/>
|
||||
</View>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
// Empty stylesheet for future styles
|
||||
const styles = StyleSheet.create({
|
||||
confirmBtn: {
|
||||
backgroundColor: "#ea156d",
|
||||
},
|
||||
cancelBtn: {
|
||||
backgroundColor: "white",
|
||||
},
|
||||
dialog: {
|
||||
backgroundColor: "white",
|
||||
paddingHorizontal: 25,
|
||||
paddingTop: 35,
|
||||
paddingBottom: 17,
|
||||
borderRadius: 20,
|
||||
},
|
||||
title: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 22,
|
||||
marginBottom: 20,
|
||||
},
|
||||
text: {
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
marginBottom: 25,
|
||||
},
|
||||
});
|
||||
|
||||
export default CalendarSettingsDialog;
|
||||
@ -1,128 +0,0 @@
|
||||
import React, { useState } from "react";
|
||||
import { Dialog, Button, Text, View } from "react-native-ui-lib";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { Feather } from "@expo/vector-icons";
|
||||
|
||||
interface ConfirmationDialogProps {
|
||||
visible: boolean;
|
||||
onDismiss: () => void;
|
||||
onFirstYes: () => void;
|
||||
onConfirm: () => void;
|
||||
}
|
||||
|
||||
const DeleteProfileDialogs: React.FC<ConfirmationDialogProps> = ({
|
||||
visible,
|
||||
onDismiss,
|
||||
onFirstYes,
|
||||
onConfirm,
|
||||
}) => {
|
||||
const [confirmationDialog, setConfirmationDialog] = useState<boolean>(false);
|
||||
return (
|
||||
<>
|
||||
<Dialog
|
||||
visible={visible}
|
||||
onDismiss={onDismiss}
|
||||
containerStyle={styles.dialog}
|
||||
>
|
||||
<View centerH>
|
||||
<Feather name="alert-triangle" size={70} color="#ff1637" />
|
||||
</View>
|
||||
<Text center style={styles.title}>
|
||||
Are you sure?
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 18,
|
||||
fontFamily: "PlusJakartaSans_700Bold",
|
||||
color: "#979797",
|
||||
marginBottom: 20,
|
||||
}}
|
||||
center
|
||||
>
|
||||
This action will permanently delete all your data, you won't be able
|
||||
to recover it!
|
||||
</Text>
|
||||
<View centerV></View>
|
||||
<View row right gap-8>
|
||||
<Button
|
||||
label="Cancel"
|
||||
onPress={onDismiss}
|
||||
style={styles.cancelBtn}
|
||||
color="#999999"
|
||||
labelStyle={{ fontFamily: "Poppins_500Medium", fontSize: 13.53 }}
|
||||
/>
|
||||
<Button
|
||||
label="Yes"
|
||||
onPress={() => {
|
||||
setTimeout(() => setConfirmationDialog(true), 300);
|
||||
onFirstYes();
|
||||
}}
|
||||
style={styles.confirmBtn}
|
||||
labelStyle={{ fontFamily: "PlusJakartaSans_500Medium" }}
|
||||
/>
|
||||
</View>
|
||||
</Dialog>
|
||||
<Dialog
|
||||
visible={confirmationDialog}
|
||||
onDismiss={() => setConfirmationDialog(false)}
|
||||
containerStyle={styles.dialog}
|
||||
>
|
||||
<View center paddingH-10 paddingT-15 paddingB-5>
|
||||
<Text style={styles.title}>
|
||||
We're sorry to see you go, are you really sure you want to delete
|
||||
everything?
|
||||
</Text>
|
||||
<View row right gap-8 marginT-15>
|
||||
<Button
|
||||
label="Cancel"
|
||||
onPress={() => {
|
||||
setConfirmationDialog(false);
|
||||
}}
|
||||
style={styles.cancelBtn}
|
||||
color="#999999"
|
||||
labelStyle={{ fontFamily: "Poppins_500Medium", fontSize: 13.53 }}
|
||||
/>
|
||||
<Button
|
||||
label="Yes"
|
||||
onPress={() => {
|
||||
onConfirm();
|
||||
setConfirmationDialog(false);
|
||||
}}
|
||||
style={styles.confirmBtn}
|
||||
labelStyle={{ fontFamily: "PlusJakartaSans_500Medium" }}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// Empty stylesheet for future styles
|
||||
const styles = StyleSheet.create({
|
||||
confirmBtn: {
|
||||
backgroundColor: "#ff1637",
|
||||
},
|
||||
cancelBtn: {
|
||||
backgroundColor: "white",
|
||||
},
|
||||
dialog: {
|
||||
backgroundColor: "white",
|
||||
paddingHorizontal: 25,
|
||||
paddingTop: 25,
|
||||
paddingBottom: 17,
|
||||
borderRadius: 20,
|
||||
},
|
||||
title: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 22,
|
||||
marginBottom: 5,
|
||||
},
|
||||
text: {
|
||||
fontFamily: "PlusJakartaSans_400Regular",
|
||||
fontSize: 16,
|
||||
marginBottom: 0,
|
||||
},
|
||||
});
|
||||
|
||||
export default DeleteProfileDialogs;
|
||||
@ -3,42 +3,27 @@ import {
|
||||
Button,
|
||||
Card,
|
||||
Colors,
|
||||
Dialog, Image,
|
||||
KeyboardAwareScrollView,
|
||||
Dialog,
|
||||
FloatingButton,
|
||||
PanningProvider,
|
||||
Picker,
|
||||
Text,
|
||||
TextField,
|
||||
TextFieldRef,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import React, {useEffect, useRef, useState} from "react";
|
||||
import {ImageBackground, Platform, StyleSheet} from "react-native";
|
||||
import React, {useState} from "react";
|
||||
import {ScrollView, StyleSheet} from "react-native";
|
||||
import {PickerSingleValue} from "react-native-ui-lib/src/components/picker/types";
|
||||
import {useCreateSubUser} from "@/hooks/firebase/useCreateSubUser";
|
||||
import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
|
||||
import {ProfileType} from "@/contexts/AuthContext";
|
||||
import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers";
|
||||
import UserMenu from "@/components/pages/settings/user_settings_views/UserMenu";
|
||||
import {uuidv4} from "@firebase/util";
|
||||
import QRIcon from "@/assets/svgs/QRIcon";
|
||||
import EmailIcon from "@/assets/svgs/EmailIcon";
|
||||
import CircledXIcon from "@/assets/svgs/CircledXIcon";
|
||||
import ProfileIcon from "@/assets/svgs/ProfileIcon";
|
||||
import NavToDosIcon from "@/assets/svgs/NavToDosIcon";
|
||||
import Ionicons from "@expo/vector-icons/Ionicons";
|
||||
import KeyboardManager, {PreviousNextView,} from "react-native-keyboard-manager";
|
||||
import {ScrollView} from "react-native-gesture-handler";
|
||||
import {useUploadProfilePicture} from "@/hooks/useUploadProfilePicture";
|
||||
import {ImagePickerAsset} from "expo-image-picker";
|
||||
|
||||
type MyGroupProps = {
|
||||
onNewUserClick: boolean;
|
||||
setOnNewUserClick: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
};
|
||||
|
||||
const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) => {
|
||||
const MyGroup = () => {
|
||||
const [showAddUserDialog, setShowAddUserDialog] = useState(false);
|
||||
const [showNewUserInfoDialog, setShowNewUserInfoDialog] = useState(false);
|
||||
const [selectedStatus, setSelectedStatus] = useState<
|
||||
string | PickerSingleValue
|
||||
>(ProfileType.CHILD);
|
||||
@ -46,19 +31,10 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
const [lastName, setLastName] = useState("");
|
||||
const [email, setEmail] = useState("");
|
||||
|
||||
const [newUserId, setNewUserId] = useState("")
|
||||
|
||||
const lNameRef = useRef<TextFieldRef>(null);
|
||||
const emailRef = useRef<TextFieldRef>(null);
|
||||
|
||||
const [showQRCodeDialog, setShowQRCodeDialog] = useState<string | boolean>(
|
||||
false
|
||||
);
|
||||
const [showQRCodeDialog, setShowQRCodeDialog] = useState("");
|
||||
|
||||
const {mutateAsync: createSubUser, isLoading, isError} = useCreateSubUser();
|
||||
const {data: familyMembers} = useGetFamilyMembers(true);
|
||||
const {user} = useAuthContext();
|
||||
const {pickImage, changeProfilePicture, handleClearImage, pfpUri, profileImageAsset} = useUploadProfilePicture(newUserId)
|
||||
|
||||
const parents =
|
||||
familyMembers?.filter((x) => x.userType === ProfileType.PARENT) ?? [];
|
||||
@ -67,22 +43,18 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
const caregivers =
|
||||
familyMembers?.filter((x) => x.userType === ProfileType.CAREGIVER) ?? [];
|
||||
const familyDevices =
|
||||
familyMembers?.filter((x) => x.userType === ProfileType.FAMILY_DEVICE) ??
|
||||
[];
|
||||
familyMembers?.filter((x) => x.userType === ProfileType.FAMILY_DEVICE) ?? [];
|
||||
|
||||
const handleCreateSubUser = async () => {
|
||||
if (
|
||||
!firstName ||
|
||||
(selectedStatus !== ProfileType.FAMILY_DEVICE && !lastName)
|
||||
) {
|
||||
if (!firstName || (selectedStatus !== ProfileType.FAMILY_DEVICE && !lastName)) {
|
||||
console.error("First name and last name are required");
|
||||
return;
|
||||
}
|
||||
|
||||
// if (selectedStatus !== ProfileType.FAMILY_DEVICE && !email) {
|
||||
// console.error("Email is required for non-family device users");
|
||||
// return;
|
||||
// }
|
||||
if (selectedStatus !== ProfileType.FAMILY_DEVICE && !email) {
|
||||
console.error("Email is required for non-family device users");
|
||||
return;
|
||||
}
|
||||
|
||||
if (email && !email.includes("@")) {
|
||||
console.error("Invalid email address");
|
||||
@ -96,41 +68,25 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
password: uuidv4(),
|
||||
userType: selectedStatus as ProfileType,
|
||||
});
|
||||
console.log(res);
|
||||
console.log(res)
|
||||
|
||||
if (!isError) {
|
||||
setOnNewUserClick(false);
|
||||
setShowNewUserInfoDialog(false);
|
||||
|
||||
if (res?.data?.userId) {
|
||||
if (profileImageAsset) {
|
||||
await changeProfilePicture(profileImageAsset)
|
||||
setShowQRCodeDialog(res.data.userId);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
setShowQRCodeDialog(res.data.userId);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
handleClearImage()
|
||||
if(res?.data?.userId) {
|
||||
setTimeout(() => {
|
||||
setShowQRCodeDialog(res.data.userId)
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (Platform.OS === "ios") KeyboardManager.setEnableAutoToolbar(true);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setFirstName("");
|
||||
setLastName("");
|
||||
setEmail("");
|
||||
}, []);
|
||||
|
||||
// @ts-ignore
|
||||
return (
|
||||
<View marginB-70>
|
||||
<ScrollView>
|
||||
<View>
|
||||
<View style={{flex: 1}}>
|
||||
<View>
|
||||
<ScrollView style={styles.card}>
|
||||
{!parents.length && !children.length && !caregivers.length && (
|
||||
<Text text70 marginV-10>
|
||||
{isLoading ? "Loading...." : "No user devices added"}
|
||||
@ -138,8 +94,8 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
)}
|
||||
|
||||
{(!!parents.length || !!children.length) && (
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.subTit} marginB-10>
|
||||
<>
|
||||
<Text style={styles.subTit} marginV-10>
|
||||
Family
|
||||
</Text>
|
||||
{[...parents, ...children]?.map((member, index) => (
|
||||
@ -150,45 +106,35 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
style={styles.familyCard}
|
||||
row
|
||||
centerV
|
||||
paddingT-10
|
||||
padding-10
|
||||
>
|
||||
{member.pfp ? (
|
||||
<ImageBackground
|
||||
style={styles.pfp}
|
||||
borderRadius={10.56}
|
||||
source={{uri: member.pfp || undefined}}
|
||||
/>
|
||||
) : (
|
||||
<View
|
||||
style={[styles.pfp, {backgroundColor: "#ea156d"}]}
|
||||
/>
|
||||
)}
|
||||
<View row marginL-10 centerV>
|
||||
<Text style={styles.name}>
|
||||
<Avatar
|
||||
source={{uri: "https://via.placeholder.com/60"}}
|
||||
size={40}
|
||||
backgroundColor={Colors.grey60}
|
||||
/>
|
||||
<View marginL-10>
|
||||
<Text text70M>
|
||||
{member.firstName} {member.lastName}
|
||||
</Text>
|
||||
</View>
|
||||
<View flexG/>
|
||||
<View row centerV gap-10>
|
||||
<Text style={styles.userType}>
|
||||
<Text text90 grey40>
|
||||
{member.userType === ProfileType.PARENT
|
||||
? `Admin${member.uid === user?.uid ? " (You)" : ""}`
|
||||
? "Admin (You)"
|
||||
: "Child"}
|
||||
</Text>
|
||||
<UserMenu
|
||||
setShowQRCodeDialog={(val) => setShowQRCodeDialog(val)}
|
||||
showQRCodeDialog={showQRCodeDialog === member?.uid}
|
||||
user={member}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View flex-1/>
|
||||
|
||||
<UserMenu setShowQRCodeDialog={(val) => setShowQRCodeDialog("")} showQRCodeDialog={showQRCodeDialog === member?.uid} userId={member?.uid!}/>
|
||||
</Card>
|
||||
))}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
|
||||
{!!caregivers.length && (
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.subTit} marginB-10 marginT-15>
|
||||
<>
|
||||
<Text text70 marginB-10 marginT-15>
|
||||
Caregivers
|
||||
</Text>
|
||||
{caregivers?.map((member) => (
|
||||
@ -202,7 +148,7 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
padding-10
|
||||
>
|
||||
<Avatar
|
||||
source={{uri: member?.pfp ?? undefined}}
|
||||
source={{uri: "https://via.placeholder.com/60"}}
|
||||
size={40}
|
||||
backgroundColor={Colors.grey60}
|
||||
/>
|
||||
@ -215,16 +161,10 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View flex-1/>
|
||||
|
||||
<UserMenu
|
||||
setShowQRCodeDialog={(val) => setShowQRCodeDialog(val)}
|
||||
showQRCodeDialog={showQRCodeDialog === member?.uid}
|
||||
user={member}
|
||||
/>
|
||||
<UserMenu setShowQRCodeDialog={(val) => setShowQRCodeDialog("")} showQRCodeDialog={showQRCodeDialog === member?.uid} userId={member?.uid!}/>
|
||||
</Card>
|
||||
))}
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
|
||||
{!!familyDevices.length && (
|
||||
@ -243,56 +183,49 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
padding-10
|
||||
>
|
||||
<Avatar
|
||||
source={{uri: member?.pfp ?? undefined}}
|
||||
source={{uri: "https://via.placeholder.com/60"}}
|
||||
size={40}
|
||||
backgroundColor={Colors.grey60}
|
||||
/>
|
||||
<View marginL-10>
|
||||
<Text text70M>{member.firstName}</Text>
|
||||
<Text text70M>
|
||||
{member.firstName}
|
||||
</Text>
|
||||
<Text text90 grey40>
|
||||
Family Device
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View flex-1/>
|
||||
|
||||
<UserMenu
|
||||
setShowQRCodeDialog={(val) => setShowQRCodeDialog(val)}
|
||||
showQRCodeDialog={showQRCodeDialog === member?.uid}
|
||||
user={member}
|
||||
/>
|
||||
<UserMenu setShowQRCodeDialog={(val) => setShowQRCodeDialog("")} showQRCodeDialog={showQRCodeDialog === member?.uid} userId={member?.uid!}/>
|
||||
</Card>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
||||
<FloatingButton
|
||||
fullWidth
|
||||
hideBackgroundOverlay
|
||||
visible
|
||||
button={{
|
||||
label: "+ Add a user device",
|
||||
onPress: () => setShowAddUserDialog(true),
|
||||
}}
|
||||
/>
|
||||
|
||||
<Dialog
|
||||
visible={showAddUserDialog}
|
||||
onDismiss={() => setShowAddUserDialog(false)}
|
||||
panDirection={PanningProvider.Directions.DOWN}
|
||||
>
|
||||
<Card
|
||||
paddingH-25
|
||||
paddingT-40
|
||||
paddingB-20
|
||||
gap-10
|
||||
centerH
|
||||
borderRadius={20}
|
||||
>
|
||||
<Text style={styles.dialogTitle} marginB-35>
|
||||
Add a new user device
|
||||
</Text>
|
||||
<Card padding-25 gap-10>
|
||||
<Text>Add a new user device</Text>
|
||||
|
||||
<Button backgroundColor={"#FD1775"} style={styles.dialogBtn}>
|
||||
<QRIcon/>
|
||||
<Text style={styles.dialogBtnLbl} marginL-7>
|
||||
Show a QR Code
|
||||
</Text>
|
||||
<Button backgroundColor={"#FD1775"}>
|
||||
<Text white>Show a QR Code</Text>
|
||||
</Button>
|
||||
<Button
|
||||
style={styles.dialogBtn}
|
||||
backgroundColor={"#05A8B6"}
|
||||
onPress={() => {
|
||||
setShowAddUserDialog(false);
|
||||
@ -301,229 +234,118 @@ const MyGroup: React.FC<MyGroupProps> = ({onNewUserClick, setOnNewUserClick}) =>
|
||||
}, 500);
|
||||
}}
|
||||
>
|
||||
<EmailIcon/>
|
||||
<Text style={styles.dialogBtnLbl} marginL-7>
|
||||
Enter email address
|
||||
</Text>
|
||||
<Text white>Enter email address</Text>
|
||||
</Button>
|
||||
|
||||
<TouchableOpacity
|
||||
onPress={() => setShowAddUserDialog(false)}
|
||||
center
|
||||
marginT-30
|
||||
>
|
||||
<Text style={styles.dialogBackBtn}>Return to user settings</Text>
|
||||
<TouchableOpacity onPress={() => setShowAddUserDialog(false)} center>
|
||||
<Text>Return to user settings</Text>
|
||||
</TouchableOpacity>
|
||||
</Card>
|
||||
</Dialog>
|
||||
|
||||
<Dialog
|
||||
panDirection={PanningProvider.Directions.DOWN}
|
||||
visible={onNewUserClick}
|
||||
onDismiss={() => setOnNewUserClick(false)}
|
||||
visible={showNewUserInfoDialog}
|
||||
onDismiss={() => setShowNewUserInfoDialog(false)}
|
||||
>
|
||||
<PreviousNextView>
|
||||
<KeyboardAwareScrollView>
|
||||
<Card padding-25 style={styles.dialogCard}>
|
||||
<View row spread>
|
||||
<Text style={{fontFamily: "Manrope_500Medium", fontSize: 16}}>
|
||||
New User Information
|
||||
</Text>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
setOnNewUserClick(false);
|
||||
}}
|
||||
>
|
||||
<CircledXIcon/>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<View style={styles.divider} spread/>
|
||||
<Card padding-25 style={styles.dialogCard}>
|
||||
<View row spread>
|
||||
<Text text60M>New User Information</Text>
|
||||
<TouchableOpacity onPress={() => setShowAddUserDialog(false)}>
|
||||
<Text>X</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
<View row centerV gap-20 marginV-20>
|
||||
{pfpUri ? (
|
||||
<Image
|
||||
height={65.54}
|
||||
width={65.54}
|
||||
style={{borderRadius: 25}}
|
||||
source={{uri: pfpUri}}
|
||||
/>
|
||||
) : (
|
||||
<View
|
||||
height={65.54}
|
||||
width={65.54}
|
||||
children={
|
||||
<ProfileIcon color={"#d6d6d6"} width={37} height={37}/>
|
||||
}
|
||||
backgroundColor={Colors.grey60}
|
||||
style={{borderRadius: 25}}
|
||||
center
|
||||
/>
|
||||
)}
|
||||
|
||||
{pfpUri ? (
|
||||
<TouchableOpacity onPress={handleClearImage}>
|
||||
<Text color={Colors.red40} style={styles.jakarta13} marginL-15>
|
||||
Clear user photo
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
) : (
|
||||
<TouchableOpacity onPress={pickImage}>
|
||||
<Text color="#50be0c" style={styles.jakarta13} marginL-15>
|
||||
Upload User Profile Photo
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
|
||||
</View>
|
||||
|
||||
<Text style={styles.jakarta12}>Member Status</Text>
|
||||
<View style={styles.viewPicker}>
|
||||
<Picker
|
||||
editable={!isLoading}
|
||||
value={selectedStatus}
|
||||
onChange={(item) => setSelectedStatus(item)}
|
||||
showSearch
|
||||
floatingPlaceholder
|
||||
style={styles.inViewPicker}
|
||||
trailingAccessory={
|
||||
<View
|
||||
style={{
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
height: "100%",
|
||||
marginTop: -38,
|
||||
paddingRight: 15,
|
||||
}}
|
||||
>
|
||||
<Ionicons
|
||||
name={"chevron-down"}
|
||||
style={{alignSelf: "center"}}
|
||||
size={20}
|
||||
color={"#000000"}
|
||||
/>
|
||||
</View>
|
||||
}
|
||||
>
|
||||
<Picker.Item label="Child" value={ProfileType.CHILD}/>
|
||||
<Picker.Item label="Parent" value={ProfileType.PARENT}/>
|
||||
<Picker.Item
|
||||
label="Caregiver"
|
||||
value={ProfileType.CAREGIVER}
|
||||
/>
|
||||
<Picker.Item
|
||||
label="Family Device"
|
||||
value={ProfileType.FAMILY_DEVICE}
|
||||
/>
|
||||
</Picker>
|
||||
</View>
|
||||
|
||||
<Text style={styles.jakarta12}>
|
||||
{selectedStatus === ProfileType.FAMILY_DEVICE
|
||||
? "Device Name"
|
||||
: "First Name"}
|
||||
<View row centerV gap-20 marginV-20>
|
||||
<Avatar
|
||||
imageStyle={{borderRadius: 10}}
|
||||
containerStyle={{borderRadius: 10}}
|
||||
size={60}
|
||||
backgroundColor={Colors.grey60}
|
||||
/>
|
||||
<TouchableOpacity onPress={() => {
|
||||
}}>
|
||||
<Text style={{color: Colors.green10}}>
|
||||
Upload User Profile Photo
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
<Text style={styles.label}>Member Status</Text>
|
||||
<Picker
|
||||
editable={!isLoading}
|
||||
value={selectedStatus}
|
||||
//@ts-ignore
|
||||
onChange={(item) => setSelectedStatus(item)}
|
||||
style={styles.picker}
|
||||
showSearch
|
||||
floatingPlaceholder
|
||||
>
|
||||
<Picker.Item label="Child" value={ProfileType.CHILD}/>
|
||||
<Picker.Item label="Parent" value={ProfileType.PARENT}/>
|
||||
<Picker.Item label="Caregiver" value={ProfileType.CAREGIVER}/>
|
||||
<Picker.Item label="Family Device" value={ProfileType.FAMILY_DEVICE}/>
|
||||
</Picker>
|
||||
|
||||
<Text style={styles.label}>
|
||||
{selectedStatus === ProfileType.FAMILY_DEVICE ? "Device Name" : "First Name"}
|
||||
</Text>
|
||||
<TextField
|
||||
editable={!isLoading}
|
||||
placeholder={selectedStatus === ProfileType.FAMILY_DEVICE ? "Device name" : "First name"}
|
||||
value={firstName}
|
||||
onChangeText={setFirstName}
|
||||
style={styles.inputField}
|
||||
/>
|
||||
|
||||
{selectedStatus !== ProfileType.FAMILY_DEVICE && (
|
||||
<>
|
||||
<Text style={styles.label}>Last Name</Text>
|
||||
<TextField
|
||||
editable={!isLoading}
|
||||
placeholder={
|
||||
selectedStatus === ProfileType.FAMILY_DEVICE
|
||||
? "Device name"
|
||||
: "First name"
|
||||
}
|
||||
value={firstName}
|
||||
onChangeText={setFirstName}
|
||||
placeholder="Last name"
|
||||
value={lastName}
|
||||
onChangeText={setLastName}
|
||||
style={styles.inputField}
|
||||
onSubmitEditing={() => {
|
||||
lNameRef.current?.focus();
|
||||
}}
|
||||
blurOnSubmit={false}
|
||||
returnKeyType="next"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{selectedStatus !== ProfileType.FAMILY_DEVICE && (
|
||||
<>
|
||||
<Text style={styles.jakarta12}>Last Name</Text>
|
||||
<TextField
|
||||
ref={lNameRef}
|
||||
editable={!isLoading}
|
||||
placeholder="Last name"
|
||||
value={lastName}
|
||||
onChangeText={setLastName}
|
||||
style={styles.inputField}
|
||||
onSubmitEditing={() => {
|
||||
emailRef.current?.focus();
|
||||
}}
|
||||
blurOnSubmit={false}
|
||||
returnKeyType="next"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{selectedStatus !== ProfileType.FAMILY_DEVICE && (
|
||||
<>
|
||||
<Text style={styles.jakarta12}>Email Address (Optional)</Text>
|
||||
<TextField
|
||||
ref={emailRef}
|
||||
editable={!isLoading}
|
||||
placeholder="Email address"
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
keyboardType="email-address"
|
||||
autoCapitalize="none"
|
||||
style={styles.inputField}
|
||||
returnKeyType="done"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Button
|
||||
disabled={
|
||||
!firstName ||
|
||||
(selectedStatus !== ProfileType.FAMILY_DEVICE && !lastName) ||
|
||||
isLoading
|
||||
}
|
||||
label={isLoading ? "Adding..." : "Add group member"}
|
||||
backgroundColor="#fd1775"
|
||||
labelStyle={{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 15,
|
||||
marginLeft: 7,
|
||||
}}
|
||||
style={{marginTop: 20, backgroundColor: "#fd1775"}}
|
||||
iconSource={() => <NavToDosIcon width={22} color={"white"}/>}
|
||||
onPress={handleCreateSubUser}
|
||||
{selectedStatus !== ProfileType.FAMILY_DEVICE && (
|
||||
<>
|
||||
<Text style={styles.label}>Email Address (Optional)</Text>
|
||||
<TextField
|
||||
editable={!isLoading}
|
||||
placeholder="Email address"
|
||||
value={email}
|
||||
onChangeText={setEmail}
|
||||
keyboardType="email-address"
|
||||
autoCapitalize="none"
|
||||
style={styles.inputField}
|
||||
/>
|
||||
</Card>
|
||||
</KeyboardAwareScrollView>
|
||||
</PreviousNextView>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Button
|
||||
disabled={!firstName || (selectedStatus !== ProfileType.FAMILY_DEVICE && !lastName) || isLoading}
|
||||
label={isLoading ? "Adding..." : "Add group member"}
|
||||
backgroundColor="#FD1775"
|
||||
style={{marginTop: 20}}
|
||||
onPress={handleCreateSubUser}
|
||||
/>
|
||||
</Card>
|
||||
</Dialog>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
dialogBtn: {
|
||||
height: 47,
|
||||
width: 279,
|
||||
},
|
||||
dialogTitle: {fontFamily: "Manrope_600SemiBold", fontSize: 22},
|
||||
dialogBackBtn: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 15,
|
||||
color: "#a7a7a7",
|
||||
},
|
||||
card: {
|
||||
marginVertical: 15,
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
borderRadius: 12,
|
||||
paddingHorizontal: 21,
|
||||
paddingVertical: 20,
|
||||
},
|
||||
bottomButton: {
|
||||
position: "absolute",
|
||||
bottom: 50,
|
||||
backgroundColor: "#e8156c",
|
||||
width: "100%",
|
||||
borderRadius: 15,
|
||||
padding: 20,
|
||||
},
|
||||
familyCard: {
|
||||
marginBottom: 10,
|
||||
@ -532,9 +354,6 @@ const styles = StyleSheet.create({
|
||||
width: "100%",
|
||||
},
|
||||
inputField: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 13,
|
||||
color: "#565656",
|
||||
borderRadius: 50,
|
||||
paddingVertical: 12,
|
||||
paddingHorizontal: 16,
|
||||
@ -554,26 +373,6 @@ const styles = StyleSheet.create({
|
||||
borderWidth: 1,
|
||||
marginTop: -20,
|
||||
height: 40,
|
||||
zIndex: 10,
|
||||
},
|
||||
viewPicker: {
|
||||
borderRadius: 50,
|
||||
backgroundColor: Colors.grey80,
|
||||
marginBottom: 16,
|
||||
borderColor: Colors.grey50,
|
||||
borderWidth: 1,
|
||||
marginTop: 0,
|
||||
height: 40,
|
||||
zIndex: 10,
|
||||
},
|
||||
inViewPicker: {
|
||||
borderRadius: 50,
|
||||
paddingVertical: 12,
|
||||
paddingHorizontal: 16,
|
||||
marginBottom: 16,
|
||||
marginTop: -20,
|
||||
height: 40,
|
||||
zIndex: 10,
|
||||
},
|
||||
label: {
|
||||
marginBottom: 5,
|
||||
@ -587,32 +386,7 @@ const styles = StyleSheet.create({
|
||||
subTit: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
dialogBtnLbl: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 15,
|
||||
color: "white",
|
||||
},
|
||||
divider: {height: 0.7, backgroundColor: "#e6e6e6", width: "100%"},
|
||||
jakarta12: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 12,
|
||||
color: "#a1a1a1",
|
||||
},
|
||||
jakarta13: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 13,
|
||||
},
|
||||
pfp: {aspectRatio: 1, width: 37.03, borderRadius: 10.56},
|
||||
userType: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 12,
|
||||
color: "#858585",
|
||||
},
|
||||
name: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 16,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default MyGroup;
|
||||
|
||||
@ -1,178 +1,33 @@
|
||||
import React, {useCallback, useEffect, useRef, useState} from "react";
|
||||
import { StyleSheet, TouchableOpacity } from "react-native";
|
||||
import { Text, TextField, View } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import { ImageBackground, StyleSheet } from "react-native";
|
||||
import { ScrollView } from "react-native-gesture-handler";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import {
|
||||
Button,
|
||||
Colors,
|
||||
Image,
|
||||
Picker,
|
||||
Text,
|
||||
TextField,
|
||||
View,
|
||||
} from "react-native-ui-lib";
|
||||
import Ionicons from "@expo/vector-icons/Ionicons";
|
||||
import * as tz from "tzdata";
|
||||
import * as Localization from "expo-localization";
|
||||
import debounce from "debounce";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import { useUpdateUserData } from "@/hooks/firebase/useUpdateUserData";
|
||||
import { useChangeProfilePicture } from "@/hooks/firebase/useChangeProfilePicture";
|
||||
import { colorMap } from "@/constants/colorMap";
|
||||
import DeleteProfileDialogs from "../user_components/DeleteProfileDialogs";
|
||||
import {AntDesign} from "@expo/vector-icons";
|
||||
|
||||
const MyProfile = () => {
|
||||
const { user, profileData } = useAuthContext();
|
||||
const [timeZone, setTimeZone] = useState<string>(
|
||||
profileData?.timeZone! ?? Localization.getCalendars()[0].timeZone
|
||||
);
|
||||
|
||||
const [lastName, setLastName] = useState<string>(profileData?.lastName || "");
|
||||
const [firstName, setFirstName] = useState<string>(
|
||||
profileData?.firstName || ""
|
||||
);
|
||||
const [profileImage, setProfileImage] = useState<
|
||||
string | ImagePicker.ImagePickerAsset | null
|
||||
>(profileData?.pfp || null);
|
||||
|
||||
const [selectedColor, setSelectedColor] = useState<string>(
|
||||
profileData?.eventColor ?? colorMap.pink
|
||||
);
|
||||
const [previousSelectedColor, setPreviousSelectedColor] = useState<string>(
|
||||
profileData?.eventColor ?? colorMap.pink
|
||||
);
|
||||
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState<boolean>(false);
|
||||
|
||||
const handleHideDeleteDialog = () => {
|
||||
setShowDeleteDialog(false);
|
||||
};
|
||||
const handleShowDeleteDialog = () => {
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const { mutateAsync: updateUserData } = useUpdateUserData();
|
||||
const { mutateAsync: changeProfilePicture } = useChangeProfilePicture();
|
||||
const isFirstRender = useRef(true);
|
||||
|
||||
const handleUpdateUserData = async () => {
|
||||
await updateUserData({ newUserData: { firstName, lastName, timeZone } });
|
||||
};
|
||||
|
||||
const debouncedUserDataUpdate = debounce(handleUpdateUserData, 500);
|
||||
|
||||
useEffect(() => {
|
||||
if (isFirstRender.current) {
|
||||
isFirstRender.current = false;
|
||||
return;
|
||||
}
|
||||
debouncedUserDataUpdate();
|
||||
}, [timeZone, lastName, firstName]);
|
||||
|
||||
useEffect(() => {
|
||||
if (profileData) {
|
||||
setFirstName(profileData.firstName || "");
|
||||
setLastName(profileData.lastName || "");
|
||||
setTimeZone(
|
||||
profileData.timeZone || Localization.getCalendars()[0].timeZone!
|
||||
);
|
||||
}
|
||||
}, [profileData]);
|
||||
|
||||
const pickImage = async () => {
|
||||
const permissionResult =
|
||||
await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (!permissionResult.granted) {
|
||||
alert("Permission to access camera roll is required!");
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: true,
|
||||
aspect: [1, 1],
|
||||
quality: 1,
|
||||
});
|
||||
|
||||
if (!result.canceled) {
|
||||
setProfileImage(result.assets[0].uri);
|
||||
await changeProfilePicture(result.assets[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClearImage = async () => {
|
||||
await updateUserData({ newUserData: { pfp: null } });
|
||||
setProfileImage(null);
|
||||
};
|
||||
|
||||
const pfpUri =
|
||||
profileImage && typeof profileImage === "object" && "uri" in profileImage
|
||||
? profileImage.uri
|
||||
: profileImage;
|
||||
|
||||
const handleChangeColor = (color: string) => {
|
||||
setPreviousSelectedColor(selectedColor);
|
||||
setSelectedColor(color);
|
||||
debouncedUpdateUserData(color);
|
||||
};
|
||||
|
||||
const debouncedUpdateUserData = useCallback(
|
||||
debounce(async (color: string) => {
|
||||
try {
|
||||
await updateUserData({
|
||||
newUserData: {
|
||||
eventColor: color,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to update color:", error);
|
||||
setSelectedColor(previousSelectedColor);
|
||||
}
|
||||
}, 500),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<ScrollView style={{ paddingBottom: 20, flex: 1 }}>
|
||||
<ScrollView style={{ paddingBottom: 100, flex: 1 }}>
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.subTit}>Your Profile</Text>
|
||||
<View row spread paddingH-15 centerV marginV-15>
|
||||
<TouchableOpacity onPress={pickImage}>
|
||||
{pfpUri ? (
|
||||
<Image
|
||||
key={pfpUri}
|
||||
style={styles.pfp}
|
||||
source={pfpUri ? { uri: pfpUri } : null}
|
||||
/>
|
||||
) : (
|
||||
<View
|
||||
center
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 65.54,
|
||||
backgroundColor: profileData?.eventColor ?? colorMap.pink,
|
||||
borderRadius: 20,
|
||||
}}
|
||||
>
|
||||
<Text style={styles.pfpTxt}>
|
||||
{profileData?.firstName?.at(0)}
|
||||
{profileData?.lastName?.at(0)}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
<ImageBackground
|
||||
style={styles.pfp}
|
||||
source={require("../../../../assets/images/profile-picture.png")}
|
||||
/>
|
||||
|
||||
<TouchableOpacity onPress={pickImage}>
|
||||
<Text style={styles.photoSet} color="#50be0c" onPress={pickImage}>
|
||||
{profileData?.pfp ? "Change" : "Add"} Photo
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
{profileData?.pfp && (
|
||||
<TouchableOpacity onPress={handleClearImage}>
|
||||
<Text style={styles.photoSet}>Remove Photo</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
<Text style={styles.photoSet} color="#50be0c">
|
||||
Change Photo
|
||||
</Text>
|
||||
<Text style={styles.photoSet}>Remove Photo</Text>
|
||||
</View>
|
||||
<View paddingH-15>
|
||||
<Text text80 marginT-10 marginB-7 style={styles.label}>
|
||||
@ -185,6 +40,7 @@ const MyProfile = () => {
|
||||
value={firstName}
|
||||
onChangeText={async (value) => {
|
||||
setFirstName(value);
|
||||
await updateUserData({ newUserData: { firstName: value } });
|
||||
}}
|
||||
/>
|
||||
<Text text80 marginT-10 marginB-7 style={styles.label}>
|
||||
@ -197,13 +53,13 @@ const MyProfile = () => {
|
||||
value={lastName}
|
||||
onChangeText={async (value) => {
|
||||
setLastName(value);
|
||||
await updateUserData({ newUserData: { lastName: value } });
|
||||
}}
|
||||
/>
|
||||
<Text text80 marginT-10 marginB-7 style={styles.label}>
|
||||
Email address
|
||||
</Text>
|
||||
<TextField
|
||||
editable={false}
|
||||
text70
|
||||
placeholder="Email address"
|
||||
value={user?.email?.toString()}
|
||||
@ -214,127 +70,16 @@ const MyProfile = () => {
|
||||
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.subTit}>Settings</Text>
|
||||
<Text style={styles.jakarta12}>Time Zone</Text>
|
||||
<View style={styles.viewPicker}>
|
||||
<Picker
|
||||
value={timeZone}
|
||||
onChange={(item) => setTimeZone(item as string)}
|
||||
showSearch
|
||||
floatingPlaceholder
|
||||
style={styles.inViewPicker}
|
||||
trailingAccessory={
|
||||
<View
|
||||
style={{
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
height: "100%",
|
||||
marginTop: -38,
|
||||
paddingRight: 15,
|
||||
}}
|
||||
>
|
||||
<Ionicons
|
||||
name={"chevron-down"}
|
||||
style={{ alignSelf: "center" }}
|
||||
size={20}
|
||||
color={"#000000"}
|
||||
/>
|
||||
</View>
|
||||
}
|
||||
>
|
||||
{timeZoneItems}
|
||||
</Picker>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.cardTitle} marginB-14>
|
||||
Color Preference
|
||||
<Text text80 marginT-20 marginB-7 style={styles.label}>
|
||||
Time Zone
|
||||
</Text>
|
||||
<View row spread>
|
||||
<TouchableOpacity onPress={() => handleChangeColor(colorMap.pink)}>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.pink}>
|
||||
{selectedColor == colorMap.pink && (
|
||||
<AntDesign name="check" size={30} color="white"/>
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
onPress={() => handleChangeColor(colorMap.orange)}
|
||||
>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.orange}>
|
||||
{selectedColor == colorMap.orange && (
|
||||
<AntDesign name="check" size={30} color="white"/>
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => handleChangeColor(colorMap.green)}>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.green}>
|
||||
{selectedColor == colorMap.green && (
|
||||
<AntDesign name="check" size={30} color="white"/>
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={() => handleChangeColor(colorMap.teal)}>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.teal}>
|
||||
{selectedColor == colorMap.teal && (
|
||||
<AntDesign name="check" size={30} color="white"/>
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
onPress={() => handleChangeColor(colorMap.purple)}
|
||||
>
|
||||
<View style={styles.colorBox} backgroundColor={colorMap.purple}>
|
||||
{selectedColor == colorMap.purple && (
|
||||
<AntDesign name="check" size={30} color="white"/>
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<TextField text70 placeholder="Time Zone" style={styles.txtBox} />
|
||||
</View>
|
||||
<Button
|
||||
size="large"
|
||||
backgroundColor="#ff1637"
|
||||
label="Delete Profile"
|
||||
style={{ marginTop: 10 }}
|
||||
labelStyle={{ fontFamily: "PlusJakartaSans_500Medium", fontSize: 15 }}
|
||||
onPress={handleShowDeleteDialog}
|
||||
/>
|
||||
<DeleteProfileDialogs
|
||||
onFirstYes={() => {
|
||||
setShowDeleteDialog(false);
|
||||
}}
|
||||
visible={showDeleteDialog}
|
||||
onDismiss={handleHideDeleteDialog}
|
||||
onConfirm={() => {
|
||||
console.log("delete account here");
|
||||
}}
|
||||
/>
|
||||
</ScrollView>
|
||||
);
|
||||
};
|
||||
|
||||
const timeZoneItems = Object.keys(tz.zones)
|
||||
.sort()
|
||||
.map((zone) => (
|
||||
<Picker.Item
|
||||
key={zone}
|
||||
label={zone.replace("/", " / ").replace("_", " ")}
|
||||
value={zone}
|
||||
/>
|
||||
));
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
cardTitle: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
colorBox: {
|
||||
aspectRatio: 1,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
width: 51,
|
||||
borderRadius: 12,
|
||||
},
|
||||
card: {
|
||||
marginVertical: 15,
|
||||
backgroundColor: "white",
|
||||
@ -343,15 +88,10 @@ const styles = StyleSheet.create({
|
||||
paddingHorizontal: 20,
|
||||
paddingVertical: 21,
|
||||
},
|
||||
pfpTxt: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 30,
|
||||
color: "white",
|
||||
},
|
||||
pfp: {
|
||||
aspectRatio: 1,
|
||||
width: 65.54,
|
||||
backgroundColor: "gray",
|
||||
backgroundColor: "green",
|
||||
borderRadius: 20,
|
||||
},
|
||||
txtBox: {
|
||||
@ -362,7 +102,7 @@ const styles = StyleSheet.create({
|
||||
padding: 15,
|
||||
height: 45,
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 13,
|
||||
fontSize: 13
|
||||
},
|
||||
subTit: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
@ -371,37 +111,12 @@ const styles = StyleSheet.create({
|
||||
label: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 12,
|
||||
color: "#a1a1a1",
|
||||
color: "#a1a1a1"
|
||||
},
|
||||
photoSet: {
|
||||
photoSet:{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 13.07,
|
||||
},
|
||||
jakarta12: {
|
||||
paddingVertical: 10,
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 12,
|
||||
color: "#a1a1a1",
|
||||
},
|
||||
viewPicker: {
|
||||
borderRadius: 50,
|
||||
backgroundColor: Colors.grey80,
|
||||
marginBottom: 16,
|
||||
borderColor: Colors.grey50,
|
||||
borderWidth: 1,
|
||||
marginTop: 0,
|
||||
height: 40,
|
||||
zIndex: 10,
|
||||
},
|
||||
inViewPicker: {
|
||||
borderRadius: 50,
|
||||
paddingVertical: 12,
|
||||
paddingHorizontal: 16,
|
||||
marginBottom: 16,
|
||||
marginTop: -20,
|
||||
height: 40,
|
||||
zIndex: 10,
|
||||
},
|
||||
fontSize: 13.07
|
||||
}
|
||||
});
|
||||
|
||||
export default MyProfile;
|
||||
|
||||
@ -1,78 +1,67 @@
|
||||
import React from "react";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Dialog,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native-ui-lib";
|
||||
import QRCode from "react-native-qrcode-svg";
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/components/panningViews/panningProvider";
|
||||
import Ionicons from "@expo/vector-icons/Ionicons";
|
||||
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
|
||||
import { UserProfile } from "@/hooks/firebase/types/profileTypes";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { ProfileType } from "@/contexts/AuthContext";
|
||||
import React, {useState} from 'react';
|
||||
import {Button, Card, Colors, Dialog, Hint, ListItem, Text, View} from 'react-native-ui-lib';
|
||||
import QRCode from 'react-native-qrcode-svg';
|
||||
import {PanningDirectionsEnum} from "react-native-ui-lib/src/components/panningViews/panningProvider";
|
||||
|
||||
const UserMenu = ({
|
||||
user,
|
||||
showQRCodeDialog,
|
||||
setShowQRCodeDialog,
|
||||
}: {
|
||||
user: UserProfile;
|
||||
showQRCodeDialog: boolean;
|
||||
setShowQRCodeDialog: (value: string | boolean) => void;
|
||||
userId,
|
||||
showQRCodeDialog,
|
||||
setShowQRCodeDialog
|
||||
}: {
|
||||
userId: string,
|
||||
showQRCodeDialog: boolean,
|
||||
setShowQRCodeDialog: (value: boolean) => void
|
||||
}) => {
|
||||
const handleShowQRCode = () => {
|
||||
setShowQRCodeDialog(user.uid!);
|
||||
};
|
||||
const [showHint, setShowHint] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<TouchableOpacity onPress={handleShowQRCode}>
|
||||
<Ionicons name="qr-code-outline" size={24} color="black" />
|
||||
</TouchableOpacity>
|
||||
const handleShowQRCode = () => {
|
||||
setShowHint(false);
|
||||
setTimeout(() => {
|
||||
setShowQRCodeDialog(true);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
<Dialog
|
||||
visible={showQRCodeDialog}
|
||||
onDismiss={() => setShowQRCodeDialog(false)}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
>
|
||||
<Card padding-20 center>
|
||||
<Text
|
||||
center
|
||||
marginT-15
|
||||
marginH-15
|
||||
marginB-25
|
||||
style={{ fontSize: 18, fontFamily: "Manrope_500Medium" }}
|
||||
>
|
||||
{user.userType !== ProfileType.FAMILY_DEVICE
|
||||
? `Open Cally on ${user.firstName}'s device and scan the code to link it to your family group`
|
||||
: "Open Cally on the family device and scan the code to link it to your family group"}
|
||||
</Text>
|
||||
<QRCode value={user.uid!} size={150} />
|
||||
<Button
|
||||
marginT-20
|
||||
style={styles.button}
|
||||
label="Close"
|
||||
labelStyle={{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 15,
|
||||
}}
|
||||
onPress={() => setShowQRCodeDialog(false)}
|
||||
/>
|
||||
</Card>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Hint
|
||||
onBackgroundPress={() => setShowHint(false)}
|
||||
onPress={() => setShowHint(true)}
|
||||
color={Colors.white}
|
||||
customContent={
|
||||
<View height={18}>
|
||||
<ListItem onPress={handleShowQRCode}>
|
||||
<Text>Show Login QR Code</Text>
|
||||
</ListItem>
|
||||
</View>
|
||||
}
|
||||
enableShadow
|
||||
visible={showHint}
|
||||
backdropColor="transparent"
|
||||
>
|
||||
<View>
|
||||
<Button link onPress={() => setShowHint(!showHint)}>
|
||||
<Text>...</Text>
|
||||
</Button>
|
||||
</View>
|
||||
</Hint>
|
||||
|
||||
<Dialog
|
||||
visible={showQRCodeDialog}
|
||||
onDismiss={() => setShowQRCodeDialog(false)}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
>
|
||||
<Card padding-20 center>
|
||||
<Text marginB-10>Scan this QR Code to Login:</Text>
|
||||
<QRCode value={userId} size={150}/>
|
||||
<Button
|
||||
marginT-20
|
||||
label="Close"
|
||||
onPress={() => setShowQRCodeDialog(false)}
|
||||
/>
|
||||
</Card>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: {
|
||||
backgroundColor: "#d9d9d9",
|
||||
width: 117,
|
||||
height: 47,
|
||||
},
|
||||
});
|
||||
|
||||
export default UserMenu;
|
||||
|
||||
@ -1,68 +1,64 @@
|
||||
import { Dimensions, StyleSheet } from "react-native";
|
||||
import { StyleSheet } from "react-native";
|
||||
import React, { useState } from "react";
|
||||
import { Button, ButtonSize, Text, View } from "react-native-ui-lib";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import LinearGradient from "react-native-linear-gradient";
|
||||
import AddChoreDialog from "./AddChoreDialog";
|
||||
import PlusIcon from "@/assets/svgs/PlusIcon";
|
||||
|
||||
const AddChore = () => {
|
||||
|
||||
const [isVisible, setIsVisible] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<View
|
||||
row
|
||||
spread
|
||||
paddingH-20
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: 15,
|
||||
width: "100%",
|
||||
}}
|
||||
<LinearGradient
|
||||
colors={["transparent", "#f9f8f7"]}
|
||||
locations={[0, 0.5]}
|
||||
style={styles.gradient}
|
||||
>
|
||||
<View style={styles.buttonContainer}>
|
||||
<Button
|
||||
marginB-30
|
||||
marginH-25
|
||||
size={ButtonSize.large}
|
||||
style={styles.button}
|
||||
onPress={() => setIsVisible(!isVisible)}
|
||||
>
|
||||
<PlusIcon />
|
||||
<Text
|
||||
white
|
||||
style={{ fontFamily: "Manrope_600SemiBold", fontSize: 15 }}
|
||||
marginL-5
|
||||
>
|
||||
Create new to do
|
||||
<AntDesign name="plus" size={24} color="white" />
|
||||
<Text white text60R marginL-10>
|
||||
Add To Do
|
||||
</Text>
|
||||
</Button>
|
||||
</View>
|
||||
{isVisible && (
|
||||
<AddChoreDialog isVisible={isVisible} setIsVisible={setIsVisible} />
|
||||
)}
|
||||
</View>
|
||||
<AddChoreDialog isVisible={isVisible} setIsVisible={setIsVisible} />
|
||||
</LinearGradient>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddChore;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
divider: { height: 1, backgroundColor: "#e4e4e4", marginVertical: 15 },
|
||||
gradient: {
|
||||
height: 150,
|
||||
height: "25%",
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
width: "100%",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
buttonContainer: {
|
||||
position: "absolute",
|
||||
bottom: 25,
|
||||
width: "100%",
|
||||
alignItems: "center",
|
||||
},
|
||||
button: {
|
||||
backgroundColor: "rgb(253, 23, 117)",
|
||||
height: 53.26,
|
||||
borderRadius: 30,
|
||||
width: 335,
|
||||
paddingVertical: 20,
|
||||
},
|
||||
topBtn: {
|
||||
backgroundColor: "white",
|
||||
color: "#05a8b6",
|
||||
},
|
||||
rotateSwitch: {
|
||||
marginLeft: 35,
|
||||
marginBottom: 10,
|
||||
marginTop: 25,
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,360 +1,275 @@
|
||||
import {
|
||||
Button,
|
||||
ButtonSize,
|
||||
DateTimePicker,
|
||||
Dialog,
|
||||
Picker,
|
||||
PickerModes,
|
||||
Switch,
|
||||
Text,
|
||||
TextField,
|
||||
TextFieldRef,
|
||||
View
|
||||
} from "react-native-ui-lib";
|
||||
import React, {useEffect, useRef, useState} from "react";
|
||||
import { View, Text, Button, Switch } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import PointsSlider from "@/components/shared/PointsSlider";
|
||||
import {repeatOptions, useToDosContext} from "@/contexts/ToDosContext";
|
||||
import {Ionicons} from "@expo/vector-icons";
|
||||
import {PanningDirectionsEnum} from "react-native-ui-lib/src/incubator/panView";
|
||||
import {Dimensions, KeyboardAvoidingView, StyleSheet} from "react-native";
|
||||
import { repeatOptions, useToDosContext } from "@/contexts/ToDosContext";
|
||||
import { Feather, AntDesign, Ionicons } from "@expo/vector-icons";
|
||||
import {
|
||||
Dialog,
|
||||
TextField,
|
||||
DateTimePicker,
|
||||
Picker,
|
||||
ButtonSize,
|
||||
} from "react-native-ui-lib";
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
||||
import { Dimensions, StyleSheet } from "react-native";
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import {IToDo} from "@/hooks/firebase/types/todoData";
|
||||
import AssigneesDisplay from "@/components/shared/AssigneesDisplay";
|
||||
import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers";
|
||||
import CalendarIcon from "@/assets/svgs/CalendarIcon";
|
||||
import ClockOIcon from "@/assets/svgs/ClockOIcon";
|
||||
import ProfileIcon from "@/assets/svgs/ProfileIcon";
|
||||
import RepeatFreq from "./RepeatFreq";
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||
|
||||
interface IAddChoreDialog {
|
||||
isVisible: boolean;
|
||||
setIsVisible: (value: boolean) => void;
|
||||
selectedTodo?: IToDo;
|
||||
isVisible: boolean;
|
||||
setIsVisible: (value: boolean) => void;
|
||||
selectedTodo?: IToDo;
|
||||
}
|
||||
|
||||
const defaultTodo = {
|
||||
id: "",
|
||||
title: "",
|
||||
points: 10,
|
||||
date: new Date(),
|
||||
rotate: false,
|
||||
repeatType: "Every week",
|
||||
assignees: [],
|
||||
repeatDays: []
|
||||
id: "",
|
||||
title: "",
|
||||
points: 10,
|
||||
date: new Date(),
|
||||
rotate: false,
|
||||
repeatType: "Every week",
|
||||
};
|
||||
|
||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
const {user} = useAuthContext()
|
||||
const {addToDo, updateToDo} = useToDosContext();
|
||||
const [todo, setTodo] = useState<IToDo>(
|
||||
addChoreDialogProps.selectedTodo ?? defaultTodo
|
||||
);
|
||||
const [selectedAssignees, setSelectedAssignees] = useState<string[]>(
|
||||
addChoreDialogProps?.selectedTodo?.assignees ?? []
|
||||
);
|
||||
const {width} = Dimensions.get("screen");
|
||||
const [points, setPoints] = useState<number>(todo.points);
|
||||
const { addToDo, updateToDo } = useToDosContext();
|
||||
const [todo, setTodo] = useState<IToDo>(
|
||||
addChoreDialogProps.selectedTodo ?? defaultTodo
|
||||
);
|
||||
const { width, height } = Dimensions.get("screen");
|
||||
|
||||
const titleRef = useRef<TextFieldRef>(null)
|
||||
const [points, setPoints] = useState<number>(todo.points);
|
||||
|
||||
const {data: members} = useGetFamilyMembers();
|
||||
let sortedMembers = members?.sort((a, b) => {
|
||||
if (a.uid === user?.uid) return -1;
|
||||
if (b.uid === user?.uid) return 1;
|
||||
return 0;
|
||||
})
|
||||
const handleClose = () => {
|
||||
setTodo(defaultTodo);
|
||||
addChoreDialogProps.setIsVisible(false);
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setTodo(defaultTodo);
|
||||
setSelectedAssignees([]);
|
||||
addChoreDialogProps.setIsVisible(false);
|
||||
};
|
||||
const handleChange = (text: string) => {
|
||||
const numericValue = parseInt(text, 10);
|
||||
|
||||
const handleChange = (text: string) => {
|
||||
const numericValue = parseInt(text, 10);
|
||||
|
||||
if (!isNaN(numericValue) && numericValue >= 0 && numericValue <= 100) {
|
||||
setPoints(numericValue);
|
||||
} else if (text === "") {
|
||||
setPoints(0);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRepeatDaysChange = (day: string, set: boolean) => {
|
||||
if (set) {
|
||||
const updatedTodo = {
|
||||
...todo,
|
||||
repeatDays: [...todo.repeatDays, day]
|
||||
}
|
||||
setTodo(updatedTodo);
|
||||
} else {
|
||||
const array = todo.repeatDays ?? [];
|
||||
let index = array.indexOf(day);
|
||||
array.splice(index, 1);
|
||||
const updatedTodo = {
|
||||
...todo,
|
||||
repeatDays: array
|
||||
}
|
||||
setTodo(updatedTodo);
|
||||
}
|
||||
if (!isNaN(numericValue) && numericValue >= 0 && numericValue <= 100) {
|
||||
setPoints(numericValue);
|
||||
} else if (text === "") {
|
||||
setPoints(0);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
titleRef?.current?.focus()
|
||||
}, 500)
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
height={"90%"}
|
||||
width={width}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
onDismiss={() => handleClose}
|
||||
containerStyle={{
|
||||
borderRadius: 10,
|
||||
backgroundColor: "white",
|
||||
alignSelf: "stretch",
|
||||
padding: 0,
|
||||
paddingTop: 4,
|
||||
margin: 0,
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
height={"90%"}
|
||||
width={width}
|
||||
panDirection={PanningDirectionsEnum.DOWN}
|
||||
onDismiss={() => handleClose}
|
||||
containerStyle={{
|
||||
borderRadius: 10,
|
||||
backgroundColor: "white",
|
||||
alignSelf: "stretch",
|
||||
padding: 0,
|
||||
paddingTop: 4,
|
||||
margin: 0,
|
||||
}}
|
||||
visible={addChoreDialogProps.isVisible}
|
||||
>
|
||||
<View row spread>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
style={styles.topBtn}
|
||||
label="Cancel"
|
||||
onPress={() => {
|
||||
handleClose();
|
||||
}}
|
||||
/>
|
||||
<View marginT-12>
|
||||
<DropModalIcon
|
||||
onPress={() => {
|
||||
handleClose();
|
||||
}}
|
||||
visible={addChoreDialogProps.isVisible}
|
||||
>
|
||||
<View row spread>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
style={styles.topBtn}
|
||||
label="Cancel"
|
||||
onPress={() => {
|
||||
handleClose();
|
||||
}}
|
||||
/>
|
||||
<View marginT-12>
|
||||
<DropModalIcon
|
||||
onPress={() => {
|
||||
handleClose();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
style={styles.topBtn}
|
||||
label="Save"
|
||||
onPress={() => {
|
||||
try {
|
||||
if (addChoreDialogProps.selectedTodo) {
|
||||
updateToDo({
|
||||
...todo,
|
||||
points: points,
|
||||
assignees: selectedAssignees
|
||||
});
|
||||
} else {
|
||||
addToDo({
|
||||
...todo,
|
||||
done: false,
|
||||
points: points,
|
||||
assignees: selectedAssignees,
|
||||
repeatDays: todo.repeatDays ?? []
|
||||
});
|
||||
}
|
||||
handleClose();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
/>
|
||||
</View>
|
||||
<Button
|
||||
color="#05a8b6"
|
||||
style={styles.topBtn}
|
||||
label="Save"
|
||||
onPress={() => {
|
||||
try {
|
||||
if (addChoreDialogProps.selectedTodo) {
|
||||
updateToDo({ ...todo, points: points });
|
||||
} else {
|
||||
addToDo({
|
||||
...todo,
|
||||
done: false,
|
||||
points: points,
|
||||
});
|
||||
}
|
||||
handleClose();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<TextField
|
||||
placeholder="Add a To Do"
|
||||
value={todo?.title}
|
||||
onChangeText={(text) => {
|
||||
setTodo((oldValue: IToDo) => ({ ...oldValue, title: text }));
|
||||
}}
|
||||
placeholderTextColor="#2d2d30"
|
||||
text60R
|
||||
marginT-15
|
||||
marginL-30
|
||||
/>
|
||||
<View style={styles.divider} marginT-8 />
|
||||
<View marginL-30 centerV>
|
||||
<View row marginB-10>
|
||||
{todo?.date && (
|
||||
<View row centerV>
|
||||
<Feather name="calendar" size={25} color="#919191" />
|
||||
<DateTimePicker
|
||||
value={todo.date}
|
||||
text70
|
||||
marginL-8
|
||||
onChange={(date) => {
|
||||
setTodo((oldValue: IToDo) => ({ ...oldValue, date: date }));
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<KeyboardAvoidingView>
|
||||
<TextField
|
||||
placeholder="Add a To Do"
|
||||
value={todo?.title}
|
||||
onChangeText={(text) => {
|
||||
setTodo((oldValue: IToDo) => ({...oldValue, title: text}));
|
||||
}}
|
||||
placeholderTextColor="#2d2d30"
|
||||
text60R
|
||||
marginT-15
|
||||
marginL-30
|
||||
ref={titleRef}
|
||||
/>
|
||||
<View style={styles.divider} marginT-8/>
|
||||
<View marginL-30 centerV>
|
||||
<View row marginB-10>
|
||||
{todo?.date && (
|
||||
<View row centerV>
|
||||
<CalendarIcon color="#919191" width={24} height={24}/>
|
||||
<DateTimePicker
|
||||
value={todo.date}
|
||||
text70
|
||||
style={{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
}}
|
||||
marginL-12
|
||||
onChange={(date) => {
|
||||
setTodo((oldValue: IToDo) => ({...oldValue, date: date}));
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<View row centerV>
|
||||
<ClockOIcon/>
|
||||
<Picker
|
||||
marginL-12
|
||||
placeholder="Select Repeat Type"
|
||||
value={todo?.repeatType}
|
||||
onChange={(value) => {
|
||||
if (value) {
|
||||
if (value.toString() == "None") {
|
||||
setTodo((oldValue) => ({
|
||||
...oldValue,
|
||||
date: null,
|
||||
repeatType: "None",
|
||||
}));
|
||||
} else {
|
||||
setTodo((oldValue) => ({
|
||||
...oldValue,
|
||||
date: new Date(),
|
||||
repeatType: value.toString(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
}}
|
||||
topBarProps={{title: "Repeat"}}
|
||||
style={{
|
||||
marginVertical: 5,
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
}}
|
||||
>
|
||||
{repeatOptions.map((option) => (
|
||||
<Picker.Item
|
||||
key={option.value}
|
||||
label={option.label}
|
||||
value={option.value}
|
||||
/>
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
{todo.repeatType == "Every week" && <RepeatFreq handleRepeatDaysChange={handleRepeatDaysChange}
|
||||
repeatDays={todo.repeatDays ?? []}/>}
|
||||
</View>
|
||||
<View style={styles.divider}/>
|
||||
)}
|
||||
</View>
|
||||
<View row centerV>
|
||||
<AntDesign name="clockcircleo" size={24} color="#919191" />
|
||||
<Picker
|
||||
marginL-8
|
||||
placeholder="Select Repeat Type"
|
||||
value={todo?.repeatType}
|
||||
onChange={(value) => {
|
||||
if (value) {
|
||||
if (value.toString() == "None") {
|
||||
setTodo((oldValue) => ({
|
||||
...oldValue,
|
||||
date: null,
|
||||
repeatType: "None",
|
||||
}));
|
||||
} else {
|
||||
setTodo((oldValue) => ({
|
||||
...oldValue,
|
||||
date: new Date(),
|
||||
repeatType: value.toString(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
}}
|
||||
topBarProps={{ title: "Repeat" }}
|
||||
style={{ marginVertical: 5 }}
|
||||
>
|
||||
{repeatOptions.map((option) => (
|
||||
<Picker.Item
|
||||
key={option.value}
|
||||
label={option.label}
|
||||
value={option.value}
|
||||
/>
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
|
||||
<View marginH-30 marginB-10 row centerV>
|
||||
<ProfileIcon color="#919191"/>
|
||||
<Text style={styles.sub} marginL-10>
|
||||
Assignees
|
||||
</Text>
|
||||
<View flex-1/>
|
||||
<Picker
|
||||
marginL-8
|
||||
value={selectedAssignees}
|
||||
onChange={(value) => {
|
||||
setSelectedAssignees(value);
|
||||
}}
|
||||
style={{marginVertical: 5}}
|
||||
mode={PickerModes.MULTI}
|
||||
renderInput={() => (
|
||||
<Button
|
||||
size={ButtonSize.small}
|
||||
paddingH-8
|
||||
iconSource={() => (
|
||||
<Ionicons name="add-outline" size={20} color="#ea156c"/>
|
||||
)}
|
||||
style={{
|
||||
marginLeft: "auto",
|
||||
borderRadius: 8,
|
||||
backgroundColor: "#ffe8f1",
|
||||
borderColor: "#ea156c",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
color="#ea156c"
|
||||
label="Assign"
|
||||
labelStyle={{fontFamily: "Manrope_600SemiBold", fontSize: 14}}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
{sortedMembers?.map((member) => (
|
||||
<Picker.Item
|
||||
key={member.uid}
|
||||
label={member?.firstName + " " + member?.lastName}
|
||||
value={member?.uid!}
|
||||
/>
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
<View row marginL-27 marginT-0>
|
||||
<AssigneesDisplay
|
||||
selectedAttendees={selectedAssignees}
|
||||
setSelectedAttendees={setSelectedAssignees}
|
||||
/>
|
||||
</View>
|
||||
<View row centerV style={styles.rotateSwitch}>
|
||||
<Text style={{fontFamily: "PlusJakartaSans_500Medium", fontSize: 16}}>
|
||||
Take Turns
|
||||
</Text>
|
||||
<Switch
|
||||
onColor={"#ea156c"}
|
||||
value={todo.rotate}
|
||||
style={{width: 43.06, height: 27.13}}
|
||||
marginL-10
|
||||
onValueChange={(value) =>
|
||||
setTodo((oldValue) => ({...oldValue, rotate: value}))
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.divider}/>
|
||||
<View marginH-30 marginB-15 row centerV>
|
||||
<Ionicons name="gift-outline" size={25} color="#919191"/>
|
||||
<Text style={styles.sub} marginL-10>
|
||||
Reward Points
|
||||
</Text>
|
||||
</View>
|
||||
<PointsSlider
|
||||
points={points}
|
||||
setPoints={setPoints}
|
||||
handleChange={handleChange}
|
||||
/>
|
||||
</KeyboardAvoidingView>
|
||||
</Dialog>
|
||||
);
|
||||
<View marginH-30 marginB-10 row centerV>
|
||||
<Ionicons name="person-circle-outline" size={28} color="#919191" />
|
||||
<Text text70R marginL-10>
|
||||
Assignees
|
||||
</Text>
|
||||
<Button
|
||||
size={ButtonSize.small}
|
||||
paddingH-8
|
||||
iconSource={() => (
|
||||
<Ionicons name="add-outline" size={20} color="#ea156c" />
|
||||
)}
|
||||
style={{
|
||||
marginLeft: "auto",
|
||||
borderRadius: 8,
|
||||
backgroundColor: "#ffe8f1",
|
||||
borderColor: "#ea156c",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
color="#ea156c"
|
||||
label="Assign"
|
||||
/>
|
||||
</View>
|
||||
<View row marginH-13 marginT-13>
|
||||
<View
|
||||
marginL-30
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 50,
|
||||
backgroundColor: "red",
|
||||
borderRadius: 50,
|
||||
}}
|
||||
/>
|
||||
<View
|
||||
marginL-30
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: 50,
|
||||
backgroundColor: "red",
|
||||
borderRadius: 50,
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View row centerV style={styles.rotateSwitch}>
|
||||
<Text text80>Take Turns</Text>
|
||||
<Switch
|
||||
onColor={"#ea156c"}
|
||||
value={todo.rotate}
|
||||
marginL-10
|
||||
onValueChange={(value) =>
|
||||
setTodo((oldValue) => ({ ...oldValue, rotate: value }))
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
<View marginH-30 marginB-15 row centerV>
|
||||
<Ionicons name="gift-outline" size={25} color="#919191" />
|
||||
<Text text70BL marginL-10>
|
||||
Reward Points
|
||||
</Text>
|
||||
</View>
|
||||
<PointsSlider
|
||||
points={points}
|
||||
setPoints={setPoints}
|
||||
handleChange={handleChange}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddChoreDialog;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
divider: {height: 1, backgroundColor: "#e4e4e4", marginVertical: 15},
|
||||
gradient: {
|
||||
height: "25%",
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
width: "100%",
|
||||
},
|
||||
buttonContainer: {
|
||||
position: "absolute",
|
||||
bottom: 25,
|
||||
width: "100%",
|
||||
},
|
||||
button: {
|
||||
backgroundColor: "rgb(253, 23, 117)",
|
||||
paddingVertical: 20,
|
||||
},
|
||||
topBtn: {
|
||||
backgroundColor: "white",
|
||||
color: "#05a8b6",
|
||||
},
|
||||
rotateSwitch: {
|
||||
marginLeft: 35,
|
||||
marginBottom: 10,
|
||||
marginTop: 25,
|
||||
},
|
||||
sub: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 18,
|
||||
},
|
||||
divider: { height: 1, backgroundColor: "#e4e4e4", marginVertical: 15 },
|
||||
gradient: {
|
||||
height: "25%",
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
width: "100%",
|
||||
},
|
||||
buttonContainer: {
|
||||
position: "absolute",
|
||||
bottom: 25,
|
||||
width: "100%",
|
||||
},
|
||||
button: {
|
||||
backgroundColor: "rgb(253, 23, 117)",
|
||||
paddingVertical: 20,
|
||||
},
|
||||
topBtn: {
|
||||
backgroundColor: "white",
|
||||
color: "#05a8b6",
|
||||
},
|
||||
rotateSwitch: {
|
||||
marginLeft: 35,
|
||||
marginBottom: 10,
|
||||
marginTop: 25,
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
import { View, Text, TouchableOpacity, Picker } from "react-native-ui-lib";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {DAYS_OF_WEEK_ENUM} from "@/hooks/firebase/types/todoData";
|
||||
|
||||
const RepeatFreq = ({ repeatDays, handleRepeatDaysChange }: { repeatDays: string[], handleRepeatDaysChange: Function }) => {
|
||||
const [weeks, setWeeks] = useState<number>(1);
|
||||
const weekOptions: number[] = Array.from({ length: 52 }, (_, i) => i + 1);
|
||||
|
||||
useEffect(() => {}, [weeks]);
|
||||
|
||||
return (
|
||||
<View row centerV spread marginR-30>
|
||||
<RepeatOption value={DAYS_OF_WEEK_ENUM.MONDAY} handleRepeatDaysChange={handleRepeatDaysChange} repeatDays={repeatDays}/>
|
||||
<RepeatOption value={DAYS_OF_WEEK_ENUM.TUESDAY} handleRepeatDaysChange={handleRepeatDaysChange} repeatDays={repeatDays}/>
|
||||
<RepeatOption value={DAYS_OF_WEEK_ENUM.WEDNESDAY} handleRepeatDaysChange={handleRepeatDaysChange} repeatDays={repeatDays}/>
|
||||
<RepeatOption value={DAYS_OF_WEEK_ENUM.THURSDAY} handleRepeatDaysChange={handleRepeatDaysChange} repeatDays={repeatDays}/>
|
||||
<RepeatOption value={DAYS_OF_WEEK_ENUM.FRIDAY} handleRepeatDaysChange={handleRepeatDaysChange} repeatDays={repeatDays}/>
|
||||
<RepeatOption value={DAYS_OF_WEEK_ENUM.SATURDAY} handleRepeatDaysChange={handleRepeatDaysChange} repeatDays={repeatDays}/>
|
||||
<RepeatOption value={DAYS_OF_WEEK_ENUM.SUNDAY} handleRepeatDaysChange={handleRepeatDaysChange} repeatDays={repeatDays}/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default RepeatFreq;
|
||||
|
||||
const RepeatOption = ({ value, handleRepeatDaysChange, repeatDays }: { value: string, handleRepeatDaysChange: Function, repeatDays: string[] }) => {
|
||||
const [isSet, setisSet] = useState(repeatDays.includes(value));
|
||||
|
||||
|
||||
const handleDayChange = () => {
|
||||
handleRepeatDaysChange(value, !isSet)
|
||||
setisSet(!isSet);
|
||||
}
|
||||
|
||||
return (
|
||||
<TouchableOpacity onPress={handleDayChange}>
|
||||
<View
|
||||
center
|
||||
marginT-8
|
||||
marginB-4
|
||||
width={28}
|
||||
height={28}
|
||||
style={{
|
||||
backgroundColor: isSet ? "#fd1575" : "white",
|
||||
borderRadius: 100,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: !isSet ? "Manrope_400Regular" : "Manrope_700Bold",
|
||||
color: isSet ? "white" : "gray",
|
||||
}}
|
||||
>
|
||||
{value.at(0)}
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
@ -1,36 +1,23 @@
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
Checkbox,
|
||||
TouchableOpacity,
|
||||
Dialog,
|
||||
Button,
|
||||
ButtonSize,
|
||||
Checkbox,
|
||||
} from "react-native-ui-lib";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { useToDosContext } from "@/contexts/ToDosContext";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import PointsSlider from "@/components/shared/PointsSlider";
|
||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||
import { ImageBackground, StyleSheet } from "react-native";
|
||||
import { ImageBackground } from "react-native";
|
||||
import AddChoreDialog from "@/components/pages/todos/AddChoreDialog";
|
||||
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
|
||||
import RepeatIcon from "@/assets/svgs/RepeatIcon";
|
||||
import { ProfileType, useAuthContext } from "@/contexts/AuthContext";
|
||||
import { format } from "date-fns";
|
||||
|
||||
const ToDoItem = (props: {
|
||||
item: IToDo;
|
||||
isSettings?: boolean;
|
||||
is7Days?: boolean;
|
||||
}) => {
|
||||
const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
const { updateToDo } = useToDosContext();
|
||||
const { data: members } = useGetFamilyMembers();
|
||||
const { profileData } = useAuthContext();
|
||||
const isParent = profileData?.userType === ProfileType.PARENT;
|
||||
|
||||
const [visible, setVisible] = useState<boolean>(false);
|
||||
const [editing, setEditing] = useState<boolean>(false);
|
||||
const [points, setPoints] = useState(props.item.points);
|
||||
const [pointsModalVisible, setPointsModalVisible] = useState<boolean>(false);
|
||||
|
||||
@ -43,62 +30,36 @@ const ToDoItem = (props: {
|
||||
setPoints(0);
|
||||
}
|
||||
};
|
||||
|
||||
const getInitials = (firstName: string, lastName: string) => {
|
||||
return `${firstName.charAt(0)}${lastName.charAt(0)}`;
|
||||
};
|
||||
|
||||
const selectedMembers = members?.filter((x) =>
|
||||
props?.item?.assignees?.includes(x?.uid!)
|
||||
);
|
||||
|
||||
let isTodoEditable;
|
||||
if (isParent) {
|
||||
isTodoEditable = true;
|
||||
} else {
|
||||
isTodoEditable = props.item.creatorId === profileData?.uid;
|
||||
}
|
||||
|
||||
return (
|
||||
<View
|
||||
key={props.item.id}
|
||||
centerV
|
||||
paddingV-10
|
||||
paddingH-13
|
||||
marginV-10
|
||||
style={{
|
||||
borderRadius: 17,
|
||||
backgroundColor: "white",
|
||||
backgroundColor: props.item.done ? "#e0e0e0" : "white",
|
||||
opacity: props.item.done ? 0.3 : 1,
|
||||
}}
|
||||
>
|
||||
{visible && (
|
||||
<AddChoreDialog
|
||||
isVisible={visible}
|
||||
setIsVisible={setVisible}
|
||||
selectedTodo={props.item}
|
||||
/>
|
||||
)}
|
||||
<AddChoreDialog isVisible={editing} setIsVisible={setEditing} selectedTodo={props.item}/>
|
||||
<View paddingB-8 row spread>
|
||||
<Text
|
||||
<Text
|
||||
text70
|
||||
style={{
|
||||
textDecorationLine: props.item.done ? "line-through" : "none",
|
||||
fontFamily: "Manrope_500Medium",
|
||||
color: props.item.done ? "#a09f9f" : "black",
|
||||
fontSize: 15,
|
||||
textDecorationLine: props.item.done ? "line-through" : "none",
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
}}
|
||||
onPress={() => {
|
||||
isTodoEditable ? setVisible(true) : null;
|
||||
setEditing(true);
|
||||
}}
|
||||
>
|
||||
>
|
||||
{props.item.title}
|
||||
</Text>
|
||||
</Text>
|
||||
<Checkbox
|
||||
value={props.item.done}
|
||||
containerStyle={[styles.checkbox, { borderRadius: 50 }]}
|
||||
style={styles.checked}
|
||||
size={26.64}
|
||||
borderRadius={50}
|
||||
containerStyle={{borderWidth: 0.7, borderRadius: 50, borderColor: 'gray', height: 24.64, width: 24.64}}
|
||||
color="#fd1575"
|
||||
onValueChange={(value) => {
|
||||
updateToDo({ id: props.item.id, done: !props.item.done });
|
||||
@ -111,108 +72,39 @@ const ToDoItem = (props: {
|
||||
height={0.7}
|
||||
width={"100%"}
|
||||
style={{
|
||||
backgroundColor: "#e7e7e7",
|
||||
backgroundColor: props.item.done ? "#b8b8b8" : "#e7e7e7",
|
||||
}}
|
||||
centerH
|
||||
/>
|
||||
</View>
|
||||
<View centerV centerH marginT-8 row spread>
|
||||
<View row>
|
||||
{props.item.points && props.item.points > 0 ? (
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
if (props.isSettings) {
|
||||
setPointsModalVisible(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<View centerV row gap-3>
|
||||
<Ionicons name="gift-outline" size={20} color="#46a80a" />
|
||||
<Text
|
||||
color="#46a80a"
|
||||
style={{ fontSize: 12, fontFamily: "Manrope_500Medium" }}
|
||||
>
|
||||
{props.item.points} points
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
) : (
|
||||
<View />
|
||||
)}
|
||||
|
||||
{!(props.item.repeatType == "None") && (
|
||||
<View row centerV marginL-8>
|
||||
<RepeatIcon style={{ marginRight: 4 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 12,
|
||||
fontFamily: "Manrope_500Medium",
|
||||
color: "#858585",
|
||||
}}
|
||||
>
|
||||
{(() => {
|
||||
switch (props.item.repeatType) {
|
||||
case "Once a month":
|
||||
return "Monthly";
|
||||
case "Every week":
|
||||
return "Weekly";
|
||||
case "Once a year":
|
||||
return "Yearly";
|
||||
default:
|
||||
return props.item.repeatType;
|
||||
}
|
||||
})()}
|
||||
{props.item.date &&
|
||||
props.is7Days &&
|
||||
" / " + format(props.item.date, "EEEE")}
|
||||
{props.item.points && props.item.points > 0 ? (
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
if (props.isSettings) {
|
||||
setPointsModalVisible(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<View centerV row gap-3>
|
||||
<Ionicons name="gift-outline" size={20} color="#46a80a" />
|
||||
<Text color="#46a80a" style={{ fontSize: 12, fontFamily: "Manrope_500Medium" }}>
|
||||
{props.item.points} points
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<View row style={{ gap: 3 }}>
|
||||
{selectedMembers?.map((member) => {
|
||||
return member?.pfp ? (
|
||||
<ImageBackground
|
||||
source={{ uri: member.pfp }}
|
||||
style={{
|
||||
height: 24.64,
|
||||
aspectRatio: 1,
|
||||
borderRadius: 22,
|
||||
overflow: "hidden",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<View
|
||||
style={{
|
||||
position: "relative",
|
||||
width: 24.64,
|
||||
aspectRatio: 1,
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: member.eventColor || "#ccc",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
borderRadius: 100, // Circular shape
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: "#fff",
|
||||
fontSize: 12,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{getInitials(member.firstName, member.lastName ?? "")}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
) : (
|
||||
<View />
|
||||
)}
|
||||
<ImageBackground
|
||||
source={require("../../../assets/images/child-picture.png")}
|
||||
style={{
|
||||
height: 24.64,
|
||||
aspectRatio: 1,
|
||||
borderRadius: 22,
|
||||
overflow: "hidden",
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<Dialog
|
||||
visible={pointsModalVisible}
|
||||
@ -265,17 +157,3 @@ const ToDoItem = (props: {
|
||||
};
|
||||
|
||||
export default ToDoItem;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
checkbox: {
|
||||
borderRadius: 50,
|
||||
borderWidth: 0.7,
|
||||
color: "#bfbfbf",
|
||||
borderColor: "#bfbfbf",
|
||||
width: 24.64,
|
||||
aspectRatio: 1,
|
||||
},
|
||||
checked: {
|
||||
borderRadius: 50,
|
||||
},
|
||||
});
|
||||
|
||||
@ -2,76 +2,32 @@ import { View, Text, TouchableOpacity, Icon } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import { useToDosContext } from "@/contexts/ToDosContext";
|
||||
import ToDoItem from "./ToDoItem";
|
||||
import {
|
||||
addDays,
|
||||
format,
|
||||
isToday,
|
||||
isTomorrow,
|
||||
isWithinInterval,
|
||||
} from "date-fns";
|
||||
import { format, isToday, isTomorrow } from "date-fns";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||
|
||||
const groupToDosByDate = (toDos: IToDo[]) => {
|
||||
let sortedTodos = toDos.sort((a, b) => a.date - b.date);
|
||||
return sortedTodos.reduce(
|
||||
(groups, toDo) => {
|
||||
let dateKey;
|
||||
let subDateKey;
|
||||
return sortedTodos.reduce((groups, toDo) => {
|
||||
let dateKey;
|
||||
|
||||
const isNext7Days = (date: Date) => {
|
||||
const today = new Date();
|
||||
return isWithinInterval(date, { start: today, end: addDays(today, 7) });
|
||||
};
|
||||
|
||||
const isNext30Days = (date: Date) => {
|
||||
const today = new Date();
|
||||
return isWithinInterval(date, {
|
||||
start: today,
|
||||
end: addDays(today, 30),
|
||||
});
|
||||
};
|
||||
|
||||
if (toDo.date === null) {
|
||||
dateKey = "No Date";
|
||||
} else if (isToday(toDo.date)) {
|
||||
dateKey = "Today";
|
||||
} else if (isTomorrow(toDo.date)) {
|
||||
dateKey = "Tomorrow";
|
||||
} else if (isNext7Days(toDo.date)) {
|
||||
dateKey = "Next 7 Days";
|
||||
} else if (isNext30Days(toDo.date)) {
|
||||
dateKey = "Next 30 Days";
|
||||
subDateKey = format(toDo.date, "MMM d");
|
||||
} else {
|
||||
return groups;
|
||||
}
|
||||
|
||||
if (!groups[dateKey]) {
|
||||
groups[dateKey] = {
|
||||
items: [],
|
||||
subgroups: {},
|
||||
};
|
||||
}
|
||||
|
||||
if (dateKey === "Next 30 Days" && subDateKey) {
|
||||
if (!groups[dateKey].subgroups[subDateKey]) {
|
||||
groups[dateKey].subgroups[subDateKey] = [];
|
||||
}
|
||||
groups[dateKey].subgroups[subDateKey].push(toDo);
|
||||
} else {
|
||||
groups[dateKey].items.push(toDo);
|
||||
}
|
||||
|
||||
return groups;
|
||||
},
|
||||
{} as {
|
||||
[key: string]: {
|
||||
items: IToDo[];
|
||||
subgroups: { [key: string]: IToDo[] };
|
||||
};
|
||||
if (toDo.date === null) {
|
||||
dateKey = "No Date";
|
||||
} else if (isToday(toDo.date)) {
|
||||
dateKey = "Today • " + format(toDo.date, "EEE MMM dd");
|
||||
} else if (isTomorrow(toDo.date)) {
|
||||
dateKey = "Tomorrow • " + format(toDo.date, "EEE MMM dd");
|
||||
} else {
|
||||
dateKey = format(toDo.date, "EEE MMM dd");
|
||||
}
|
||||
);
|
||||
|
||||
if (!groups[dateKey]) {
|
||||
groups[dateKey] = [];
|
||||
}
|
||||
|
||||
groups[dateKey].push(toDo);
|
||||
return groups;
|
||||
}, {} as { [key: string]: IToDo[] });
|
||||
};
|
||||
|
||||
const ToDosList = ({ isSettings }: { isSettings?: boolean }) => {
|
||||
@ -91,139 +47,11 @@ const ToDosList = ({ isSettings }: { isSettings?: boolean }) => {
|
||||
}));
|
||||
};
|
||||
|
||||
const noDateToDos = groupedToDos["No Date"]?.items || [];
|
||||
const noDateToDos = groupedToDos["No Date"] || [];
|
||||
const datedToDos = Object.keys(groupedToDos).filter(
|
||||
(key) => key !== "No Date"
|
||||
);
|
||||
|
||||
const renderTodoGroup = (dateKey: string) => {
|
||||
const isExpanded = expandedGroups[dateKey] || false;
|
||||
|
||||
if (dateKey === "Next 30 Days") {
|
||||
const subgroups = Object.entries(groupedToDos[dateKey].subgroups).sort(
|
||||
([dateA], [dateB]) => {
|
||||
const dateAObj = new Date(dateA);
|
||||
const dateBObj = new Date(dateB);
|
||||
return dateAObj.getTime() - dateBObj.getTime();
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<View key={dateKey}>
|
||||
<TouchableOpacity
|
||||
onPress={() => toggleExpand(dateKey)}
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 0,
|
||||
marginBottom: 4,
|
||||
marginTop: 15,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "Manrope_700Bold",
|
||||
fontSize: 15,
|
||||
color: "#484848",
|
||||
}}
|
||||
>
|
||||
{dateKey}
|
||||
</Text>
|
||||
<AntDesign
|
||||
name={isExpanded ? "caretdown" : "caretright"}
|
||||
size={24}
|
||||
color="#fd1575"
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
|
||||
{isExpanded &&
|
||||
subgroups.map(([subDate, items]) => {
|
||||
const sortedItems = [
|
||||
...items.filter((toDo) => !toDo.done),
|
||||
...items.filter((toDo) => toDo.done),
|
||||
];
|
||||
|
||||
return (
|
||||
<View key={subDate} marginT-15>
|
||||
<View
|
||||
style={{
|
||||
marginBottom: 8,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 14,
|
||||
color: "#919191",
|
||||
}}
|
||||
>
|
||||
{subDate}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{sortedItems.map((item) => (
|
||||
<ToDoItem
|
||||
isSettings={isSettings}
|
||||
key={item.id}
|
||||
item={item}
|
||||
is7Days={false}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const sortedToDos = [
|
||||
...groupedToDos[dateKey].items.filter((toDo) => !toDo.done),
|
||||
...groupedToDos[dateKey].items.filter((toDo) => toDo.done),
|
||||
];
|
||||
|
||||
return (
|
||||
<View key={dateKey}>
|
||||
<TouchableOpacity
|
||||
onPress={() => toggleExpand(dateKey)}
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 0,
|
||||
marginBottom: 4,
|
||||
marginTop: 15,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: "Manrope_700Bold",
|
||||
fontSize: 15,
|
||||
color: "#484848",
|
||||
}}
|
||||
>
|
||||
{dateKey}
|
||||
</Text>
|
||||
<AntDesign
|
||||
name={isExpanded ? "caretdown" : "caretright"}
|
||||
size={24}
|
||||
color="#fd1575"
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
|
||||
{isExpanded &&
|
||||
sortedToDos.map((item) => (
|
||||
<ToDoItem
|
||||
isSettings={isSettings}
|
||||
key={item.id}
|
||||
item={item}
|
||||
is7Days={dateKey === "Next 7 Days"}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<View marginB-402>
|
||||
{noDateToDos.length > 0 && (
|
||||
@ -237,14 +65,26 @@ const ToDosList = ({ isSettings }: { isSettings?: boolean }) => {
|
||||
>
|
||||
Unscheduled
|
||||
</Text>
|
||||
<AntDesign
|
||||
name={expandNoDate ? "caretdown" : "caretright"}
|
||||
size={24}
|
||||
color="#fd1575"
|
||||
onPress={() => {
|
||||
setExpandNoDate(!expandNoDate);
|
||||
}}
|
||||
/>
|
||||
{!expandNoDate && (
|
||||
<AntDesign
|
||||
name="caretright"
|
||||
size={24}
|
||||
color="#fd1575"
|
||||
onPress={() => {
|
||||
setExpandNoDate(!expandNoDate);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{expandNoDate && (
|
||||
<AntDesign
|
||||
name="caretdown"
|
||||
size={24}
|
||||
color="#fd1575"
|
||||
onPress={() => {
|
||||
setExpandNoDate(!expandNoDate);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
{expandNoDate &&
|
||||
noDateToDos
|
||||
@ -255,7 +95,50 @@ const ToDosList = ({ isSettings }: { isSettings?: boolean }) => {
|
||||
</View>
|
||||
)}
|
||||
|
||||
{datedToDos.map(renderTodoGroup)}
|
||||
{datedToDos.map((dateKey) => {
|
||||
const isExpanded = expandedGroups[dateKey] || false;
|
||||
const sortedToDos = [
|
||||
...groupedToDos[dateKey].filter((toDo) => !toDo.done),
|
||||
...groupedToDos[dateKey].filter((toDo) => toDo.done),
|
||||
];
|
||||
|
||||
return (
|
||||
<View key={dateKey}>
|
||||
<TouchableOpacity
|
||||
onPress={() => toggleExpand(dateKey)}
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 20,
|
||||
marginVertical: 8,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
text70
|
||||
style={{
|
||||
fontFamily: "Manrope_700Bold",
|
||||
fontSize: 15,
|
||||
color: "#484848",
|
||||
}}
|
||||
>
|
||||
{dateKey}
|
||||
</Text>
|
||||
{!isExpanded && (
|
||||
<AntDesign name="caretright" size={24} color="#fd1575" />
|
||||
)}
|
||||
{isExpanded && (
|
||||
<AntDesign name="caretdown" size={24} color="#fd1575" />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
|
||||
{isExpanded &&
|
||||
sortedToDos.map((item) => (
|
||||
<ToDoItem isSettings={isSettings} key={item.id} item={item} />
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
@ -1,21 +1,19 @@
|
||||
import { Button, Text, View } from "react-native-ui-lib";
|
||||
import { View, Text, Button, ButtonSize } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import HeaderTemplate from "@/components/shared/HeaderTemplate";
|
||||
import AddChore from "./AddChore";
|
||||
import ProgressCard from "./ProgressCard";
|
||||
import ToDosList from "./ToDosList";
|
||||
import { Dimensions, ScrollView, StyleSheet } from "react-native";
|
||||
import { Dimensions, ScrollView } from "react-native";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||
import { ProfileType, useAuthContext } from "@/contexts/AuthContext";
|
||||
import FamilyChoresProgress from "./family-chores/FamilyChoresProgress";
|
||||
import UserChoresProgress from "./user-chores/UserChoresProgress";
|
||||
import { useAtom } from "jotai";
|
||||
import { toDosPageIndex } from "../calendar/atoms";
|
||||
|
||||
const ToDosPage = () => {
|
||||
const [pageIndex, setPageIndex] = useState<number>(0);
|
||||
const { profileData } = useAuthContext();
|
||||
const [pageIndex, setPageIndex] = useAtom(toDosPageIndex);
|
||||
|
||||
const { width, height } = Dimensions.get("screen");
|
||||
const pageLink = (
|
||||
<TouchableOpacity onPress={() => setPageIndex(1)}>
|
||||
@ -25,58 +23,49 @@ const ToDosPage = () => {
|
||||
</TouchableOpacity>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
>
|
||||
<View
|
||||
paddingH-25
|
||||
height={"100%"}
|
||||
width={width}
|
||||
>
|
||||
{pageIndex == 0 && (
|
||||
<View paddingH-25 backgroundColor="#f9f8f7" height={"100%"} width={width}>
|
||||
{pageIndex == 0 && (
|
||||
<View>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
>
|
||||
<View>
|
||||
<View>
|
||||
<HeaderTemplate
|
||||
message="Here are your To Do's"
|
||||
isWelcome={true}
|
||||
link={profileData?.userType == ProfileType.PARENT && pageLink}
|
||||
isToDos={true}
|
||||
/>
|
||||
{profileData?.userType == ProfileType.CHILD && (
|
||||
<View marginB-25>
|
||||
<ProgressCard
|
||||
children={
|
||||
<Button
|
||||
backgroundColor="transparent"
|
||||
onPress={() => setPageIndex(2)}
|
||||
<HeaderTemplate
|
||||
message="Here are your To Do's"
|
||||
isWelcome={true}
|
||||
link={profileData?.userType == ProfileType.PARENT && pageLink}
|
||||
/>
|
||||
{profileData?.userType == ProfileType.CHILD && (
|
||||
<View marginB-25>
|
||||
<ProgressCard
|
||||
children={
|
||||
<Button
|
||||
backgroundColor="transparent"
|
||||
onPress={() => setPageIndex(2)}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
textDecorationLine: "underline",
|
||||
color: "#05a8b6",
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
textDecorationLine: "underline",
|
||||
color: "#05a8b6",
|
||||
}}
|
||||
>
|
||||
View your full progress report here
|
||||
</Text>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<ToDosList />
|
||||
</View>
|
||||
View your full progress report here
|
||||
</Text>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<ToDosList />
|
||||
</View>
|
||||
)}
|
||||
{pageIndex == 1 && (
|
||||
<FamilyChoresProgress setPageIndex={setPageIndex} />
|
||||
)}
|
||||
{pageIndex == 2 && <UserChoresProgress setPageIndex={setPageIndex} />}
|
||||
</ScrollView>
|
||||
{profileData?.userType == ProfileType.PARENT && <AddChore />}
|
||||
</View>
|
||||
</ScrollView>
|
||||
<AddChore />
|
||||
</>
|
||||
)}
|
||||
{pageIndex == 1 && <FamilyChoresProgress setPageIndex={setPageIndex} />}
|
||||
{pageIndex == 2 && <UserChoresProgress setPageIndex={setPageIndex} />}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ import React from "react";
|
||||
import { ImageBackground, StyleSheet } from "react-native";
|
||||
import FamilyChart from "./FamilyChart";
|
||||
import { TouchableOpacity } from "react-native-ui-lib/src/incubator";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
|
||||
const FamilyChoresProgress = ({
|
||||
setPageIndex,
|
||||
@ -13,20 +12,7 @@ const FamilyChoresProgress = ({
|
||||
return (
|
||||
<View marginT-20 marginH-5>
|
||||
<TouchableOpacity onPress={() => setPageIndex(0)}>
|
||||
<View row marginT-4 marginB-10 centerV>
|
||||
<Ionicons
|
||||
name="chevron-back"
|
||||
size={14}
|
||||
color="#979797"
|
||||
style={{ paddingBottom: 3 }}
|
||||
/>
|
||||
<Text
|
||||
style={{ fontFamily: "Poppins_400Regular", fontSize: 14.71 }}
|
||||
color="#979797"
|
||||
>
|
||||
Return to To Do's
|
||||
</Text>
|
||||
</View>
|
||||
<Text style={{ fontFamily: "Manrope_200", fontSize: 12 }}>Back to ToDos</Text>
|
||||
</TouchableOpacity>
|
||||
<View centerH>
|
||||
<Text style={{ fontFamily: "Manrope_700Bold", fontSize: 19 }}>
|
||||
|
||||