Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(mobile): 项目标题支持滑动新建任务和项目搜索
Dasha2b3b853ca73
diff --git a/apps/mobile/app/devices/[deviceId].tsx b/apps/mobile/app/devices/[deviceId].tsxindex 0f5d16dccc..b800d68986 100644--- a/apps/mobile/app/devices/[deviceId].tsx+++ b/apps/mobile/app/devices/[deviceId].tsx@@ -161,6 +161,7 @@ function DeviceDetailScreenContent() {automationWorkingDir?: string;automationSessionIds?: string;statusFilter?: string;+ search?: string;}>();const deviceId = readRouteString(params.deviceId) ?? '';const deviceName = readRouteString(params.name) ?? readRouteString(params.deviceName) ?? deviceId;@@ -203,7 +204,7 @@ function DeviceDetailScreenContent() {() => parseRouteStatusFilter(readRouteString(params.statusFilter)),);const [filtersOpen, setFiltersOpen] = useState(false);- const [searchOpen, setSearchOpen] = useState(false);+ const [searchOpen, setSearchOpen] = useState(() => readRouteString(params.search) === '1');const [searchFilterOpen, setSearchFilterOpen] = useState(false);const insets = useSafeAreaInsets();const headerHeight = useHeaderHeight();diff --git a/apps/mobile/docs/mobile-design-guide.md b/apps/mobile/docs/mobile-design-guide.mdindex 4285dcbe88..ddc1b57947 100644--- a/apps/mobile/docs/mobile-design-guide.md+++ b/apps/mobile/docs/mobile-design-guide.md@@ -221,6 +221,7 @@ function Foo() {### iOS 外壳 vs Cindy 内容+- **项目标题滑动(iOS / Android)**:仅标题整行横移,展开的子任务不随之移动。右滑露出「新建任务」,超过屏宽 55% 松手打开预填项目电脑与目录的新建页;发送后才创建任务。左滑露出「全部任务」「搜索」,必须点按,搜索限定当前项目并聚焦输入框。点标题继续展开/收起,已有滑开行时先收起操作;自定义排序仍为长按后纵向拖动。项目与任务共用滑动互斥注册表,滚动收行,左屏缘保留返回手势。动作沿用圆形到胶囊的形态,标题内按钮为 44pt,使用双模式 token,并通过标题的无障碍动作提供等价入口。只对有明确电脑和目录的项目启用,不把对话或 Cindy Make 聚合组视为单一目录。实现见 `src/session/SwipeableProjectHeader.tsx`、`HomeSurface.tsx`。- **任务/伙伴切换**:按左任务、右伙伴的顺序做同一套横向滑动转场,抽屉和标题下拉选择都复用 HomeModePanes;不重建已访问列表,不丢搜索或滚动位置。滑动用不回弹的临界阻尼弹簧(参数见 DESIGN.md §14.4),快速反向切换从当前位置继续;系统减弱动态效果或尚未取得该偏好时直接切换。滑动只用于 iOS;Android 顶栏画在各自页面里,滑动会带着顶栏一起走,因此保持直接切换。导航栏和顶部模糊固定不动,模糊由 HomeModePanes 统一绘制一层。- **首页菜单提示点**:可见圆点直径 6pt,原生工具栏用同尺寸画布的有点/无点模板图,避免空的数字徽章被系统放大。图标位置、按钮外框和点击范围不随提示点出现而变化。diff --git a/apps/mobile/src/__tests__/swipeableProjectHeader.test.tsx b/apps/mobile/src/__tests__/swipeableProjectHeader.test.tsxnew file mode 100644index 0000000000..2f2e81612f--- /dev/null+++ b/apps/mobile/src/__tests__/swipeableProjectHeader.test.tsx@@ -0,0 +1,128 @@+// @vitest-environment jsdom+import { act, createElement, type ReactNode } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { SwipeableProjectHeader } from '@/session/SwipeableProjectHeader';+import { createSwipeRowRegistry } from '@/session/swipeRowRegistry';++const native = vi.hoisted(() => ({+ props: null as any, offset: { value: 0 }, close: vi.fn(), reset: vi.fn(),+}));+vi.mock('react-native', async () => {+ const { createElement: el } = await import('react');+ return {+ View: ({ children }: { children?: ReactNode }) => el('div', null, children),+ Pressable: ({ children, accessibilityLabel, onPress }: any) =>+ el('button', { 'aria-label': accessibilityLabel, onClick: onPress }, children),+ StyleSheet: { create: (value: unknown) => value },+ useWindowDimensions: () => ({ width: 400 }),+ };+});+vi.mock('react-native-reanimated', async () => {+ const { View } = await import('react-native');+ return { default: { View }, useAnimatedStyle: (factory: () => unknown) => factory(),+ interpolate: () => 1 };+});+vi.mock('@/platform/gestureHandler', async () => {+ const { createElement: el, Fragment, forwardRef, useImperativeHandle } = await import('react');+ return {+ SwipeDirection: { RIGHT: 'right', LEFT: 'left' },+ ReanimatedSwipeable: forwardRef((props: any, ref) => {+ native.props = props;+ useImperativeHandle(ref, () => ({ close: native.close, reset: native.reset }));+ return el(Fragment, null, props.renderLeftActions({}, native.offset),+ props.renderRightActions({}, native.offset), props.children);+ }),+ };+});+vi.mock('lucide-react-native', () => ({ List: () => null, Search: () => null, SquarePen: () => null }));+vi.mock('react-i18next', async (importOriginal) => ({+ ...await importOriginal<typeof import('react-i18next')>(),+ useTranslation: () => ({ t: (key: string) => key }),+}));+vi.mock('@/theme', () => ({+ iconSize: { xl: 24 }, iconStroke: { regular: 2 },+ useTheme: () => ({ colors: {} }), useThemedStyles: (make: (colors: object) => unknown) => make({}),+}));++Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });+let root: Root;+let host: HTMLDivElement;+let registry: ReturnType<typeof createSwipeRowRegistry>;+let destination: string;+function render(projectKey = 'project-a') {+ act(() => root.render(createElement(SwipeableProjectHeader, {+ projectKey, registry,+ onNewTask: () => { destination = 'new'; },+ onOpenTasks: () => { destination = 'tasks'; },+ onSearch: () => { destination = 'search'; },+ children: 'Project',+ })));+}+beforeEach(() => {+ vi.clearAllMocks(); native.offset.value = 0;+ registry = createSwipeRowRegistry(); destination = 'home';+ host = document.createElement('div'); root = createRoot(host);+});+afterEach(() => act(() => root.unmount()));++// Unit: production project header at the native gesture boundary. Existing+// session-row tests cover archive/pin and classic Animated, not these navigation+// actions. Minimal failures: pull past the threshold then retract, or reuse an+// opened project row while a task row owns the same page registry.+describe('project header navigation and swipe lifecycle', () => {+ it.each([+ ['right', 260, 'new'],+ ['right', 100, 'home'],+ ['left', -260, 'home'],+ ])('only opens new-task on a released full right swipe (%s, %s)', (direction, end, target) => {+ render();+ act(() => native.props.onSwipeableOpenStartDrag());+ native.offset.value = 280;+ expect(destination).toBe('home');+ native.offset.value = Number(end);+ act(() => native.props.onSwipeableWillOpen(direction));+ expect(destination).toBe(target);+ if (target === 'new') {+ expect(native.close).toHaveBeenCalledOnce();+ expect(registry.closeOpenRow()).toBe(false);+ }+ });++ it.each([['newTask', 'new'], ['allTasks', 'tasks'], ['search', 'search']])(+ 'closes the revealed header before opening %s', (action, target) => {+ render();+ act(() => native.props.onSwipeableOpenStartDrag());+ act(() => host.querySelector<HTMLButtonElement>(`[aria-label="devices.list.projectActions.${action}"]`)!.click());+ expect(destination).toBe(target);+ expect(native.close).toHaveBeenCalledOnce();+ expect(registry.closeOpenRow()).toBe(false);+ },+ );++ it('shares mutual exclusion with task rows and does not clear their newer registration', () => {+ render();+ const closeTask = vi.fn();+ registry.onRowOpen('task-a', closeTask);+ act(() => native.props.onSwipeableOpenStartDrag());+ expect(closeTask).toHaveBeenCalledOnce();+ registry.onRowOpen('task-b', closeTask);+ expect(native.close).toHaveBeenCalledOnce();+ act(() => native.props.onSwipeableClose());+ act(() => root.render(null));+ expect(registry.closeOpenRow()).toBe(true);+ expect(closeTask).toHaveBeenCalledTimes(2);+ });++ it('resets a recycled header and retires its previous open-row registration', () => {+ render();+ act(() => native.props.onSwipeableOpenStartDrag());+ native.reset.mockClear();+ render('project-b');+ expect(native.reset).toHaveBeenCalledOnce();+ expect(registry.closeOpenRow()).toBe(false);+ act(() => native.props.onSwipeableOpenStartDrag());+ expect(registry.closeOpenRow()).toBe(true);+ expect(native.close).toHaveBeenCalledOnce();+ });+});diff --git a/apps/mobile/src/i18n/locales/en/devices.json b/apps/mobile/src/i18n/locales/en/devices.jsonindex e0d6579e15..af36629a92 100644--- a/apps/mobile/src/i18n/locales/en/devices.json+++ b/apps/mobile/src/i18n/locales/en/devices.json@@ -241,6 +241,11 @@}},"list": {+ "projectActions": {+ "newTask": "New task",+ "allTasks": "All tasks",+ "search": "Search"+ },"taskSuggestions": {"connected": "Computer connected","title": "Away from your computer?\nYou can still get started.",diff --git a/apps/mobile/src/i18n/locales/ja/devices.json b/apps/mobile/src/i18n/locales/ja/devices.jsonindex f41f43f67c..0f17744cb4 100644--- a/apps/mobile/src/i18n/locales/ja/devices.json+++ b/apps/mobile/src/i18n/locales/ja/devices.json@@ -241,6 +241,11 @@}},"list": {+ "projectActions": {+ "newTask": "新しいタスク",+ "allTasks": "すべてのタスク",+ "search": "検索"+ },"taskSuggestions": {"connected": "コンピューターに接続済み","title": "コンピューターから離れていても、\n始められます。",diff --git a/apps/mobile/src/i18n/locales/ko/devices.json b/apps/mobile/src/i18n/locales/ko/devices.jsonindex 89be7cd50b..9105fc44e2 100644--- a/apps/mobile/src/i18n/locales/ko/devices.json+++ b/apps/mobile/src/i18n/locales/ko/devices.json@@ -241,6 +241,11 @@}},"list": {+ "projectActions": {+ "newTask": "새 작업",+ "allTasks": "모든 작업",+ "search": "검색"+ },"taskSuggestions": {"connected": "컴퓨터에 연결됨","title": "컴퓨터 앞에 없어도\n일을 시작할 수 있어요.",diff --git a/apps/mobile/src/i18n/locales/zh-CN/devices.json b/apps/mobile/src/i18n/locales/zh-CN/devices.jsonindex d0368cbde9..840102053c 100644--- a/apps/mobile/src/i18n/locales/zh-CN/devices.json+++ b/apps/mobile/src/i18n/locales/zh-CN/devices.json@@ -241,6 +241,11 @@}},"list": {+ "projectActions": {+ "newTask": "新建任务",+ "allTasks": "全部任务",+ "search": "搜索"+ },"taskSuggestions": {"connected": "电脑已连接","title": "不在电脑旁,\n也能开始一件事。",diff --git a/apps/mobile/src/i18n/locales/zh-TW/devices.json b/apps/mobile/src/i18n/locales/zh-TW/devices.jsonindex 888eea87bb..713de5eb32 100644--- a/apps/mobile/src/i18n/locales/zh-TW/devices.json+++ b/apps/mobile/src/i18n/locales/zh-TW/devices.json@@ -241,6 +241,11 @@}},"list": {+ "projectActions": {+ "newTask": "新增任務",+ "allTasks": "全部任務",+ "search": "搜尋"+ },"taskSuggestions": {"connected": "電腦已連線","title": "不在電腦旁,\n也能開始一件事。",diff --git a/apps/mobile/src/session/HomeSurface.tsx b/apps/mobile/src/session/HomeSurface.tsxindex a1e8558067..3e44c7a43e 100644--- a/apps/mobile/src/session/HomeSurface.tsx+++ b/apps/mobile/src/session/HomeSurface.tsx@@ -5,6 +5,7 @@ import type { HomeMode } from './homeViewPreferenceStore';import { TaskTagDots } from '@/session/TaskTags';import { ResidentHomeList, useResidentHomeList } from './ResidentHomeList';import { HomeNewTaskButton } from './HomeNewTaskButton';+import { SwipeableProjectHeader } from './SwipeableProjectHeader';import { useRetainedHomeState, getHomeViewSession } from './homeViewSession';import { rememberRecentTask } from './recentTasks';import { homeListStyles, SESSION_ROW_LONG_PRESS_MS, SessionStatusMark, SessionStatusPulse } from '@/session/HomeListVisuals';@@ -2372,9 +2373,10 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSys}, [auth, loggingOut, router, t]);const toggleProject = useCallback((key: string) => {+ if (swipeRegistry.closeOpenRow()) return;runDisclosure(() => setCollapsedProjectKeys((current) =>current.includes(key) ? current.filter((item) => item !== key) : [...current, key]));- }, [runDisclosure]);+ }, [runDisclosure, swipeRegistry]);const showAllDialogueSessions = useCallback(() => {runDisclosure(() => setDialogueShowAll(true));@@ -2463,6 +2465,7 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSyskey: string;title: string;}) => {+ swipeRegistry.closeOpenRow();const expectedAccountGeneration = accountGeneration;const epoch = projectDragEpochRef.current + 1;projectDragEpochRef.current = epoch;@@ -2520,7 +2523,7 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSysif (pending === 0) finish();});}- }, [accountGeneration, projectDragY, visibleProjectKeys]);+ }, [accountGeneration, projectDragY, visibleProjectKeys, swipeRegistry]);const moveProjectDrag = useCallback((absoluteY: number) => {const session = projectDragRef.current;@@ -2672,8 +2675,9 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSysrunDisclosure(() => setPinnedCollapsed((collapsed) => !collapsed));}, [runDisclosure]);- const openProjectSessions = useCallback((project: MobileHomeProjectGroup) => {+ const openProjectSessions = useCallback((project: MobileHomeProjectGroup, search = false) => {if (!project.deviceId) return;+ swipeRegistry.closeOpenRow();guardedPush({pathname: '/devices/[deviceId]',// 带上 workingDir + 项目名,让目标页只显示「这个项目」的会话(名副其实地"查看全部 N 条")。@@ -2683,12 +2687,13 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSysdeviceId: project.deviceId,name: project.deviceName,statusFilter,+ ...(search ? { search: '1' } : {}),...(project.workingDir? { workingDir: project.workingDir, projectName: project.title }: {}),},});- }, [guardedPush, statusFilter]);+ }, [guardedPush, statusFilter, swipeRegistry]);// renderItem 提取为稳定引用:打开「选项」sheet 等与列表数据无关的页面状态变更不再改变// renderItem 身份,SectionList 可见行不随之全量重渲染(review P2:每行 Swipeable 动画树@@ -2710,6 +2715,7 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSysonArchive={archiveSession}onOpenAutomationGroup={openAutomationGroup}onOpenProjectSessions={openProjectSessions}+ onNewProjectTask={openNewSession}onOpenSession={openSession}onShowOptions={showSessionOptions}onToggleAutomationGroup={toggleAutomationGroup}@@ -2743,6 +2749,7 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSysexpandedAutomationGroups,openAutomationGroup,openProjectSessions,+ openNewSession,openSession,pinnedCollapsed,sections,@@ -3730,6 +3737,8 @@ function ProjectRow({onDragStart,onOpenAutomationGroup,onOpenProject,+ onNewTask,+ onSearchProject,onOpenSession,onToggle,onToggleAutomationGroup,@@ -3751,6 +3760,8 @@ function ProjectRow({onDragStart?: (input: { absoluteY: number; count: number; key: string; title: string }) => void;onOpenAutomationGroup(group: RemoteAutomationSessionGroup): void;onOpenProject(): void;+ onNewTask(): void;+ onSearchProject(): void;onOpenSession(item: RemoteSessionListItem): void;onToggle(): void;onToggleAutomationGroup(key: string): void;@@ -3761,7 +3772,7 @@ function ProjectRow({showAll?: boolean;/** 前一行也是块(项目组 / 自动化组)时不画顶线:前块底线已是这根分割线。 */suppressTopBorder?: boolean;- /** 提供时项目子行挂与顶层普通会话行同款的左右滑操作(组行仍不挂,子行经透传可滑)。 */+ /** 项目标题与子任务共用同一滑动互斥注册表。 */swipe?: SessionSwipeControls;}) {const styles = useThemedStyles(makeStyles);@@ -3862,6 +3873,7 @@ function ProjectRow({? `${project.title} (${machineIdentity.displayLabel})`: project.title;const reorderable = kind === 'project' && !!onDragStart && !!onDragMove && !!onDragEnd;+ const actionable = kind === 'project' && !!project.deviceId && !!project.workingDir && !!swipe;const dragGesture = useMemo(() => {if (!onDragStart || !onDragMove || !onDragEnd || kind !== 'project') return null;const start = onDragStart;@@ -3869,6 +3881,8 @@ function ProjectRow({const finish = onDragEnd;return Gesture.Pan().activateAfterLongPress(380)+ .activeOffsetY([-8, 8])+ .failOffsetX([-12, 12]).onStart((event) => {runOnJS(start)({absoluteY: event.absoluteY,@@ -3891,6 +3905,19 @@ function ProjectRow({? t('devices.list.a11y.dialogue'): t('devices.list.a11y.project', { title: displayTitle })}accessibilityRole="button"+ accessibilityActions={actionable ? [+ { name: 'newTask', label: t('devices.list.projectActions.newTask') },+ { name: 'allTasks', label: t('devices.list.projectActions.allTasks') },+ { name: 'search', label: t('devices.list.projectActions.search') },+ ] : undefined}+ onAccessibilityAction={actionable ? (event) => {+ swipe?.registry.closeOpenRow();+ switch (event.nativeEvent.actionName) {+ case 'newTask': onNewTask(); break;+ case 'allTasks': onOpenProject(); break;+ case 'search': onSearchProject(); break;+ }+ } : undefined}accessibilityState={{ expanded: !collapsed }}accessibilityValue={collapsedStatusA11y ? { text: collapsedStatusA11y } : undefined}onLayout={(event) => {@@ -3971,7 +3998,12 @@ function ProjectRow({viewportHeight={viewportHeight}/>) : null}- {dragGesture ? <GestureDetector gesture={dragGesture}>{header}</GestureDetector> : header}+ {actionable && swipe ? (+ <SwipeableProjectHeader projectKey={project.key} registry={swipe.registry}+ onNewTask={onNewTask} onOpenTasks={onOpenProject} onSearch={onSearchProject}>+ {dragGesture ? <GestureDetector gesture={dragGesture}>{header}</GestureDetector> : header}+ </SwipeableProjectHeader>+ ) : dragGesture ? <GestureDetector gesture={dragGesture}>{header}</GestureDetector> : header}{collapsed ? null : (<DisclosureItem exit style={styles.projectChildren} testID="home.projectChildren">@@ -4090,6 +4122,7 @@ function HomeListRowInner({onArchive,onOpenAutomationGroup,onOpenProjectSessions,+ onNewProjectTask,onOpenSession,onProjectDragEnd,onProjectDragMove,@@ -4117,7 +4150,8 @@ function HomeListRowInner({nextIsBlock: boolean;onArchive(session: RemoteSession): void;onOpenAutomationGroup(group: RemoteAutomationSessionGroup): void;- onOpenProjectSessions(project: MobileHomeProjectGroup): void;+ onOpenProjectSessions(project: MobileHomeProjectGroup, search?: boolean): void;+ onNewProjectTask(project: MobileHomeProjectGroup): void;onOpenSession(item: RemoteSessionListItem): void;onProjectDragEnd?: () => void;onProjectDragMove?: (absoluteY: number) => void;@@ -4151,6 +4185,8 @@ function HomeListRowInner({onDragStart={item.kind === 'project' ? onProjectDragStart : undefined}onOpenAutomationGroup={onOpenAutomationGroup}onOpenProject={item.kind === 'dialogue' ? onShowAllDialogue : () => onOpenProjectSessions(item.project)}+ onNewTask={() => onNewProjectTask(item.project)}+ onSearchProject={() => onOpenProjectSessions(item.project, true)}onOpenSession={onOpenSession}onToggle={() => onToggleProject(item.project.key)}onToggleAutomationGroup={onToggleAutomationGroup}diff --git a/apps/mobile/src/session/SwipeableProjectHeader.tsx b/apps/mobile/src/session/SwipeableProjectHeader.tsxnew file mode 100644index 0000000000..4c29e7d510--- /dev/null+++ b/apps/mobile/src/session/SwipeableProjectHeader.tsx@@ -0,0 +1,138 @@+import { memo, useCallback, useEffect, useRef, type ReactNode } from 'react';+import { Pressable, StyleSheet, View, useWindowDimensions } from 'react-native';+import Animated, { interpolate, useAnimatedStyle, type SharedValue } from 'react-native-reanimated';+import { List, Search, SquarePen, type LucideIcon } from 'lucide-react-native';+import { useTranslation } from 'react-i18next';+import { ReanimatedSwipeable, SwipeDirection, type SwipeableMethods } from '@/platform/gestureHandler';+import type { SwipeRowRegistry } from './swipeRowRegistry';+import { iconSize, iconStroke, useTheme, useThemedStyles, type ThemeColors } from '@/theme';+import { radius, spacing } from '@/theme/tokens';++// The project header is 56pt high; 44pt actions retain a full touch target.+const ACTION_SIZE = 44;+const GAP = spacing.sm;+const LEADING_WIDTH = ACTION_SIZE + GAP * 2;+const TRAILING_WIDTH = ACTION_SIZE * 2 + GAP * 3;++interface Props {+ projectKey: string;+ registry: SwipeRowRegistry;+ onNewTask(): void;+ onOpenTasks(): void;+ onSearch(): void;+ children: ReactNode;+}++/** Only wraps the header, so expanded tasks never move with the project swipe. */+export const SwipeableProjectHeader = memo(function SwipeableProjectHeader({+ projectKey, registry, onNewTask, onOpenTasks, onSearch, children,+}: Props) {+ const { t } = useTranslation();+ const { colors } = useTheme();+ const styles = useThemedStyles(makeStyles);+ const { width } = useWindowDimensions();+ const methods = useRef<SwipeableMethods | null>(null);+ const translation = useRef<SharedValue<number> | null>(null);+ const rowKey = `project:${projectKey}`;+ const close = useCallback(() => methods.current?.close(), []);+ useEffect(() => {+ methods.current?.reset();+ return () => registry.onRowClose(rowKey);+ }, [registry, rowKey]);+ const run = useCallback((action: () => void) => {+ registry.onRowClose(rowKey);+ close();+ action();+ }, [close, registry, rowKey]);++ return (+ <ReanimatedSwipeable+ ref={methods}+ testID={`home.projectSwipe.${projectKey}`}+ containerStyle={styles.surface}+ childrenContainerStyle={styles.surface}+ // Leave the screen edge available to native back navigation.+ hitSlop={{ left: -spacing.xl }}+ overshootRight={false}+ onSwipeableOpenStartDrag={() => registry.onRowOpen(rowKey, close)}+ onSwipeableClose={() => registry.onRowClose(rowKey)}+ onSwipeableWillOpen={(direction) => {+ // Release only. Left swipes always require an explicit action tap.+ if (direction === SwipeDirection.RIGHT && (translation.current?.value ?? 0) >= width * 0.55) {+ run(onNewTask);+ }+ }}+ renderLeftActions={(_progress, offset) => {+ translation.current = offset;+ return <View style={styles.leadingShell}>+ <ProjectAction icon={SquarePen} label={t('devices.list.projectActions.newTask')}+ onPress={() => run(onNewTask)} offset={offset} leading styles={styles}+ background={colors.cta} foreground={colors.ctaText} />+ </View>;+ }}+ renderRightActions={(_progress, offset) => {+ translation.current = offset;+ return <View style={styles.trailingShell}>+ <ProjectAction icon={List} label={t('devices.list.projectActions.allTasks')}+ onPress={() => run(onOpenTasks)} offset={offset} styles={styles}+ background={colors.swipeActionNeutral} foreground={colors.swipeActionText} index={1} />+ <ProjectAction icon={Search} label={t('devices.list.projectActions.search')}+ onPress={() => run(onSearch)} offset={offset} styles={styles}+ background={colors.swipeActionNeutral} foreground={colors.swipeActionText} />+ </View>;+ }}+ >+ {children}+ </ReanimatedSwipeable>+ );+});++function ProjectAction({ icon: Icon, label, onPress, offset, leading = false, index = 0, styles, background, foreground }: {+ icon: LucideIcon;+ label: string;+ onPress(): void;+ offset: SharedValue<number>;+ leading?: boolean;+ index?: number;+ styles: ReturnType<typeof makeStyles>;+ background: string;+ foreground: string;+}) {+ const animatedStyle = useAnimatedStyle(() => {+ const revealed = Math.max(0, leading ? offset.value : -offset.value);+ const progress = Math.min(1, revealed / (leading ? LEADING_WIDTH : TRAILING_WIDTH));+ return {+ opacity: interpolate(progress, [0.15, 0.7], [0, 1], 'clamp'),+ transform: [{ scale: interpolate(progress, [0.15, 1], [0.5, 1], 'clamp') }],+ width: leading ? Math.max(ACTION_SIZE, revealed - GAP * 2) : ACTION_SIZE,+ };+ });+ return <Animated.View style={[styles.action, { backgroundColor: background },+ leading ? { left: GAP } : { right: GAP + index * (ACTION_SIZE + GAP) }, animatedStyle]}>+ <Pressable accessibilityLabel={label} accessibilityRole="button" onPress={onPress}+ style={styles.pressable}>+ <View style={styles.icon}>+ <Icon size={iconSize.xl} strokeWidth={iconStroke.regular} color={foreground} />+ </View>+ </Pressable>+ </Animated.View>;+}++const makeStyles = (colors: ThemeColors) => StyleSheet.create({+ surface: { backgroundColor: colors.surface },+ leadingShell: { width: LEADING_WIDTH, overflow: 'visible' },+ trailingShell: { width: TRAILING_WIDTH, overflow: 'visible' },+ action: {+ borderRadius: radius.pill,+ height: ACTION_SIZE,+ position: 'absolute',+ top: '50%',+ marginTop: -ACTION_SIZE / 2,+ overflow: 'hidden',+ },+ pressable: { flex: 1 },+ icon: {+ alignItems: 'center', justifyContent: 'center',+ position: 'absolute', top: 0, bottom: 0, right: 0, width: ACTION_SIZE,+ },+});