import AccountButton from '@components/AccountButton' import CustomText from '@components/Text' import navigationRef from '@helpers/navigationRef' import { RootStackScreenProps } from '@utils/navigation/navigators' import { getInstances } from '@utils/slices/instancesSlice' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import * as VideoThumbnails from 'expo-video-thumbnails' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { FlatList, Image, ScrollView, View } from 'react-native' import { SafeAreaProvider } from 'react-native-safe-area-context' import { useSelector } from 'react-redux' const Share = ({ text, media }: { text?: string | undefined media?: | { uri: string mime: string }[] | undefined }) => { const { colors } = useTheme() const [images, setImages] = useState([]) useEffect(() => { const prepareThumbs = async (media: { uri: string; mime: string }[]) => { const thumbs: string[] = [] for (const m of media) { if (m.mime.startsWith('image/')) { thumbs.push(m.uri) } else if (m.mime.startsWith('video/')) { const { uri } = await VideoThumbnails.getThumbnailAsync(m.uri) thumbs.push(uri) } } setImages(thumbs) } if (media) { prepareThumbs(media) } }, []) if (text) { return ( ) } if (media) { return ( ( )} ItemSeparatorComponent={() => ( )} /> ) } return null } // Only needed when data incoming into the app when there are multiple accounts const ScreenAccountSelection = ({ route: { params: { share } } }: RootStackScreenProps<'Screen-AccountSelection'>) => { const { colors } = useTheme() const { t } = useTranslation('screenAccountSelection') const instances = useSelector(getInstances, () => true) return ( {share ? : null} {t('content.select_account')} {instances.length ? instances .slice() .sort((a, b) => `${a.uri}${a.account.acct}`.localeCompare( `${b.uri}${b.account.acct}` ) ) .map((instance, index) => { return ( { navigationRef.navigate('Screen-Compose', { type: 'share', ...share }) }} /> ) }) : null} ) } export default ScreenAccountSelection