import React from 'react' import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native' import {Image} from 'expo-image' import { AppBskyEmbedExternal, AppBskyEmbedImages, AppBskyEmbedRecordWithMedia, AppBskyEmbedVideo, } from '@atproto/api' import {Trans} from '@lingui/macro' import {parseTenorGif} from '#/lib/strings/embed-player' import {atoms as a} from '#/alf' import {Text} from '#/components/Typography' import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' /** * Streamlined MediaPreview component which just handles images, gifs, and videos */ export function Embed({ embed, style, }: { embed?: | AppBskyEmbedImages.View | AppBskyEmbedRecordWithMedia.View | AppBskyEmbedExternal.View | AppBskyEmbedVideo.View | {[k: string]: unknown} style?: StyleProp }) { let media = AppBskyEmbedRecordWithMedia.isView(embed) ? embed.media : embed if (AppBskyEmbedImages.isView(media)) { return ( {media.images.map(image => ( ))} ) } else if (AppBskyEmbedExternal.isView(embed) && embed.external.thumb) { let url: URL | undefined try { url = new URL(embed.external.uri) } catch {} if (url) { const {success} = parseTenorGif(url) if (success) { return ( ) } } } else if (AppBskyEmbedVideo.isView(embed)) { return ( ) } return null } export function Outer({ children, style, }: { children?: React.ReactNode style?: StyleProp }) { return {children} } export function ImageItem({ thumbnail, alt, children, }: { thumbnail: string alt?: string children?: React.ReactNode }) { return ( {children} ) } export function GifItem({thumbnail, alt}: {thumbnail: string; alt?: string}) { return ( GIF ) } export function VideoItem({ thumbnail, alt, }: { thumbnail?: string alt?: string }) { if (!thumbnail) { return ( ) } return ( ) } const styles = StyleSheet.create({ altContainer: { backgroundColor: 'rgba(0, 0, 0, 0.75)', borderRadius: 6, paddingHorizontal: 6, paddingVertical: 3, position: 'absolute', right: 5, bottom: 5, zIndex: 2, }, alt: { color: 'white', fontSize: 7, fontWeight: 'bold', }, })