tooot/src/components/Timelines/Timeline/Shared/Avatar.tsx

39 lines
1.0 KiB
TypeScript
Raw Normal View History

2020-11-28 17:07:30 +01:00
import React, { useCallback } from 'react'
2020-10-28 00:02:37 +01:00
import { Image, Pressable, StyleSheet } from 'react-native'
2020-12-13 14:04:25 +01:00
import { StyleConstants } from '@utils/styles/constants'
2020-12-18 00:00:45 +01:00
import { useNavigation } from '@react-navigation/native'
2020-11-23 00:07:32 +01:00
2020-10-31 21:04:46 +01:00
export interface Props {
2020-12-18 23:58:53 +01:00
queryKey?: QueryKey.Timeline
2020-12-03 01:28:56 +01:00
account: Mastodon.Account
2020-10-31 21:04:46 +01:00
}
const TimelineAvatar: React.FC<Props> = ({ queryKey, account }) => {
2020-10-28 00:02:37 +01:00
const navigation = useNavigation()
2020-10-30 00:49:05 +01:00
// Need to fix go back root
2020-11-28 17:07:30 +01:00
const onPress = useCallback(() => {
2020-12-21 21:47:15 +01:00
queryKey && navigation.push('Screen-Shared-Account', { account })
2020-11-28 17:07:30 +01:00
}, [])
2020-10-28 00:02:37 +01:00
return (
2020-11-28 17:07:30 +01:00
<Pressable style={styles.avatar} onPress={onPress}>
2020-12-21 22:58:53 +01:00
<Image source={{ uri: account.avatar_static }} style={styles.image} />
2020-10-28 00:02:37 +01:00
</Pressable>
)
2020-10-25 01:35:41 +02:00
}
const styles = StyleSheet.create({
avatar: {
2020-12-19 01:57:57 +01:00
flexBasis: StyleConstants.Avatar.M,
height: StyleConstants.Avatar.M,
2020-11-30 00:24:53 +01:00
marginRight: StyleConstants.Spacing.S
2020-10-28 00:02:37 +01:00
},
image: {
width: '100%',
2020-11-23 00:07:32 +01:00
height: '100%',
borderRadius: 6
2020-10-25 01:35:41 +02:00
}
})
2020-12-03 01:28:56 +01:00
export default React.memo(TimelineAvatar, () => true)