tooot/src/components/Timeline/Shared/HeaderShared/Application.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-01-24 02:25:43 +01:00
import analytics from '@components/analytics'
2021-01-01 23:10:47 +01:00
import openLink from '@components/openLink'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { StyleSheet, Text } from 'react-native'
export interface Props {
application?: Mastodon.Application
}
const HeaderSharedApplication: React.FC<Props> = ({ application }) => {
const { theme } = useTheme()
2021-01-19 01:13:45 +01:00
const { t } = useTranslation('componentTimeline')
2021-01-01 23:10:47 +01:00
return application && application.name !== 'Web' ? (
<Text
2021-01-24 02:25:43 +01:00
onPress={async () => {
analytics('timeline_shared_header_application_press', {
application
})
2021-01-01 23:10:47 +01:00
application.website && (await openLink(application.website))
2021-01-24 02:25:43 +01:00
}}
2021-01-01 23:10:47 +01:00
style={[styles.application, { color: theme.secondary }]}
>
{t('shared.header.shared.application', { application: application.name })}
</Text>
) : null
}
const styles = StyleSheet.create({
application: {
...StyleConstants.FontStyle.S,
marginLeft: StyleConstants.Spacing.S
}
})
export default HeaderSharedApplication