From ef2a4f51266b035bdefd159a3e14ac70cc377de0 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Mon, 24 Feb 2025 10:02:36 +0500 Subject: [PATCH] mobile: refactor some sheets into screens --- .../components/container/floating-button.tsx | 12 +- .../app/components/selection-header/index.tsx | 7 +- .../components/sheets/add-notebook/index.tsx | 20 +- .../mobile/app/components/side-menu/index.tsx | 11 +- apps/mobile/app/components/toast/index.tsx | 22 +- .../mobile/app/components/ui/notice/index.tsx | 24 +- apps/mobile/app/hooks/use-actions.tsx | 21 +- .../app/navigation/navigation-stack.tsx | 9 + .../link-notebooks}/index.tsx | 299 +- .../move-notebook/index.tsx | 122 +- .../move-notes/index.tsx} | 275 +- apps/mobile/app/services/navigation.ts | 5 +- .../mobile/app/stores/use-navigation-store.ts | 13 +- packages/intl/locale/en.po | 3004 ++++++------- packages/intl/locale/pseudo-LOCALE.po | 3724 +++++++++-------- packages/intl/src/strings.ts | 7 +- 16 files changed, 3829 insertions(+), 3746 deletions(-) rename apps/mobile/app/{components/sheets/add-to => screens/link-notebooks}/index.tsx (60%) rename apps/mobile/app/{components/sheets => screens}/move-notebook/index.tsx (80%) rename apps/mobile/app/{components/sheets/move-notes/movenote.tsx => screens/move-notes/index.tsx} (51%) diff --git a/apps/mobile/app/components/container/floating-button.tsx b/apps/mobile/app/components/container/floating-button.tsx index c3ef0056c..3dc8e7990 100644 --- a/apps/mobile/app/components/container/floating-button.tsx +++ b/apps/mobile/app/components/container/floating-button.tsx @@ -41,12 +41,16 @@ interface FloatingButtonProps { color?: string; shouldShow?: boolean; alwaysVisible?: boolean; + icon?: string; + testID?: string; } const FloatingButton = ({ onPress, color, - alwaysVisible = false + alwaysVisible = false, + icon, + testID }: FloatingButtonProps) => { const { colors } = useThemeColors(); const deviceMode = useSettingStore((state) => state.deviceMode); @@ -116,7 +120,7 @@ const FloatingButton = ({ ]} > { const ids = selectedItemsList; const notebooks = await db.notebooks.all.items(ids); - MoveNotebookSheet.present(notebooks); + MoveNotebook.present(notebooks); }, visible: renderedInRoute === "Notebooks", icon: "arrow-right-bold-box-outline" @@ -230,7 +229,7 @@ export const SelectionHeader = React.memo( title: strings.linkNotebook(), onPress: async () => { await sleep(100); - MoveNoteSheet.present(); + // MoveNoteSheet.present(); }, visible: type === "note", icon: "plus" diff --git a/apps/mobile/app/components/sheets/add-notebook/index.tsx b/apps/mobile/app/components/sheets/add-notebook/index.tsx index 81e4bbd57..4d8e3a1f4 100644 --- a/apps/mobile/app/components/sheets/add-notebook/index.tsx +++ b/apps/mobile/app/components/sheets/add-notebook/index.tsx @@ -40,7 +40,6 @@ import { Button } from "../../ui/button"; import Input from "../../ui/input"; import Seperator from "../../ui/seperator"; import Heading from "../../ui/typography/heading"; -import { MoveNotes } from "../move-notes/movenote"; export const AddNotebookSheet = ({ notebook, @@ -103,11 +102,22 @@ export const AddNotebookSheet = ({ useNotebookStore.getState().refresh(); } - if (!notebook && showMoveNotesOnComplete && id) { - MoveNotes.present(await db.notebooks.notebook(id)); - } else { - close?.(true); + if (showMoveNotesOnComplete && id) { + ToastManager.show({ + heading: "Notebook added", + type: "success", + context: "global", + actionText: "Link notes", + duration: 8000, + func: async () => { + Navigation.navigate("MoveNotes", { + notebook: (await db.notebooks.notebook(id)) as Notebook + }); + ToastManager.hide(); + } + }); } + close?.(true); }; return ( diff --git a/apps/mobile/app/components/side-menu/index.tsx b/apps/mobile/app/components/side-menu/index.tsx index a7a785467..78a0f50f2 100644 --- a/apps/mobile/app/components/side-menu/index.tsx +++ b/apps/mobile/app/components/side-menu/index.tsx @@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +import { strings } from "@notesnook/intl"; import { useThemeColors } from "@notesnook/theme"; import React from "react"; import { View } from "react-native"; @@ -34,12 +35,13 @@ import { db } from "../../common/database"; import { useGroupOptions } from "../../hooks/use-group-options"; import { presentSheet, ToastManager } from "../../services/event-manager"; import Navigation from "../../services/navigation"; +import { useTagStore } from "../../stores/use-tag-store"; import { useThemeStore } from "../../stores/use-theme-store"; import { deleteItems } from "../../utils/functions"; import { AppFontSize } from "../../utils/size"; import { DefaultAppStyles } from "../../utils/styles"; +import { presentDialog } from "../dialog/functions"; import { AddNotebookSheet } from "../sheets/add-notebook"; -import { MoveNotebookSheet } from "../sheets/move-notebook"; import Sort from "../sheets/sort"; import { IconButton } from "../ui/icon-button"; import { Pressable } from "../ui/pressable"; @@ -51,9 +53,6 @@ import { useSideMenuNotebookSelectionStore, useSideMenuTagsSelectionStore } from "./stores"; -import { presentDialog } from "../dialog/functions"; -import { strings } from "@notesnook/intl"; -import { useTagStore } from "../../stores/use-tag-store"; const renderScene = SceneMap({ home: SideMenuHome, notebooks: SideMenuNotebooks, @@ -206,7 +205,9 @@ const TabBar = ( .getState() .getSelectedItemIds(); const notebooks = await db.notebooks.all.items(ids); - MoveNotebookSheet.present(notebooks); + Navigation.navigate("MoveNotebook", { + selectedNotebooks: notebooks + }); break; } case "Close": { diff --git a/apps/mobile/app/components/toast/index.tsx b/apps/mobile/app/components/toast/index.tsx index a6cf538bc..3608d9d81 100644 --- a/apps/mobile/app/components/toast/index.tsx +++ b/apps/mobile/app/components/toast/index.tsx @@ -37,10 +37,11 @@ import { } from "../../services/event-manager"; import { getElevationStyle } from "../../utils/elevation"; import { eHideToast, eShowToast } from "../../utils/events"; -import { AppFontSize } from "../../utils/size"; +import { AppFontSize, defaultBorderRadius } from "../../utils/size"; import { Button } from "../ui/button"; import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; +import { DefaultAppStyles } from "../../utils/styles"; export const Toast = ({ context = "global" }) => { const { colors, isDark } = useThemeColors(); @@ -133,14 +134,14 @@ export const Toast = ({ context = "global" }) => { ...getElevationStyle(5), backgroundColor: isDark ? colors.static.black : colors.static.white, alignSelf: "center", - borderRadius: 100, + borderRadius: defaultBorderRadius * 2, paddingVertical: 12, paddingHorizontal: 12, justifyContent: "space-between", flexDirection: "row", alignItems: "center", - maxWidth: "95%", - gap: 10, + maxWidth: "90%", + gap: DefaultAppStyles.GAP_SMALL, flexShrink: 1 }} > @@ -148,7 +149,7 @@ export const Toast = ({ context = "global" }) => { style={{ flexDirection: "row", alignItems: "center", - gap: 10, + gap: DefaultAppStyles.GAP_SMALL, flexShrink: 1 }} > @@ -178,7 +179,6 @@ export const Toast = ({ context = "global" }) => { @@ -194,7 +194,7 @@ export const Toast = ({ context = "global" }) => { {toastOptions.message || toastOptions.heading ? ( {toastOptions.message || toastOptions.heading} @@ -205,10 +205,12 @@ export const Toast = ({ context = "global" }) => { {toastOptions.func ? (