This commit is contained in:
Milan Paunovic
2024-10-28 01:27:33 +01:00
parent 7c18fd1d40
commit 059082cf65
8 changed files with 1052 additions and 1067 deletions

View File

@ -1,123 +1,119 @@
import { Dimensions, ScrollView } from "react-native"; import {Dimensions, ScrollView, StyleSheet} from "react-native";
import React, { useState } from "react"; import React, {useState} from "react";
import { View, Text, Button } from "react-native-ui-lib"; import {Button, Text, TextField, View} from "react-native-ui-lib";
import DumpList from "./DumpList"; import DumpList from "./DumpList";
import HeaderTemplate from "@/components/shared/HeaderTemplate"; import HeaderTemplate from "@/components/shared/HeaderTemplate";
import { TextField } from "react-native-ui-lib"; import {Feather, MaterialIcons} from "@expo/vector-icons";
import { StyleSheet } from "react-native";
import { Feather, MaterialIcons } from "@expo/vector-icons";
import { TextInput } from "react-native-gesture-handler";
import AddBrainDump from "./AddBrainDump"; import AddBrainDump from "./AddBrainDump";
import LinearGradient from "react-native-linear-gradient"; import LinearGradient from "react-native-linear-gradient";
const BrainDumpPage = () => { const BrainDumpPage = () => {
const [searchText, setSearchText] = useState<string>(""); const [searchText, setSearchText] = useState<string>("");
const [isAddVisible, setIsAddVisible] = useState<boolean>(false); const [isAddVisible, setIsAddVisible] = useState<boolean>(false);
return ( return (
<View height={"100%"}> <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 }}
>
Drop your notes on-the-go here, and{"\n"}organize them later.
</Text>
}
/>
<View> <View>
<View style={styles.searchField} centerV> <ScrollView
<TextField showsVerticalScrollIndicator={false}
value={searchText} showsHorizontalScrollIndicator={false}
onChangeText={(value) => { >
setSearchText(value); <View marginH-25>
}} <HeaderTemplate
leadingAccessory={ message={"Welcome to your notes!"}
<Feather isWelcome={false}
name="search" children={
size={24} <Text
color="#9b9b9b" style={{fontFamily: "Manrope_400Regular", fontSize: 14}}
style={{ paddingRight: 10 }} >
/> Drop your notes on-the-go here, and{"\n"}organize them later.
} </Text>
style={{ }
fontFamily: "Manrope_500Medium", />
fontSize: 15, <View>
}} <View style={styles.searchField} centerV>
placeholder="Search notes..." <TextField
/> value={searchText}
</View> onChangeText={(value) => {
<DumpList searchText={searchText} /> 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> </View>
</View> <LinearGradient
</ScrollView> colors={["#f9f8f700", "#f9f8f7"]}
</View> locations={[0,1]}
<LinearGradient style={{
colors={["#f2f2f2", "transparent"]} position: "absolute",
start={{ x: 0.5, y: 1 }} bottom: 0,
end={{ x: 0.5, y: 0 }} height: 120,
style={{ width: Dimensions.get("screen").width,
position: "absolute", justifyContent:'center',
bottom: 0, alignItems:"center"
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 <Button
</Text> style={{
</View> height: 40,
</Button> position: "relative",
</LinearGradient> width: "90%",
<AddBrainDump bottom: -10,
addBrainDumpProps={{ borderRadius: 30,
isVisible: isAddVisible, backgroundColor: "#fd1775",
setIsVisible: setIsAddVisible, }}
}} color="white"
/> enableShadow
</View> 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({ const styles = StyleSheet.create({
searchField: { searchField: {
borderWidth: 0.7, borderWidth: 0.7,
borderColor: "#9b9b9b", borderColor: "#9b9b9b",
borderRadius: 15, borderRadius: 15,
height: 42, height: 42,
paddingLeft: 10, paddingLeft: 10,
marginVertical: 20, marginVertical: 20,
}, },
}); });
export default BrainDumpPage; export default BrainDumpPage;

View File

@ -1,134 +1,125 @@
import React, { memo } from "react"; import React, {memo} from "react";
import { import {Button, Picker, PickerModes, SegmentedControl, Text, View,} from "react-native-ui-lib";
Button, import {MaterialIcons} from "@expo/vector-icons";
Picker, import {modeMap, months} from "./constants";
PickerModes, import {StyleSheet} from "react-native";
SegmentedControl, import {useAtom} from "jotai";
Text, import {modeAtom, selectedDateAtom} from "@/components/pages/calendar/atoms";
View, import {isSameDay} from "date-fns";
} from "react-native-ui-lib"; import {useAuthContext} from "@/contexts/AuthContext";
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 { isSameDay } from "date-fns";
import { useAuthContext } from "@/contexts/AuthContext";
export const CalendarHeader = memo(() => { export const CalendarHeader = memo(() => {
const [selectedDate, setSelectedDate] = useAtom(selectedDateAtom); const [selectedDate, setSelectedDate] = useAtom(selectedDateAtom);
const [mode, setMode] = useAtom(modeAtom); const [mode, setMode] = useAtom(modeAtom);
const { profileData } = useAuthContext(); const {profileData} = useAuthContext();
const handleSegmentChange = (index: number) => { const handleSegmentChange = (index: number) => {
const selectedMode = modeMap.get(index); const selectedMode = modeMap.get(index);
if (selectedMode) { if (selectedMode) {
setTimeout(() => { setTimeout(() => {
setMode(selectedMode as "day" | "week" | "month"); setMode(selectedMode as "day" | "week" | "month");
}, 150); }, 150);
} }
}; };
const handleMonthChange = (month: string) => { const handleMonthChange = (month: string) => {
const currentDay = selectedDate.getDate(); const currentDay = selectedDate.getDate();
const currentYear = selectedDate.getFullYear(); const currentYear = selectedDate.getFullYear();
const newMonthIndex = months.indexOf(month); const newMonthIndex = months.indexOf(month);
const updatedDate = new Date(currentYear, newMonthIndex, currentDay); const updatedDate = new Date(currentYear, newMonthIndex, currentDay);
setSelectedDate(updatedDate); setSelectedDate(updatedDate);
}; };
const isSelectedDateToday = isSameDay(selectedDate, new Date()); const isSelectedDateToday = isSameDay(selectedDate, new Date());
return ( return (
<View <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
padding-7
style={{ style={{
borderRadius: 5, flexDirection: "row",
backgroundColor: "white", justifyContent: "space-between",
borderWidth: 0.7, alignItems: "center",
borderColor: "#dadce0", paddingHorizontal: 10,
height: 30, paddingVertical: 8,
borderRadius: 20,
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
backgroundColor: "white",
marginBottom: 10,
}} }}
labelStyle={{ >
fontSize: 12, <View row centerV gap-3>
color: "black", <Text style={{fontFamily: "Manrope_500Medium", fontSize: 17}}>
fontFamily: "Manrope_500Medium", {selectedDate.getFullYear()}
}} </Text>
label={new Date().toLocaleDateString("en-US", { <Picker
timeZone: profileData?.timeZone || "", value={months[selectedDate.getMonth()]}
})} placeholder={"Select Month"}
onPress={() => { style={{fontFamily: "Manrope_500Medium", fontSize: 17, width: 85}}
setSelectedDate(new Date()); mode={PickerModes.SINGLE}
setMode("day"); onChange={(itemValue) => handleMonthChange(itemValue as string)}
console.log(profileData?.timeZone) 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> <View row centerV>
<SegmentedControl {!isSelectedDateToday && (
segments={[{ label: "D" }, { label: "W" }, { label: "M" }]} <Button
backgroundColor="#ececec" size={"xSmall"}
inactiveColor="#919191" marginR-0
activeBackgroundColor="#ea156c" avoidInnerPadding
activeColor="white" style={{
outlineColor="white" borderRadius: 50,
outlineWidth={3} backgroundColor: "white",
segmentLabelStyle={styles.segmentslblStyle} borderWidth: 0.7,
onChangeIndex={handleSegmentChange} borderColor: "#dadce0",
initialIndex={mode === "day" ? 0 : mode === "week" ? 1 : 2} height: 30,
/> paddingHorizontal: 10
}}
labelStyle={{
fontSize: 12,
color: "black",
fontFamily: "Manrope_500Medium",
}}
label={new Date().toLocaleDateString("en-US", {
timeZone: profileData?.timeZone || "",
})}
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> </View>
</View> );
</View>
);
}); });
const styles = StyleSheet.create({ const styles = StyleSheet.create({
segmentslblStyle: { segmentslblStyle: {
fontSize: 12, fontSize: 12,
fontFamily: "Manrope_600SemiBold", fontFamily: "Manrope_600SemiBold",
}, },
}); });

View File

@ -103,10 +103,11 @@ export const EventCalendar: React.FC<EventCalendarProps> = React.memo(
}, []); }, []);
const dayHeaderColor = useMemo(() => { const dayHeaderColor = useMemo(() => {
return isSameDate(todaysDate, selectedDate) && mode === "day" ? "white" : "#4d4d4d"; return isSameDate(todaysDate, selectedDate) ? "white" : "#4d4d4d";
}, [selectedDate, mode]); }, [selectedDate, mode]);
const dateStyle = useMemo(() => { const dateStyle = useMemo(() => {
if (mode === "week") return undefined
return isSameDate(todaysDate, selectedDate) && mode === "day" return isSameDate(todaysDate, selectedDate) && mode === "day"
? styles.dayHeader ? styles.dayHeader
: styles.otherDayHeader; : styles.otherDayHeader;

View File

@ -1,96 +1,78 @@
import { StyleSheet } from "react-native"; import {StyleSheet} from "react-native";
import React, { useState } from "react"; import React from "react";
import { import {Button, View,} from "react-native-ui-lib";
Button, import {useGroceryContext} from "@/contexts/GroceryContext";
Colors, import {FontAwesome6} from "@expo/vector-icons";
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 { isAddingGrocery, setIsAddingGrocery } = useGroceryContext();
const [visible, setVisible] = useState<boolean>(false);
const handleShowDialog = () => { const AddGroceryItem = () => {
setVisible(true); const {setIsAddingGrocery} = useGroceryContext();
};
const handleHideDialog = () => { return (
setVisible(false); <View
}; row
return ( spread
<View paddingH-25
row style={{
spread position: "absolute",
paddingH-25 bottom: 20,
style={{ width: "100%",
position: "absolute", height: 60,
bottom: 20, }}
width: "100%", >
height: 60, <View style={styles.btnContainer} row>
}} <Button
> color="white"
<View style={styles.btnContainer} row> backgroundColor="#fd1775"
<Button label="Add item"
color="white" text70L
backgroundColor="#fd1775" iconSource={() => <FontAwesome6 name="add" size={18} color="white"/>}
label="Add item" style={styles.finishShopBtn}
text70L labelStyle={styles.addBtnLbl}
iconSource={() => <FontAwesome6 name="add" size={18} color="white" />} enableShadow
style={styles.finishShopBtn} onPress={() => {
labelStyle={styles.addBtnLbl} setIsAddingGrocery(true);
enableShadow }}
onPress={() => { />
setIsAddingGrocery(true); </View>
}} </View>
/> );
</View>
</View>
);
}; };
export default AddGroceryItem; export default AddGroceryItem;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
paddingVertical: 10, paddingVertical: 10,
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
justifyContent: "space-between", justifyContent: "space-between",
}, },
inner: { inner: {
paddingHorizontal: 20, paddingHorizontal: 20,
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
}, },
title: { title: {
fontSize: 20, fontSize: 20,
fontWeight: "400", fontWeight: "400",
textAlign: "center", textAlign: "center",
}, },
divider: { divider: {
width: "100%", width: "100%",
height: 1, height: 1,
backgroundColor: "#E0E0E0", backgroundColor: "#E0E0E0",
marginVertical: 10, marginVertical: 10,
}, },
btnContainer: { btnContainer: {
width: "100%", width: "100%",
justifyContent: "center", justifyContent: "center",
}, },
finishShopBtn: { finishShopBtn: {
width: "100%", width: "100%",
}, },
shoppingBtn: { shoppingBtn: {
flex: 1, flex: 1,
marginHorizontal: 3, marginHorizontal: 3,
}, },
addBtnLbl: { fontFamily: "Manrope_500Medium", fontSize: 17, marginLeft: 5 }, addBtnLbl: {fontFamily: "Manrope_500Medium", fontSize: 17, marginLeft: 5},
}); });

View File

@ -1,159 +1,167 @@
import { Text, View } from "react-native-ui-lib"; import {Text, TextField, TextFieldRef, View} from "react-native-ui-lib";
import React, { useEffect, useRef, useState } from "react"; import React, {useEffect, useRef} from "react";
import { TextField, TextFieldRef } from "react-native-ui-lib"; import {GroceryCategory, useGroceryContext} from "@/contexts/GroceryContext";
import { GroceryCategory, useGroceryContext } from "@/contexts/GroceryContext"; import {Dropdown} from "react-native-element-dropdown";
import { Dropdown } from "react-native-element-dropdown";
import CloseXIcon from "@/assets/svgs/CloseXIcon"; import CloseXIcon from "@/assets/svgs/CloseXIcon";
import { StyleSheet } from "react-native"; import {StyleSheet} from "react-native";
import DropdownIcon from "@/assets/svgs/DropdownIcon"; import DropdownIcon from "@/assets/svgs/DropdownIcon";
import {AntDesign} from "@expo/vector-icons"; import {AntDesign} from "@expo/vector-icons";
interface IEditGrocery { interface IEditGrocery {
id?: string; id?: string;
title: string; title: string;
category: GroceryCategory; category: GroceryCategory;
setTitle: (value: string) => void; setTitle: (value: string) => void;
setCategory?: (category: GroceryCategory) => void; setCategory?: (category: GroceryCategory) => void;
setSubmit?: (value: boolean) => void; setSubmit?: (value: boolean) => void;
closeEdit?: () => void; closeEdit?: () => void;
handleEditSubmit?: Function; handleEditSubmit?: Function;
} }
const EditGroceryItem = ({ editGrocery }: { editGrocery: IEditGrocery }) => {
const { fuzzyMatchGroceryCategory } = useGroceryContext();
const inputRef = useRef<TextFieldRef>(null);
const groceryCategoryOptions = Object.values(GroceryCategory).map( const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
(category) => ({ const {fuzzyMatchGroceryCategory} = useGroceryContext();
label: category, const inputRef = useRef<TextFieldRef>(null);
value: category,
})
);
useEffect(() => { const groceryCategoryOptions = Object.values(GroceryCategory).map(
if (inputRef.current) { (category) => ({
inputRef.current.focus(); // Focus on the TextField label: category,
value: category,
})
);
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();
}
} }
console.log(editGrocery.category);
}, []);
return ( useEffect(() => {
<View if (inputRef.current) {
style={{ inputRef.current.focus();
backgroundColor: "white", }
width: "100%",
borderRadius: 25, console.log(editGrocery.category);
paddingHorizontal: 13, }, []);
paddingVertical: 10,
marginTop: 0, return (
}} <View
> style={{
<View row spread centerV> backgroundColor: "white",
<TextField width: "100%",
text70T borderRadius: 25,
style={{}} paddingHorizontal: 13,
ref={inputRef} paddingVertical: 10,
placeholder="Grocery" marginTop: 0,
value={editGrocery.title} }}
onChangeText={(value) => { >
editGrocery.setTitle(value); <View row spread centerV>
let groceryCategory = fuzzyMatchGroceryCategory(value); <TextField
if (editGrocery.setCategory) { text70T
editGrocery.setCategory(groceryCategory); ref={inputRef}
} placeholder="Grocery"
}} value={editGrocery.title}
maxLength={25} onSubmitEditing={handleSubmit}
/> numberOfLines={1}
<View row centerV> returnKeyType="done"
<AntDesign onChangeText={(value) => {
name="check" editGrocery.setTitle(value);
size={24} let groceryCategory = fuzzyMatchGroceryCategory(value);
style={{ if (editGrocery.setCategory) {
color: "green", editGrocery.setCategory(groceryCategory);
marginRight: 15, }
}}
maxLength={25}
/>
<View row centerV>
<AntDesign
name="check"
size={24}
style={{
color: "green",
marginRight: 15,
}}
onPress={handleSubmit}
/>
<CloseXIcon
onPress={() => {
if (editGrocery.closeEdit) {
editGrocery.closeEdit();
}
}}
/>
</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>
);
}} }}
onPress={() => { onChange={(item) => {
if (editGrocery.setSubmit) {
editGrocery.setSubmit(true);
}
if (editGrocery.handleEditSubmit) { if (editGrocery.handleEditSubmit) {
editGrocery.handleEditSubmit({ editGrocery.handleEditSubmit({
id: editGrocery.id, id: editGrocery.id,
title: editGrocery.title, category: item.value,
category: editGrocery.category,
}); });
} if (editGrocery.closeEdit) editGrocery.closeEdit();
if (editGrocery.closeEdit) { } else {
editGrocery.closeEdit(); if (editGrocery.setCategory) {
} editGrocery.setCategory(item.value);
}} }
/>
<CloseXIcon
onPress={() => {
if (editGrocery.closeEdit) {
editGrocery.closeEdit();
} }
}} }}
/> />
</View> </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({ const styles = StyleSheet.create({
itemText: { itemText: {
fontFamily: "Manrope_400Regular", fontFamily: "Manrope_400Regular",
fontSize: 15.42, fontSize: 15.42,
paddingLeft: 15, paddingLeft: 15,
}, },
selectedText: { selectedText: {
fontFamily: "Manrope_500Medium", fontFamily: "Manrope_500Medium",
fontSize: 13.2, fontSize: 13.2,
color: "#fd1775", color: "#fd1775",
}, },
dropdownStyle: { borderRadius: 6.61, height: 115.34, width: 187 }, dropdownStyle: {borderRadius: 6.61, height: 115.34, width: 187},
itemStyle: { padding: 0, margin: 0 }, itemStyle: {padding: 0, margin: 0},
}); });
export default EditGroceryItem; export default EditGroceryItem;

View File

@ -1,302 +1,294 @@
import { FlatList, StyleSheet } from "react-native"; import {FlatList, StyleSheet} from "react-native";
import React, { useEffect, useState } from "react"; import React, {useEffect, useState} from "react";
import { Text, TouchableOpacity, View } from "react-native-ui-lib"; import {Text, TouchableOpacity, View} from "react-native-ui-lib";
import GroceryItem from "./GroceryItem"; import GroceryItem from "./GroceryItem";
import { import {GroceryCategory, GroceryFrequency, useGroceryContext,} from "@/contexts/GroceryContext";
GroceryCategory,
GroceryFrequency,
useGroceryContext,
} from "@/contexts/GroceryContext";
import HeaderTemplate from "@/components/shared/HeaderTemplate"; import HeaderTemplate from "@/components/shared/HeaderTemplate";
import { AntDesign, MaterialIcons } from "@expo/vector-icons"; import {AntDesign} from "@expo/vector-icons";
import EditGroceryItem from "./EditGroceryItem"; import EditGroceryItem from "./EditGroceryItem";
import { ProfileType, useAuthContext } from "@/contexts/AuthContext"; import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
import { IGrocery } from "@/hooks/firebase/types/groceryData"; import {IGrocery} from "@/hooks/firebase/types/groceryData";
import AddPersonIcon from "@/assets/svgs/AddPersonIcon"; import AddPersonIcon from "@/assets/svgs/AddPersonIcon";
const GroceryList = () => { const GroceryList = () => {
const { const {
groceries, groceries,
updateGroceryItem, updateGroceryItem,
isAddingGrocery, isAddingGrocery,
setIsAddingGrocery, setIsAddingGrocery,
addGrocery, addGrocery,
} = useGroceryContext(); } = useGroceryContext();
const { profileData } = useAuthContext(); const {profileData} = useAuthContext();
const [approvedGroceries, setapprovedGroceries] = useState<IGrocery[]>( const [approvedGroceries, setapprovedGroceries] = useState<IGrocery[]>(
groceries?.filter((item) => item.approved === true) groceries?.filter((item) => item.approved)
); );
const [pendingGroceries, setPendingGroceries] = useState<IGrocery[]>( const [pendingGroceries, setPendingGroceries] = useState<IGrocery[]>(
groceries?.filter((item) => item.approved !== true) groceries?.filter((item) => !item.approved)
); );
const [category, setCategory] = useState<GroceryCategory>( const [category, setCategory] = useState<GroceryCategory>(
GroceryCategory.None GroceryCategory.None
); );
const [title, setTitle] = useState<string>(""); const [title, setTitle] = useState<string>("");
const [submit, setSubmitted] = useState<boolean>(false); const [submit, setSubmitted] = useState<boolean>(false);
const [pendingVisible, setPendingVisible] = useState<boolean>(true); const [pendingVisible, setPendingVisible] = useState<boolean>(true);
const [approvedVisible, setApprovedVisible] = useState<boolean>(true); const [approvedVisible, setApprovedVisible] = useState<boolean>(true);
// Group approved groceries by category // Group approved groceries by category
const approvedGroceriesByCategory = approvedGroceries?.reduce( const approvedGroceriesByCategory = approvedGroceries?.reduce(
(groups: any, item: IGrocery) => { (groups: any, item: IGrocery) => {
const category = item.category || "Uncategorized"; const category = item.category || "Uncategorized";
if (!groups[category]) { if (!groups[category]) {
groups[category] = []; groups[category] = [];
} }
groups[category].push(item); groups[category].push(item);
return groups; return groups;
}, },
{} {}
); );
useEffect(() => { useEffect(() => {
if (submit) { if (submit) {
if (title?.length > 2 && title?.length <= 25) { if (title?.length > 2 && title?.length <= 25) {
addGrocery({ addGrocery({
id: "", id: "",
title: title, title: title,
category: category, category: category,
approved: profileData?.userType === ProfileType.PARENT, approved: profileData?.userType === ProfileType.PARENT,
recurring: false, recurring: false,
frequency: GroceryFrequency.Never, frequency: GroceryFrequency.Never,
bought: false, bought: false,
}); });
setIsAddingGrocery(false); setIsAddingGrocery(false);
setSubmitted(false); setSubmitted(false);
setTitle(""); setTitle("");
} }
} }
}, [submit]); }, [submit]);
useEffect(() => { useEffect(() => {
/**/ setapprovedGroceries(groceries?.filter((item) => item.approved));
}, [category]); setPendingGroceries(groceries?.filter((item) => !item.approved));
}, [groceries]);
useEffect(() => { return (
setapprovedGroceries(groceries?.filter((item) => item.approved === true)); <View marginH-20 marginB-20>
setPendingGroceries(groceries?.filter((item) => item.approved !== true)); <HeaderTemplate
}, [groceries]); message={"Welcome to your grocery list"}
isWelcome={false}
return ( >
<View marginH-20 marginB-20> <View row centerV>
<HeaderTemplate <View
message={"Welcome to your grocery list"} backgroundColor="#e2eed8"
isWelcome={false} paddingH-15
> paddingV-8
<View row centerV> marginR-5
<View centerV
backgroundColor="#e2eed8" style={{borderRadius: 50}}
paddingH-15 >
paddingV-8 <Text text70BL color="#46a80a" style={styles.counterText}>
marginR-5 {approvedGroceries?.length} list{" "}
centerV {approvedGroceries?.length === 1 ? (
style={{ borderRadius: 50 }} <Text text70BL color="#46a80a" style={styles.counterText}>
> item
<Text text70BL color="#46a80a" style={styles.counterText}> </Text>
{approvedGroceries?.length} list{" "} ) : (
{approvedGroceries?.length === 1 ? ( <Text text70BL color="#46a80a" style={styles.counterText}>
<Text text70BL color="#46a80a" style={styles.counterText}> items
item </Text>
</Text> )}
) : ( </Text>
<Text text70BL color="#46a80a" style={styles.counterText}> </View>
items <View
</Text> backgroundColor="#faead2"
)} padding-8
</Text> paddingH-12
</View> marginR-15
<View style={{borderRadius: 50}}
backgroundColor="#faead2" >
padding-8 <Text text70 style={styles.counterText} color="#e28800">
paddingH-12 {pendingGroceries?.length} pending
marginR-15 </Text>
style={{ borderRadius: 50 }} </View>
> <TouchableOpacity>
<Text text70 style={styles.counterText} color="#e28800"> <AddPersonIcon width={24}/>
{pendingGroceries?.length} pending </TouchableOpacity>
</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 && (
<View style={{ marginTop: 8 }}>
<EditGroceryItem
editGrocery={{
title: title,
setCategory: setCategory,
category: category,
setTitle: setTitle,
setSubmit: setSubmitted,
closeEdit: () => setIsAddingGrocery(false)
}}
/>
</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 })
}
/>
)
)}
</View> </View>
)} </HeaderTemplate>
keyExtractor={(category) => category}
/> {/* Pending Approval Section */}
) <View row spread marginT-40 marginB-10 centerV>
: approvedVisible && ( <View row centerV>
<Text style={styles.noItemTxt}>No approved items.</Text> <Text style={styles.subHeader}>Pending Approval</Text>
)} {pendingVisible && (
</View> <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 && (
<View style={{marginTop: 8}}>
<EditGroceryItem
editGrocery={{
title: title,
setCategory: setCategory,
category: category,
setTitle: setTitle,
setSubmit: setSubmitted,
closeEdit: () => setIsAddingGrocery(false)
}}
/>
</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})
}
/>
)
)}
</View>
)}
keyExtractor={(category) => category}
/>
)
: approvedVisible && (
<Text style={styles.noItemTxt}>No approved items.</Text>
)}
</View>
);
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({
dropIcon: { dropIcon: {
marginHorizontal: 10, marginHorizontal: 10,
}, },
noItemTxt: { noItemTxt: {
fontFamily: "Manrope_400Regular", fontFamily: "Manrope_400Regular",
fontSize: 14, fontSize: 14,
}, },
counterText: { counterText: {
fontSize: 14, fontSize: 14,
fontFamily: "PlusJakartaSans_600SemiBold", fontFamily: "PlusJakartaSans_600SemiBold",
}, },
subHeader: { subHeader: {
fontSize: 15, fontSize: 15,
fontFamily: "Manrope_700Bold", fontFamily: "Manrope_700Bold",
}, },
counterNr: { counterNr: {
fontFamily: "PlusJakartaSans_600SemiBold", fontFamily: "PlusJakartaSans_600SemiBold",
fontSize: 14 fontSize: 14
} }
}); });
export default GroceryList; export default GroceryList;

View File

@ -1,38 +1,38 @@
import { Text, ScrollView } from "react-native"; import {ScrollView} from "react-native";
import { View } from "react-native-ui-lib"; import {View} from "react-native-ui-lib";
import React, { useEffect, useRef } from "react"; import React, {useEffect, useRef} from "react";
import AddGroceryItem from "./AddGroceryItem"; import AddGroceryItem from "./AddGroceryItem";
import GroceryList from "./GroceryList"; import GroceryList from "./GroceryList";
import { useGroceryContext } from "@/contexts/GroceryContext"; import {useGroceryContext} from "@/contexts/GroceryContext";
const GroceryWrapper = () => { const GroceryWrapper = () => {
const { isAddingGrocery } = useGroceryContext(); const {isAddingGrocery} = useGroceryContext();
const scrollViewRef = useRef<ScrollView>(null); // Reference to the ScrollView const scrollViewRef = useRef<ScrollView>(null); // Reference to the ScrollView
useEffect(() => { useEffect(() => {
if (isAddingGrocery && scrollViewRef.current) { if (isAddingGrocery && scrollViewRef.current) {
scrollViewRef.current.scrollTo({ scrollViewRef.current.scrollTo({
y: 400, // Adjust this value to scroll a bit down (100 is an example) y: 400, // Adjust this value to scroll a bit down (100 is an example)
animated: true, animated: true,
}); });
} }
}, [isAddingGrocery]); }, [isAddingGrocery]);
return ( return (
<View height={"100%"} paddingT-15 paddingH-15> <View height={"100%"} paddingT-15 paddingH-15>
<View height={"100%"}> <View height={"100%"}>
<ScrollView <ScrollView
ref={scrollViewRef} // Assign the ref to the ScrollView ref={scrollViewRef}
automaticallyAdjustKeyboardInsets={true} automaticallyAdjustKeyboardInsets={true}
> >
<View marginB-70> <View marginB-70>
<GroceryList /> <GroceryList/>
</View> </View>
</ScrollView> </ScrollView>
{!isAddingGrocery && <AddGroceryItem />} {!isAddingGrocery && <AddGroceryItem/>}
</View> </View>
</View> </View>
); );
}; };
export default GroceryWrapper; export default GroceryWrapper;

View File

@ -1,338 +1,353 @@
import { View, Text, Button, Switch, PickerModes } from "react-native-ui-lib";
import React, { useRef, useState } from "react";
import PointsSlider from "@/components/shared/PointsSlider";
import { repeatOptions, useToDosContext } from "@/contexts/ToDosContext";
import { Feather, AntDesign, Ionicons } from "@expo/vector-icons";
import { import {
Dialog, Button,
TextField, ButtonSize,
DateTimePicker, DateTimePicker,
Picker, Dialog,
ButtonSize, Picker,
PickerModes,
Switch,
Text,
TextField,
TextFieldRef,
View
} from "react-native-ui-lib"; } from "react-native-ui-lib";
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView"; import React, {useEffect, useRef, useState} from "react";
import { Dimensions, StyleSheet } from "react-native"; 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 DropModalIcon from "@/assets/svgs/DropModalIcon"; import DropModalIcon from "@/assets/svgs/DropModalIcon";
import { IToDo } from "@/hooks/firebase/types/todoData"; import {IToDo} from "@/hooks/firebase/types/todoData";
import AssigneesDisplay from "@/components/shared/AssigneesDisplay"; import AssigneesDisplay from "@/components/shared/AssigneesDisplay";
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers"; import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers";
import CalendarIcon from "@/assets/svgs/CalendarIcon"; import CalendarIcon from "@/assets/svgs/CalendarIcon";
import ClockIcon from "@/assets/svgs/ClockIcon";
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";
interface IAddChoreDialog { interface IAddChoreDialog {
isVisible: boolean; isVisible: boolean;
setIsVisible: (value: boolean) => void; setIsVisible: (value: boolean) => void;
selectedTodo?: IToDo; selectedTodo?: IToDo;
} }
const defaultTodo = { const defaultTodo = {
id: "", id: "",
title: "", title: "",
points: 10, points: 10,
date: new Date(), date: new Date(),
rotate: false, rotate: false,
repeatType: "Every week", repeatType: "Every week",
assignees: [], assignees: [],
repeatDays: [] repeatDays: []
}; };
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => { const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
const { addToDo, updateToDo } = useToDosContext(); const {addToDo, updateToDo} = useToDosContext();
const [todo, setTodo] = useState<IToDo>( const [todo, setTodo] = useState<IToDo>(
addChoreDialogProps.selectedTodo ?? defaultTodo addChoreDialogProps.selectedTodo ?? defaultTodo
); );
const [selectedAssignees, setSelectedAssignees] = useState<string[]>( const [selectedAssignees, setSelectedAssignees] = useState<string[]>(
addChoreDialogProps?.selectedTodo?.assignees ?? [] addChoreDialogProps?.selectedTodo?.assignees ?? []
); );
const { width, height } = Dimensions.get("screen"); const {width} = Dimensions.get("screen");
const [points, setPoints] = useState<number>(todo.points); const [points, setPoints] = useState<number>(todo.points);
const { data: members } = useGetFamilyMembers(); const titleRef = useRef<TextFieldRef>(null)
const handleClose = () => { const {data: members} = useGetFamilyMembers();
setTodo(defaultTodo);
setSelectedAssignees([]);
addChoreDialogProps.setIsVisible(false);
};
const handleChange = (text: string) => { const handleClose = () => {
const numericValue = parseInt(text, 10); setTodo(defaultTodo);
setSelectedAssignees([]);
addChoreDialogProps.setIsVisible(false);
};
if (!isNaN(numericValue) && numericValue >= 0 && numericValue <= 100) { const handleChange = (text: string) => {
setPoints(numericValue); const numericValue = parseInt(text, 10);
} else if (text === "") {
setPoints(0);
}
};
const handleRepeatDaysChange = (day: string, set: boolean) => { if (!isNaN(numericValue) && numericValue >= 0 && numericValue <= 100) {
if (set) { setPoints(numericValue);
const updatedTodo = { } else if (text === "") {
...todo, setPoints(0);
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);
}
}
return ( const handleRepeatDaysChange = (day: string, set: boolean) => {
<Dialog if (set) {
bottom={true} const updatedTodo = {
height={"90%"} ...todo,
width={width} repeatDays: [...todo.repeatDays, day]
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();
}}
/>
</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);
} }
}} setTodo(updatedTodo);
/> } else {
</View> const array = todo.repeatDays ?? [];
<TextField let index = array.indexOf(day);
placeholder="Add a To Do" array.splice(index, 1);
autoFocus const updatedTodo = {
value={todo?.title} ...todo,
onChangeText={(text) => { repeatDays: array
setTodo((oldValue: IToDo) => ({ ...oldValue, title: text })); }
}} setTodo(updatedTodo);
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>
<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 marginH-30 marginB-10 row centerV> useEffect(() => {
<ProfileIcon color="#919191" /> setTimeout(() => {
<Text style={styles.sub} marginL-10> titleRef?.current?.focus()
Assignees }, 500)
</Text> }, []);
<View flex-1 />
<Picker return (
marginL-8 <Dialog
value={selectedAssignees} bottom={true}
onChange={(value) => { height={"90%"}
setSelectedAssignees([...selectedAssignees, ...value]); width={width}
}} panDirection={PanningDirectionsEnum.DOWN}
style={{ marginVertical: 5 }} onDismiss={() => handleClose}
mode={PickerModes.MULTI} containerStyle={{
renderInput={() => ( borderRadius: 10,
<Button backgroundColor: "white",
size={ButtonSize.small} alignSelf: "stretch",
paddingH-8 padding: 0,
iconSource={() => ( paddingTop: 4,
<Ionicons name="add-outline" size={20} color="#ea156c" /> margin: 0,
)} }}
style={{ visible={addChoreDialogProps.isVisible}
marginLeft: "auto",
borderRadius: 8,
backgroundColor: "#ffe8f1",
borderColor: "#ea156c",
borderWidth: 1,
}}
color="#ea156c"
label="Assign"
labelStyle={{ fontFamily: "Manrope_600SemiBold", fontSize: 14 }}
/>
)}
> >
{members?.map((member) => ( <View row spread>
<Picker.Item <Button
key={member.uid} color="#05a8b6"
label={member?.firstName + " " + member?.lastName} style={styles.topBtn}
value={member?.uid!} label="Cancel"
/> onPress={() => {
))} handleClose();
</Picker> }}
</View> />
<View row marginL-27 marginT-0> <View marginT-12>
<AssigneesDisplay <DropModalIcon
selectedAttendees={selectedAssignees} onPress={() => {
setSelectedAttendees={setSelectedAssignees} handleClose();
/> }}
</View> />
<View row centerV style={styles.rotateSwitch}> </View>
<Text style={{ fontFamily: "PlusJakartaSans_500Medium", fontSize: 16 }}> <Button
Take Turns color="#05a8b6"
</Text> style={styles.topBtn}
<Switch label="Save"
onColor={"#ea156c"} onPress={() => {
value={todo.rotate} try {
style={{ width: 43.06, height: 27.13 }} if (addChoreDialogProps.selectedTodo) {
marginL-10 updateToDo({
onValueChange={(value) => ...todo,
setTodo((oldValue) => ({ ...oldValue, rotate: value })) points: points,
} assignees: selectedAssignees
/> });
</View> } else {
<View style={styles.divider} /> addToDo({
<View marginH-30 marginB-15 row centerV> ...todo,
<Ionicons name="gift-outline" size={25} color="#919191" /> done: false,
<Text style={styles.sub} marginL-10> points: points,
Reward Points assignees: selectedAssignees,
</Text> repeatDays: todo.repeatDays ?? []
</View> });
<PointsSlider }
points={points} handleClose();
setPoints={setPoints} } catch (error) {
handleChange={handleChange} console.error(error);
/> }
</Dialog> }}
); />
</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 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([...selectedAssignees, ...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}}
/>
)}
>
{members?.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>
);
}; };
export default AddChoreDialog; export default AddChoreDialog;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
divider: { height: 1, backgroundColor: "#e4e4e4", marginVertical: 15 }, divider: {height: 1, backgroundColor: "#e4e4e4", marginVertical: 15},
gradient: { gradient: {
height: "25%", height: "25%",
position: "absolute", position: "absolute",
bottom: 0, bottom: 0,
width: "100%", width: "100%",
}, },
buttonContainer: { buttonContainer: {
position: "absolute", position: "absolute",
bottom: 25, bottom: 25,
width: "100%", width: "100%",
}, },
button: { button: {
backgroundColor: "rgb(253, 23, 117)", backgroundColor: "rgb(253, 23, 117)",
paddingVertical: 20, paddingVertical: 20,
}, },
topBtn: { topBtn: {
backgroundColor: "white", backgroundColor: "white",
color: "#05a8b6", color: "#05a8b6",
}, },
rotateSwitch: { rotateSwitch: {
marginLeft: 35, marginLeft: 35,
marginBottom: 10, marginBottom: 10,
marginTop: 25, marginTop: 25,
}, },
sub: { sub: {
fontFamily: "Manrope_600SemiBold", fontFamily: "Manrope_600SemiBold",
fontSize: 18, fontSize: 18,
}, },
}); });