diff --git a/apps/mobile/app/components/list-items/note/index.tsx b/apps/mobile/app/components/list-items/note/index.tsx index afbaae87e..75814a332 100644 --- a/apps/mobile/app/components/list-items/note/index.tsx +++ b/apps/mobile/app/components/list-items/note/index.tsx @@ -55,6 +55,7 @@ import { TimeSince } from "../../ui/time-since"; import Heading from "../../ui/typography/heading"; import Paragraph from "../../ui/typography/paragraph"; import dayjs from "dayjs"; +import { ExpiryDate } from "../../ui/expiry-date"; type NoteItemProps = { item: Note | BaseTrashItem; @@ -266,6 +267,21 @@ const NoteItem = ({ /> ) : null} + {item.expiryDate?.value ? ( + + ) : null} + {notebooks?.items ?.filter( (item) => diff --git a/apps/mobile/app/components/ui/expiry-date/index.tsx b/apps/mobile/app/components/ui/expiry-date/index.tsx new file mode 100644 index 000000000..e5eba35fd --- /dev/null +++ b/apps/mobile/app/components/ui/expiry-date/index.tsx @@ -0,0 +1,86 @@ +/* +This file is part of the Notesnook project (https://notesnook.com/) + +Copyright (C) 2023 Streetwriters (Private) Limited + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ +import { Note } from "@notesnook/core"; +import { useThemeColors } from "@notesnook/theme"; +import React from "react"; +import { TextStyle, ViewStyle } from "react-native"; +import { AppFontSize, defaultBorderRadius } from "../../../utils/size"; +import { DefaultAppStyles } from "../../../utils/styles"; +import { Button, ButtonProps } from "../button"; +import dayjs from "dayjs"; + +export const ExpiryDate = ({ + note, + color, + style, + textStyle, + iconSize, + short, + ...props +}: { + note: Note; + color?: string; + style?: ViewStyle; + textStyle?: TextStyle; + iconSize?: number; + short?: boolean; +} & ButtonProps) => { + const { colors } = useThemeColors(); + + const expiryValue = note?.expiryDate?.value; + if (!expiryValue) return null; + + const expiryDate = dayjs(expiryValue); + const now = dayjs(); + const isToday = expiryDate.isSame(now, "day"); + const isTomorrow = expiryDate.isSame(now.add(1, "day"), "day"); + + const formattedDate = isToday + ? "Today" + : isTomorrow + ? "Tomorrow" + : expiryDate.format("DD MMM YYYY"); + + const isUrgent = isToday || isTomorrow; + + return ( +