import React from 'react' import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native' import {Image} from 'expo-image' import {AppBskyFeedDefs} from '@atproto/api' import {Trans} from '@lingui/macro' import {isTenorGifUri} from '#/lib/strings/embed-player' import {atoms as a, useTheme} from '#/alf' import {MediaInsetBorder} from '#/components/MediaInsetBorder' import {Text} from '#/components/Typography' import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' import * as bsky from '#/types/bsky' /** * Streamlined MediaPreview component which just handles images, gifs, and videos */ export function Embed({ embed, style, }: { embed: AppBskyFeedDefs.PostView['embed'] style?: StyleProp }) { const e = bsky.post.parseEmbed(embed) if (!e) return null if (e.type === 'images') { return ( {e.view.images.map(image => ( ))} ) } else if (e.type === 'link') { if (!e.view.external.thumb) return null if (!isTenorGifUri(e.view.external.uri)) return null return ( ) } else if (e.type === 'video') { return ( ) } else if ( e.type === 'post_with_media' && // ignore further "nested" RecordWithMedia e.media.type !== 'post_with_media' && // ignore any unknowns e.media.view !== null ) { 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 }) { const t = useTheme() 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: '600', }, })