tooot/src/components/Hashtag.tsx

43 lines
1.2 KiB
TypeScript
Raw Normal View History

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'
import { Pressable } from 'react-native'
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(() => {
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'
style={{ padding: StyleConstants.Spacing.S * 1.5 }}
2021-04-09 21:43:12 +02:00
onPress={customOnPress || onPress}
>
<CustomText fontStyle='M' style={{ color: colors.primaryDefault }}>
2021-01-24 02:25:43 +01:00
#{hashtag.name}
</CustomText>
2021-01-16 00:00:31 +01:00
</Pressable>
)
}
export default ComponentHashtag