mirror of
https://github.com/tooot-app/app
synced 2025-02-15 19:30:55 +01:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { useNavigation } from '@react-navigation/native'
|
|
import { StackNavigationProp } from '@react-navigation/stack'
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
|
import React, { useCallback } from 'react'
|
|
import { Pressable, StyleSheet, Text } from 'react-native'
|
|
import analytics from './analytics'
|
|
|
|
export interface Props {
|
|
hashtag: Mastodon.Tag
|
|
onPress?: () => void
|
|
origin?: string
|
|
}
|
|
|
|
const ComponentHashtag: React.FC<Props> = ({
|
|
hashtag,
|
|
onPress: customOnPress,
|
|
origin
|
|
}) => {
|
|
const { theme } = useTheme()
|
|
const navigation = useNavigation<
|
|
StackNavigationProp<Nav.TabLocalStackParamList>
|
|
>()
|
|
|
|
const onPress = useCallback(() => {
|
|
analytics('search_account_press', { page: origin })
|
|
navigation.push('Tab-Shared-Hashtag', { hashtag: hashtag.name })
|
|
}, [])
|
|
|
|
return (
|
|
<Pressable
|
|
accessibilityRole='button'
|
|
style={styles.itemDefault}
|
|
onPress={customOnPress || onPress}
|
|
>
|
|
<Text style={[styles.itemHashtag, { color: theme.primaryDefault }]}>
|
|
#{hashtag.name}
|
|
</Text>
|
|
</Pressable>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
itemDefault: {
|
|
padding: StyleConstants.Spacing.S * 1.5
|
|
},
|
|
itemHashtag: {
|
|
...StyleConstants.FontStyle.M
|
|
}
|
|
})
|
|
|
|
export default ComponentHashtag
|