Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 恢复原生显示菜单并通过文件图像保留 6pt 提示
Dasha566ac1cd44f
diff --git a/apps/mobile/src/__tests__/nativePullDownMenu.test.tsx b/apps/mobile/src/__tests__/nativePullDownMenu.test.tsxindex 6b4d9a3d4a..a9e42ae082 100644--- a/apps/mobile/src/__tests__/nativePullDownMenu.test.tsx+++ b/apps/mobile/src/__tests__/nativePullDownMenu.test.tsx@@ -22,6 +22,9 @@ vi.mock("@/theme", async () => {vi.mock("@/platform/chrome/AnchoredPullDownMenu", () => ({AnchoredPullDownMenu: () => null,}));+vi.mock("@/platform/chrome/useNativeMenuReminderImage", () => ({+ useNativeMenuReminderImage: () => '/cache/filter-reminder.png',+}));vi.mock("@react-native-menu/menu", () => ({MenuView: ({ actions, style }: { actions: MenuAction[]; style?: unknown }) => {native.actions = actions;@@ -31,6 +34,28 @@ vi.mock("@react-native-menu/menu", () => ({}));describe("native menu symbol colors", () => {+ // PR #7642: a reminder used to replace the whole UIMenu and lose its SF Symbols.+ // Exercise the real presenter/conversion; the image preparation hook is isolated.+ // Existing color tests did not cover presenter replacement or loss of row icons.+ // Unit tier, minimum input: an on/off reminder beside a normal symbol and a checked row.+ it.each([false, true])('keeps UIMenu, row icons and checks with reminder=%s', (active) => {+ native.actions = [];+ renderToStaticMarkup(createElement(NativePullDownMenu, {+ actions: [+ { id: 'sort', title: 'Sort', image: 'arrow.up.arrow.down' },+ { id: 'status', title: 'Status', image: 'checklist', filterReminder: active,+ subactions: [{ id: 'archived', title: 'Archived', state: 'on', filterReminder: active }] },+ ],+ children: null,+ onAction: vi.fn(),+ }));+ expect(native.actions[0]).toMatchObject({ image: 'arrow.up.arrow.down' });+ expect(native.actions[1]).toMatchObject({+ image: active ? '/cache/filter-reminder.png' : 'checklist',+ subactions: [{ id: 'archived', state: 'on', ...(active ? { image: '/cache/filter-reminder.png' } : {}) }],+ });+ });+it.each(["light", "dark"] as const)("supplies visible colors to Fabric in %s mode",(mode) => {diff --git a/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx b/apps/mobile/src/platform/chrome/NativePullDownMenu.tsxindex 516c17d940..27f023adb7 100644--- a/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx+++ b/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx@@ -10,6 +10,7 @@ import {} from "react-native";import { AnchoredPullDownMenu } from "@/platform/chrome/AnchoredPullDownMenu";import { useTheme, type ThemeColors } from "@/theme";+import { useNativeMenuReminderImage } from './useNativeMenuReminderImage';export type NativePullDownAction = {disabled?: boolean;@@ -47,18 +48,23 @@ export function usesNativePullDownMenu(): boolean {function toMenuAction(action: NativePullDownAction,colors: ThemeColors,+ reminderImage: string | undefined,): MenuAction {+ const showReminder = action.filterReminder && reminderImage !== undefined;+ const image = showReminder ? reminderImage : action.image;return {id: action.id,title: action.title,// Fabric defaults the library's optional Int32 imageColor to transparent.// Always pair a symbol with a visible semantic color.- ...(action.image+ ...(image? {- image: action.image,- imageColor: action.destructive- ? colors.destructive- : colors.textPrimary,+ image,+ imageColor: showReminder+ ? colors.statusAccent+ : action.destructive+ ? colors.destructive+ : colors.textPrimary,}: {}),...(action.subtitle ? { subtitle: action.subtitle } : {}),@@ -79,7 +85,7 @@ function toMenuAction(...(action.subactions?.length? {subactions: action.subactions.map((item) =>- toMenuAction(item, colors),+ toMenuAction(item, colors, reminderImage),),}: {}),@@ -105,9 +111,7 @@ function childDisabled(children: ReactNode): boolean {return (children.props as { disabled?: unknown }).disabled === true;}-/** MenuView 只支持系统符号或原生资源,不能用 JS PNG 精确绘制 6pt 提示点。- * 使用提醒字段的菜单复用已有自绘路径;false 也算,切换筛选时保持同一个呈现器。- */+/** Prepare the image even while off, so changing the filter needs no new load. */function usesFilterReminder(actions: readonly NativePullDownAction[]): boolean {return actions.some((action) =>action.filterReminder !== undefined ||@@ -116,8 +120,7 @@ function usesFilterReminder(actions: readonly NativePullDownAction[]): boolean {}/**- * 收起时完全是调用方原来的按钮/标题;iOS 一般用系统 UIMenu,带筛选提醒的菜单用- * 现有自绘面板以保留 6pt 圆点;Android 用 Material 下拉菜单。+ * 收起时完全是调用方原来的按钮/标题;iOS 用系统 UIMenu,Android 用 Material 下拉菜单。* iOS 尚未编进 MenuView 的包只渲染 children,* 由调用方继续走自绘面板。*/@@ -153,6 +156,7 @@ export function NativePullDownMenu({testID?: string;}) {const { colors } = useTheme();+ const reminderImage = useNativeMenuReminderImage(usesFilterReminder(actions));if (disabled || childDisabled(children) || !usesNativePullDownMenu())return children;// 一项能点的都没有(空列表或全部禁用)时不挂菜单,触发控件也显示为禁用:@@ -161,7 +165,7 @@ export function NativePullDownMenu({return isValidElement<{ disabled?: boolean }>(children)? cloneElement(children, { disabled: true }): children;- if (Platform.OS === "android" || usesFilterReminder(actions)) {+ if (Platform.OS === "android") {return (<AnchoredPullDownMenuaccessibilityLabel={accessibilityLabel}@@ -178,7 +182,7 @@ export function NativePullDownMenu({}return (<MenuView- actions={actions.map((action) => toMenuAction(action, colors))}+ actions={actions.map((action) => toMenuAction(action, colors, reminderImage))}onPressAction={({ nativeEvent }) => {if (nativeEvent.event) onAction(nativeEvent.event);}}diff --git a/apps/mobile/src/platform/chrome/useNativeMenuReminderImage.ts b/apps/mobile/src/platform/chrome/useNativeMenuReminderImage.tsnew file mode 100644index 0000000000..ca5d321d8e--- /dev/null+++ b/apps/mobile/src/platform/chrome/useNativeMenuReminderImage.ts@@ -0,0 +1,40 @@+import { useEffect, useState } from 'react';+import { Image, Platform } from 'react-native';++/** MenuView uses UIImage(named:), which accepts an absolute file path, not a file URL.+ * Materialize the bundled image at 1x so UIImage keeps its 20pt canvas and 6pt dot.+ * ImageManipulator owns the temporary output directory; retain only this mount's file.+ */+export function useNativeMenuReminderImage(enabled: boolean): string | undefined {+ const [path, setPath] = useState<string>();+ useEffect(() => {+ if (!enabled || Platform.OS !== 'ios') return;+ let disposed = false;+ let removeImage: (() => void) | undefined;+ void (async () => {+ const [{ ImageManipulator, SaveFormat }, { File }] = await Promise.all([+ import('expo-image-manipulator'),+ import('expo-file-system'),+ ]);+ if (disposed) return;+ const source = Image.resolveAssetSource(require('../../../assets/navigation/filter-reminder.png'));+ const context = ImageManipulator.manipulate(source.uri);+ let image: Awaited<ReturnType<typeof context.renderAsync>> | undefined;+ try {+ context.resize({ width: 20, height: 20 });+ image = await context.renderAsync();+ const saved = await image.saveAsync({ format: SaveFormat.PNG });+ removeImage = () => {+ try { new File(saved.uri).delete(); } catch { /* OS cache cleanup can finish later. */ }+ };+ if (disposed) removeImage();+ else setPath(decodeURIComponent(saved.uri.replace(/^file:\/\//, '')));+ } finally {+ image?.release();+ context.release();+ }+ })().catch(() => { /* Keep the native menu and its ordinary row icons available. */ });+ return () => { disposed = true; removeImage?.(); };+ }, [enabled]);+ return path;+}diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.mdindex 204f356dc0..2843ab96a6 100644--- a/docs/design-rules/DESIGN.md+++ b/docs/design-rules/DESIGN.md@@ -312,12 +312,13 @@ _Dark Mode text uses softened neutrals to reduce eye strain: **Soft Gray** (`#d4When the sidebar display-settings trigger shows the archived-view reminder, repeatthe same static accent dot on the Task status submenu and its selected Archivedoption. Desktop and Mobile retain neutral labels and selection checkmarks. Active-and All remove the whole reminder path. The native iOS toolbar menu uses its image-slot for the dot. MenuView cannot display JS-bundled custom images, so display-settings-menus outside the toolbar reuse the existing Cindy menu and shared 6pt inline dot,-including when the reminder is off, keeping the presenter stable across selections.-This extends the existing filter reminder registration without changing which-settings light the entry indicator.+and All remove the whole reminder path. Native iOS menus retain their system UIMenu+and toolbar presenters and use the image slot for the dot. MenuView receives an+absolute path to a temporary 1x copy of the bundled PNG: a 20pt canvas containing+the same 6pt dot. Ordinary row icons and selection checkmarks remain available.+Custom menus remain fallback paths and use the shared inline dot. This extends+the existing filter reminder registration without changing which settings light+the entry indicator.## 3. Typography Rules