about summary refs log tree commit diff
path: root/src/view/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/com')
-rw-r--r--src/view/com/profile/ProfileHeader.tsx25
-rw-r--r--src/view/com/util/ViewHeader.tsx77
2 files changed, 102 insertions, 0 deletions
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 (
     <View style={styles.outer}>
       <Image style={styles.banner} source={BANNER} />
+      {store.nav.tab.canGoBack ? (
+        <TouchableOpacity style={styles.backButton} onPress={onPressBack}>
+          <FontAwesomeIcon
+            size={14}
+            icon="angle-left"
+            style={styles.backIcon}
+          />
+        </TouchableOpacity>
+      ) : undefined}
       <View style={styles.avi}>
         <UserAvatar size={80} displayName={view.displayName} name={view.name} />
       </View>
@@ -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 (
+    <View style={styles.header}>
+      {store.nav.tab.canGoBack ? (
+        <TouchableOpacity onPress={onPressBack}>
+          <FontAwesomeIcon
+            size={14}
+            icon="angle-left"
+            style={styles.backIcon}
+          />
+        </TouchableOpacity>
+      ) : (
+        <View style={styles.cornerPlaceholder} />
+      )}
+      <View style={styles.titleContainer}>
+        <Text style={styles.title}>{title}</Text>
+        {subtitle ? (
+          <Text style={styles.subtitle} numberOfLines={1}>
+            {subtitle}
+          </Text>
+        ) : undefined}
+      </View>
+      <View style={styles.cornerPlaceholder} />
+    </View>
+  )
+}
+
+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},
+})