/* 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 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 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, { useRef } from "react"; import { Dimensions, Platform, View, useWindowDimensions } from "react-native"; import { FlatList } from "react-native-actions-sheet"; import { db } from "../../common/database"; import { DDS } from "../../services/device-detection"; import { presentSheet } from "../../services/event-manager"; import SearchService from "../../services/search"; import { useThemeColors } from "@notesnook/theme"; import { ColorValues } from "../../utils/colors"; import { SIZE } from "../../utils/size"; import SheetProvider from "../sheet-provider"; import { ReminderTime } from "../ui/reminder-time"; import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; import { DateMeta } from "./date-meta"; import { Items } from "./items"; import Notebooks from "./notebooks"; import { Synced } from "./synced"; import { Tags, TagStrip } from "./tags"; const Line = ({ top = 6, bottom = 6 }) => { const { colors } = useThemeColors(); return ( ); }; export const Properties = ({ close = () => {}, item, buttons = [] }) => { const { colors } = useThemeColors(); const alias = item.alias || item.title; const isColor = !!ColorValues[item.title]; if (!item || !item.id) { return ( Start writing to save your note. ); } return ( "properties-scroll-item"} renderItem={() => ( {item.type === "tag" && !isColor ? ( # ) : null} {alias} {item.type === "note" ? ( ) : null} {item.type === "reminder" ? ( ) : null} {item.type === "note" ? : null} { close(); setTimeout(() => { SearchService.updateAndSearch(); }, 1000); }} /> {DDS.isTab ? ( ) : null} )} /> ); }; Properties.present = (item, buttons = [], isSheet) => { if (!item) return; let type = item?.type; let props = []; let android = []; switch (type) { case "trash": props[0] = item; props.push(["delete", "restore"]); break; case "note": android = Platform.OS === "android" ? ["pin-to-notifications"] : []; props[0] = db.notes.note(item.id).data; props.push([ "notebooks", "add-reminder", "share", "export", "copy", "publish", "pin", "favorite", "attachments", "lock-unlock", "trash", "remove-from-topic", "remove-from-notebook", "history", "read-only", "reminders", "local-only", "duplicate", ...android, ...buttons ]); break; case "notebook": props[0] = db.notebooks.notebook(item.id).data; props.push([ "edit-notebook", "pin", "add-shortcut", "trash", "default-notebook" ]); break; case "topic": props[0] = db.notebooks .notebook(item.notebookId) .topics.topic(item.id)._topic; props.push([ "move-notes", "edit-topic", "add-shortcut", "trash", "default-topic" ]); break; case "tag": props[0] = db.tags.tag(item.id); props.push(["add-shortcut", "trash", "rename-tag"]); break; case "reminder": { props[0] = db.reminders.reminder(item.id); props.push(["edit-reminder", "trash", "disable-reminder"]); break; } } if (!props[0]) return; presentSheet({ context: isSheet ? "local" : undefined, component: (ref, close) => ( { close(); }} actionSheetRef={ref} item={props[0]} buttons={props[1]} /> ) }); };