Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadQueueControl.tsx

652 lines26.1 KB

1import { type StaticScreenProps, useNavigation } from "@react-navigation/native";
2import { useAtomValue } from "@effect/atom-react";
3import type { ChatAttachment, EnvironmentId, RunId, ThreadId } from "@t3tools/contracts";
4import { Atom } from "effect/reactivity";
5import { Image } from "expo-image";
6import * as Haptics from "expo-haptics";
7import { useEffect, useEffectEvent, useRef, useState } from "react";
8import { Animated, Platform, Pressable, ScrollView, View } from "react-native";
9import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
10import ReanimatedSwipeable, {
11 type SwipeableMethods,
12} from "react-native-gesture-handler/ReanimatedSwipeable";
13import { Screen, ScreenStack, ScreenStackHeaderConfig } from "react-native-screens";
14import { useSafeAreaInsets } from "react-native-safe-area-context";
15import Reanimated, { ReduceMotion, useAnimatedStyle, withTiming } from "react-native-reanimated";
16​
17import { Button } from "../../components/ui/Button";
18import { AndroidSheetHeader } from "../../components/ui/AndroidScreenHeader";
19import { AppText as Text } from "../../components/ui/AppText";
20import { SymbolView } from "../../components/ui/AppSymbol";
21import { Menu } from "../../components/ui/Menu";
22import { ScreenContent } from "../../components/ui/ScreenContent";
23import { scopedThreadKey } from "../../lib/scopedEntities";
24import { useUniwindTheme } from "../../lib/useUniwindTheme";
25import { NativeStackScreenOptions, nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
26import { useAssetUrl } from "../../state/assets";
27import { assetImageSource } from "../../lib/assetImageSource";
28import { beginQueuedRunEdit, useQueuedRunEdit } from "../../state/queued-run-edit";
29import { environmentThreadDetails, threadEnvironment } from "../../state/threads";
30import { useAtomCommand } from "../../state/use-atom-command";
31import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
32import {
33 REMOVE_QUEUED_MESSAGE_ACCESSIBILITY_LABEL,
34 buildCancelQueuedRunCommand,
35 resolveQueueDragBeforeRunId,
36 resolveQueueDropBeforeRunId,
37 resolveThreadQueueRowControls,
38} from "./threadQueueControlPresentation";
39import { threadDragGapOffset } from "./threadDragGap";
40​
41const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
42const REMOVE_ACTION_WIDTH = 76;
43const THUMBNAIL_LIMIT = 3;
44const EMPTY_QUEUED_COUNT_ATOM = Atom.make(0).pipe(
45 Atom.withLabel("mobile-thread-queue-count:empty"),
46);
47​
48type QueueTarget = { readonly environmentId: EnvironmentId; readonly threadId: ThreadId };
49type QueueAction = "steer" | "edit" | "up" | "down" | "remove";
50type QueueRowLayout = { readonly id: RunId; readonly y?: number; readonly height?: number };
51​
52export function useThreadQueueWorkflow(target: QueueTarget) {
53 return useAtomValue(environmentThreadDetails.queueWorkflowAtom(target));
55​
56export function useThreadQueuedCount(target: QueueTarget | null) {
57 return useAtomValue(
58 target === null ? EMPTY_QUEUED_COUNT_ATOM : environmentThreadDetails.queuedCountAtom(target),
59 );
61​
62export function ThreadQueueSheet({ route }: StaticScreenProps<QueueTarget>) {
63 const { layout } = useAdaptiveWorkspaceLayout();
64 const target = route.params;
65 const navigation = useNavigation();
66 const insets = useSafeAreaInsets();
67 const theme = useUniwindTheme();
68 const workflow = useThreadQueueWorkflow(target);
69 const threadKey = scopedThreadKey(target.environmentId, target.threadId);
70 const editing = useQueuedRunEdit(threadKey);
71 const reorder = useAtomCommand(threadEnvironment.reorderQueuedRun, "reorder queued message");
72 const promote = useAtomCommand(threadEnvironment.promoteQueuedRun, "promote queued message");
73 const cancel = useAtomCommand(threadEnvironment.cancelQueuedRun, "remove queued message");
74 const resume = useAtomCommand(threadEnvironment.resumeThreadQueue, "resume queue");
75 const [resuming, setResuming] = useState(false);
76 const [busyRunId, setBusyRunId] = useState<RunId | null>(null);
77 const busyRef = useRef(false);
78 const [draggedRunId, setDraggedRunId] = useState<RunId | null>(null);
79 const [previewBeforeRunId, setPreviewBeforeRunId] = useState<RunId | null | undefined>();
80 const [dragRows, setDragRows] = useState<ReadonlyArray<QueueRowLayout> | null>(null);
81 const rowLayouts = useRef(new Map<RunId, { y: number; height: number }>());
82 const drag = useRef<{
83 runId: RunId;
84 order: string;
85 beforeRunId: RunId | null | undefined;
86 rows: ReadonlyArray<QueueRowLayout>;
87 } | null>(null);
88 const [translation] = useState(() => new Animated.Value(0));
89 const queuedRuns = workflow?.queuedRuns ?? [];
90 const order = queuedRuns.map(({ run }) => run.id).join(",");
91​
92 useEffect(() => {
93 if (drag.current && drag.current.order !== order) {
94 drag.current = null;
95 setDraggedRunId(null);
96 setPreviewBeforeRunId(undefined);
97 setDragRows(null);
98 translation.setValue(0);
99 }
100 }, [order, translation]);
101​
102 const hadQueuedRuns = useRef(queuedRuns.length > 0);
103 useEffect(() => {
104 if (queuedRuns.length > 0) {
105 hadQueuedRuns.current = true;
106 return;
107 }
108 if (hadQueuedRuns.current) navigation.goBack();
109 }, [navigation, queuedRuns.length]);
110​
111 const move = async (runId: RunId, beforeRunId: RunId | null) => {
112 if (busyRef.current || !workflow?.canReorder) return;
113 busyRef.current = true;
114 setBusyRunId(runId);
115 void Haptics.selectionAsync();
116 await reorder({ ...target, input: { threadId: target.threadId, runId, beforeRunId } });
117 busyRef.current = false;
118 setBusyRunId(null);
119 };
120​
121 const act = async (runId: RunId, action: QueueAction) => {
122 if (busyRef.current) return;
123 const index = queuedRuns.findIndex(({ run }) => run.id === runId);
124 if (index < 0) return;
125 if (action === "up" && index > 0) {
126 await move(runId, queuedRuns[index - 1]!.run.id);
127 return;
128 }
129 if (action === "down" && index < queuedRuns.length - 1) {
130 await move(runId, queuedRuns[index + 2]?.run.id ?? null);
131 return;
132 }
133 if (action === "edit") {
134 const entry = queuedRuns[index]!;
135 void Haptics.selectionAsync();
136 beginQueuedRunEdit(threadKey, {
137 runId,
138 messageId: entry.messageId,
139 originalText: entry.text,
140 existingAttachments: entry.attachments,
141 ...(entry.context ? { context: entry.context } : {}),
142 });
143 navigation.goBack();
144 return;
145 }
146 if (action !== "steer" && action !== "remove") return;
147 busyRef.current = true;
148 setBusyRunId(runId);
149 void Haptics.selectionAsync();
150 if (action === "remove") {
151 await cancel(buildCancelQueuedRunCommand({ ...target, runId }));
152 } else if (workflow?.canSendNow) {
153 await resume({ ...target, input: { threadId: target.threadId, runId } });
154 } else if (workflow?.activeRun && workflow.canPromoteToSteer) {
155 await promote({
156 ...target,
157 input: {
158 threadId: target.threadId,
159 queuedRunId: runId,
160 targetRunId: workflow.activeRun.id,
161 },
162 });
163 }
164 busyRef.current = false;
165 setBusyRunId(null);
166 };
167​
168 const canReorder = workflow?.canReorder === true && queuedRuns.length > 1;
169 const sourceLayout = dragRows?.find((row) => row.id === draggedRunId);
170 const lastLayout = dragRows?.at(-1);
171 const insertionOffset =
172 previewBeforeRunId === undefined
173 ? undefined
174 : previewBeforeRunId === null
175 ? lastLayout?.y === undefined || lastLayout.height === undefined
176 ? undefined
177 : lastLayout.y + lastLayout.height
178 : dragRows?.find((row) => row.id === previewBeforeRunId)?.y;
179 const queueRows = () =>
180 queuedRuns.map(({ run }) => ({ id: run.id, ...rowLayouts.current.get(run.id) }));
181 const content = (
182 <ScrollView
183 nestedScrollEnabled
184 className="flex-1"
185 scrollEnabled={draggedRunId === null}
186 // UIKit must inset content beneath the floating translucent iOS header.
187 contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
188 contentContainerClassName="px-5 pb-6"
189 contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 16) + 8 }}
190 >
191 {workflow?.isHeld && queuedRuns.length > 0 ? (
192 <View className="gap-2 py-3">
193 <Text className="text-sm text-foreground-muted">Queue paused</Text>
194 <Button
195 label="Resume queue"
196 disabled={resuming || busyRunId !== null}
197 onPress={async () => {
198 if (busyRef.current) return;
199 busyRef.current = true;
200 setResuming(true);
201 await resume({ ...target, input: { threadId: target.threadId } });
202 busyRef.current = false;
203 setResuming(false);
204 }}
205 />
206 </View>
207 ) : null}
208 {queuedRuns.length === 0 ? (
209 <Text className="pt-6 text-center text-sm text-foreground-muted">
210 No messages waiting in this queue.
211 </Text>
212 ) : null}
213 {queuedRuns.map(({ run, text, attachments, context }, index) => {
214 const layout = dragRows?.find((row) => row.id === run.id);
215 const offset =
216 sourceLayout?.y !== undefined &&
217 sourceLayout.height !== undefined &&
218 layout?.y !== undefined &&
219 insertionOffset !== undefined
220 ? threadDragGapOffset(layout.y, sourceLayout.y, sourceLayout.height, insertionOffset)
221 : 0;
222 const controls = resolveThreadQueueRowControls({
223 busy: busyRunId !== null || draggedRunId !== null,
224 canPromoteToSteer: workflow?.canPromoteToSteer ?? false,
225 canSendNow: workflow?.canSendNow ?? false,
226 canReorder: workflow?.canReorder ?? false,
227 index,
228 isEditing: editing?.runId === run.id,
229 isGuestMessage: context?.guest !== undefined,
230 queuedCount: queuedRuns.length,
231 text,
232 });
233 const title =
234 controls.displayText || (attachments.length > 0 ? "Attachments" : "Queued message");
235 return (
236 <QueueShiftedRow
237 key={run.id}
238 offset={offset}
239 dragging={draggedRunId !== null}
240 lifted={draggedRunId === run.id}
241 onLayout={({ nativeEvent }) => rowLayouts.current.set(run.id, nativeEvent.layout)}
242 >
243 <Animated.View
244 className="flex-row items-center border-b border-border bg-sheet"
245 style={
246 draggedRunId === run.id
247 ? { transform: [{ translateY: translation }], zIndex: 1, opacity: 0.85 }
248 : undefined
249 }
250 >
251 {canReorder ? (
252 // Keep the vertical handle outside the sideways swipeable so their pans do not race.
253 <QueueDragHandle
254 disabled={busyRunId !== null}
255 title={title}
256 canMoveUp={controls.canMoveUp}
257 canMoveDown={controls.canMoveDown}
258 onStep={(action) => void act(run.id, action)}
259 onStart={() => {
260 const rows = queueRows();
261 const beforeRunId = resolveQueueDragBeforeRunId(rows, run.id, 0);
262 drag.current = { runId: run.id, order, beforeRunId, rows };
263 translation.setValue(0);
264 setDragRows(rows);
265 setPreviewBeforeRunId(beforeRunId);
266 setDraggedRunId(run.id);
267 void Haptics.selectionAsync();
268 }}
269 onMove={(y) => {
270 const current = drag.current;
271 if (current?.runId !== run.id || current.order !== order) return;
272 translation.setValue(y);
273 const before = resolveQueueDragBeforeRunId(current.rows, run.id, y);
274 if (current.beforeRunId !== before) {
275 current.beforeRunId = before;
276 setPreviewBeforeRunId(before);
277 }
278 }}
279 onEnd={(y, success) => {
280 const started = drag.current;
281 const stop = () => {
282 if (drag.current !== started) return;
283 drag.current = null;
284 setDraggedRunId(null);
285 setPreviewBeforeRunId(undefined);
286 setDragRows(null);
287 translation.setValue(0);
288 };
289 if (!success || started?.order !== order || started.runId !== run.id) {
290 stop();
291 return;
292 }
293 const before = resolveQueueDropBeforeRunId(started.rows, run.id, y);
294 if (before === undefined) {
295 stop();
296 return;
297 }
298 const source = started.rows.find((row) => row.id === run.id);
299 const tail = started.rows.at(-1);
300 const insertion =
301 before === null
302 ? tail?.y !== undefined && tail.height !== undefined
303 ? tail.y + tail.height
304 : undefined
305 : started.rows.find((row) => row.id === before)?.y;
306 if (
307 source?.y !== undefined &&
308 source.height !== undefined &&
309 insertion !== undefined
310 ) {
311 Animated.timing(translation, {
312 toValue: insertion - source.y - (insertion > source.y ? source.height : 0),
313 duration: 160,
314 useNativeDriver: true,
315 }).start();
316 }
317 setPreviewBeforeRunId(before);
318 void move(run.id, before).finally(stop);
319 }}
320 />
321 ) : null}
322 <QueueRowSwipeable
323 enabled={draggedRunId === null && busyRunId === null && controls.canDismiss}
324 background={theme["--color-sheet"]}
325 onRemove={() => void act(run.id, "remove")}
326 >
327 <View className="flex-row items-center">
328 <Menu
329 accessibilityLabel={`Actions for queued message ${index + 1}`}
330 shouldOpenOnLongPress
331 style={{ flex: 1 }}
332 actions={[
333 ...(workflow?.canPromoteToSteer || workflow?.canSendNow
334 ? [
335 {
336 id: "steer",
337 title: workflow?.canSendNow ? "Send now" : "Steer now",
338 attributes: { disabled: !controls.canSend },
339 image: Platform.OS === "ios" ? "arrow.turn.left.up" : "arrow_upward",
340 },
341 ]
342 : []),
343 {
344 id: "edit",
345 title: "Edit",
346 attributes: { disabled: !controls.canEdit },
347 image: Platform.OS === "ios" ? "pencil" : "edit",
348 },
349 { id: "up", title: "Move up", attributes: { disabled: !controls.canMoveUp } },
350 {
351 id: "down",
352 title: "Move down",
353 attributes: { disabled: !controls.canMoveDown },
354 },
355 {
356 id: "remove",
357 title: "Remove",
358 attributes: { disabled: !controls.canDismiss, destructive: true },
359 },
360 ]}
361 onPressAction={({ nativeEvent }) =>
362 void act(run.id, nativeEvent.event as QueueAction)
363 }
364 >
365 <Pressable
366 accessibilityRole="button"
367 accessibilityLabel={title}
368 accessibilityHint={
369 controls.canEdit
370 ? "Opens this message in the composer for editing"
371 : undefined
372 }
373 disabled={!controls.canEdit}
374 onPress={() => void act(run.id, "edit")}
375 className="min-h-14 flex-row items-center gap-2.5 py-2.5 active:opacity-70"
376 >
377 <QueueAttachmentThumbnails
378 environmentId={target.environmentId}
379 attachments={attachments}
380 />
381 <Text
382 className={
383 controls.isEditing
384 ? "min-w-0 flex-1 text-sm text-foreground-muted"
385 : "min-w-0 flex-1 text-sm text-foreground"
386 }
387 numberOfLines={1}
388 >
389 {context?.guest === undefined ? null : (
390 <Text className="font-t3-medium text-adaptive-fuchsia-600-300">
391 {`${context.guest.name} `}
392 </Text>
393 )}
394 {title}
395 </Text>
396 {controls.isEditing ? (
397 <Text className="shrink-0 text-2xs uppercase tracking-wide text-primary">
398 Editing
399 </Text>
400 ) : null}
401 </Pressable>
402 </Menu>
403 {workflow?.canPromoteToSteer || workflow?.canSendNow ? (
404 // Outside the edit row and full row height, so a near miss never opens the editor.
405 <Pressable
406 accessibilityRole="button"
407 accessibilityLabel={
408 workflow?.canSendNow
409 ? `Send message ${index + 1} now`
410 : `Steer with message ${index + 1} now`
411 }
412 disabled={!controls.canSend}
413 onPress={() => void act(run.id, "steer")}
414 className="shrink-0 justify-center self-stretch pl-4 active:opacity-70 disabled:opacity-40"
415 >
416 <View className="min-h-9 flex-row items-center gap-1.5 rounded-full bg-primary px-4">
417 <SymbolView
418 name={workflow?.canSendNow ? "arrow.up" : "arrow.turn.left.up"}
419 size={13}
420 tintColorClassName="accent-primary-foreground"
421 />
422 <Text className="font-t3-medium text-sm text-primary-foreground">
423 {workflow?.canSendNow ? "Send now" : "Steer"}
424 </Text>
425 </View>
426 </Pressable>
427 ) : null}
428 </View>
429 </QueueRowSwipeable>
430 </Animated.View>
431 </QueueShiftedRow>
432 );
433 })}
434 </ScrollView>
435 );
436​
437 if (Platform.OS === "ios") {
438 // Plain formSheets lack stack headers; host one in a nested native stack.
439 return (
440 <GestureHandlerRootView style={{ flex: 1 }}>
441 <View collapsable={false} className="flex-1 bg-sheet">
442 <ScreenStack style={{ flex: 1 }}>
443 <Screen
444 activityState={2}
445 enabled
446 isNativeStack
447 screenId="thread-queue-sheet-native"
448 scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}
449 style={{ backgroundColor: theme["--color-sheet"], flex: 1 }}
450 >
451 {content}
452 <ScreenStackHeaderConfig
453 backgroundColor="rgba(0,0,0,0)"
454 color={theme["--color-foreground"]}
455 hideBackButton
456 hideShadow={false}
457 title="Queued"
458 titleColor={theme["--color-foreground"]}
459 titleFontSize={18}
460 titleFontWeight="800"
461 translucent
462 />
463 </Screen>
464 </ScreenStack>
465 </View>
466 </GestureHandlerRootView>
467 );
468 }
469​
470 return (
471 <GestureHandlerRootView style={{ flex: 1 }}>
472 <View collapsable={false} className="flex-1 bg-sheet">
473 <NativeStackScreenOptions options={{ sheetCornerRadius: 28 }} />
474 <AndroidSheetHeader title="Queued" onBack={() => navigation.goBack()} />
475 <ScreenContent insetHorizontal={layout.usesSplitView}>{content}</ScreenContent>
476 </View>
477 </GestureHandlerRootView>
478 );
480​
481function QueueShiftedRow(props: {
482 readonly offset: number;
483 readonly dragging: boolean;
484 readonly lifted: boolean;
485 readonly onLayout: React.ComponentProps<typeof View>["onLayout"];
486 readonly children: React.ReactNode;
487}) {
488 const { dragging, offset } = props;
489 const style = useAnimatedStyle(() => ({
490 transform: [
491 {
492 translateY: dragging
493 ? withTiming(offset, { duration: 160, reduceMotion: ReduceMotion.System })
494 : offset,
495 },
496 ],
497 }));
498 return (
499 <Reanimated.View onLayout={props.onLayout} style={[style, { zIndex: props.lifted ? 1 : 0 }]}>
500 {props.children}
501 </Reanimated.View>
502 );
504​
505function QueueRowSwipeable(props: {
506 readonly enabled: boolean;
507 readonly background: string;
508 readonly onRemove: () => void;
509 readonly children: React.ReactNode;
510}) {
511 const swipeableRef = useRef<SwipeableMethods | null>(null);
512 return (
513 <ReanimatedSwipeable
514 ref={swipeableRef}
515 enabled={props.enabled}
516 friction={2}
517 rightThreshold={40}
518 overshootRight={false}
519 // Require a clearly sideways swipe to avoid competing with sheet scroll and drag handles.
520 failOffsetY={[-12, 12]}
521 containerStyle={{ backgroundColor: props.background, flex: 1 }}
522 childrenContainerStyle={{ backgroundColor: props.background }}
523 onSwipeableOpen={(direction) => {
524 if (direction !== "right") return;
525 swipeableRef.current?.close();
526 props.onRemove();
527 }}
528 renderRightActions={() => (
529 <Pressable
530 accessibilityRole="button"
531 accessibilityLabel={REMOVE_QUEUED_MESSAGE_ACCESSIBILITY_LABEL}
532 disabled={!props.enabled}
533 onPress={() => {
534 swipeableRef.current?.close();
535 props.onRemove();
536 }}
537 className="items-center justify-center bg-danger active:opacity-70 disabled:opacity-40"
538 style={{ width: REMOVE_ACTION_WIDTH }}
539 >
540 <SymbolView name="trash" size={16} tintColorClassName="accent-danger-foreground" />
541 <Text className="pt-1 text-2xs font-t3-medium text-danger-foreground">Remove</Text>
542 </Pressable>
543 )}
544 >
545 {props.children}
546 </ReanimatedSwipeable>
547 );
549​
550function QueueAttachmentThumbnails(props: {
551 readonly environmentId: EnvironmentId;
552 readonly attachments: ReadonlyArray<ChatAttachment>;
553}) {
554 const images = props.attachments.filter((attachment) => attachment.mimeType.startsWith("image/"));
555 const shown = images.slice(0, THUMBNAIL_LIMIT);
556 const overflow = props.attachments.length - shown.length;
557 if (props.attachments.length === 0) return null;
558 return (
559 <View className="shrink-0 flex-row items-center gap-1">
560 {shown.map((attachment) => (
561 <QueueAttachmentThumbnail
562 key={attachment.id}
563 environmentId={props.environmentId}
564 attachment={attachment}
565 />
566 ))}
567 {overflow > 0 ? (
568 <View className="h-6 min-w-6 items-center justify-center rounded bg-subtle px-1">
569 <Text className="text-2xs tabular-nums text-foreground-muted">
570 {shown.length === 0 ? `${overflow}` : `+${overflow}`}
571 </Text>
572 </View>
573 ) : null}
574 </View>
575 );
577​
578function QueueAttachmentThumbnail(props: {
579 readonly environmentId: EnvironmentId;
580 readonly attachment: ChatAttachment;
581}) {
582 const resource = {
583 _tag: "attachment",
584 attachmentId: props.attachment.id,
585 fileName: props.attachment.name,
586 mimeType: props.attachment.mimeType,
587 disposition: "inline",
588 } as const;
589 const url = useAssetUrl(props.environmentId, resource);
590 if (url === null) {
591 return <View className="h-6 w-6 rounded bg-subtle" />;
592 }
593 return (
594 <Image
595 source={assetImageSource(props.environmentId, resource, url)}
596 cachePolicy="memory-disk"
597 contentFit="cover"
598 style={{ width: 24, height: 24, borderRadius: 4 }}
599 accessibilityIgnoresInvertColors
600 />
601 );
603​
604function QueueDragHandle(props: {
605 disabled: boolean;
606 title: string;
607 canMoveUp: boolean;
608 canMoveDown: boolean;
609 onStep: (action: "up" | "down") => void;
610 onStart: () => void;
611 onMove: (y: number) => void;
612 onEnd: (y: number, success: boolean) => void;
613}) {
614 const onStart = useEffectEvent(() => props.onStart());
615 const onMove = useEffectEvent((y: number) => props.onMove(y));
616 const onEnd = useEffectEvent((y: number, success: boolean) => props.onEnd(y, success));
617 const gesture = Gesture.Pan()
618 .enabled(!props.disabled)
619 .minDistance(0)
620 .shouldCancelWhenOutside(false)
621 .runOnJS(true)
622 .onStart(() => onStart())
623 .onUpdate((event) => onMove(event.translationY))
624 .onFinalize((event, success) => onEnd(event.translationY, success));
625 return (
626 <GestureDetector gesture={gesture}>
627 <View
628 collapsable={false}
629 accessible
630 accessibilityRole="adjustable"
631 accessibilityLabel={`Reorder ${props.title}`}
632 accessibilityState={{ disabled: props.disabled }}
633 accessibilityActions={[
634 ...(props.canMoveUp ? [{ name: "decrement", label: "Move up" }] : []),
635 ...(props.canMoveDown ? [{ name: "increment", label: "Move down" }] : []),
636 ]}
637 onAccessibilityAction={({ nativeEvent }) => {
638 if (props.disabled) return;
639 if (nativeEvent.actionName === "decrement" && props.canMoveUp) props.onStep("up");
640 if (nativeEvent.actionName === "increment" && props.canMoveDown) props.onStep("down");
641 }}
642 className="h-12 w-8 items-center justify-center"
643 >
644 <SymbolView
645 name="line.3.horizontal"
646 size={16}
647 tintColorClassName="accent-foreground-muted"
648 />
649 </View>
650 </GestureDetector>
651 );