tooot/src/components/Timelines/Timeline/Header.tsx

62 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-01-24 02:25:43 +01:00
import analytics from '@components/analytics'
2021-01-07 19:13:09 +01:00
import { useNavigation } from '@react-navigation/native'
import Icon from '@root/components/Icon'
import { StyleConstants } from '@root/utils/styles/constants'
import { useTheme } from '@root/utils/styles/ThemeManager'
2021-01-18 00:23:40 +01:00
import { updatePublicRemoteNotice } from '@utils/slices/contextsSlice'
2021-01-07 19:13:09 +01:00
import React from 'react'
2021-01-19 01:13:45 +01:00
import { useTranslation } from 'react-i18next'
2021-01-07 19:13:09 +01:00
import { StyleSheet, Text, View } from 'react-native'
2021-01-18 00:23:40 +01:00
import { useDispatch } from 'react-redux'
2021-01-07 19:13:09 +01:00
const TimelineHeader = React.memo(
() => {
2021-01-19 01:13:45 +01:00
const { t } = useTranslation('componentTimeline')
2021-01-18 00:23:40 +01:00
const dispatch = useDispatch()
2021-01-07 19:13:09 +01:00
const navigation = useNavigation()
const { theme } = useTheme()
return (
<View style={[styles.base, { borderColor: theme.border }]}>
<Text style={[styles.text, { color: theme.primary }]}>
2021-01-19 01:13:45 +01:00
{t('header.explanation')}
2021-01-07 19:13:09 +01:00
<Text
style={{ color: theme.blue }}
2021-01-10 02:12:14 +01:00
onPress={() => {
2021-01-24 02:25:43 +01:00
analytics('timeline_remote_header_press')
2021-01-18 00:23:40 +01:00
dispatch(updatePublicRemoteNotice(1))
2021-01-12 00:12:44 +01:00
navigation.navigate('Screen-Me', {
screen: 'Screen-Me-Root',
params: { navigateAway: 'Screen-Me-Settings-UpdateRemote' }
})
2021-01-10 02:12:14 +01:00
}}
2021-01-07 19:13:09 +01:00
>
2021-01-19 01:13:45 +01:00
{t('header.button')}
2021-01-07 19:13:09 +01:00
<Icon
name='ArrowRight'
size={StyleConstants.Font.Size.S}
color={theme.blue}
/>
</Text>
</Text>
</View>
)
},
() => true
)
const styles = StyleSheet.create({
base: {
margin: StyleConstants.Spacing.Global.PagePadding,
paddingHorizontal: StyleConstants.Spacing.M,
paddingVertical: StyleConstants.Spacing.S,
borderWidth: 1,
borderRadius: 6
},
text: {
...StyleConstants.FontStyle.S
}
})
export default TimelineHeader