Open History to see the last commit
1import { Link } from "@tanstack/react-router";
2import { ChartColumn, Folder, FolderPlus, Trash } from "lucide-react";
3import { useState } from "react";
4import type { ReactNode } from "react";
5
6import { useAccount, useFolders, useNoteCounts } from "@/data/notes-data";
7
8import { AccountAvatar, QuickNotesIcon, SharedIcon } from "../icons";
9import {
10 GlassCircle,
11 GlassPill,
12 InsetCard,
13 InsetRow,
14 IosScreen,
15 LargeTitle,
16 RowChevron,
17 SearchAndCompose,
18 SectionHeader,
19} from "./ui";
20
21export function IosFoldersScreen() {
22 const folders = useFolders();
23 const counts = useNoteCounts();
24 const account = useAccount();
25 const [iCloudOpen, setICloudOpen] = useState(true);
26
27 const quickNotes = folders.find((folder) => folder.role === "quick-notes");
28 const iCloudFolders = folders.filter((folder) => folder.role !== "quick-notes");
29
30 return (
31 <IosScreen
32 trailing={
33 <>
34 <GlassCircle aria-label="New folder">
35 <FolderPlus />
36 </GlassCircle>
37 <GlassPill className="px-4 text-[17px]">Edit</GlassPill>
38 </>
39 }
40 bottom={<SearchAndCompose />}
41 >
42 <LargeTitle title="Folders" />
43
44 <InsetCard>
45 {quickNotes && (
46 <InsetRow first separatorInset={58}>
47 <FolderRow
48 folderId={quickNotes.id}
49 icon={<QuickNotesIcon className="size-[30px] rounded-[8px]" />}
50 name={quickNotes.name}
51 count={counts[quickNotes.id]}
52 />
53 </InsetRow>
54 )}
55 <InsetRow first={!quickNotes} separatorInset={58}>
56 <FolderRow
57 folderId="shared"
58 icon={<SharedIcon className="size-[30px] rounded-[8px]" />}
59 name="Shared"
60 count={counts.shared}
61 />
62 </InsetRow>
63 </InsetCard>
64
65 <SectionHeader chevron open={iCloudOpen} onToggle={() => setICloudOpen((open) => !open)}>
66 iCloud
67 </SectionHeader>
68 {iCloudOpen && (
69 <InsetCard>
70 <InsetRow first separatorInset={58}>
71 <FolderRow folderId="all" icon={<FolderGlyph />} name="All iCloud" count={counts.all} />
72 </InsetRow>
73 {iCloudFolders.map((folder) => (
74 <InsetRow key={folder.id} separatorInset={58}>
75 <FolderRow
76 folderId={folder.id}
77 icon={<FolderGlyph />}
78 name={folder.name}
79 count={counts[folder.id]}
80 />
81 </InsetRow>
82 ))}
83 <InsetRow separatorInset={58}>
84 <FolderRow
85 folderId="recently-deleted"
86 icon={<Trash className="size-[26px] text-notes-accent" strokeWidth={1.6} />}
87 name="Recently Deleted"
88 count={counts["recently-deleted"]}
89 />
90 </InsetRow>
91 </InsetCard>
92 )}
93
94 <SectionHeader chevron open={false}>
95 Tags
96 </SectionHeader>
97
98 <SectionHeader>Account</SectionHeader>
99 <InsetCard>
100 <InsetRow first separatorInset={58}>
101 <Link to="/settings" className="flex min-h-[60px] items-center gap-3 px-4 py-2">
102 <AccountAvatar name={account.name} className="size-[30px]" />
103 <span className="min-w-0 flex-1 leading-tight">
104 <span className="block truncate text-[17px]">{account.name}</span>
105 <span className="block truncate text-[14px] text-ios-secondary">{account.email}</span>
106 </span>
107 <RowChevron />
108 </Link>
109 </InsetRow>
110 <InsetRow separatorInset={58}>
111 <Link to="/analytics" className="flex h-[52px] items-center gap-3 px-4">
112 <span className="grid w-[30px] place-items-center">
113 <ChartColumn className="size-[24px] text-notes-accent" strokeWidth={1.8} />
114 </span>
115 <span className="flex-1 text-[17px]">Analytics</span>
116 <RowChevron />
117 </Link>
118 </InsetRow>
119 </InsetCard>
120 </IosScreen>
121 );
122}
123
124function FolderRow({
125 folderId,
126 icon,
127 name,
128 count,
129}: {
130 folderId: string;
131 icon: ReactNode;
132 name: string;
133 count: number | undefined;
134}) {
135 return (
136 <Link
137 to="/folders/$folderId"
138 params={{ folderId }}
139 className="flex h-[52px] items-center gap-3 px-4 active:bg-black/5 dark:active:bg-white/5"
140 >
141 <span className="grid w-[30px] place-items-center">{icon}</span>
142 <span className="min-w-0 flex-1 truncate text-[17px]">{name}</span>
143 <span className="text-[17px] text-ios-secondary tabular-nums">{count ?? 0}</span>
144 <RowChevron />
145 </Link>
146 );
147}
148
149function FolderGlyph() {
150 return <Folder className="size-[26px] text-notes-accent" strokeWidth={1.6} />;
151}