mirror of
https://github.com/urosran/cally.git
synced 2025-07-17 02:25:10 +00:00
Merge branch 'dev' of https://github.com/urosran/cally into dev
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import {AntDesign, Ionicons} from "@expo/vector-icons";
|
import {Ionicons} from "@expo/vector-icons";
|
||||||
import React, {useCallback, useState} from "react";
|
import React, {useCallback, useState} from "react";
|
||||||
import {Button, Checkbox, Text, View} from "react-native-ui-lib";
|
import {Button, Checkbox, Text, View} from "react-native-ui-lib";
|
||||||
import {ActivityIndicator, ScrollView, StyleSheet} from "react-native";
|
import {ActivityIndicator, ScrollView, StyleSheet} from "react-native";
|
||||||
@ -10,7 +10,6 @@ import AppleIcon from "@/assets/svgs/AppleIcon";
|
|||||||
import GoogleIcon from "@/assets/svgs/GoogleIcon";
|
import GoogleIcon from "@/assets/svgs/GoogleIcon";
|
||||||
import OutlookIcon from "@/assets/svgs/OutlookIcon";
|
import OutlookIcon from "@/assets/svgs/OutlookIcon";
|
||||||
import ExpoLocalization from "expo-localization/src/ExpoLocalization";
|
import ExpoLocalization from "expo-localization/src/ExpoLocalization";
|
||||||
import {colorMap} from "@/constants/colorMap";
|
|
||||||
import {useSetAtom} from "jotai";
|
import {useSetAtom} from "jotai";
|
||||||
import {settingsPageIndex} from "../calendar/atoms";
|
import {settingsPageIndex} from "../calendar/atoms";
|
||||||
import CalendarSettingsDialog from "./calendar_components/CalendarSettingsDialog";
|
import CalendarSettingsDialog from "./calendar_components/CalendarSettingsDialog";
|
||||||
@ -53,13 +52,6 @@ const CalendarSettingsPage = () => {
|
|||||||
setModalVisible(false);
|
setModalVisible(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const [selectedColor, setSelectedColor] = useState<string>(
|
|
||||||
profileData?.eventColor ?? colorMap.pink
|
|
||||||
);
|
|
||||||
const [previousSelectedColor, setPreviousSelectedColor] = useState<string>(
|
|
||||||
profileData?.eventColor ?? colorMap.pink
|
|
||||||
);
|
|
||||||
|
|
||||||
const {mutateAsync: updateUserData} = useUpdateUserData();
|
const {mutateAsync: updateUserData} = useUpdateUserData();
|
||||||
const {mutateAsync: clearToken} = useClearTokens();
|
const {mutateAsync: clearToken} = useClearTokens();
|
||||||
|
|
||||||
@ -78,22 +70,6 @@ const CalendarSettingsPage = () => {
|
|||||||
fetchAndSaveAppleEvents
|
fetchAndSaveAppleEvents
|
||||||
} = useCalSync()
|
} = useCalSync()
|
||||||
|
|
||||||
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 debouncedUpdateFirstDayOfWeek = useCallback(
|
const debouncedUpdateFirstDayOfWeek = useCallback(
|
||||||
debounce(async (firstDayOfWeek: string) => {
|
debounce(async (firstDayOfWeek: string) => {
|
||||||
try {
|
try {
|
||||||
@ -114,12 +90,6 @@ const CalendarSettingsPage = () => {
|
|||||||
debouncedUpdateFirstDayOfWeek(firstDayOfWeek);
|
debouncedUpdateFirstDayOfWeek(firstDayOfWeek);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChangeColor = (color: string) => {
|
|
||||||
setPreviousSelectedColor(selectedColor);
|
|
||||||
setSelectedColor(color);
|
|
||||||
debouncedUpdateUserData(color);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<TouchableOpacity onPress={() => setPageIndex(0)}>
|
<TouchableOpacity onPress={() => setPageIndex(0)}>
|
||||||
@ -140,52 +110,6 @@ const CalendarSettingsPage = () => {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<View marginH-30 marginB-30>
|
<View marginH-30 marginB-30>
|
||||||
<Text style={styles.subTitle}>Calendar settings</Text>
|
<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}>
|
<View style={styles.card}>
|
||||||
<Text style={styles.cardTitle}>Weekly Start Date</Text>
|
<Text style={styles.cardTitle}>Weekly Start Date</Text>
|
||||||
<View row marginV-5 marginT-20>
|
<View row marginV-5 marginT-20>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, {useCallback, useEffect, useRef, useState} from "react";
|
||||||
import { StyleSheet, TouchableOpacity } from "react-native";
|
import { StyleSheet, TouchableOpacity } from "react-native";
|
||||||
import { ScrollView } from "react-native-gesture-handler";
|
import { ScrollView } from "react-native-gesture-handler";
|
||||||
import * as ImagePicker from "expo-image-picker";
|
import * as ImagePicker from "expo-image-picker";
|
||||||
@ -20,6 +20,7 @@ import { useUpdateUserData } from "@/hooks/firebase/useUpdateUserData";
|
|||||||
import { useChangeProfilePicture } from "@/hooks/firebase/useChangeProfilePicture";
|
import { useChangeProfilePicture } from "@/hooks/firebase/useChangeProfilePicture";
|
||||||
import { colorMap } from "@/constants/colorMap";
|
import { colorMap } from "@/constants/colorMap";
|
||||||
import DeleteProfileDialogs from "../user_components/DeleteProfileDialogs";
|
import DeleteProfileDialogs from "../user_components/DeleteProfileDialogs";
|
||||||
|
import {AntDesign} from "@expo/vector-icons";
|
||||||
|
|
||||||
const MyProfile = () => {
|
const MyProfile = () => {
|
||||||
const { user, profileData } = useAuthContext();
|
const { user, profileData } = useAuthContext();
|
||||||
@ -34,6 +35,13 @@ const MyProfile = () => {
|
|||||||
string | ImagePicker.ImagePickerAsset | null
|
string | ImagePicker.ImagePickerAsset | null
|
||||||
>(profileData?.pfp || 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 [showDeleteDialog, setShowDeleteDialog] = useState<boolean>(false);
|
||||||
|
|
||||||
const handleHideDeleteDialog = () => {
|
const handleHideDeleteDialog = () => {
|
||||||
@ -102,6 +110,28 @@ const MyProfile = () => {
|
|||||||
? profileImage.uri
|
? profileImage.uri
|
||||||
: profileImage;
|
: 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 (
|
return (
|
||||||
<ScrollView style={{ paddingBottom: 20, flex: 1 }}>
|
<ScrollView style={{ paddingBottom: 20, flex: 1 }}>
|
||||||
<View style={styles.card}>
|
<View style={styles.card}>
|
||||||
@ -215,6 +245,52 @@ const MyProfile = () => {
|
|||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
<View style={styles.card}>
|
||||||
|
<Text style={styles.cardTitle} marginB-14>
|
||||||
|
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>
|
||||||
<Button
|
<Button
|
||||||
size="large"
|
size="large"
|
||||||
backgroundColor="#ff1637"
|
backgroundColor="#ff1637"
|
||||||
@ -248,6 +324,17 @@ const timeZoneItems = Object.keys(tz.zones)
|
|||||||
));
|
));
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
cardTitle: {
|
||||||
|
fontFamily: "Manrope_500Medium",
|
||||||
|
fontSize: 15,
|
||||||
|
},
|
||||||
|
colorBox: {
|
||||||
|
aspectRatio: 1,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
width: 51,
|
||||||
|
borderRadius: 12,
|
||||||
|
},
|
||||||
card: {
|
card: {
|
||||||
marginVertical: 15,
|
marginVertical: 15,
|
||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
|
@ -25,6 +25,7 @@ import CalendarIcon from "@/assets/svgs/CalendarIcon";
|
|||||||
import ClockOIcon from "@/assets/svgs/ClockOIcon";
|
import ClockOIcon from "@/assets/svgs/ClockOIcon";
|
||||||
import ProfileIcon from "@/assets/svgs/ProfileIcon";
|
import ProfileIcon from "@/assets/svgs/ProfileIcon";
|
||||||
import RepeatFreq from "./RepeatFreq";
|
import RepeatFreq from "./RepeatFreq";
|
||||||
|
import {useAuthContext} from "@/contexts/AuthContext";
|
||||||
|
|
||||||
interface IAddChoreDialog {
|
interface IAddChoreDialog {
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
@ -44,6 +45,7 @@ const defaultTodo = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||||
|
const {user} = useAuthContext()
|
||||||
const {addToDo, updateToDo} = useToDosContext();
|
const {addToDo, updateToDo} = useToDosContext();
|
||||||
const [todo, setTodo] = useState<IToDo>(
|
const [todo, setTodo] = useState<IToDo>(
|
||||||
addChoreDialogProps.selectedTodo ?? defaultTodo
|
addChoreDialogProps.selectedTodo ?? defaultTodo
|
||||||
@ -57,6 +59,11 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
const titleRef = useRef<TextFieldRef>(null)
|
const titleRef = useRef<TextFieldRef>(null)
|
||||||
|
|
||||||
const {data: members} = useGetFamilyMembers();
|
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 = () => {
|
const handleClose = () => {
|
||||||
setTodo(defaultTodo);
|
setTodo(defaultTodo);
|
||||||
@ -272,7 +279,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{members?.map((member) => (
|
{sortedMembers?.map((member) => (
|
||||||
<Picker.Item
|
<Picker.Item
|
||||||
key={member.uid}
|
key={member.uid}
|
||||||
label={member?.firstName + " " + member?.lastName}
|
label={member?.firstName + " " + member?.lastName}
|
||||||
|
@ -13,7 +13,7 @@ const PointsSlider = (props: {
|
|||||||
value={props.points}
|
value={props.points}
|
||||||
onValueChange={(value) => props.setPoints(value)}
|
onValueChange={(value) => props.setPoints(value)}
|
||||||
minimumValue={0}
|
minimumValue={0}
|
||||||
step={10}
|
step={5}
|
||||||
thumbTintColor="white"
|
thumbTintColor="white"
|
||||||
minimumTrackTintColor="#91d5ff"
|
minimumTrackTintColor="#91d5ff"
|
||||||
thumbStyle={{borderWidth: 3, borderColor: '#91d5ff'}}
|
thumbStyle={{borderWidth: 3, borderColor: '#91d5ff'}}
|
||||||
@ -21,7 +21,7 @@ const PointsSlider = (props: {
|
|||||||
/>
|
/>
|
||||||
<View row spread>
|
<View row spread>
|
||||||
<Text style={{fontSize: 13, color: '#858585'}}>0</Text>
|
<Text style={{fontSize: 13, color: '#858585'}}>0</Text>
|
||||||
<Text style={{fontSize: 13, color: '#858585'}}>50</Text>
|
<Text style={{fontSize: 13, color: '#858585', marginLeft: 15}}>50</Text>
|
||||||
<Text style={{fontSize: 13, color: '#858585'}}>100</Text>
|
<Text style={{fontSize: 13, color: '#858585'}}>100</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -61,9 +61,8 @@ export const useCreateTodo = () => {
|
|||||||
dates.push(newDate);
|
dates.push(newDate);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: for the next 52 weeks
|
|
||||||
let index = 1;
|
let index = 1;
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 52; i++) {
|
||||||
dates?.forEach((dateToAdd) => {
|
dates?.forEach((dateToAdd) => {
|
||||||
index ++;
|
index ++;
|
||||||
let newTodoDate = addWeeks(dateToAdd, i);
|
let newTodoDate = addWeeks(dateToAdd, i);
|
||||||
|
@ -73,7 +73,7 @@ export const useUpdateTodo = () => {
|
|||||||
dates.push(newDate);
|
dates.push(newDate);
|
||||||
});
|
});
|
||||||
|
|
||||||
let todosToAddCycles = 4;
|
let todosToAddCycles = 52;
|
||||||
if (firstTodo?.repeatType === REPEAT_TYPE.EVERY_WEEK) {
|
if (firstTodo?.repeatType === REPEAT_TYPE.EVERY_WEEK) {
|
||||||
todosToAddCycles = filteredTodos?.length / firstTodo?.repeatDays?.length;
|
todosToAddCycles = filteredTodos?.length / firstTodo?.repeatDays?.length;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user