import React, {useEffect, useState} from 'react' import { ActivityIndicator, Image, ImageStyle, StyleSheet, StyleProp, Text, TouchableWithoutFeedback, View, ViewStyle, } from 'react-native' import { Record as PostRecord, Entity, } from '../../../third-party/api/src/client/types/app/bsky/feed/post' import * as AppBskyEmbedImages from '../../../third-party/api/src/client/types/app/bsky/embed/images' import * as AppBskyEmbedExternal from '../../../third-party/api/src/client/types/app/bsky/embed/external' import {Link} from '../util/Link' import {LinkMeta, getLikelyType, LikelyType} from '../../../lib/link-meta' import {colors} from '../../lib/styles' import {AutoSizedImage} from './images/AutoSizedImage' type Embed = | AppBskyEmbedImages.Presented | AppBskyEmbedExternal.Presented | {$type: string; [k: string]: unknown} export function PostEmbeds({ embed, style, }: { embed?: Embed style?: StyleProp }) { if (embed?.$type === 'app.bsky.embed.images#presented') { const imgEmbed = embed as AppBskyEmbedImages.Presented if (imgEmbed.images.length > 0) { const Thumb = ({i, style}: {i: number; style: StyleProp}) => ( ) if (imgEmbed.images.length === 4) { return ( ) } else if (imgEmbed.images.length === 3) { return ( ) } else if (imgEmbed.images.length === 2) { return ( ) } else { return ( ) } } } if (embed?.$type === 'app.bsky.embed.external#presented') { const externalEmbed = embed as AppBskyEmbedExternal.Presented const link = externalEmbed.external return ( {link.thumb ? ( ) : undefined} {link.title || link.uri} {link.uri} {link.description ? ( {link.description} ) : undefined} ) } return } const styles = StyleSheet.create({ imagesContainer: { marginBottom: 10, }, imagesWidthSpacer: { width: 5, }, imagesHeightSpacer: { height: 5, }, imagePair: { flexDirection: 'row', }, imagePairItem: { resizeMode: 'contain', flex: 1, borderRadius: 4, }, imageWide: {}, imageWideItem: { resizeMode: 'contain', borderRadius: 4, }, imageBig: {}, imageBigItem: { borderRadius: 4, }, extOuter: { borderWidth: 1, borderColor: colors.gray2, borderRadius: 8, padding: 10, }, extImage: { // TODO }, extTitle: { fontSize: 16, fontWeight: 'bold', }, extDescription: { marginTop: 4, fontSize: 15, }, extUrl: { color: colors.gray4, }, })