import analytics from '@components/analytics' import Button from '@components/Button' import haptics from '@components/haptics' import { ParseHTML } from '@components/Parse' import RelativeTime from '@components/RelativeTime' import { BlurView } from '@react-native-community/blur' import { useAccessibility } from '@utils/accessibility/AccessibilityManager' import { RootStackScreenProps } from '@utils/navigation/navigators' import { useAnnouncementMutation, useAnnouncementQuery } from '@utils/queryHooks/announcement' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useCallback, useEffect, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { Dimensions, Platform, Pressable, StyleSheet, Text, View } from 'react-native' import { Circle } from 'react-native-animated-spinkit' import FastImage from 'react-native-fast-image' import { FlatList, ScrollView } from 'react-native-gesture-handler' import { SafeAreaView } from 'react-native-safe-area-context' const ScreenAnnouncements: React.FC< RootStackScreenProps<'Screen-Announcements'> > = ({ route: { params: { showAll = false } }, navigation }) => { const { reduceMotionEnabled } = useAccessibility() const { colors, mode } = useTheme() const [index, setIndex] = useState(0) const { t } = useTranslation('screenAnnouncements') const query = useAnnouncementQuery({ showAll, options: { select: announcements => announcements.filter(announcement => showAll ? announcement : !announcement.read ) } }) const mutation = useAnnouncementMutation({ onSettled: () => { haptics('Success') query.refetch() } }) useEffect(() => { if (!showAll && query.data?.length === 0) { navigation.goBack() } }, [query.data]) const renderItem = useCallback( ({ item, index }: { item: Mastodon.Announcement; index: number }) => ( navigation.goBack()} /> ]} /> {item.reactions?.length ? ( {item.reactions?.map(reaction => ( { analytics('accnouncement_reaction_press', { current: reaction.me }) mutation.mutate({ id: item.id, type: 'reaction', name: reaction.name, me: reaction.me }) }} > {reaction.url ? ( ) : ( {reaction.name} )} {reaction.count ? ( {reaction.count} ) : null} ))} {/* invisibleTextInputRef.current?.focus()} > */} ) : null}