From ab107793e42b39f59a619b944c2cc37437ef0d22 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Tue, 24 Oct 2023 16:16:59 +1300 Subject: [PATCH] Change style of weight items - Make them smaller - Bold+underline current day weight --- WeightItem.tsx | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/WeightItem.tsx b/WeightItem.tsx index 04c9313..3ae9062 100644 --- a/WeightItem.tsx +++ b/WeightItem.tsx @@ -1,6 +1,6 @@ import { NavigationProp, useNavigation } from "@react-navigation/native"; import { format } from "date-fns"; -import { useCallback } from "react"; +import { useCallback, useMemo } from "react"; import { List, Text } from "react-native-paper"; import Settings from "./settings"; import Weight from "./weight"; @@ -19,15 +19,31 @@ export default function WeightItem({ navigation.navigate("EditWeight", { weight: item }); }, [item, navigation]); - const description = useCallback(() => { - return {format(new Date(item.created), settings.date || "P")}; - }, [item.created, settings.date]); + const today = useMemo(() => { + const now = new Date(); + const created = new Date(item.created); + return ( + now.getFullYear() === created.getFullYear() && + now.getMonth() === created.getMonth() && + now.getDate() === created.getDate() + ); + }, [item.created]); return ( ( + + {format(new Date(item.created), settings.date || "P")} + + )} /> ); }