about summary refs log tree commit diff
path: root/src/view/screens/Settings.tsx
blob: 2438ea75df8f16175e69d41f4bb656dc87492141 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React, {useEffect} from 'react'
import {Image, 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 {Link} from '../com/util/Link'
import {UserAvatar} from '../com/util/UserAvatar'

export const Settings = observer(function Settings({visible}: ScreenParams) {
  const store = useStores()

  useEffect(() => {
    if (!visible) {
      return
    }
    store.nav.setTitle('Settings')
  }, [visible, store])

  const onPressSignout = () => {
    store.session.logout()
  }

  return (
    <View style={[s.flex1, s.pl10, s.pr10]}>
      <Text style={styles.title}>Settings</Text>
      <View style={[s.flexRow]}>
        <Text>Signed in as</Text>
        <View style={s.flex1} />
        <TouchableOpacity onPress={onPressSignout}>
          <Text style={[s.blue3, s.bold]}>Sign out</Text>
        </TouchableOpacity>
      </View>
      <Link href={`/profile/${store.me.name}`} title="Your profile">
        <View style={styles.profile}>
          <UserAvatar
            size={40}
            displayName={store.me.displayName}
            name={store.me.name || ''}
          />
          <View style={[s.ml10]}>
            <Text style={[s.f18]}>{store.me.displayName}</Text>
            <Text style={[s.gray5]}>@{store.me.name}</Text>
          </View>
        </View>
      </Link>
    </View>
  )
})

const styles = StyleSheet.create({
  title: {
    fontSize: 32,
    fontWeight: 'bold',
    marginTop: 20,
    marginBottom: 14,
  },
  profile: {
    flexDirection: 'row',
    marginVertical: 6,
    backgroundColor: colors.white,
    borderRadius: 4,
    paddingVertical: 10,
    paddingHorizontal: 10,
  },
  avi: {
    width: 40,
    height: 40,
    borderRadius: 30,
    marginRight: 8,
  },
})