diff --git a/apps/mobile/app/components/dialog/dialog-header.tsx b/apps/mobile/app/components/dialog/dialog-header.tsx index 8b1ab7053..57b26e3ae 100644 --- a/apps/mobile/app/components/dialog/dialog-header.tsx +++ b/apps/mobile/app/components/dialog/dialog-header.tsx @@ -35,6 +35,7 @@ type DialogHeaderProps = { loading?: boolean; title?: string; type?: PressableButtonProps["type"]; + icon?: string }; paragraphColor?: string; padding?: number; @@ -96,6 +97,7 @@ const DialogHeader = ({ loading={button.loading} fontSize={13} title={button.title} + icon={button.icon} type={button.type || "grayBg"} height={25} /> diff --git a/apps/mobile/app/components/list-items/note/index.js b/apps/mobile/app/components/list-items/note/index.js index 35520ba90..0d3de364c 100644 --- a/apps/mobile/app/components/list-items/note/index.js +++ b/apps/mobile/app/components/list-items/note/index.js @@ -35,6 +35,10 @@ import { IconButton } from "../../ui/icon-button"; import { TimeSince } from "../../ui/time-since"; import Heading from "../../ui/typography/heading"; import Paragraph from "../../ui/typography/paragraph"; +import { getUpcomingReminder } from "../../../utils/time"; +import { formatReminderTime } from "../../../utils/time/index"; +import { TouchableOpacity } from "react-native"; +import ReminderSheet from "../../sheets/reminder"; const navigateToTopic = (topic) => { TopicNotes.navigate(topic, true); @@ -86,6 +90,8 @@ const NoteItem = ({ const compactMode = notesListMode === "compact"; const attachmentCount = db.attachments?.ofNote(item.id, "all")?.length || 0; const notebooks = React.useMemo(() => getNotebook(item), [item]); + const reminders = db.relations.from(item, "reminder"); + const current = getUpcomingReminder(reminders); return ( <> @@ -154,6 +160,37 @@ const NoteItem = ({ ) : null} + {current && current.date ? ( + { + Properties.present(item); + }} + style={{ + backgroundColor: colors.nav, + borderRadius: 5, + flexDirection: "row", + paddingHorizontal: 5, + paddingVertical: 3, + alignItems: "center", + marginTop: 5, + justifyContent: "flex-start", + alignSelf: "flex-start" + }} + > + <> + + + {formatReminderTime(current)} + + + + ) : null} + {item.type === "note" ? ( diff --git a/apps/mobile/app/components/properties/index.js b/apps/mobile/app/components/properties/index.js index 90624dce0..0709254d1 100644 --- a/apps/mobile/app/components/properties/index.js +++ b/apps/mobile/app/components/properties/index.js @@ -124,7 +124,8 @@ export const Properties = ({ alignItems: "center", justifyContent: "flex-start", alignSelf: "flex-start", - marginBottom: 5 + marginBottom: 5, + marginTop: !item.description ? 5 : 0 }} > {item.date ? ( @@ -249,7 +250,7 @@ Properties.present = (item, buttons = [], isSheet) => { } if (!props[0]) return; presentSheet({ - context:isSheet ? "local" : undefined, + context: isSheet ? "local" : undefined, component: (ref, close) => ( { diff --git a/apps/mobile/app/components/sheets/reminders-list/index.tsx b/apps/mobile/app/components/sheets/relations-list/index.tsx similarity index 53% rename from apps/mobile/app/components/sheets/reminders-list/index.tsx rename to apps/mobile/app/components/sheets/relations-list/index.tsx index 3b6447632..108c94f6b 100644 --- a/apps/mobile/app/components/sheets/reminders-list/index.tsx +++ b/apps/mobile/app/components/sheets/relations-list/index.tsx @@ -16,20 +16,25 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import React, { RefObject, useState } from "react"; +import React, { RefObject, useEffect, useState } from "react"; import { View } from "react-native"; import ActionSheet from "react-native-actions-sheet"; +import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import { db } from "../../../common/database"; import { - presentSheet, - PresentSheetOptions + PresentSheetOptions, + presentSheet } from "../../../services/event-manager"; +import { Reminder } from "../../../services/notifications"; +import { useRelationStore } from "../../../stores/use-relation-store"; +import { useThemeStore } from "../../../stores/use-theme-store"; +import { SIZE } from "../../../utils/size"; import DialogHeader from "../../dialog/dialog-header"; import List from "../../list"; -import { useEffect } from "react"; -import { Reminder } from "../../../services/notifications"; -import { PressableButtonProps } from "../../ui/pressable"; import SheetProvider from "../../sheet-provider"; +import { Button } from "../../ui/button"; +import { PressableButtonProps } from "../../ui/pressable"; +import Paragraph from "../../ui/typography/paragraph"; type RelationsListProps = { actionSheetRef: RefObject; @@ -40,6 +45,7 @@ type RelationsListProps = { relationType: "to" | "from"; title: string; button?: Button; + onAdd: () => void; }; type Button = { @@ -47,6 +53,11 @@ type Button = { loading?: boolean | undefined; title?: string | undefined; type?: PressableButtonProps["type"]; + icon?: string; +}; + +const IconsByType = { + reminder: "bell" }; export const RelationsList = ({ @@ -57,27 +68,68 @@ export const RelationsList = ({ referenceType, relationType, title, - button + button, + onAdd }: RelationsListProps) => { + const relations = useRelationStore(); const [items, setItems] = useState([]); + const colors = useThemeStore((state) => state.colors); + const hasNoReminders = !items || items.length === 0; useEffect(() => { - db.relations?.[relationType]?.( - { id: item?.id, type: item.type }, - referenceType - ).then((items) => setItems(items as any)); - }, [item?.id, item?.type, referenceType, relationType]); + setItems( + db.relations?.[relationType]?.( + { id: item?.id, type: item.type }, + referenceType + ) as any + ); + }, [item?.id, item?.type, referenceType, relationType, relations.updater]); + console.log(items); return ( - + - - + {hasNoReminders ? ( + + + + No {referenceType}s linked to this {item.type}. + + )} + +