family chart, other fixes

This commit is contained in:
ivic00
2024-12-04 19:48:04 +01:00
parent c86a355b97
commit 1b288d095f
5 changed files with 208 additions and 175 deletions

View File

@ -68,7 +68,7 @@ export const ManuallyAddEventModal = () => {
setDeleteModalVisible(false); setDeleteModalVisible(false);
setSelectedNewEndDate(undefined); setSelectedNewEndDate(undefined);
setEditEvent(undefined); setEditEvent(undefined);
setCreator(null) setCreator(null);
}, },
initialDate: selectedNewEventDate || editEvent?.start, initialDate: selectedNewEventDate || editEvent?.start,
}; };
@ -85,7 +85,7 @@ export const ManuallyAddEventModal = () => {
useEffect(() => { useEffect(() => {
if (allDayAtom === true) setIsAllDay(true); if (allDayAtom === true) setIsAllDay(true);
}, [allDayAtom]) }, [allDayAtom]);
const [startTime, setStartTime] = useState(() => { const [startTime, setStartTime] = useState(() => {
const date = initialDate ?? new Date(); const date = initialDate ?? new Date();
@ -127,14 +127,16 @@ export const ManuallyAddEventModal = () => {
const { data: members } = useGetFamilyMembers(true); const { data: members } = useGetFamilyMembers(true);
const titleRef = useRef<TextFieldRef>(null); const titleRef = useRef<TextFieldRef>(null);
const [creator, setCreator] = useState(''); const [creator, setCreator] = useState("");
useEffect(() => { useEffect(() => {
if (editEvent) { if (editEvent) {
let creatorMember = members?.find((member) => member?.uid === editEvent.creatorId); let creatorMember = members?.find(
(member) => member?.uid === editEvent.creatorId
);
const fullName = `${creatorMember?.firstName ?? ""}`; const fullName = `${creatorMember?.firstName ?? ""}`;
setCreator(fullName); setCreator(fullName);
} }
}, [members]) }, [members]);
const isLoading = isDeleting || isAdding; const isLoading = isDeleting || isAdding;
@ -225,7 +227,7 @@ export const ManuallyAddEventModal = () => {
allDay: isAllDay, allDay: isAllDay,
attendees: selectedAttendees, attendees: selectedAttendees,
notes: details, notes: details,
location: location location: location,
}; };
if (editEvent?.id) eventData.id = editEvent?.id; if (editEvent?.id) eventData.id = editEvent?.id;
@ -242,7 +244,7 @@ export const ManuallyAddEventModal = () => {
const validateEvent = () => { const validateEvent = () => {
if (!title) { if (!title) {
Alert.alert('Alert', 'Title field cannot be empty'); Alert.alert("Alert", "Title field cannot be empty");
return false; return false;
} }
// if (!selectedAttendees || selectedAttendees?.length === 0) { // if (!selectedAttendees || selectedAttendees?.length === 0) {
@ -251,7 +253,7 @@ export const ManuallyAddEventModal = () => {
// } // }
return true; return true;
} };
const getRepeatLabel = () => { const getRepeatLabel = () => {
const selectedDays = repeatInterval; const selectedDays = repeatInterval;
@ -496,11 +498,16 @@ export const ManuallyAddEventModal = () => {
<DateTimePicker <DateTimePicker
value={endTime} value={endTime}
onChange={(time) => { onChange={(time) => {
if (time >= endTime) {
setEndTime(time); setEndTime(time);
if (
endDate.getDate() === startDate.getDate() &&
time.getHours() < startTime.getHours()
) {
const newEndDate = new Date(endDate);
newEndDate.setDate(newEndDate.getDate() + 1);
setEndDate(newEndDate);
} }
}} }}
minimumDate={startTime}
minuteInterval={5} minuteInterval={5}
dateTimeFormatter={(date, mode) => dateTimeFormatter={(date, mode) =>
date.toLocaleTimeString("en-us", { date.toLocaleTimeString("en-us", {
@ -647,13 +654,18 @@ export const ManuallyAddEventModal = () => {
setLocation(text); setLocation(text);
}} }}
placeholderTextColor="#2d2d30" placeholderTextColor="#2d2d30"
style={{ fontFamily: "Manrope_500Medium", fontSize: 16, minWidth: "100%"}} style={{
fontFamily: "Manrope_500Medium",
fontSize: 16,
minWidth: "100%",
}}
marginL-12 marginL-12
paddingR-12 paddingR-12
/> />
</View> </View>
</View> </View>
{editEvent && <> {editEvent && (
<>
<View style={styles.divider} /> <View style={styles.divider} />
<View marginH-32 marginB-0 centerV flex-1> <View marginH-32 marginB-0 centerV flex-1>
<View row centerV style={{ flexGrow: 1 }}> <View row centerV style={{ flexGrow: 1 }}>
@ -662,13 +674,19 @@ export const ManuallyAddEventModal = () => {
editable={false} editable={false}
value={creator} value={creator}
placeholderTextColor="#2d2d30" placeholderTextColor="#2d2d30"
style={{ fontFamily: "Manrope_500Medium", fontSize: 16, minWidth: "100%", color: "black"}} style={{
fontFamily: "Manrope_500Medium",
fontSize: 16,
minWidth: "100%",
color: "black",
}}
marginL-12 marginL-12
paddingR-12 paddingR-12
/> />
</View> </View>
</View> </View>
</>} </>
)}
<View style={styles.divider} /> <View style={styles.divider} />
<View marginH-30 marginB-0 spread centerV flex-1> <View marginH-30 marginB-0 spread centerV flex-1>
<TouchableOpacity onPress={() => detailsRef?.current?.focus()}> <TouchableOpacity onPress={() => detailsRef?.current?.focus()}>

View File

@ -43,6 +43,13 @@ const GroceryList = ({onInputFocus}: {onInputFocus: (y: number) => void}) => {
groups[category] = []; groups[category] = [];
} }
groups[category].push(item); groups[category].push(item);
// Sort items within each category - bought items at bottom
groups[category].sort((a: IGrocery, b: IGrocery) => {
if (a.bought === b.bought) return 0;
return a.bought ? 1 : -1;
});
return groups; return groups;
}, },
{} {}

View File

@ -177,9 +177,13 @@ const ToDoItem = (props: {
</View> </View>
)} )}
</View> </View>
<View row centerV marginL-3> <View row centerV marginL-5 marginT-2>
<Text <Text
style={{ fontSize: 12, fontFamily: "Manrope_500Medium" }} style={{
fontSize: 12,
fontFamily: "Manrope_500Medium",
color: "#858585",
}}
> >
Created by: {creator} Created by: {creator}
</Text> </Text>
@ -207,7 +211,7 @@ const ToDoItem = (props: {
aspectRatio: 1, aspectRatio: 1,
borderWidth: 2, borderWidth: 2,
borderRadius: 100, borderRadius: 100,
borderColor: member.eventColor || 'transparent' borderColor: member.eventColor || '#ccc',
}} }}
> >
<View <View

View File

@ -74,10 +74,22 @@ const FamilyChart = () => {
yAxisThickness={0} // Hide the Y-axis line yAxisThickness={0} // Hide the Y-axis line
yAxisLabelTexts={["0", "200", "400", "600", "800", "1000"]} // Custom Y-axis labels yAxisLabelTexts={["0", "200", "400", "600", "800", "1000"]} // Custom Y-axis labels
hideRules={false} // Show the horizontal lines hideRules={false} // Show the horizontal lines
rulesColor="#dadada" // Color for the horizontal lines rulesType="solid"
rulesThickness={1.2}
rulesColor="#DADADA" // Color for the horizontal lines
stackBorderTopLeftRadius={5} // Round the bars stackBorderTopLeftRadius={5} // Round the bars
stackBorderTopRightRadius={5} // Round the bars stackBorderTopRightRadius={5} // Round the bars
spacing={16} spacing={16}
xAxisLabelTextStyle={{
fontSize: 10.41,
fontFamily: "Manrope_600SemiBold",
color: "#7f7f7f",
}}
yAxisTextStyle={{
fontSize: 9.61,
fontFamily: "Manrope_400Regular",
color: "#7f7f7f",
}}
disableScroll disableScroll
/> />
); );

View File

@ -4,14 +4,23 @@ import { ImageBackground, StyleSheet } from "react-native";
import FamilyChart from "./FamilyChart"; import FamilyChart from "./FamilyChart";
import { TouchableOpacity } from "react-native-ui-lib/src/incubator"; import { TouchableOpacity } from "react-native-ui-lib/src/incubator";
import { Ionicons } from "@expo/vector-icons"; import { Ionicons } from "@expo/vector-icons";
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
import { ProfileType } from "@/contexts/AuthContext";
import { ScrollView } from "react-native-gesture-handler";
const FamilyChoresProgress = ({ const FamilyChoresProgress = ({
setPageIndex, setPageIndex,
}: { }: {
setPageIndex: (value: number) => void; setPageIndex: (value: number) => void;
}) => { }) => {
const { data: familyMembers } = useGetFamilyMembers();
const children = familyMembers?.filter(
(member) => member.userType === ProfileType.CHILD
);
return ( return (
<View marginT-20 marginH-5> <View marginT-20 marginH-5 marginB-100>
<ScrollView>
<TouchableOpacity onPress={() => setPageIndex(0)}> <TouchableOpacity onPress={() => setPageIndex(0)}>
<View row marginT-4 marginB-10 centerV> <View row marginT-4 marginB-10 centerV>
<Ionicons <Ionicons
@ -29,22 +38,25 @@ const FamilyChoresProgress = ({
</View> </View>
</TouchableOpacity> </TouchableOpacity>
<View centerH> <View centerH>
<Text style={{ fontFamily: "Manrope_700Bold", fontSize: 19 }}> <Text style={{ fontFamily: "Manrope_700Bold", fontSize: 23 }}>
Family Chores Progress Report Family Chores Progress Report
</Text> </Text>
</View> </View>
<View row spread marginT-35 marginB-20> <View row spread marginT-35 marginB-20>
<Text text70 style={{ fontFamily: "Manrope_600SemiBold" }}> <Text style={{ fontFamily: "Manrope_700Bold", fontSize: 15 }}>
Points earned this week Points earned this week
</Text> </Text>
<View row> <View row>
{children?.map((child, index) => (
<View <View
key={child.uid}
style={styles.pfpSmall} style={styles.pfpSmall}
backgroundColor="#05a8b6" backgroundColor={child.eventColor || "#05a8b6"}
center center
children={ >
{child.pfp ? (
<ImageBackground <ImageBackground
source={require("../../../../assets/images/child1-picture.png")} source={{ uri: child.pfp }}
style={{ style={{
height: 25, height: 25,
aspectRatio: 1, aspectRatio: 1,
@ -52,40 +64,43 @@ const FamilyChoresProgress = ({
overflow: "hidden", overflow: "hidden",
}} }}
/> />
} ) : (
/> <Text color="white" style={{fontSize: 15}}>
<View {child.firstName.at(0)}
style={styles.pfpSmall} {child.lastName.at(0)}
backgroundColor="#ebd825" </Text>
center )}
children={ </View>
<ImageBackground ))}
source={require("../../../../assets/images/child-picture.png")}
style={{
height: 25,
aspectRatio: 1,
borderRadius: 22,
overflow: "hidden",
}}
/>
}
/>
</View> </View>
</View> </View>
<View style={styles.card} paddingL-10> <View style={styles.card} paddingL-10>
<FamilyChart /> <FamilyChart />
</View> </View>
<Text text70 style={{ fontFamily: "Manrope_600SemiBold" }} marginV-20> <Text
text70
style={{ fontFamily: "Manrope_700Bold", fontSize: 15 }}
marginV-20
>
Chore Tracker Chore Tracker
</Text> </Text>
<View style={styles.card} marginB-20 row spread centerV> {children?.map((child) => (
<View
key={child.uid}
style={styles.card}
marginB-20
row
spread
centerV
>
<View <View
style={styles.pfpBig} style={styles.pfpBig}
backgroundColor="#05a8b6" backgroundColor={child.eventColor || "#05a8b6"}
center center
children={ >
{child.pfp ? (
<ImageBackground <ImageBackground
source={require("../../../../assets/images/child1-picture.png")} source={{ uri: child.pfp }}
style={{ style={{
height: 45, height: 45,
aspectRatio: 1, aspectRatio: 1,
@ -93,54 +108,31 @@ const FamilyChoresProgress = ({
overflow: "hidden", overflow: "hidden",
}} }}
/> />
} ) : (
/> <Text color="white" style={{ fontSize: 20 }}>
{child.firstName.at(0)}
{child.lastName.at(0)}
</Text>
)}
</View>
<Text <Text
color="#858585" color="#858585"
style={{ fontFamily: "Manrope_600SemiBold", fontSize: 17 }} style={{ fontFamily: "Manrope_600SemiBold", fontSize: 15 }}
> >
Emily {child.firstName}
</Text> </Text>
<View centerV> <View centerV>
<Text style={{ fontSize: 16, fontFamily: "Manrope_700Bold" }}> <Text style={{ fontSize: 15, fontFamily: "Manrope_700Bold" }}>
{" "}
x/y chores completed
</Text>
</View>
</View>
<View style={styles.card} row spread centerV>
<View
style={styles.pfpBig}
backgroundColor="#ebd825"
center
children={
<ImageBackground
source={require("../../../../assets/images/child-picture.png")}
style={{
height: 45,
aspectRatio: 1,
borderRadius: 22,
overflow: "hidden",
}}
/>
}
/>
<Text
color="#858585"
style={{ fontFamily: "Manrope_600SemiBold", fontSize: 17 }}
>
Austin
</Text>
<View row centerV centerH>
<Text style={{ fontSize: 16, fontFamily: "Manrope_700Bold" }}>
{" "}
x/y chores completed x/y chores completed
</Text> </Text>
</View> </View>
</View> </View>
))}
</ScrollView>
</View> </View>
); );
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({
pfpSmall: { pfpSmall: {
width: 30, width: 30,