Open History to see the last commit
1import { Platform, Pressable, View, type StyleProp, type ViewStyle } from "react-native";
2
3import { cn } from "../lib/cn";
4import type { DraftComposerFileAttachment } from "../lib/composerImages";
5import { SymbolView } from "./AppSymbol";
6import { AppText } from "./AppText";
7import { VideoAttachmentMenu } from "./VideoAttachmentMenu";
8import { VideoThumbnailImage } from "./VideoThumbnailImage";
9
10export function VideoAttachmentTile(props: {
11 readonly name: string;
12 readonly sourceIdentifier: string;
13 readonly thumbnailSource: string | DraftComposerFileAttachment | null;
14 readonly compact?: boolean;
15 readonly onPress: (sourceIdentifier: string) => void;
16 readonly onShare?: () => void;
17 readonly disabled?: boolean;
18 readonly className?: string;
19 readonly style?: StyleProp<ViewStyle>;
20}) {
21 return (
22 <VideoAttachmentMenu
23 sourceIdentifier={props.sourceIdentifier}
24 onOpen={() => props.onPress(props.sourceIdentifier)}
25 onShare={props.onShare}
26 disabled={props.disabled}
27 >
28 <Pressable
29 accessibilityRole="button"
30 accessibilityLabel={`Play ${props.name}`}
31 accessibilityHint={
32 Platform.OS === "ios" && props.onShare
33 ? "Touch and hold for save and share options"
34 : undefined
35 }
36 accessibilityState={{ disabled: props.disabled ?? false }}
37 disabled={props.disabled}
38 onPress={() => props.onPress(props.sourceIdentifier)}
39 className={cn("items-center justify-center overflow-hidden bg-black/80", props.className)}
40 style={props.style}
41 >
42 <VideoThumbnailImage cacheKey={props.sourceIdentifier} source={props.thumbnailSource} />
43 <View
44 className={cn(
45 "items-center justify-center rounded-full bg-black/45",
46 props.compact ? "size-6" : "size-12",
47 )}
48 >
49 <SymbolView
50 name="play"
51 size={props.compact ? 15 : 24}
52 tintColor="#ffffff"
53 type="monochrome"
54 />
55 </View>
56 {!props.compact ? (
57 <View className="absolute inset-x-0 bottom-0 bg-black/55 px-2 py-1.5">
58 <AppText className="text-center text-xs text-white" numberOfLines={1}>
59 {props.name}
60 </AppText>
61 </View>
62 ) : null}
63 </Pressable>
64 </VideoAttachmentMenu>
65 );
66}