From e930ae111384aecbf6c854ceddb834641dcbc10c Mon Sep 17 00:00:00 2001 From: yoma Date: Thu, 9 Jul 2026 05:01:21 +0800 Subject: [PATCH] Add mobile notebook picker modal --- apps/mobile/src/screens/WorkspaceScreen.tsx | 116 ++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/apps/mobile/src/screens/WorkspaceScreen.tsx b/apps/mobile/src/screens/WorkspaceScreen.tsx index cfca8d2b..8192d2a0 100644 --- a/apps/mobile/src/screens/WorkspaceScreen.tsx +++ b/apps/mobile/src/screens/WorkspaceScreen.tsx @@ -232,6 +232,7 @@ export const WorkspaceScreen = () => { const [searchText, setSearchText] = useState(""); const [createOpen, setCreateOpen] = useState(false); const [notesActionsOpen, setNotesActionsOpen] = useState(false); + const [notebookPickerOpen, setNotebookPickerOpen] = useState(false); const [memoActionsMemo, setMemoActionsMemo] = useState(null); const [templatesOpen, setTemplatesOpen] = useState(false); const [editingMemo, setEditingMemo] = useState(null); @@ -833,6 +834,7 @@ export const WorkspaceScreen = () => { onFilterModeChange={setMemoFilterMode} onMemoListDensityChange={handleMemoListDensityChange} onOpenActions={() => setNotesActionsOpen(true)} + onOpenNotebookPicker={() => setNotebookPickerOpen(true)} onOpenTemplates={() => setTemplatesOpen(true)} onMemoPress={handleMemoPress} onMemoLongPress={(memo) => setMemoActionsMemo(memo)} @@ -922,6 +924,18 @@ export const WorkspaceScreen = () => { updateMutation={updateMemoMutation} /> + setNotebookPickerOpen(false)} + onSelect={(notebookId) => { + setActiveNotebookId(notebookId); + setNotebookPickerOpen(false); + }} + visible={notebookPickerOpen} + /> void; onMemoListDensityChange: (density: MobileMemoListDensity) => void; onOpenActions: () => void; + onOpenNotebookPicker: () => void; onMemoLongPress: (memo: MemoSummary) => void; onMemoPress: (memoId: string) => void; onOpenTemplates: () => void; @@ -1202,6 +1218,11 @@ const NotesView = ({ {memoCount} 条笔记 + {memoView === "notebook" ? ( + + + + ) : null} @@ -1325,6 +1346,101 @@ const NotesActionsModal = ({ ); +const NotebookPickerModal = ({ + activeNotebookId, + notebookSortMode, + notebooks, + notebooksMemoCount, + onClose, + onSelect, + visible, +}: { + activeNotebookId: string; + notebookSortMode: MobileNotebookSortMode; + notebooks: Notebook[]; + notebooksMemoCount: number; + onClose: () => void; + onSelect: (notebookId: string) => void; + visible: boolean; +}) => { + const [searchText, setSearchText] = useState(""); + const notebookOptions = flattenNotebooks(notebooks, notebookSortMode); + const visibleNotebookOptions = filterNotebookOptions(notebookOptions, searchText); + + useEffect(() => { + if (visible) { + setSearchText(""); + } + }, [visible]); + + return ( + + + + + + + 选择笔记本 + + + + + + + + {searchText ? ( + setSearchText("")}> + + + ) : null} + + + onSelect(ALL_NOTES_ID)} style={[styles.moveNotebookRow, activeNotebookId === ALL_NOTES_ID && styles.moveNotebookRowActive]}> + + + 全部笔记 + + {notebooksMemoCount} 条笔记 + + {activeNotebookId === ALL_NOTES_ID ? : null} + + + {searchText.trim() ? "匹配的笔记本" : "笔记本"} + {visibleNotebookOptions.map(({ depth, notebook }) => ( + onSelect(notebook.id)} + style={[styles.moveNotebookRow, activeNotebookId === notebook.id && styles.moveNotebookRowActive, depth > 0 && { marginLeft: Math.min(depth * 14, 42) }]} + > + + + {depth > 0 ? `${"· ".repeat(depth)}${notebook.name}` : notebook.name} + + {notebook.memoCount} 条笔记 + + {activeNotebookId === notebook.id ? : null} + + ))} + {visibleNotebookOptions.length === 0 ? ( + + + 没有匹配的笔记本 + + ) : null} + + + + ); +}; + const MemoActionsModal = ({ isBusy, memo,