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

42 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'
import { useNavigation } from '@react-navigation/native'
2020-12-13 14:04:25 +01:00
import { StyleConstants } from '@utils/styles/constants'
2020-11-23 00:07:32 +01:00
2020-10-31 21:04:46 +01:00
export interface Props {
queryKey?: App.QueryKey
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(() => {
queryKey &&
navigation.navigate('Screen-Shared-Account', {
id: account.id
})
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-03 01:28:56 +01:00
<Image source={{ uri: account.avatar }} 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-12 22:19:18 +01:00
flexBasis: StyleConstants.Avatar.S,
2020-11-30 00:24:53 +01:00
height: StyleConstants.Avatar.S,
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)