@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 83 lines 3.28 KB
Raw
1 import { useGT } from "gt-react-native";
2 import { Platform, Pressable, View, type StyleProp, type ViewStyle } from "react-native";
3
4 import { cn } from "../lib/cn";
5 import type { DraftComposerFileAttachment } from "../lib/composerImages";
6 import { useMediaActions } from "../state/mediaActions";
7 import { type MediaActionsSource } from "../lib/mediaActionsSource";
8 import { SymbolView } from "./ui/AppSymbol";
9 import { AppText } from "./ui/AppText";
10 import { MediaActionsMenu } from "./MediaActionsMenu";
11 import { PresentationSource } from "./ui/NativePresentation";
12 import { VideoThumbnailImage } from "./VideoThumbnailImage";
13
14 export function VideoAttachmentTile(props: {
15 readonly name: string;
16 readonly sourceIdentifier: string;
17 readonly thumbnailSource: string | DraftComposerFileAttachment | null;
18 readonly actionsSource?: MediaActionsSource;
19 readonly compact?: boolean;
20 readonly onPress: (sourceIdentifier: string) => void;
21 readonly disabled?: boolean;
22 readonly className?: string;
23 readonly style?: StyleProp<ViewStyle>;
24 }) {
25 const gt = useGT();
26 const mediaActions = useMediaActions(props.disabled ? undefined : props.actionsSource);
27 const hasActions = mediaActions.actions.length > 0;
28 return (
29 <PresentationSource
30 identifier={props.sourceIdentifier}
31 accessible={Platform.OS === "ios"}
32 accessibilityRole="button"
33 accessibilityLabel={gt("Play {name}", { name: props.name })}
34 accessibilityState={{ disabled: props.disabled ?? false }}
35 onAccessibilityTap={() => {
36 if (!props.disabled) props.onPress(props.sourceIdentifier);
37 }}
38 accessibilityActions={mediaActions.actions.map(({ id, title }) => ({
39 name: id,
40 label: title,
41 }))}
42 onAccessibilityAction={({ nativeEvent }) => {
43 if (props.disabled) return;
44 mediaActions.actions.find(({ id }) => id === nativeEvent.actionName)?.run();
45 }}
46 >
47 <MediaActionsMenu media={mediaActions}>
48 <Pressable
49 accessibilityRole="button"
50 accessibilityLabel={gt("Play {name}", { name: props.name })}
51 accessibilityHint={hasActions ? gt("Touch and hold for media actions") : undefined}
52 accessibilityState={{ disabled: props.disabled ?? false }}
53 disabled={props.disabled}
54 onPress={() => props.onPress(props.sourceIdentifier)}
55 className={cn("items-center justify-center overflow-hidden bg-black/80", props.className)}
56 style={props.style}
57 >
58 <VideoThumbnailImage cacheKey={props.sourceIdentifier} source={props.thumbnailSource} />
59 <View
60 className={cn(
61 "items-center justify-center rounded-full bg-black/45",
62 props.compact ? "size-6" : "size-12",
63 )}
64 >
65 <SymbolView
66 name="play"
67 size={props.compact ? 15 : 24}
68 tintColor="#ffffff"
69 type="monochrome"
70 />
71 </View>
72 {!props.compact ? (
73 <View className="absolute inset-x-0 bottom-0 bg-black/55 px-2 py-1.5">
74 <AppText className="text-center text-xs text-white" numberOfLines={1}>
75 {props.name}
76 </AppText>
77 </View>
78 ) : null}
79 </Pressable>
80 </MediaActionsMenu>
81 </PresentationSource>
82 );
83 }