AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
feat(mobile): share core UI contract
tianma-ifdb4b8bd86c7f
diff --git a/apps/mobile/src/screens/WorkspaceScreen.tsx b/apps/mobile/src/screens/WorkspaceScreen.tsxindex 9e5dd15f..34ca868e 100644--- a/apps/mobile/src/screens/WorkspaceScreen.tsx+++ b/apps/mobile/src/screens/WorkspaceScreen.tsx@@ -78,6 +78,7 @@ import { Alert, Pressable, Text, TextInput } from "../components/LocalizedText";import Markdown, { type RenderRules } from "react-native-markdown-display";import { SvgXml } from "react-native-svg";import { buildRevisionDiffRows, createExcerpt, docToMarkdown, docToText, getNotebookDescendantIds, markdownToDoc, type ApiToken, type AuthUser, type MemoDetail, type MemoRevision, type MemoSummary, type Notebook, type ResourceListItem, type RevisionDiffRow, type TagSummary, type TiptapDoc } from "@edgeever/shared";+import { MOBILE_UI_METRICS, toggleMobileMemoFilterMode } from "@edgeever/shared/mobile-ui";import { clearMobileMemoDraft, clearMobileNewMemoDraft, readMobileMemoDraft, readMobileNewMemoDraft, writeMobileMemoDraft, writeMobileNewMemoDraft, type MobileMemoDraft } from "../lib/mobile-drafts";import {readMobileImageCompressionEnabled,@@ -1033,9 +1034,9 @@ export const WorkspaceScreen = () => {}}onSetMemoView={(nextMemoView) => nextMemoView === "trash" ? showTrash() : showAllNotes()}searchText={searchText}- searchTotalCount={searchActive+ totalMemoCount={searchActive? searchQuery.data?.pages[0]?.totalCount ?? searchResults.length- : 0}+ : memosQuery.data?.pages[0]?.totalCount ?? memos.length}selectionMode={selectionMode}selectedMemoIds={selectedMemoIds}error={searchActive ? searchQuery.error : memosQuery.error}@@ -1203,7 +1204,7 @@ export const WorkspaceScreen = () => {{activeView !== "settings" && !selectionMode ? (<View- style={[styles.bottomNav, { height: 52 + safeAreaInsets.bottom, paddingBottom: safeAreaInsets.bottom }]}+ style={[styles.bottomNav, { height: MOBILE_UI_METRICS.bottomNavigationHeight + safeAreaInsets.bottom, paddingBottom: safeAreaInsets.bottom }]}><BottomNavItemactive={activeView === "notes"}@@ -1256,7 +1257,7 @@ const NotesView = ({onSearchTextChange,onSetMemoView,searchText,- searchTotalCount,+ totalMemoCount,selectedMemoIds,selectionMode,}: {@@ -1283,17 +1284,27 @@ const NotesView = ({onSearchTextChange: (value: string) => void;onSetMemoView: (memoView: MemoView) => void;searchText: string;- searchTotalCount: number;+ totalMemoCount: number;selectionMode: boolean;selectedMemoIds: Set<string>;}) => {const { resolvedTheme } = useMobileTheme();const localePreference = useMobileLocalePreference();const searchActive = searchText.trim().length > 0;+ const filterActive = memoFilterMode !== "all";const englishLocale = isEnglishMobileLocale(localePreference);const searchStatusLabel = englishLocale ? "Searching" : "正在搜索";- const searchResultLabel = englishLocale ? `${searchTotalCount} ${searchTotalCount === 1 ? "result" : "results"}` : `${searchTotalCount} 条结果`;+ const searchResultLabel = englishLocale ? `${totalMemoCount} ${totalMemoCount === 1 ? "result" : "results"}` : `${totalMemoCount} 条结果`;const exitSearchLabel = englishLocale ? "Exit search" : "退出搜索";+ const activeFilterLabel = memoFilterMode === "pinned"+ ? (englishLocale ? "Pinned" : "置顶")+ : memoFilterMode === "tagged"+ ? (englishLocale ? "Tagged" : "有标签")+ : (englishLocale ? "Untagged" : "无标签");+ const filterResultLabel = englishLocale+ ? `Filter: ${activeFilterLabel} · ${totalMemoCount} ${totalMemoCount === 1 ? "note" : "notes"}`+ : `筛选:${activeFilterLabel} · ${totalMemoCount} 条`;+ const resetFilterLabel = englishLocale ? "Reset" : "重置";return (<View style={styles.viewBody}>@@ -1350,30 +1361,40 @@ const NotesView = ({active={memoFilterMode === "pinned"}icon={<Sparkles color={memoFilterMode === "pinned" ? "#ffffff" : "#475569"} size={18} />}label="置顶"- onPress={() => onFilterModeChange(memoFilterMode === "pinned" ? "all" : "pinned")}+ onPress={() => onFilterModeChange(toggleMobileMemoFilterMode(memoFilterMode, "pinned"))}/><MobileFilterButtonactive={memoFilterMode === "tagged"}icon={<Tag color={memoFilterMode === "tagged" ? "#ffffff" : "#475569"} size={18} />}label="有标签"- onPress={() => onFilterModeChange(memoFilterMode === "tagged" ? "all" : "tagged")}+ onPress={() => onFilterModeChange(toggleMobileMemoFilterMode(memoFilterMode, "tagged"))}/><MobileFilterButtonactive={memoFilterMode === "untagged"}icon={<Tag color={memoFilterMode === "untagged" ? "#ffffff" : "#475569"} size={18} />}label="无标签"- onPress={() => onFilterModeChange(memoFilterMode === "untagged" ? "all" : "untagged")}+ onPress={() => onFilterModeChange(toggleMobileMemoFilterMode(memoFilterMode, "untagged"))}/></View>- {searchActive ? (- <View accessibilityLiveRegion="polite" style={styles.mobileListConstraint}>- <View style={styles.mobileSearchStatusPill}>- <Search color="#ffffff" size={12} />- <Text style={styles.mobileSearchStatusPillText}>{searchStatusLabel}</Text>- </View>- <Text numberOfLines={1} style={styles.mobileListConstraintText}>{searchResultLabel}</Text>- <Pressable accessibilityLabel={exitSearchLabel} accessibilityRole="button" onPress={() => onSearchTextChange("")}>- <Text style={styles.mobileListConstraintAction}>{exitSearchLabel}</Text>+ {searchActive || filterActive ? (+ <View accessibilityLiveRegion="polite" style={[styles.mobileListConstraint, !searchActive && styles.mobileListConstraintFilter]}>+ {searchActive ? (+ <View style={styles.mobileSearchStatusPill}>+ <Search color="#ffffff" size={12} />+ <Text style={styles.mobileSearchStatusPillText}>{searchStatusLabel}</Text>+ </View>+ ) : null}+ <Text numberOfLines={1} style={[styles.mobileListConstraintText, !searchActive && styles.mobileListConstraintTextFilter]}>+ {searchActive ? searchResultLabel : filterResultLabel}+ </Text>+ <Pressable+ accessibilityLabel={searchActive ? exitSearchLabel : resetFilterLabel}+ accessibilityRole="button"+ onPress={searchActive ? () => onSearchTextChange("") : () => onFilterModeChange("all")}+ >+ <Text style={[styles.mobileListConstraintAction, !searchActive && styles.mobileListConstraintActionFilter]}>+ {searchActive ? exitSearchLabel : resetFilterLabel}+ </Text></Pressable></View>) : null}@@ -4995,7 +5016,7 @@ const MemoCard = memo(function MemoCard({</View>{listDensity === "preview" ? (<Text numberOfLines={2} style={styles.memoExcerpt}>- {memo.excerpt || "没有正文预览"}+ {memo.excerpt || "空笔记"}</Text>) : null}<View style={[styles.memoMeta, listDensity === "compact" && styles.memoMetaCompact]}>@@ -6103,14 +6124,14 @@ const baseWorkspaceStyles = StyleSheet.create({flexDirection: "row",justifyContent: "space-between",marginBottom: 12,- minHeight: 36,+ minHeight: MOBILE_UI_METRICS.compactControlHeight,},mobileNotebookTitleButton: {alignItems: "center",flexDirection: "row",flexShrink: 1,gap: 4,- minHeight: 36,+ minHeight: MOBILE_UI_METRICS.compactControlHeight,paddingRight: 12,},mobileNotebookTitle: {@@ -6121,10 +6142,10 @@ const baseWorkspaceStyles = StyleSheet.create({},mobileMoreButton: {alignItems: "center",- borderRadius: 18,- height: 36,+ borderRadius: MOBILE_UI_METRICS.compactControlHeight / 2,+ height: MOBILE_UI_METRICS.compactControlHeight,justifyContent: "center",- width: 36,+ width: MOBILE_UI_METRICS.compactControlHeight,},mobileSearchRow: {alignItems: "center",@@ -6135,12 +6156,12 @@ const baseWorkspaceStyles = StyleSheet.create({alignItems: "center",backgroundColor: "#f1f5f9",borderColor: "transparent",- borderRadius: 18,+ borderRadius: MOBILE_UI_METRICS.compactControlHeight / 2,borderWidth: 1,flex: 1,flexDirection: "row",gap: 8,- height: 36,+ height: MOBILE_UI_METRICS.compactControlHeight,paddingHorizontal: 12,},mobileSearchButtonActive: {@@ -6154,7 +6175,7 @@ const baseWorkspaceStyles = StyleSheet.create({color: "#0f172a",flex: 1,fontSize: 14,- height: 36,+ height: MOBILE_UI_METRICS.compactControlHeight,paddingVertical: 0,},mobileSearchInputActiveDark: {@@ -6181,6 +6202,12 @@ const baseWorkspaceStyles = StyleSheet.create({paddingHorizontal: 10,paddingVertical: 6,},+ mobileListConstraintFilter: {+ backgroundColor: "#ffffff",+ borderColor: "#e2e8f0",+ borderLeftColor: "#e2e8f0",+ borderLeftWidth: 1,+ },mobileSearchStatusPill: {alignItems: "center",backgroundColor: "#059669",@@ -6201,20 +6228,26 @@ const baseWorkspaceStyles = StyleSheet.create({fontSize: 12,fontWeight: "700",},+ mobileListConstraintTextFilter: {+ color: "#64748b",+ },mobileListConstraintAction: {color: "#065f46",fontSize: 12,fontWeight: "700",},+ mobileListConstraintActionFilter: {+ color: "#475569",+ },mobileFilterButton: {alignItems: "center",backgroundColor: "#ffffff",borderColor: "#e2e8f0",- borderRadius: 18,+ borderRadius: MOBILE_UI_METRICS.compactControlHeight / 2,borderWidth: 1,- height: 36,+ height: MOBILE_UI_METRICS.compactControlHeight,justifyContent: "center",- width: 36,+ width: MOBILE_UI_METRICS.compactControlHeight,},mobileFilterButtonActive: {backgroundColor: "#334155",@@ -6991,7 +7024,7 @@ const baseWorkspaceStyles = StyleSheet.create({},listActionSheet: {backgroundColor: "#ffffff",- borderRadius: 10,+ borderRadius: MOBILE_UI_METRICS.floatingSheetCornerRadius,marginHorizontal: 12,maxHeight: "82%",overflow: "hidden",@@ -7903,16 +7936,16 @@ const baseWorkspaceStyles = StyleSheet.create({alignItems: "center",backgroundColor: "#10b981",borderColor: "#ffffff",- borderRadius: 26,+ borderRadius: MOBILE_UI_METRICS.floatingCreateButtonSize / 2,borderWidth: 4,- height: 52,+ height: MOBILE_UI_METRICS.floatingCreateButtonSize,justifyContent: "center",marginTop: -16,shadowColor: "#10b981",shadowOffset: { width: 0, height: 10 },shadowOpacity: 0.28,shadowRadius: 18,- width: 52,+ width: MOBILE_UI_METRICS.floatingCreateButtonSize,},bottomCreateButtonDisabled: {backgroundColor: "#cbd5e1",@@ -7951,6 +7984,7 @@ const baseWorkspaceStyles = StyleSheet.create({bottomNavItem: {alignItems: "center",gap: 4,+ minHeight: MOBILE_UI_METRICS.minimumTouchTarget,minWidth: 58,},bottomNavText: {diff --git a/apps/web/src/components/MemoListMobileSheets.tsx b/apps/web/src/components/MemoListMobileSheets.tsxindex 302da9b4..8be8dfbd 100644--- a/apps/web/src/components/MemoListMobileSheets.tsx+++ b/apps/web/src/components/MemoListMobileSheets.tsx@@ -102,7 +102,7 @@ export const MobileListActionsSheet = ({return (<Drawer open={true} onOpenChange={(open) => { if (!open) onClose(); }}>- <DrawerContent className="bottom-[calc(5.25rem+env(safe-area-inset-bottom))] max-h-[calc(100dvh_-_6.75rem_-_env(safe-area-inset-bottom))] overflow-hidden rounded-md lg:hidden">+ <DrawerContent className="bottom-[calc(5.25rem+env(safe-area-inset-bottom))] max-h-[calc(100dvh_-_6.75rem_-_env(safe-area-inset-bottom))] overflow-hidden rounded-mobile-sheet lg:hidden"><header className="flex h-12 items-center justify-between border-b border-slate-200 px-4"><DrawerHeader className="min-w-0 p-0"><DrawerTitle className="truncate">{t("mobileSheets.listOptions")}</DrawerTitle>@@ -217,7 +217,7 @@ export const MobileMoveSheet = ({return (<Drawer open={true} onOpenChange={(open) => { if (!open) onClose(); }}>- <DrawerContent className="bottom-[calc(5.25rem+env(safe-area-inset-bottom))] max-h-[calc(100dvh_-_6.75rem_-_env(safe-area-inset-bottom))] overflow-hidden rounded-md lg:hidden">+ <DrawerContent className="bottom-[calc(5.25rem+env(safe-area-inset-bottom))] max-h-[calc(100dvh_-_6.75rem_-_env(safe-area-inset-bottom))] overflow-hidden rounded-mobile-sheet lg:hidden"><header className="flex h-12 items-center justify-between border-b border-slate-200 px-4"><DrawerHeader className="min-w-0 p-0"><DrawerTitle className="truncate">{t("mobileSheets.moveToNotebook")}</DrawerTitle>@@ -300,7 +300,7 @@ export const MobileSelectionMoreSheet = ({return (<Drawer open={true} onOpenChange={(open) => { if (!open) onClose(); }}>- <DrawerContent className="bottom-[calc(5.25rem+env(safe-area-inset-bottom))] max-h-[calc(100dvh_-_6.75rem_-_env(safe-area-inset-bottom))] overflow-hidden rounded-md lg:hidden">+ <DrawerContent className="bottom-[calc(5.25rem+env(safe-area-inset-bottom))] max-h-[calc(100dvh_-_6.75rem_-_env(safe-area-inset-bottom))] overflow-hidden rounded-mobile-sheet lg:hidden"><header className="flex h-12 items-center justify-between border-b border-slate-200 px-4"><DrawerHeader className="min-w-0 p-0"><DrawerTitle className="truncate">{t("mobileSheets.bulkActions")}</DrawerTitle>diff --git a/apps/web/src/components/MemoListPane.tsx b/apps/web/src/components/MemoListPane.tsxindex 6459583f..bddda8a7 100644--- a/apps/web/src/components/MemoListPane.tsx+++ b/apps/web/src/components/MemoListPane.tsx@@ -53,6 +53,7 @@ import { MemoCard } from "./MemoCard";import { cn } from "@/lib/utils";import { WORKSPACE_PAGE_TITLE_CLASSNAME } from "@/lib/workspace-ui";import type { Notebook, MemoSummary } from "@edgeever/shared";+import { toggleMobileMemoFilterMode } from "@edgeever/shared/mobile-ui";import type {MemoFilterMode,MemoSortMode,@@ -1220,7 +1221,7 @@ export const MemoListPane = ({<div className={cn("items-center gap-2", mobileSearchActive ? "hidden lg:flex" : "flex")}><divclassName={cn(- "flex h-9 min-w-0 flex-1 items-center gap-2 rounded-full border px-3 text-sm transition focus-within:ring-2 lg:rounded-md",+ "flex h-mobile-control min-w-0 flex-1 items-center gap-2 rounded-full border px-3 text-sm transition focus-within:ring-2 lg:rounded-md",searchActive? "border-emerald-400 bg-emerald-50/80 text-emerald-700 shadow-[0_0_0_1px_rgba(52,211,153,0.18)] ring-1 ring-emerald-200 focus-within:border-emerald-500 focus-within:bg-white focus-within:ring-emerald-300/50": "border-transparent bg-slate-100 text-slate-500 focus-within:border-slate-300 focus-within:bg-white focus-within:ring-slate-400/20 lg:border-slate-200 lg:bg-slate-50"@@ -1265,7 +1266,7 @@ export const MemoListPane = ({<buttonkey={option.value}className={cn(- "flex h-9 w-9 items-center justify-center rounded-full border transition",+ "flex h-mobile-control w-mobile-control items-center justify-center rounded-full border transition",filterMode === option.value? "border-slate-700 bg-slate-700 text-white shadow-[0_8px_18px_rgba(15,23,42,0.16)]": "border-slate-200 bg-white text-slate-500 hover:bg-slate-50 hover:text-slate-800"@@ -1274,7 +1275,7 @@ export const MemoListPane = ({title={filterMode === option.value ? t("memoList.toggleOffFilter", { label: option.label }) : option.label}aria-label={filterMode === option.value ? t("memoList.toggleOffFilter", { label: option.label }) : option.label}aria-pressed={filterMode === option.value}- onClick={() => handleFilterModeChange(filterMode === option.value ? "all" : option.value)}+ onClick={() => handleFilterModeChange(toggleMobileMemoFilterMode(filterMode, option.value))}>{getMobileFilterIcon(option.value)}</button>diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsxindex d8bf18b7..9cbe2d34 100644--- a/apps/web/src/components/WorkspaceApp.tsx+++ b/apps/web/src/components/WorkspaceApp.tsx@@ -302,7 +302,7 @@ const MobileBottomNavButton = ({}) => (<buttonclassName={cn(- "flex h-11 flex-col items-center justify-center gap-0.5 rounded-md text-xs font-medium transition-all duration-200",+ "flex h-mobile-touch flex-col items-center justify-center gap-0.5 rounded-md text-xs font-medium transition-all duration-200",active ? "text-slate-950" : "text-slate-500 hover:bg-slate-100 hover:text-slate-950")}type="button"@@ -338,12 +338,12 @@ const MobileBottomNav = ({className="fixed inset-x-0 bottom-0 z-40 border-t border-slate-200 bg-white/95 px-5 pb-[max(0.125rem,env(safe-area-inset-bottom))] pt-0 shadow-[0_-10px_30px_rgba(15,23,42,0.08)] backdrop-blur lg:hidden"aria-label={t("nav.mobileMain")}>- <div className="relative grid h-12 grid-cols-3 items-center">+ <div className="relative grid h-mobile-bottom-nav grid-cols-3 items-center"><MobileBottomNavButton active={activeItem === "home"} icon={<Home className="h-5 w-5" />} label={t("nav.home")} onClick={onHome} /><div aria-hidden="true" /><MobileBottomNavButton active={activeItem === "settings"} icon={<UserRound className="h-5 w-5" />} label={t("nav.mine")} onClick={onOpenSettings} /><button- className="absolute left-1/2 top-[-0.8rem] flex h-[3.25rem] w-[3.25rem] -translate-x-1/2 items-center justify-center rounded-full border-[5px] border-white bg-emerald-500 text-white shadow-[0_12px_26px_rgb(var(--brand-green-rgb)/0.32)] transition hover:bg-emerald-600 disabled:cursor-not-allowed disabled:bg-emerald-200 disabled:opacity-70 disabled:hover:bg-emerald-200"+ className="absolute left-1/2 top-[-0.8rem] flex h-mobile-fab w-mobile-fab -translate-x-1/2 items-center justify-center rounded-full border-[5px] border-white bg-emerald-500 text-white shadow-[0_12px_26px_rgb(var(--brand-green-rgb)/0.32)] transition hover:bg-emerald-600 disabled:cursor-not-allowed disabled:bg-emerald-200 disabled:opacity-70 disabled:hover:bg-emerald-200"type="button"title={createMemoLabel}aria-label={createMemoLabel}diff --git a/apps/web/tailwind.config.ts b/apps/web/tailwind.config.tsindex f3682257..198f751f 100644--- a/apps/web/tailwind.config.ts+++ b/apps/web/tailwind.config.ts@@ -1,5 +1,6 @@import type { Config } from "tailwindcss";import tailwindAnimate from "tailwindcss-animate";+import { MOBILE_UI_METRICS } from "@edgeever/shared/mobile-ui";const brandGreen = (shade: number) => `rgb(var(--brand-green-${shade}-rgb) / <alpha-value>)`;const slate = (shade: number) => `rgb(var(--slate-${shade}-rgb) / <alpha-value>)`;@@ -29,8 +30,15 @@ export default {borderRadius: {lg: "var(--radius)",md: "calc(var(--radius) - 2px)",+ "mobile-sheet": `${MOBILE_UI_METRICS.floatingSheetCornerRadius}px`,sm: "calc(var(--radius) - 4px)",},+ spacing: {+ "mobile-bottom-nav": `${MOBILE_UI_METRICS.bottomNavigationHeight}px`,+ "mobile-control": `${MOBILE_UI_METRICS.compactControlHeight}px`,+ "mobile-fab": `${MOBILE_UI_METRICS.floatingCreateButtonSize}px`,+ "mobile-touch": `${MOBILE_UI_METRICS.minimumTouchTarget}px`,+ },colors: {slate: {50: slate(50),diff --git a/packages/shared/package.json b/packages/shared/package.jsonindex 7db12640..5d5cead1 100644--- a/packages/shared/package.json+++ b/packages/shared/package.json@@ -5,7 +5,8 @@"type": "module","exports": {".": "./src/index.ts",- "./i18n": "./src/i18n/index.ts"+ "./i18n": "./src/i18n/index.ts",+ "./mobile-ui": "./src/mobile-ui.ts"},"types": "./src/index.ts","dependencies": {diff --git a/packages/shared/src/mobile-ui.test.mjs b/packages/shared/src/mobile-ui.test.mjsnew file mode 100644index 00000000..312d2c08--- /dev/null+++ b/packages/shared/src/mobile-ui.test.mjs@@ -0,0 +1,16 @@+import { describe, expect, test } from "bun:test";+import { MOBILE_UI_METRICS, toggleMobileMemoFilterMode } from "./mobile-ui.ts";++describe("mobile UI contract", () => {+ test("keeps core touch targets and navigation metrics stable", () => {+ expect(MOBILE_UI_METRICS.minimumTouchTarget).toBeGreaterThanOrEqual(44);+ expect(MOBILE_UI_METRICS.bottomNavigationHeight).toBe(52);+ expect(MOBILE_UI_METRICS.floatingCreateButtonSize).toBe(52);+ });++ test("toggles an exclusive memo filter off when pressed again", () => {+ expect(toggleMobileMemoFilterMode("all", "pinned")).toBe("pinned");+ expect(toggleMobileMemoFilterMode("pinned", "pinned")).toBe("all");+ expect(toggleMobileMemoFilterMode("tagged", "untagged")).toBe("untagged");+ });+});diff --git a/packages/shared/src/mobile-ui.ts b/packages/shared/src/mobile-ui.tsnew file mode 100644index 00000000..c0feb124--- /dev/null+++ b/packages/shared/src/mobile-ui.ts@@ -0,0 +1,14 @@+export const MOBILE_UI_METRICS = {+ bottomNavigationHeight: 52,+ compactControlHeight: 36,+ floatingCreateButtonSize: 52,+ floatingSheetCornerRadius: 10,+ minimumTouchTarget: 44,+} as const;++export type MobileMemoFilterMode = "all" | "tagged" | "untagged" | "pinned";++export const toggleMobileMemoFilterMode = (+ current: MobileMemoFilterMode,+ requested: Exclude<MobileMemoFilterMode, "all">+): MobileMemoFilterMode => current === requested ? "all" : requested;