mirror of
https://github.com/urosran/cally.git
synced 2025-07-15 09:45:20 +00:00
add todo repeat freq
This commit is contained in:
@ -4,6 +4,7 @@ const CalendarIcon: React.FC<SvgProps> = (props) => (
|
||||
<Svg
|
||||
width={props.width || 21}
|
||||
height={props.height || 21}
|
||||
viewBox="0 0 21 21"
|
||||
fill="none"
|
||||
{...props}
|
||||
>
|
||||
|
20
assets/svgs/ClockOIcon.tsx
Normal file
20
assets/svgs/ClockOIcon.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
20
assets/svgs/DropdownIcon.tsx
Normal file
20
assets/svgs/DropdownIcon.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
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,8 +1,11 @@
|
||||
import {Text, View} from "react-native";
|
||||
import { Text, View } from "react-native-ui-lib";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { TextField, TextFieldRef } from "react-native-ui-lib";
|
||||
import {GroceryCategory, useGroceryContext,} from "@/contexts/GroceryContext";
|
||||
import CategoryDropdown from "./CategoryDropdown";
|
||||
import { GroceryCategory, useGroceryContext } from "@/contexts/GroceryContext";
|
||||
import { Dropdown } from "react-native-element-dropdown";
|
||||
import CloseXIcon from "@/assets/svgs/CloseXIcon";
|
||||
import { StyleSheet } from "react-native";
|
||||
import DropdownIcon from "@/assets/svgs/DropdownIcon";
|
||||
|
||||
interface IEditGrocery {
|
||||
id?: string;
|
||||
@ -12,23 +15,25 @@ interface IEditGrocery {
|
||||
setCategory?: (category: GroceryCategory) => void;
|
||||
setSubmit?: (value: boolean) => void;
|
||||
closeEdit?: (value: boolean) => void;
|
||||
handleEditSubmit?: Function
|
||||
handleEditSubmit?: Function;
|
||||
}
|
||||
|
||||
const EditGroceryItem = ({ editGrocery }: { editGrocery: IEditGrocery }) => {
|
||||
const { fuzzyMatchGroceryCategory } = useGroceryContext();
|
||||
const inputRef = useRef<TextFieldRef>(null);
|
||||
const [category, setCategory] = useState<GroceryCategory>(GroceryCategory.None);
|
||||
|
||||
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
|
||||
}
|
||||
console.log(editGrocery.category);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@ -37,13 +42,15 @@ const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
||||
backgroundColor: "white",
|
||||
width: "100%",
|
||||
borderRadius: 25,
|
||||
padding: 15,
|
||||
marginTop: 10
|
||||
paddingHorizontal: 13,
|
||||
paddingVertical: 10,
|
||||
marginTop: 0,
|
||||
}}
|
||||
>
|
||||
<View row spread centerV>
|
||||
<TextField
|
||||
text70T
|
||||
style={{fontWeight: "400"}}
|
||||
style={{}}
|
||||
ref={inputRef}
|
||||
placeholder="Grocery"
|
||||
value={editGrocery.title}
|
||||
@ -54,11 +61,12 @@ const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
||||
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});
|
||||
editGrocery.handleEditSubmit({
|
||||
id: editGrocery.id,
|
||||
title: editGrocery.title,
|
||||
category: editGrocery.category,
|
||||
});
|
||||
}
|
||||
if (editGrocery.closeEdit) {
|
||||
editGrocery.closeEdit(false);
|
||||
@ -66,9 +74,68 @@ const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
||||
}}
|
||||
maxLength={25}
|
||||
/>
|
||||
<Text>{editGrocery.category}</Text>
|
||||
<CloseXIcon
|
||||
onPress={() => {
|
||||
if (editGrocery.closeEdit) editGrocery.closeEdit(false);
|
||||
}}
|
||||
/>
|
||||
</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 == GroceryCategory.None
|
||||
? null
|
||||
: 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,
|
||||
});
|
||||
console.log("kategorija vo diropdown: " + item.value);
|
||||
if (editGrocery.closeEdit) editGrocery.closeEdit(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</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;
|
||||
|
@ -36,7 +36,7 @@ const GroceryItem = ({
|
||||
|
||||
useEffect(() => {
|
||||
setNewTitle(item.title);
|
||||
|
||||
console.log(item);
|
||||
getItemCreator(item?.creatorId);
|
||||
}, []);
|
||||
|
||||
@ -56,11 +56,14 @@ const GroceryItem = ({
|
||||
return (
|
||||
<View
|
||||
key={item.id}
|
||||
style={{ borderRadius: 17, marginVertical: 5 }}
|
||||
style={{
|
||||
borderRadius: 17,
|
||||
marginVertical: 5,
|
||||
paddingHorizontal: isEditingTitle ? 0 : 13,
|
||||
paddingVertical: isEditingTitle ? 0 : 10,
|
||||
}}
|
||||
backgroundColor="white"
|
||||
centerV
|
||||
paddingH-13
|
||||
paddingV-10
|
||||
>
|
||||
<View row spread>
|
||||
<EditGroceryFrequency
|
||||
@ -84,11 +87,11 @@ const GroceryItem = ({
|
||||
editGrocery={{
|
||||
id: item.id,
|
||||
title: newTitle,
|
||||
category: category,
|
||||
category: item.category,
|
||||
setTitle: setNewTitle,
|
||||
setCategory: setCategory,
|
||||
closeEdit: setIsEditingTitle,
|
||||
handleEditSubmit: updateGroceryItem
|
||||
handleEditSubmit: updateGroceryItem,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
@ -115,14 +118,19 @@ const GroceryItem = ({
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
!isEditingTitle && (
|
||||
<Checkbox
|
||||
value={item.bought}
|
||||
containerStyle={styles.checkbox}
|
||||
containerStyle={[styles.checkbox, {borderRadius: 50}]}
|
||||
style={styles.checked}
|
||||
borderRadius={50}
|
||||
color="#fd1575"
|
||||
hitSlop={20}
|
||||
onValueChange={() =>
|
||||
updateGroceryItem({ id: item.id, bought: !item.bought })
|
||||
}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</View>
|
||||
{!item.approved && (
|
||||
@ -138,9 +146,9 @@ const GroceryItem = ({
|
||||
borderRadius: 50,
|
||||
backgroundColor: "red",
|
||||
marginRight: 10,
|
||||
overflow: 'hidden'
|
||||
overflow: "hidden",
|
||||
}}
|
||||
source={require('../../../assets/images/child-picture.png')}
|
||||
source={require("../../../assets/images/child-picture.png")}
|
||||
/>
|
||||
<Text color="#858585" style={styles.authorTxt}>
|
||||
Requested by {itemCreator?.firstName}
|
||||
@ -166,6 +174,9 @@ const styles = StyleSheet.create({
|
||||
fontFamily: "Manrope_500Medium",
|
||||
fontSize: 15,
|
||||
},
|
||||
checked: {
|
||||
borderRadius: 50,
|
||||
},
|
||||
});
|
||||
|
||||
export default GroceryItem;
|
||||
|
@ -30,7 +30,7 @@ const GroceryList = () => {
|
||||
groceries?.filter((item) => item.approved !== true)
|
||||
);
|
||||
const [category, setCategory] = useState<GroceryCategory>(
|
||||
GroceryCategory.Bakery
|
||||
GroceryCategory.None
|
||||
);
|
||||
const [title, setTitle] = useState<string>("");
|
||||
const [submit, setSubmitted] = useState<boolean>(false);
|
||||
|
@ -22,7 +22,11 @@ const AddChore = () => {
|
||||
onPress={() => setIsVisible(!isVisible)}
|
||||
>
|
||||
<AntDesign name="plus" size={24} color="white" />
|
||||
<Text white text60R marginL-10>
|
||||
<Text
|
||||
white
|
||||
style={{ fontFamily: "Manrope_600SemiBold", fontSize: 15 }}
|
||||
marginL-10
|
||||
>
|
||||
Create new to do
|
||||
</Text>
|
||||
</Button>
|
||||
@ -52,5 +56,6 @@ const styles = StyleSheet.create({
|
||||
paddingVertical: 15,
|
||||
paddingHorizontal: 30,
|
||||
borderRadius: 30,
|
||||
width: 335,
|
||||
},
|
||||
});
|
@ -16,6 +16,11 @@ 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 ClockIcon from "@/assets/svgs/ClockIcon";
|
||||
import ClockOIcon from "@/assets/svgs/ClockOIcon";
|
||||
import ProfileIcon from "@/assets/svgs/ProfileIcon";
|
||||
import RepeatFreq from "./RepeatFreq";
|
||||
|
||||
interface IAddChoreDialog {
|
||||
isVisible: boolean;
|
||||
@ -30,7 +35,7 @@ const defaultTodo = {
|
||||
date: new Date(),
|
||||
rotate: false,
|
||||
repeatType: "Every week",
|
||||
assignees: []
|
||||
assignees: [],
|
||||
};
|
||||
|
||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
@ -38,7 +43,9 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
const [todo, setTodo] = useState<IToDo>(
|
||||
addChoreDialogProps.selectedTodo ?? defaultTodo
|
||||
);
|
||||
const [selectedAssignees, setSelectedAssignees] = useState<string[]>(addChoreDialogProps?.selectedTodo?.assignees ?? []);
|
||||
const [selectedAssignees, setSelectedAssignees] = useState<string[]>(
|
||||
addChoreDialogProps?.selectedTodo?.assignees ?? []
|
||||
);
|
||||
const { width, height } = Dimensions.get("screen");
|
||||
const [points, setPoints] = useState<number>(todo.points);
|
||||
|
||||
@ -100,13 +107,17 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
onPress={() => {
|
||||
try {
|
||||
if (addChoreDialogProps.selectedTodo) {
|
||||
updateToDo({ ...todo, points: points, assignees: selectedAssignees });
|
||||
updateToDo({
|
||||
...todo,
|
||||
points: points,
|
||||
assignees: selectedAssignees,
|
||||
});
|
||||
} else {
|
||||
addToDo({
|
||||
...todo,
|
||||
done: false,
|
||||
points: points,
|
||||
assignees: selectedAssignees
|
||||
assignees: selectedAssignees,
|
||||
});
|
||||
}
|
||||
handleClose();
|
||||
@ -133,11 +144,15 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
<View row marginB-10>
|
||||
{todo?.date && (
|
||||
<View row centerV>
|
||||
<Feather name="calendar" size={25} color="#919191" />
|
||||
<CalendarIcon color="#919191" width={24} height={24} />
|
||||
<DateTimePicker
|
||||
value={todo.date}
|
||||
text70
|
||||
marginL-8
|
||||
style={{
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
}}
|
||||
marginL-12
|
||||
onChange={(date) => {
|
||||
setTodo((oldValue: IToDo) => ({ ...oldValue, date: date }));
|
||||
}}
|
||||
@ -146,9 +161,9 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
)}
|
||||
</View>
|
||||
<View row centerV>
|
||||
<AntDesign name="clockcircleo" size={24} color="#919191" />
|
||||
<ClockOIcon />
|
||||
<Picker
|
||||
marginL-8
|
||||
marginL-12
|
||||
placeholder="Select Repeat Type"
|
||||
value={todo?.repeatType}
|
||||
onChange={(value) => {
|
||||
@ -169,7 +184,11 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
}
|
||||
}}
|
||||
topBarProps={{ title: "Repeat" }}
|
||||
style={{ marginVertical: 5 }}
|
||||
style={{
|
||||
marginVertical: 5,
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 16,
|
||||
}}
|
||||
>
|
||||
{repeatOptions.map((option) => (
|
||||
<Picker.Item
|
||||
@ -180,12 +199,13 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
{todo.repeatType == "Every week" && <RepeatFreq/>}
|
||||
</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>
|
||||
<ProfileIcon color="#919191" />
|
||||
<Text style={styles.sub} marginL-10>
|
||||
Assignees
|
||||
</Text>
|
||||
<View flex-1 />
|
||||
@ -197,7 +217,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
}}
|
||||
style={{ marginVertical: 5 }}
|
||||
mode={PickerModes.MULTI}
|
||||
renderInput={() =>
|
||||
renderInput={() => (
|
||||
<Button
|
||||
size={ButtonSize.small}
|
||||
paddingH-8
|
||||
@ -215,7 +235,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
label="Assign"
|
||||
labelStyle={{ fontFamily: "Manrope_600SemiBold", fontSize: 14 }}
|
||||
/>
|
||||
}
|
||||
)}
|
||||
>
|
||||
{members?.map((member) => (
|
||||
<Picker.Item
|
||||
@ -227,13 +247,19 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
</Picker>
|
||||
</View>
|
||||
<View row marginL-27 marginT-0>
|
||||
<AssigneesDisplay selectedAttendees={selectedAssignees} setSelectedAttendees={setSelectedAssignees}/>
|
||||
<AssigneesDisplay
|
||||
selectedAttendees={selectedAssignees}
|
||||
setSelectedAttendees={setSelectedAssignees}
|
||||
/>
|
||||
</View>
|
||||
<View row centerV style={styles.rotateSwitch}>
|
||||
<Text text80>Take Turns</Text>
|
||||
<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 }))
|
||||
@ -243,7 +269,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
<View style={styles.divider} />
|
||||
<View marginH-30 marginB-15 row centerV>
|
||||
<Ionicons name="gift-outline" size={25} color="#919191" />
|
||||
<Text text70BL marginL-10>
|
||||
<Text style={styles.sub} marginL-10>
|
||||
Reward Points
|
||||
</Text>
|
||||
</View>
|
||||
@ -284,4 +310,8 @@ const styles = StyleSheet.create({
|
||||
marginBottom: 10,
|
||||
marginTop: 25,
|
||||
},
|
||||
sub: {
|
||||
fontFamily: "Manrope_600SemiBold",
|
||||
fontSize: 18,
|
||||
},
|
||||
});
|
||||
|
83
components/pages/todos/RepeatFreq.tsx
Normal file
83
components/pages/todos/RepeatFreq.tsx
Normal file
@ -0,0 +1,83 @@
|
||||
import { View, Text, TouchableOpacity, Picker } from "react-native-ui-lib";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
const RepeatFreq = () => {
|
||||
const [weeks, setWeeks] = useState<number>(1);
|
||||
const weekOptions: number[] = Array.from({ length: 52 }, (_, i) => i + 1);
|
||||
|
||||
useEffect(() => {
|
||||
}, [weeks]);
|
||||
|
||||
return (
|
||||
<View row centerV>
|
||||
<View row centerV>
|
||||
<RepeatOption value={"Monday"} />
|
||||
<RepeatOption value={"Tuesday"} />
|
||||
<RepeatOption value={"Wednesday"} />
|
||||
<RepeatOption value={"Thirsday"} />
|
||||
<RepeatOption value={"Friday"} />
|
||||
<RepeatOption value={"Saturday"} />
|
||||
<RepeatOption value={"Sunday"} />
|
||||
</View>
|
||||
<View row gap-5 centerV>
|
||||
<Picker
|
||||
centered
|
||||
marginL-10
|
||||
marginR-0
|
||||
paddingR-0
|
||||
textAlign="right"
|
||||
trailingAccessory={
|
||||
<Text
|
||||
style={{ fontFamily: "Manrope_600SemiBold", color: "#fd1575" }}
|
||||
>
|
||||
{weeks == 1 ? "Week" : "Weeks"}
|
||||
</Text>
|
||||
}
|
||||
value={weeks}
|
||||
onChange={(value) => {
|
||||
if (typeof value === "number") {
|
||||
setWeeks(value);
|
||||
}
|
||||
}}
|
||||
placeholder={"Select number of weeks"}
|
||||
useWheelPicker
|
||||
color={"#fd1575"}
|
||||
style={{
|
||||
maxWidth: 18,
|
||||
fontFamily: "Manrope_700Bold",
|
||||
}}
|
||||
containerStyle={{
|
||||
borderWidth: 1,
|
||||
borderRadius: 6,
|
||||
paddingRight: 5,
|
||||
paddingLeft: 3,
|
||||
borderColor: "#fd1575",
|
||||
backgroundColor: "#ffe8f1",
|
||||
}}
|
||||
>
|
||||
{weekOptions.map((num) => (
|
||||
<Picker.Item key={num} value={num} label={`${num}`} />
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default RepeatFreq;
|
||||
|
||||
const RepeatOption = ({ value }: { value: string }) => {
|
||||
const [isSet, setisSet] = useState(false);
|
||||
return (
|
||||
<TouchableOpacity padding-10 center onPress={() => setisSet(!isSet)}>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: !isSet ? "Manrope_400Regular" : "Manrope_700Bold",
|
||||
color: isSet ? "#fd1575" : "gray",
|
||||
}}
|
||||
>
|
||||
{value.at(0)}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
@ -2,7 +2,13 @@ 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 { format, isToday, isTomorrow } from "date-fns";
|
||||
import {
|
||||
addDays,
|
||||
format,
|
||||
isToday,
|
||||
isTomorrow,
|
||||
isWithinInterval,
|
||||
} from "date-fns";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||
|
||||
@ -11,12 +17,26 @@ const groupToDosByDate = (toDos: IToDo[]) => {
|
||||
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 • " + format(toDo.date, "EEE MMM dd");
|
||||
dateKey = "Today";
|
||||
} else if (isTomorrow(toDo.date)) {
|
||||
dateKey = "Tomorrow • " + format(toDo.date, "EEE MMM dd");
|
||||
dateKey = "Tomorrow";
|
||||
} else if (isNext7Days(toDo.date)) {
|
||||
dateKey = "Next 7 Days";
|
||||
} else if (isNext30Days(toDo.date)) {
|
||||
dateKey = "Next 30 Days";
|
||||
} else {
|
||||
dateKey = format(toDo.date, "EEE MMM dd");
|
||||
}
|
||||
@ -110,12 +130,12 @@ const ToDosList = ({ isSettings }: { isSettings?: boolean }) => {
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
paddingHorizontal: 20,
|
||||
marginVertical: 8,
|
||||
paddingHorizontal: 0,
|
||||
marginBottom: 4,
|
||||
marginTop: 15,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
text70
|
||||
style={{
|
||||
fontFamily: "Manrope_700Bold",
|
||||
fontSize: 15,
|
||||
|
@ -6,7 +6,9 @@ export interface IToDo {
|
||||
points: number;
|
||||
rotate: boolean;
|
||||
repeatType: string;
|
||||
creatorId?: string,
|
||||
familyId?: string,
|
||||
repeatDays?: string[];
|
||||
repeatWeeks?: number;
|
||||
creatorId?: string;
|
||||
familyId?: string;
|
||||
assignees?: string[]; // Optional list of assignees
|
||||
}
|
@ -75,6 +75,7 @@
|
||||
"react-native-app-auth": "^8.0.0",
|
||||
"react-native-big-calendar": "^4.14.0",
|
||||
"react-native-calendars": "^1.1306.0",
|
||||
"react-native-element-dropdown": "^2.12.2",
|
||||
"react-native-gesture-handler": "~2.16.1",
|
||||
"react-native-gifted-charts": "^1.4.41",
|
||||
"react-native-keyboard-manager": "^6.5.16-0",
|
||||
|
@ -8850,6 +8850,13 @@ react-native-calendars@^1.1306.0:
|
||||
optionalDependencies:
|
||||
moment "^2.29.4"
|
||||
|
||||
react-native-element-dropdown@^2.12.2:
|
||||
version "2.12.2"
|
||||
resolved "https://registry.yarnpkg.com/react-native-element-dropdown/-/react-native-element-dropdown-2.12.2.tgz#48d0c12b87591e2498c73bbde80e18374a4c262e"
|
||||
integrity sha512-Tf8hfRuniYEXo+LGoVgIMoItKWuPLX6jbqlwAFgMbBhmWGTuV+g1OVOAx/ny16kgnwp+NhgJoWpxhVvr7HSmXA==
|
||||
dependencies:
|
||||
lodash "^4.17.21"
|
||||
|
||||
react-native-gesture-handler@~2.16.1:
|
||||
version "2.16.2"
|
||||
resolved "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.16.2.tgz"
|
||||
|
Reference in New Issue
Block a user