2021-01-24 02:25:43 +01:00
|
|
|
import { useNavigation } from '@react-navigation/native'
|
|
|
|
import { StackNavigationProp } from '@react-navigation/stack'
|
2022-04-29 23:57:18 +02:00
|
|
|
import { TabLocalStackParamList } from '@utils/navigation/navigators'
|
2021-01-16 00:00:31 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
2021-01-24 02:25:43 +01:00
|
|
|
import React, { useCallback } from 'react'
|
2022-05-07 00:52:32 +02:00
|
|
|
import { Pressable } from 'react-native'
|
2021-01-24 02:25:43 +01:00
|
|
|
import analytics from './analytics'
|
2022-05-07 00:52:32 +02:00
|
|
|
import CustomText from './Text'
|
2021-01-16 00:00:31 +01:00
|
|
|
|
|
|
|
export interface Props {
|
2021-01-24 02:25:43 +01:00
|
|
|
hashtag: Mastodon.Tag
|
|
|
|
onPress?: () => void
|
|
|
|
origin?: string
|
2021-01-16 00:00:31 +01:00
|
|
|
}
|
|
|
|
|
2021-01-24 02:25:43 +01:00
|
|
|
const ComponentHashtag: React.FC<Props> = ({
|
|
|
|
hashtag,
|
|
|
|
onPress: customOnPress,
|
|
|
|
origin
|
|
|
|
}) => {
|
2022-02-12 14:51:01 +01:00
|
|
|
const { colors } = useTheme()
|
|
|
|
const navigation =
|
2022-04-29 23:57:18 +02:00
|
|
|
useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
2021-01-24 02:25:43 +01:00
|
|
|
|
|
|
|
const onPress = useCallback(() => {
|
|
|
|
analytics('search_account_press', { page: origin })
|
2021-01-30 01:29:15 +01:00
|
|
|
navigation.push('Tab-Shared-Hashtag', { hashtag: hashtag.name })
|
2021-01-24 02:25:43 +01:00
|
|
|
}, [])
|
2021-01-16 00:00:31 +01:00
|
|
|
|
|
|
|
return (
|
2021-04-09 21:43:12 +02:00
|
|
|
<Pressable
|
|
|
|
accessibilityRole='button'
|
2022-05-07 00:52:32 +02:00
|
|
|
style={{ padding: StyleConstants.Spacing.S * 1.5 }}
|
2021-04-09 21:43:12 +02:00
|
|
|
onPress={customOnPress || onPress}
|
|
|
|
>
|
2022-05-07 00:52:32 +02:00
|
|
|
<CustomText fontStyle='M' style={{ color: colors.primaryDefault }}>
|
2021-01-24 02:25:43 +01:00
|
|
|
#{hashtag.name}
|
2022-05-07 00:52:32 +02:00
|
|
|
</CustomText>
|
2021-01-16 00:00:31 +01:00
|
|
|
</Pressable>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ComponentHashtag
|