Change style of weight items
- Make them smaller - Bold+underline current day weight
This commit is contained in:
parent
cb5aa72552
commit
ab107793e4
|
@ -1,6 +1,6 @@
|
||||||
import { NavigationProp, useNavigation } from "@react-navigation/native";
|
import { NavigationProp, useNavigation } from "@react-navigation/native";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { useCallback } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import { List, Text } from "react-native-paper";
|
import { List, Text } from "react-native-paper";
|
||||||
import Settings from "./settings";
|
import Settings from "./settings";
|
||||||
import Weight from "./weight";
|
import Weight from "./weight";
|
||||||
|
@ -19,15 +19,31 @@ export default function WeightItem({
|
||||||
navigation.navigate("EditWeight", { weight: item });
|
navigation.navigate("EditWeight", { weight: item });
|
||||||
}, [item, navigation]);
|
}, [item, navigation]);
|
||||||
|
|
||||||
const description = useCallback(() => {
|
const today = useMemo(() => {
|
||||||
return <Text>{format(new Date(item.created), settings.date || "P")}</Text>;
|
const now = new Date();
|
||||||
}, [item.created, settings.date]);
|
const created = new Date(item.created);
|
||||||
|
return (
|
||||||
|
now.getFullYear() === created.getFullYear() &&
|
||||||
|
now.getMonth() === created.getMonth() &&
|
||||||
|
now.getDate() === created.getDate()
|
||||||
|
);
|
||||||
|
}, [item.created]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List.Item
|
<List.Item
|
||||||
onPress={press}
|
onPress={press}
|
||||||
title={`${item.value}${item.unit || "kg"}`}
|
title={`${item.value}${item.unit || "kg"}`}
|
||||||
description={description}
|
right={() => (
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
alignSelf: "center",
|
||||||
|
textDecorationLine: today ? "underline" : "none",
|
||||||
|
fontWeight: today ? "bold" : "normal",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{format(new Date(item.created), settings.date || "P")}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user