mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 08:24:55 +00:00
merge resolve
This commit is contained in:
@ -1,17 +1,17 @@
|
|||||||
import {Text, View} from "react-native";
|
import {Text, View} from "react-native";
|
||||||
import React, {useEffect, useRef} from "react";
|
import React, {useEffect, useRef} from "react";
|
||||||
import {TextField, TextFieldRef} from "react-native-ui-lib";
|
import {TextField, TextFieldRef} from "react-native-ui-lib";
|
||||||
import {GroceryCategory, IGrocery, useGroceryContext,} from "@/contexts/GroceryContext";
|
import {GroceryCategory, useGroceryContext,} from "@/contexts/GroceryContext";
|
||||||
|
|
||||||
interface IEditGrocery {
|
interface IEditGrocery {
|
||||||
id?: number;
|
id?: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
category: GroceryCategory;
|
||||||
setTitle: (value: string) => void;
|
setTitle: (value: string) => void;
|
||||||
setCategory?: (category: GroceryCategory) => void;
|
setCategory?: (category: GroceryCategory) => void;
|
||||||
category: GroceryCategory;
|
|
||||||
setSubmit?: (value: boolean) => void;
|
setSubmit?: (value: boolean) => void;
|
||||||
updateCategory?: (id: number, changes: Partial<IGrocery>) => void;
|
|
||||||
closeEdit?: (value: boolean) => void;
|
closeEdit?: (value: boolean) => void;
|
||||||
|
handleEditSubmit?: Function
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
||||||
@ -49,12 +49,18 @@ const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
|||||||
editGrocery.setTitle(value);
|
editGrocery.setTitle(value);
|
||||||
}}
|
}}
|
||||||
onSubmitEditing={() => {
|
onSubmitEditing={() => {
|
||||||
if (editGrocery.setSubmit) editGrocery.setSubmit(true);
|
if (editGrocery.setSubmit) {
|
||||||
if (editGrocery.closeEdit) editGrocery.closeEdit(false);
|
editGrocery.setSubmit(true);
|
||||||
if (editGrocery.updateCategory && editGrocery.id)
|
}
|
||||||
editGrocery.updateCategory(editGrocery.id, {
|
if (editGrocery.setCategory) {
|
||||||
category: fuzzyMatchGroceryCategory(editGrocery.title), title: editGrocery.title
|
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}
|
maxLength={25}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -81,15 +81,15 @@ const GroceryItem = ({
|
|||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
<EditGroceryItem
|
<EditGroceryItem
|
||||||
editGrocery={{
|
editGrocery={{
|
||||||
id: item.id,
|
id: item.id,
|
||||||
title: newTitle,
|
title: newTitle,
|
||||||
setTitle: setNewTitle,
|
category: category,
|
||||||
category: category,
|
setTitle: setNewTitle,
|
||||||
updateCategory: updateGroceryItem,
|
setCategory: setCategory,
|
||||||
closeEdit: setIsEditingTitle,
|
closeEdit: setIsEditingTitle,
|
||||||
setCategory: setCategory,
|
handleEditSubmit: updateGroceryItem
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!item.approved ? (
|
{!item.approved ? (
|
||||||
|
|||||||
@ -1,34 +1,14 @@
|
|||||||
import { StyleSheet } from "react-native";
|
import { StyleSheet } from "react-native";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import { Button, ButtonSize, Text, View } from "react-native-ui-lib";
|
||||||
Button,
|
import { AntDesign } from "@expo/vector-icons";
|
||||||
ButtonSize,
|
|
||||||
View,
|
|
||||||
Text,
|
|
||||||
ActionSheet,
|
|
||||||
TextField,
|
|
||||||
Dialog,
|
|
||||||
Slider,
|
|
||||||
NumberInput,
|
|
||||||
NumberInputData,
|
|
||||||
DateTimePicker,
|
|
||||||
Switch,
|
|
||||||
Picker,
|
|
||||||
} from "react-native-ui-lib";
|
|
||||||
import { AntDesign, Feather, Ionicons } from "@expo/vector-icons";
|
|
||||||
import LinearGradient from "react-native-linear-gradient";
|
import LinearGradient from "react-native-linear-gradient";
|
||||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/components/panningViews/panningProvider";
|
|
||||||
import { repeatOptions, useToDosContext } from "@/contexts/ToDosContext";
|
|
||||||
import { setDate } from "date-fns";
|
|
||||||
import PointsSlider from "@/components/shared/PointsSlider";
|
|
||||||
import AddChoreDialog from "./AddChoreDialog";
|
import AddChoreDialog from "./AddChoreDialog";
|
||||||
|
|
||||||
const AddChore = () => {
|
const AddChore = () => {
|
||||||
|
|
||||||
const [isVisible, setIsVisible] = useState<boolean>(false);
|
const [isVisible, setIsVisible] = useState<boolean>(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LinearGradient
|
<LinearGradient
|
||||||
colors={["transparent", "#f9f8f7"]}
|
colors={["transparent", "#f9f8f7"]}
|
||||||
@ -48,7 +28,7 @@ const AddChore = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
<AddChoreDialog isVisible={isVisible} setIsVisible={setIsVisible} />
|
<AddChoreDialog isVisible={isVisible} setIsVisible={setIsVisible} />
|
||||||
</LinearGradient>
|
</LinearGradient>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -13,26 +13,31 @@ import {
|
|||||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
||||||
import { StyleSheet } from "react-native";
|
import { StyleSheet } from "react-native";
|
||||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||||
|
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||||
|
|
||||||
interface IAddChoreDialog {
|
interface IAddChoreDialog {
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
setIsVisible: (value: boolean) => void;
|
setIsVisible: (value: boolean) => void;
|
||||||
|
selectedTodo?: IToDo
|
||||||
}
|
}
|
||||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|
||||||
const { addToDo, toDos } = useToDosContext();
|
|
||||||
|
|
||||||
const [newTitle, setNewTitle] = useState<string>("");
|
const defaultTodo = {
|
||||||
const [points, setPoints] = useState<number>(10);
|
id: "",
|
||||||
const [choreDate, setChoreDate] = useState<Date | null>(new Date());
|
title: "",
|
||||||
const [rotate, setRotate] = useState<boolean>(false);
|
points: 10,
|
||||||
const [repeatType, setRepeatType] = useState<string>("Every week");
|
date: new Date(),
|
||||||
|
rotate: false,
|
||||||
|
repeatType: "Every week"
|
||||||
|
};
|
||||||
|
|
||||||
|
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||||
|
const { addToDo, updateToDo } = useToDosContext();
|
||||||
|
const [todo, setTodo] = useState<IToDo>(addChoreDialogProps.selectedTodo ?? defaultTodo)
|
||||||
|
|
||||||
|
const [points, setPoints] = useState<number>(todo.points);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setNewTitle("");
|
setTodo(defaultTodo);
|
||||||
setPoints(10);
|
|
||||||
setChoreDate(new Date());
|
|
||||||
setRotate(false);
|
|
||||||
setRepeatType("every week");
|
|
||||||
addChoreDialogProps.setIsVisible(false);
|
addChoreDialogProps.setIsVisible(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -45,6 +50,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
setPoints(0);
|
setPoints(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
bottom={true}
|
bottom={true}
|
||||||
@ -84,15 +90,15 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
label="Save"
|
label="Save"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
try {
|
try {
|
||||||
addToDo({
|
if (addChoreDialogProps.selectedTodo) {
|
||||||
id: "",
|
updateToDo({...todo, points: points})
|
||||||
title: newTitle,
|
} else {
|
||||||
done: false,
|
addToDo({
|
||||||
date: choreDate,
|
...todo,
|
||||||
points: points,
|
done: false,
|
||||||
rotate: rotate,
|
points: points,
|
||||||
repeatType: repeatType,
|
});
|
||||||
});
|
}
|
||||||
handleClose();
|
handleClose();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -102,9 +108,9 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
</View>
|
</View>
|
||||||
<TextField
|
<TextField
|
||||||
placeholder="Add a To Do"
|
placeholder="Add a To Do"
|
||||||
value={newTitle}
|
value={todo?.title}
|
||||||
onChangeText={(text) => {
|
onChangeText={(text) => {
|
||||||
setNewTitle(text);
|
setTodo((oldValue: IToDo) => ({...oldValue, title: text}));
|
||||||
}}
|
}}
|
||||||
placeholderTextColor="#2d2d30"
|
placeholderTextColor="#2d2d30"
|
||||||
text60R
|
text60R
|
||||||
@ -114,15 +120,15 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
<View style={styles.divider} marginT-8 />
|
<View style={styles.divider} marginT-8 />
|
||||||
<View marginL-30 centerV>
|
<View marginL-30 centerV>
|
||||||
<View row marginB-10>
|
<View row marginB-10>
|
||||||
{choreDate && (
|
{todo?.date && (
|
||||||
<View row centerV>
|
<View row centerV>
|
||||||
<Feather name="calendar" size={25} color="#919191" />
|
<Feather name="calendar" size={25} color="#919191" />
|
||||||
<DateTimePicker
|
<DateTimePicker
|
||||||
value={choreDate}
|
value={todo.date}
|
||||||
text70
|
text70
|
||||||
marginL-8
|
marginL-8
|
||||||
onChange={(date) => {
|
onChange={(date) => {
|
||||||
setChoreDate(date);
|
setTodo((oldValue: IToDo) => ({...oldValue, date: date}));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@ -133,15 +139,13 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
<Picker
|
<Picker
|
||||||
marginL-8
|
marginL-8
|
||||||
placeholder="Select Repeat Type"
|
placeholder="Select Repeat Type"
|
||||||
value={repeatType}
|
value={todo?.repeatType}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
if (value.toString() == "None") {
|
if (value.toString() == "None") {
|
||||||
setChoreDate(null);
|
setTodo((oldValue) => ({...oldValue, date: null, repeatType: "None"}));
|
||||||
setRepeatType("None");
|
|
||||||
} else {
|
} else {
|
||||||
setRepeatType(value.toString());
|
setTodo((oldValue) => ({...oldValue, date: new Date(), repeatType: value.toString()}))
|
||||||
setChoreDate(new Date());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -206,9 +210,9 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
|||||||
<Text text80>Take Turns</Text>
|
<Text text80>Take Turns</Text>
|
||||||
<Switch
|
<Switch
|
||||||
onColor={"#ea156c"}
|
onColor={"#ea156c"}
|
||||||
value={rotate}
|
value={todo.rotate}
|
||||||
marginL-10
|
marginL-10
|
||||||
onValueChange={(value) => setRotate(value)}
|
onValueChange={(value) => setTodo((oldValue) => ({...oldValue, rotate: value}))}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.divider} />
|
<View style={styles.divider} />
|
||||||
|
|||||||
@ -2,19 +2,18 @@ import {
|
|||||||
View,
|
View,
|
||||||
Text,
|
Text,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
TextField,
|
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
Modal,
|
|
||||||
Dialog,
|
Dialog,
|
||||||
Button,
|
Button,
|
||||||
ButtonSize,
|
ButtonSize,
|
||||||
} from "react-native-ui-lib";
|
} from "react-native-ui-lib";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useToDosContext } from "@/contexts/ToDosContext";
|
import { useToDosContext } from "@/contexts/ToDosContext";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import PointsSlider from "@/components/shared/PointsSlider";
|
import PointsSlider from "@/components/shared/PointsSlider";
|
||||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||||
import { ImageBackground } from "react-native";
|
import { ImageBackground } from "react-native";
|
||||||
|
import AddChoreDialog from "@/components/pages/todos/AddChoreDialog";
|
||||||
|
|
||||||
const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||||
const { updateToDo } = useToDosContext();
|
const { updateToDo } = useToDosContext();
|
||||||
@ -43,38 +42,21 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
|||||||
opacity: props.item.done ? 0.3 : 1,
|
opacity: props.item.done ? 0.3 : 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<AddChoreDialog isVisible={editing} setIsVisible={setEditing} selectedTodo={props.item}/>
|
||||||
<View paddingB-8 row spread>
|
<View paddingB-8 row spread>
|
||||||
{!editing ? (
|
<Text
|
||||||
<Text
|
text70
|
||||||
text70
|
style={{
|
||||||
style={{
|
|
||||||
textDecorationLine: props.item.done ? "line-through" : "none",
|
textDecorationLine: props.item.done ? "line-through" : "none",
|
||||||
fontFamily: "Manrope_500Medium",
|
fontFamily: "Manrope_500Medium",
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (props.isSettings) {
|
setEditing(true);
|
||||||
setEditing(true);
|
}}
|
||||||
}
|
>
|
||||||
}}
|
{props.item.title}
|
||||||
>
|
</Text>
|
||||||
{props.item.title}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<TextField
|
|
||||||
value={props.item.title}
|
|
||||||
text70R
|
|
||||||
onChangeText={(text) => {
|
|
||||||
updateToDo({ id: props.item.id, title: text });
|
|
||||||
}}
|
|
||||||
onSubmitEditing={() => {
|
|
||||||
setEditing(false);
|
|
||||||
}}
|
|
||||||
onBlur={() => {
|
|
||||||
setEditing(false);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Checkbox
|
<Checkbox
|
||||||
value={props.item.done}
|
value={props.item.done}
|
||||||
containerStyle={{borderWidth: 0.7, borderRadius: 50, borderColor: 'gray', height: 24.64, width: 24.64}}
|
containerStyle={{borderWidth: 0.7, borderRadius: 50, borderColor: 'gray', height: 24.64, width: 24.64}}
|
||||||
|
|||||||
@ -7,7 +7,8 @@ import { AntDesign } from "@expo/vector-icons";
|
|||||||
import {IToDo} from "@/hooks/firebase/types/todoData";
|
import {IToDo} from "@/hooks/firebase/types/todoData";
|
||||||
|
|
||||||
const groupToDosByDate = (toDos: IToDo[]) => {
|
const groupToDosByDate = (toDos: IToDo[]) => {
|
||||||
return toDos.reduce((groups, toDo) => {
|
let sortedTodos = toDos.sort((a, b) => a.date - b.date);
|
||||||
|
return sortedTodos.reduce((groups, toDo) => {
|
||||||
let dateKey;
|
let dateKey;
|
||||||
|
|
||||||
if (toDo.date === null) {
|
if (toDo.date === null) {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ export interface IToDo {
|
|||||||
title: string;
|
title: string;
|
||||||
done: boolean;
|
done: boolean;
|
||||||
date: Date | null;
|
date: Date | null;
|
||||||
points?: number;
|
points: number;
|
||||||
rotate: boolean;
|
rotate: boolean;
|
||||||
repeatType: string;
|
repeatType: string;
|
||||||
creatorId?: string,
|
creatorId?: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user