Move search btn into the viewheader

This commit is contained in:
Paul Frazee 2022-11-20 12:25:11 -06:00
parent a21bcf10dd
commit c6108fb646
5 changed files with 40 additions and 91 deletions

View file

@ -20,6 +20,7 @@ import {
import {pluralize} from '../../lib/strings'
import {s, colors} from '../../lib/styles'
import {getGradient} from '../../lib/asset-gen'
import {MagnifyingGlassIcon} from '../../lib/icons'
import {DropdownBtn, DropdownItem} from '../util/DropdownBtn'
import Toast from '../util/Toast'
import {LoadingPlaceholder} from '../util/LoadingPlaceholder'
@ -43,10 +44,8 @@ export const ProfileHeader = observer(function ProfileHeader({
const onPressBack = () => {
store.nav.tab.goBack()
}
const onPressMyAvatar = () => {
if (store.me.handle) {
store.nav.navigate(`/profile/${store.me.handle}`)
}
const onPressSearch = () => {
store.nav.navigate(`/search`)
}
const onPressToggleFollow = () => {
view?.toggleFollowing().then(
@ -117,15 +116,9 @@ export const ProfileHeader = observer(function ProfileHeader({
/>
</TouchableOpacity>
) : undefined}
{store.me.did ? (
<TouchableOpacity style={styles.myAvatar} onPress={onPressMyAvatar}>
<UserAvatar
size={30}
handle={store.me.handle || ''}
displayName={store.me.displayName}
/>
</TouchableOpacity>
) : undefined}
<TouchableOpacity style={styles.searchBtn} onPress={onPressSearch}>
<MagnifyingGlassIcon size={19} style={styles.searchIcon} />
</TouchableOpacity>
<View style={styles.avi}>
<LoadingPlaceholder
width={80}
@ -194,15 +187,9 @@ export const ProfileHeader = observer(function ProfileHeader({
/>
</TouchableOpacity>
) : undefined}
{store.me.did ? (
<TouchableOpacity style={styles.myAvatar} onPress={onPressMyAvatar}>
<UserAvatar
size={30}
handle={store.me.handle || ''}
displayName={store.me.displayName}
/>
</TouchableOpacity>
) : undefined}
<TouchableOpacity style={styles.searchBtn} onPress={onPressSearch}>
<MagnifyingGlassIcon size={19} style={styles.searchIcon} />
</TouchableOpacity>
<View style={styles.avi}>
<UserAvatar
size={80}
@ -375,14 +362,17 @@ const styles = StyleSheet.create({
height: 14,
color: colors.black,
},
myAvatar: {
searchBtn: {
position: 'absolute',
top: 10,
right: 12,
backgroundColor: '#ffff',
padding: 1,
padding: 5,
borderRadius: 30,
},
searchIcon: {
color: colors.black,
},
avi: {
position: 'absolute',
top: 80,

View file

@ -3,6 +3,7 @@ import {StyleSheet, Text, TouchableOpacity, View} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {UserAvatar} from './UserAvatar'
import {colors} from '../../lib/styles'
import {MagnifyingGlassIcon} from '../../lib/icons'
import {useStores} from '../../../state'
export function ViewHeader({
@ -16,16 +17,14 @@ export function ViewHeader({
const onPressBack = () => {
store.nav.tab.goBack()
}
const onPressAvatar = () => {
if (store.me.handle) {
store.nav.navigate(`/profile/${store.me.handle}`)
}
const onPressSearch = () => {
store.nav.navigate(`/search`)
}
return (
<View style={styles.header}>
{store.nav.tab.canGoBack ? (
<TouchableOpacity onPress={onPressBack} style={styles.backIcon}>
<FontAwesomeIcon size={18} icon="angle-left" style={{marginTop: 3}} />
<FontAwesomeIcon size={18} icon="angle-left" style={{marginTop: 6}} />
</TouchableOpacity>
) : (
<View style={styles.cornerPlaceholder} />
@ -38,17 +37,9 @@ export function ViewHeader({
</Text>
) : undefined}
</View>
{store.me.did ? (
<TouchableOpacity onPress={onPressAvatar}>
<UserAvatar
size={24}
handle={store.me.handle || ''}
displayName={store.me.displayName}
/>
</TouchableOpacity>
) : (
<View style={styles.cornerPlaceholder} />
)}
<TouchableOpacity onPress={onPressSearch} style={styles.searchBtn}>
<MagnifyingGlassIcon size={17} style={styles.searchBtnIcon} />
</TouchableOpacity>
</View>
)
}
@ -83,8 +74,22 @@ const styles = StyleSheet.create({
},
cornerPlaceholder: {
width: 24,
height: 24,
width: 30,
height: 30,
},
backIcon: {width: 30, height: 30},
searchBtn: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: colors.gray1,
width: 30,
height: 30,
borderRadius: 15,
},
searchBtnIcon: {
color: colors.black,
position: 'relative',
top: -1,
},
backIcon: {width: 24, height: 24},
})