import Icon from '@components/Icon' import { ParseEmojis } from '@components/Parse' import { useNavigation } from '@react-navigation/native' import { StackNavigationProp } from '@react-navigation/stack' import { TabLocalStackParamList } from '@utils/navigation/navigators' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useContext } from 'react' import { useTranslation } from 'react-i18next' import { Pressable, StyleSheet, View } from 'react-native' import StatusContext from './Context' export interface Props { action: Mastodon.Notification['type'] | 'reblog' | 'pinned' isNotification?: boolean account?: Mastodon.Account } const TimelineActioned: React.FC = ({ action, isNotification, ...rest }) => { const { status } = useContext(StatusContext) const account = isNotification ? rest.account : status?.account if (!status || !account) return null const { t } = useTranslation('componentTimeline') const { colors } = useTheme() const navigation = useNavigation>() const name = account?.display_name || account?.username const iconColor = colors.primaryDefault const content = (content: string) => ( ) const onPress = () => navigation.push('Tab-Shared-Account', { account }) const children = () => { switch (action) { case 'pinned': return ( <> {content(t('shared.actioned.pinned'))} ) case 'favourite': return ( <> {content(t('shared.actioned.favourite', { name }))} ) case 'follow': return ( <> {content(t('shared.actioned.follow', { name }))} ) case 'follow_request': return ( <> {content(t('shared.actioned.follow_request', { name }))} ) case 'poll': return ( <> {content(t('shared.actioned.poll'))} ) case 'reblog': return ( <> {content( isNotification ? t('shared.actioned.reblog.notification', { name }) : t('shared.actioned.reblog.default', { name }) )} ) case 'status': return ( <> {content(t('shared.actioned.status', { name }))} ) case 'update': return ( <> {content(t('shared.actioned.update'))} ) default: return <> } } return ( ) } const styles = StyleSheet.create({ icon: { marginRight: StyleConstants.Spacing.S } }) export default TimelineActioned