From 844f534e13518dfec49372b7aa61fb0833317395 Mon Sep 17 00:00:00 2001 From: ivic00 <102467664+ivic00@users.noreply.github.com> Date: Sun, 10 Nov 2024 15:25:07 +0100 Subject: [PATCH] ui fixes and date press feature --- components/pages/calendar/EventCalendar.tsx | 17 +++++-- .../pages/calendar/ManuallyAddEventModal.tsx | 8 ++- components/pages/main/SignUpPage.tsx | 16 +++++- .../pages/settings/CalendarSettingsPage.tsx | 8 +-- components/shared/HeaderTemplate.tsx | 51 ++++++++++++------- 5 files changed, 66 insertions(+), 34 deletions(-) diff --git a/components/pages/calendar/EventCalendar.tsx b/components/pages/calendar/EventCalendar.tsx index 7aac708..ada0db9 100644 --- a/components/pages/calendar/EventCalendar.tsx +++ b/components/pages/calendar/EventCalendar.tsx @@ -71,12 +71,19 @@ export const EventCalendar: React.FC = React.memo( const handlePressDayHeader = useCallback( (date: Date) => { - setIsAllDay(true); - console.log(isAllDay); - setSelectedNewEndDate(date); - setEditVisible(true); + if (mode === "day") { + setIsAllDay(true); + setSelectedNewEndDate(date); + setEditVisible(true); + } + if (mode === 'week') + { + setSelectedDate(date) + + setMode("day") + } }, - [setSelectedNewEndDate] + [mode, setSelectedNewEndDate] ); const handleSwipeEnd = useCallback( diff --git a/components/pages/calendar/ManuallyAddEventModal.tsx b/components/pages/calendar/ManuallyAddEventModal.tsx index 4a50b94..b5df5a9 100644 --- a/components/pages/calendar/ManuallyAddEventModal.tsx +++ b/components/pages/calendar/ManuallyAddEventModal.tsx @@ -81,11 +81,9 @@ export const ManuallyAddEventModal = () => { ); useEffect(() => { - console.log(allDayAtom); - return () => { - setAllDayAtom(false); - }; - }, []); + if(allDayAtom === true) setIsAllDay(true); + }, [allDayAtom]) + const [startTime, setStartTime] = useState(() => { const date = initialDate ?? new Date(); diff --git a/components/pages/main/SignUpPage.tsx b/components/pages/main/SignUpPage.tsx index 967dc47..26279ac 100644 --- a/components/pages/main/SignUpPage.tsx +++ b/components/pages/main/SignUpPage.tsx @@ -142,9 +142,15 @@ const SignUpPage = () => { { setAllowFaceID(value); }} @@ -155,8 +161,14 @@ const SignUpPage = () => { setAcceptTerms(value)} /> diff --git a/components/pages/settings/CalendarSettingsPage.tsx b/components/pages/settings/CalendarSettingsPage.tsx index ee4ee64..68b7bd5 100644 --- a/components/pages/settings/CalendarSettingsPage.tsx +++ b/components/pages/settings/CalendarSettingsPage.tsx @@ -115,7 +115,8 @@ const CalendarSettingsPage = () => { handleChangeFirstDayOfWeek("Sundays")} /> @@ -130,8 +131,9 @@ const CalendarSettingsPage = () => { handleChangeFirstDayOfWeek("Mondays")} /> @@ -447,7 +449,7 @@ const styles = StyleSheet.create({ borderRadius: 12, }, checkbox: { - borderRadius: 50, + borderRadius: 100, }, addCalLbl: { fontSize: 16, diff --git a/components/shared/HeaderTemplate.tsx b/components/shared/HeaderTemplate.tsx index 4e77148..adbf51b 100644 --- a/components/shared/HeaderTemplate.tsx +++ b/components/shared/HeaderTemplate.tsx @@ -1,15 +1,16 @@ -import { Image, Text, View } from "react-native-ui-lib"; +import { Image, Text, TouchableOpacity, View } from "react-native-ui-lib"; import React, { useEffect, useState } from "react"; import { ProfileType, useAuthContext } from "@/contexts/AuthContext"; import { StyleSheet } from "react-native"; import { colorMap } from "@/constants/colorMap"; -import { useAtom } from "jotai"; -import { isFamilyViewAtom } from "../pages/calendar/atoms"; +import { useAtom, useSetAtom } from "jotai"; +import { isFamilyViewAtom, settingsPageIndex } from "../pages/calendar/atoms"; import { useGetChildrenByParentId } from "@/hooks/firebase/useGetChildrenByParentId"; import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers"; import { UserProfile } from "@/hooks/firebase/types/profileTypes"; import { child } from "@react-native-firebase/storage"; import CachedImage from "expo-cached-image"; +import { router } from "expo-router"; const HeaderTemplate = (props: { message: string; @@ -26,6 +27,7 @@ const HeaderTemplate = (props: { const { data: members } = useGetFamilyMembers(); const [children, setChildren] = useState([]); const [isFamilyView] = useAtom(isFamilyViewAtom); + const setSettingsPageIndexAtom = useSetAtom(settingsPageIndex); const headerHeight: number = (props.isCalendar && 65.54) || @@ -33,6 +35,11 @@ const HeaderTemplate = (props: { (props.isGroceries && 72.09) || 65.54; + const handlePfpPress = () => { + setSettingsPageIndexAtom(1); + router.push("/settings"); + }; + const styles = StyleSheet.create({ pfp: { height: headerHeight, @@ -84,11 +91,13 @@ const HeaderTemplate = (props: { {profileData?.pfp ? ( - + + + {isFamilyView && props.isCalendar && ( {children?.slice(0, 3).map((child, index) => { @@ -99,18 +108,22 @@ const HeaderTemplate = (props: { style={[styles.childrenPfp, { left: index * 19 }]} /> ) : ( - - - {child?.firstName?.at(0)} - {child?.firstName?.at(1)} - - + + + {child?.firstName?.at(0)} + {child?.firstName?.at(1)} + + + ); })} {children?.length > 3 && (