about summary refs log tree commit diff
path: root/src/view/com/composer/Prompt.tsx
blob: 319d57be3c6a04f070bda60eb18d51073f9aa000 (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
73
74
75
76
77
78
79
80
81
import React from 'react'
import {StyleSheet, TouchableOpacity, View} from 'react-native'
import {colors} from '../../lib/styles'
import {useStores} from '../../../state'
import {UserAvatar} from '../util/UserAvatar'
import {Text} from '../util/text/Text'
import {usePalette} from '../../lib/hooks/usePalette'

export function ComposePrompt({
  noAvi = false,
  text = "What's up?",
  btn = 'Post',
  onPressCompose,
}: {
  noAvi?: boolean
  text?: string
  btn?: string
  onPressCompose: () => void
}) {
  const pal = usePalette('default')
  const store = useStores()
  const onPressAvatar = () => {
    store.nav.navigate(`/profile/${store.me.handle}`)
  }
  return (
    <TouchableOpacity
      style={[
        pal.view,
        pal.border,
        styles.container,
        noAvi ? styles.noAviContainer : undefined,
      ]}
      onPress={onPressCompose}>
      {!noAvi ? (
        <TouchableOpacity style={styles.avatar} onPress={onPressAvatar}>
          <UserAvatar
            size={50}
            handle={store.me.handle || ''}
            displayName={store.me.displayName}
            avatar={store.me.avatar}
          />
        </TouchableOpacity>
      ) : undefined}
      <View style={styles.textContainer}>
        <Text type="h5" style={[pal.textLight, {fontWeight: 'normal'}]}>
          {text}
        </Text>
      </View>
      <View style={[styles.btn, {backgroundColor: pal.colors.backgroundLight}]}>
        <Text type="button" style={pal.textLight}>
          {btn}
        </Text>
      </View>
    </TouchableOpacity>
  )
}

const styles = StyleSheet.create({
  container: {
    paddingHorizontal: 10,
    paddingVertical: 10,
    flexDirection: 'row',
    alignItems: 'center',
    borderTopWidth: 1,
  },
  noAviContainer: {
    paddingVertical: 14,
  },
  avatar: {
    width: 50,
  },
  textContainer: {
    marginLeft: 10,
    flex: 1,
  },
  btn: {
    paddingVertical: 6,
    paddingHorizontal: 14,
    borderRadius: 30,
  },
})