From ab134cac93f488005febdc3b6e86fdbd85589fd0 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 1 Nov 2022 11:06:43 -0500 Subject: Add consistent view headers --- src/view/com/profile/ProfileHeader.tsx | 25 +++++++++++ src/view/com/util/ViewHeader.tsx | 77 ++++++++++++++++++++++++++++++++++ src/view/screens/Home.tsx | 2 + src/view/screens/Notifications.tsx | 20 ++------- src/view/screens/PostLikedBy.tsx | 11 ++++- src/view/screens/PostRepostedBy.tsx | 11 ++++- src/view/screens/PostThread.tsx | 9 +++- src/view/screens/ProfileFollowers.tsx | 13 ++---- src/view/screens/ProfileFollows.tsx | 13 ++---- src/view/screens/Settings.tsx | 47 +++++++++++---------- 10 files changed, 164 insertions(+), 64 deletions(-) create mode 100644 src/view/com/util/ViewHeader.tsx (limited to 'src') diff --git a/src/view/com/profile/ProfileHeader.tsx b/src/view/com/profile/ProfileHeader.tsx index 6778663a3..6445e4a92 100644 --- a/src/view/com/profile/ProfileHeader.tsx +++ b/src/view/com/profile/ProfileHeader.tsx @@ -27,6 +27,9 @@ export const ProfileHeader = observer(function ProfileHeader({ }) { const store = useStores() + const onPressBack = () => { + store.nav.tab.goBack() + } const onPressToggleFollow = () => { view?.toggleFollowing().then( () => { @@ -82,6 +85,15 @@ export const ProfileHeader = observer(function ProfileHeader({ return ( + {store.nav.tab.canGoBack ? ( + + + + ) : undefined} @@ -177,6 +189,19 @@ const styles = StyleSheet.create({ width: '100%', height: 120, }, + backButton: { + position: 'absolute', + top: 6, + left: 8, + backgroundColor: '#000a', + padding: 6, + borderRadius: 30, + }, + backIcon: { + width: 14, + height: 14, + color: colors.white, + }, avi: { position: 'absolute', top: 80, diff --git a/src/view/com/util/ViewHeader.tsx b/src/view/com/util/ViewHeader.tsx new file mode 100644 index 000000000..46be1144f --- /dev/null +++ b/src/view/com/util/ViewHeader.tsx @@ -0,0 +1,77 @@ +import React from 'react' +import {StyleSheet, Text, TouchableOpacity, View} from 'react-native' +import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' +import {s, colors} from '../../lib/styles' +import {useStores} from '../../../state' + +export function ViewHeader({ + title, + subtitle, +}: { + title: string + subtitle?: string +}) { + const store = useStores() + const onPressBack = () => { + store.nav.tab.goBack() + } + return ( + + {store.nav.tab.canGoBack ? ( + + + + ) : ( + + )} + + {title} + {subtitle ? ( + + {subtitle} + + ) : undefined} + + + + ) +} + +const styles = StyleSheet.create({ + header: { + flexDirection: 'row', + alignItems: 'center', + backgroundColor: colors.white, + paddingHorizontal: 12, + paddingBottom: 6, + borderBottomColor: colors.gray1, + borderBottomWidth: 1, + }, + + titleContainer: { + flexDirection: 'row', + alignItems: 'baseline', + marginLeft: 'auto', + marginRight: 'auto', + }, + title: { + fontSize: 16, + fontWeight: '600', + }, + subtitle: { + fontSize: 15, + marginLeft: 3, + color: colors.gray4, + maxWidth: 200, + }, + + cornerPlaceholder: { + width: 14, + height: 14, + }, + backIcon: {width: 14, height: 14}, +}) diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index 580106850..355a2cec1 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -1,6 +1,7 @@ import React, {useState, useEffect, useMemo} from 'react' import {View} from 'react-native' import {observer} from 'mobx-react-lite' +import {ViewHeader} from '../com/util/ViewHeader' import {Feed} from '../com/posts/Feed' import {FAB} from '../com/util/FloatingActionButton' import {useStores} from '../../state' @@ -53,6 +54,7 @@ export const Home = observer(function Home({ return ( + diff --git a/src/view/screens/Notifications.tsx b/src/view/screens/Notifications.tsx index e33a34c2f..50832bd8d 100644 --- a/src/view/screens/Notifications.tsx +++ b/src/view/screens/Notifications.tsx @@ -1,7 +1,7 @@ import React, {useState, useEffect} from 'react' -import {StyleSheet, Text, View} from 'react-native' +import {View} from 'react-native' +import {ViewHeader} from '../com/util/ViewHeader' import {Feed} from '../com/notifications/Feed' -import {colors} from '../lib/styles' import {useStores} from '../../state' import {NotificationsViewModel} from '../../state/models/notifications-view' import {ScreenParams} from '../routes' @@ -38,22 +38,8 @@ export const Notifications = ({visible}: ScreenParams) => { return ( - - Notifications - + {notesView && } ) } - -const styles = StyleSheet.create({ - header: { - backgroundColor: colors.white, - }, - title: { - fontSize: 30, - fontWeight: 'bold', - paddingHorizontal: 12, - paddingVertical: 6, - }, -}) diff --git a/src/view/screens/PostLikedBy.tsx b/src/view/screens/PostLikedBy.tsx index 75eeea4a9..72c6016e4 100644 --- a/src/view/screens/PostLikedBy.tsx +++ b/src/view/screens/PostLikedBy.tsx @@ -1,8 +1,10 @@ import React, {useEffect} from 'react' -import {makeRecordUri} from '../lib/strings' +import {View} from 'react-native' +import {ViewHeader} from '../com/util/ViewHeader' import {PostLikedBy as PostLikedByComponent} from '../com/post-thread/PostLikedBy' import {ScreenParams} from '../routes' import {useStores} from '../../state' +import {makeRecordUri} from '../lib/strings' export const PostLikedBy = ({visible, params}: ScreenParams) => { const store = useStores() @@ -15,5 +17,10 @@ export const PostLikedBy = ({visible, params}: ScreenParams) => { } }, [store, visible]) - return + return ( + + + + + ) } diff --git a/src/view/screens/PostRepostedBy.tsx b/src/view/screens/PostRepostedBy.tsx index 875cc978c..d9a59a268 100644 --- a/src/view/screens/PostRepostedBy.tsx +++ b/src/view/screens/PostRepostedBy.tsx @@ -1,8 +1,10 @@ import React, {useEffect} from 'react' -import {makeRecordUri} from '../lib/strings' +import {View} from 'react-native' +import {ViewHeader} from '../com/util/ViewHeader' import {PostRepostedBy as PostRepostedByComponent} from '../com/post-thread/PostRepostedBy' import {ScreenParams} from '../routes' import {useStores} from '../../state' +import {makeRecordUri} from '../lib/strings' export const PostRepostedBy = ({visible, params}: ScreenParams) => { const store = useStores() @@ -15,5 +17,10 @@ export const PostRepostedBy = ({visible, params}: ScreenParams) => { } }, [store, visible]) - return + return ( + + + + + ) } diff --git a/src/view/screens/PostThread.tsx b/src/view/screens/PostThread.tsx index 1f2deb312..a30b5521b 100644 --- a/src/view/screens/PostThread.tsx +++ b/src/view/screens/PostThread.tsx @@ -1,5 +1,7 @@ import React, {useEffect} from 'react' +import {View} from 'react-native' import {makeRecordUri} from '../lib/strings' +import {ViewHeader} from '../com/util/ViewHeader' import {PostThread as PostThreadComponent} from '../com/post-thread/PostThread' import {ScreenParams} from '../routes' import {useStores} from '../../state' @@ -15,5 +17,10 @@ export const PostThread = ({visible, params}: ScreenParams) => { } }, [visible, store.nav, name]) - return + return ( + + + + + ) } diff --git a/src/view/screens/ProfileFollowers.tsx b/src/view/screens/ProfileFollowers.tsx index 3d78a88a1..ac776a056 100644 --- a/src/view/screens/ProfileFollowers.tsx +++ b/src/view/screens/ProfileFollowers.tsx @@ -1,5 +1,6 @@ import React, {useEffect} from 'react' -import {StyleSheet, Text, View} from 'react-native' +import {View} from 'react-native' +import {ViewHeader} from '../com/util/ViewHeader' import {ProfileFollowers as ProfileFollowersComponent} from '../com/profile/ProfileFollowers' import {ScreenParams} from '../routes' import {useStores} from '../../state' @@ -16,16 +17,8 @@ export const ProfileFollowers = ({visible, params}: ScreenParams) => { return ( - Followers of {name} + ) } - -const styles = StyleSheet.create({ - title: { - fontSize: 21, - fontWeight: 'bold', - padding: 10, - }, -}) diff --git a/src/view/screens/ProfileFollows.tsx b/src/view/screens/ProfileFollows.tsx index 6f5c82478..c075851c6 100644 --- a/src/view/screens/ProfileFollows.tsx +++ b/src/view/screens/ProfileFollows.tsx @@ -1,5 +1,6 @@ import React, {useEffect} from 'react' -import {StyleSheet, Text, View} from 'react-native' +import {View} from 'react-native' +import {ViewHeader} from '../com/util/ViewHeader' import {ProfileFollows as ProfileFollowsComponent} from '../com/profile/ProfileFollows' import {ScreenParams} from '../routes' import {useStores} from '../../state' @@ -16,16 +17,8 @@ export const ProfileFollows = ({visible, params}: ScreenParams) => { return ( - Followed by {name} + ) } - -const styles = StyleSheet.create({ - title: { - fontSize: 21, - fontWeight: 'bold', - padding: 10, - }, -}) diff --git a/src/view/screens/Settings.tsx b/src/view/screens/Settings.tsx index 2438ea75d..6bc3d1015 100644 --- a/src/view/screens/Settings.tsx +++ b/src/view/screens/Settings.tsx @@ -1,9 +1,10 @@ import React, {useEffect} from 'react' -import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native' +import {StyleSheet, Text, TouchableOpacity, View} from 'react-native' import {observer} from 'mobx-react-lite' import {useStores} from '../../state' import {ScreenParams} from '../routes' import {s, colors} from '../lib/styles' +import {ViewHeader} from '../com/util/ViewHeader' import {Link} from '../com/util/Link' import {UserAvatar} from '../com/util/UserAvatar' @@ -22,28 +23,30 @@ export const Settings = observer(function Settings({visible}: ScreenParams) { } return ( - - Settings - - Signed in as - - - Sign out - - - - - - - {store.me.displayName} - @{store.me.name} - + + + + + Signed in as + + + Sign out + - + + + + + {store.me.displayName} + @{store.me.name} + + + + ) }) -- cgit 1.4.1