Enlarge the view header, left align the title, and add a compose button

zio/stable
Paul Frazee 2022-11-28 09:29:35 -06:00
parent cb5210d24d
commit 1784a4912d
5 changed files with 37 additions and 75 deletions

View File

@ -1,12 +1,6 @@
import React, {useMemo} from 'react' import React, {useMemo} from 'react'
import {observer} from 'mobx-react-lite' import {observer} from 'mobx-react-lite'
import { import {StyleSheet, Text, TouchableOpacity, View} from 'react-native'
ActivityIndicator,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native'
import LinearGradient from 'react-native-linear-gradient' import LinearGradient from 'react-native-linear-gradient'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {AtUri} from '../../../third-party/uri' import {AtUri} from '../../../third-party/uri'
@ -108,18 +102,6 @@ export const ProfileHeader = observer(function ProfileHeader({
return ( return (
<View style={styles.outer}> <View style={styles.outer}>
<LoadingPlaceholder width="100%" height={120} /> <LoadingPlaceholder width="100%" height={120} />
{store.nav.tab.canGoBack ? (
<TouchableOpacity style={styles.backButton} onPress={onPressBack}>
<FontAwesomeIcon
size={18}
icon="angle-left"
style={styles.backIcon}
/>
</TouchableOpacity>
) : undefined}
<TouchableOpacity style={styles.searchBtn} onPress={onPressSearch}>
<MagnifyingGlassIcon size={19} style={styles.searchIcon} />
</TouchableOpacity>
<View style={styles.avi}> <View style={styles.avi}>
<LoadingPlaceholder <LoadingPlaceholder
width={80} width={80}
@ -179,18 +161,6 @@ export const ProfileHeader = observer(function ProfileHeader({
return ( return (
<View style={styles.outer}> <View style={styles.outer}>
<UserBanner handle={view.handle} /> <UserBanner handle={view.handle} />
{store.nav.tab.canGoBack ? (
<TouchableOpacity style={styles.backButton} onPress={onPressBack}>
<FontAwesomeIcon
size={18}
icon="angle-left"
style={styles.backIcon}
/>
</TouchableOpacity>
) : undefined}
<TouchableOpacity style={styles.searchBtn} onPress={onPressSearch}>
<MagnifyingGlassIcon size={19} style={styles.searchIcon} />
</TouchableOpacity>
<View style={styles.avi}> <View style={styles.avi}>
<UserAvatar <UserAvatar
size={80} size={80}
@ -353,30 +323,6 @@ const styles = StyleSheet.create({
width: '100%', width: '100%',
height: 120, height: 120,
}, },
backButton: {
position: 'absolute',
top: 10,
left: 12,
backgroundColor: '#ffff',
padding: 6,
borderRadius: 30,
},
backIcon: {
width: 14,
height: 14,
color: colors.black,
},
searchBtn: {
position: 'absolute',
top: 10,
right: 12,
backgroundColor: '#ffff',
padding: 5,
borderRadius: 30,
},
searchIcon: {
color: colors.black,
},
avi: { avi: {
position: 'absolute', position: 'absolute',
top: 80, top: 80,

View File

@ -1,7 +1,6 @@
import React from 'react' import React from 'react'
import {StyleSheet, Text, TouchableOpacity, View} from 'react-native' import {StyleSheet, Text, TouchableOpacity, View} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {UserAvatar} from './UserAvatar'
import {colors} from '../../lib/styles' import {colors} from '../../lib/styles'
import {MagnifyingGlassIcon} from '../../lib/icons' import {MagnifyingGlassIcon} from '../../lib/icons'
import {useStores} from '../../../state' import {useStores} from '../../../state'
@ -9,14 +8,19 @@ import {useStores} from '../../../state'
export function ViewHeader({ export function ViewHeader({
title, title,
subtitle, subtitle,
onPost,
}: { }: {
title: string title: string
subtitle?: string subtitle?: string
onPost?: () => void
}) { }) {
const store = useStores() const store = useStores()
const onPressBack = () => { const onPressBack = () => {
store.nav.tab.goBack() store.nav.tab.goBack()
} }
const onPressCompose = () => {
store.shell.openComposer({onPost})
}
const onPressSearch = () => { const onPressSearch = () => {
store.nav.navigate(`/search`) store.nav.navigate(`/search`)
} }
@ -26,9 +30,7 @@ export function ViewHeader({
<TouchableOpacity onPress={onPressBack} style={styles.backIcon}> <TouchableOpacity onPress={onPressBack} style={styles.backIcon}>
<FontAwesomeIcon size={18} icon="angle-left" style={{marginTop: 6}} /> <FontAwesomeIcon size={18} icon="angle-left" style={{marginTop: 6}} />
</TouchableOpacity> </TouchableOpacity>
) : ( ) : undefined}
<View style={styles.cornerPlaceholder} />
)}
<View style={styles.titleContainer}> <View style={styles.titleContainer}>
<Text style={styles.title}>{title}</Text> <Text style={styles.title}>{title}</Text>
{subtitle ? ( {subtitle ? (
@ -37,8 +39,17 @@ export function ViewHeader({
</Text> </Text>
) : undefined} ) : undefined}
</View> </View>
<TouchableOpacity onPress={onPressSearch} style={styles.searchBtn}> <TouchableOpacity onPress={onPressCompose} style={styles.btn}>
<MagnifyingGlassIcon size={17} style={styles.searchBtnIcon} /> <FontAwesomeIcon size={18} icon="plus" />
</TouchableOpacity>
<TouchableOpacity
onPress={onPressSearch}
style={[styles.btn, {marginLeft: 8}]}>
<MagnifyingGlassIcon
size={18}
strokeWidth={3}
style={styles.searchBtnIcon}
/>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
) )
@ -59,33 +70,28 @@ const styles = StyleSheet.create({
titleContainer: { titleContainer: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'baseline', alignItems: 'baseline',
marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',
}, },
title: { title: {
fontSize: 16, fontSize: 21,
fontWeight: '600', fontWeight: '600',
}, },
subtitle: { subtitle: {
fontSize: 15, fontSize: 18,
marginLeft: 3, marginLeft: 6,
color: colors.gray4, color: colors.gray4,
maxWidth: 200, maxWidth: 200,
}, },
cornerPlaceholder: {
width: 30,
height: 30,
},
backIcon: {width: 30, height: 30}, backIcon: {width: 30, height: 30},
searchBtn: { btn: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
backgroundColor: colors.gray1, backgroundColor: colors.gray1,
width: 30, width: 36,
height: 30, height: 36,
borderRadius: 15, borderRadius: 20,
}, },
searchBtnIcon: { searchBtnIcon: {
color: colors.black, color: colors.black,

View File

@ -94,15 +94,17 @@ export function HomeIconSolid({
export function MagnifyingGlassIcon({ export function MagnifyingGlassIcon({
style, style,
size, size,
strokeWidth = 2,
}: { }: {
style?: StyleProp<ViewStyle> style?: StyleProp<ViewStyle>
size?: string | number size?: string | number
strokeWidth?: number
}) { }) {
return ( return (
<Svg <Svg
fill="none" fill="none"
viewBox="0 0 24 24" viewBox="0 0 24 24"
strokeWidth={2} strokeWidth={strokeWidth}
stroke="currentColor" stroke="currentColor"
width={size || 24} width={size || 24}
height={size || 24} height={size || 24}

View File

@ -80,7 +80,11 @@ export const Home = observer(function Home({
return ( return (
<View style={s.flex1}> <View style={s.flex1}>
<ViewHeader title="Bluesky" subtitle="Private Beta" /> <ViewHeader
title="Bluesky"
subtitle="Private Beta"
onPost={onCreatePost}
/>
<Feed <Feed
key="default" key="default"
feed={defaultFeedView} feed={defaultFeedView}

View File

@ -15,6 +15,7 @@ import {PostFeedLoadingPlaceholder} from '../com/util/LoadingPlaceholder'
import {ErrorScreen} from '../com/util/ErrorScreen' import {ErrorScreen} from '../com/util/ErrorScreen'
import {ErrorMessage} from '../com/util/ErrorMessage' import {ErrorMessage} from '../com/util/ErrorMessage'
import {EmptyState} from '../com/util/EmptyState' import {EmptyState} from '../com/util/EmptyState'
import {ViewHeader} from '../com/util/ViewHeader'
import Toast from '../com/util/Toast' import Toast from '../com/util/Toast'
import {s, colors} from '../lib/styles' import {s, colors} from '../lib/styles'
@ -219,8 +220,11 @@ export const Profile = observer(({navIdx, visible, params}: ScreenParams) => {
renderItem = () => <View /> renderItem = () => <View />
} }
const title =
uiState.profile.displayName || uiState.profile.handle || params.name
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ViewHeader title={title} />
{uiState.profile.hasError ? ( {uiState.profile.hasError ? (
<ErrorScreen <ErrorScreen
title="Failed to load profile" title="Failed to load profile"