Use avatar in viewheader when cant go back
parent
ac97667206
commit
135628baf2
|
@ -8,6 +8,7 @@ import {
|
||||||
View,
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
|
import {UserAvatar} from './UserAvatar'
|
||||||
import {s, colors} from '../../lib/styles'
|
import {s, colors} from '../../lib/styles'
|
||||||
import {MagnifyingGlassIcon} from '../../lib/icons'
|
import {MagnifyingGlassIcon} from '../../lib/icons'
|
||||||
import {useStores} from '../../../state'
|
import {useStores} from '../../../state'
|
||||||
|
@ -18,10 +19,12 @@ const BACK_HITSLOP = {left: 10, top: 10, right: 30, bottom: 10}
|
||||||
export const ViewHeader = observer(function ViewHeader({
|
export const ViewHeader = observer(function ViewHeader({
|
||||||
title,
|
title,
|
||||||
subtitle,
|
subtitle,
|
||||||
|
canGoBack,
|
||||||
onPost,
|
onPost,
|
||||||
}: {
|
}: {
|
||||||
title: string
|
title: string
|
||||||
subtitle?: string
|
subtitle?: string
|
||||||
|
canGoBack?: boolean
|
||||||
onPost?: () => void
|
onPost?: () => void
|
||||||
}) {
|
}) {
|
||||||
const store = useStores()
|
const store = useStores()
|
||||||
|
@ -43,19 +46,28 @@ export const ViewHeader = observer(function ViewHeader({
|
||||||
console.log(e)
|
console.log(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const canGoBack = store.nav.tab.canGoBack
|
canGoBack ??= store.nav.tab.canGoBack
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={canGoBack ? onPressBack : onPressMenu}
|
onPress={canGoBack ? onPressBack : onPressMenu}
|
||||||
hitSlop={BACK_HITSLOP}
|
hitSlop={BACK_HITSLOP}
|
||||||
style={styles.backIcon}>
|
style={canGoBack ? styles.backIcon : styles.backIconWide}>
|
||||||
<FontAwesomeIcon
|
{canGoBack ? (
|
||||||
size={18}
|
<FontAwesomeIcon
|
||||||
icon={canGoBack ? 'angle-left' : 'bars'}
|
size={18}
|
||||||
style={{marginTop: 6}}
|
icon="angle-left"
|
||||||
/>
|
style={{marginTop: 6}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<UserAvatar
|
||||||
|
size={30}
|
||||||
|
handle={store.me.handle}
|
||||||
|
displayName={store.me.displayName}
|
||||||
|
avatar={store.me.avatar}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<View style={styles.titleContainer} pointerEvents="none">
|
<View style={styles.titleContainer} pointerEvents="none">
|
||||||
<Text style={styles.title}>{title}</Text>
|
<Text style={styles.title}>{title}</Text>
|
||||||
|
@ -151,6 +163,7 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
|
|
||||||
backIcon: {width: 30, height: 30},
|
backIcon: {width: 30, height: 30},
|
||||||
|
backIconWide: {width: 40, height: 30},
|
||||||
btn: {
|
btn: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|
Loading…
Reference in New Issue