From 3424f0681621f5cdda8f8a26f9f5fcf6da58db33 Mon Sep 17 00:00:00 2001 From: Milan Paunovic Date: Sun, 20 Oct 2024 13:39:39 +0200 Subject: [PATCH] Added today button --- components/pages/calendar/CalendarHeader.tsx | 43 +++++++++++++------- components/pages/calendar/EventCalendar.tsx | 27 ++++++------ 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/components/pages/calendar/CalendarHeader.tsx b/components/pages/calendar/CalendarHeader.tsx index e97f064..fb902c8 100644 --- a/components/pages/calendar/CalendarHeader.tsx +++ b/components/pages/calendar/CalendarHeader.tsx @@ -1,10 +1,11 @@ import React, {memo} from 'react'; -import {Picker, PickerModes, SegmentedControl, Text, View} from "react-native-ui-lib"; +import {Button, Picker, PickerModes, SegmentedControl, Text, View} from "react-native-ui-lib"; 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"; export const CalendarHeader = memo(() => { const [selectedDate, setSelectedDate] = useAtom(selectedDateAtom); @@ -28,6 +29,8 @@ export const CalendarHeader = memo(() => { setSelectedDate(updatedDate); }; + const isSelectedDateToday = isSameDay(selectedDate, new Date()) + return ( { - - + + {!isSelectedDateToday && ( +