about summary refs log tree commit diff
path: root/src/view/com/modals/ProfilePreview.tsx
blob: d3267644b60ede85ec6d9bb462e21ee47950c772 (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
82
83
84
85
86
87
88
89
import React, {useState, useEffect, useCallback} from 'react'
import {StyleSheet, View} from 'react-native'
import {observer} from 'mobx-react-lite'
import {useNavigation, StackActions} from '@react-navigation/native'
import {Text} from '../util/text/Text'
import {useStores} from 'state/index'
import {ProfileModel} from 'state/models/content/profile'
import {usePalette} from 'lib/hooks/usePalette'
import {useAnalytics} from 'lib/analytics/analytics'
import {ProfileHeader} from '../profile/ProfileHeader'
import {Button} from '../util/forms/Button'
import {NavigationProp} from 'lib/routes/types'

export const snapPoints = [560]

export const Component = observer(({did}: {did: string}) => {
  const store = useStores()
  const pal = usePalette('default')
  const palInverted = usePalette('inverted')
  const navigation = useNavigation<NavigationProp>()
  const [model] = useState(new ProfileModel(store, {actor: did}))
  const {screen} = useAnalytics()

  useEffect(() => {
    screen('Profile:Preview')
    model.setup()
  }, [model, screen])

  const onPressViewProfile = useCallback(() => {
    navigation.dispatch(StackActions.push('Profile', {name: model.handle}))
    store.shell.closeModal()
  }, [navigation, store, model])

  return (
    <View style={pal.view}>
      <View style={styles.headerWrapper}>
        <ProfileHeader view={model} hideBackButton onRefreshAll={() => {}} />
      </View>
      <View style={[styles.buttonsContainer, pal.view]}>
        <View style={styles.buttons}>
          <Button
            type="inverted"
            style={[styles.button, styles.buttonWide]}
            onPress={onPressViewProfile}
            accessibilityLabel="View profile"
            accessibilityHint="">
            <Text type="button-lg" style={palInverted.text}>
              View Profile
            </Text>
          </Button>
          <Button
            type="default"
            style={styles.button}
            onPress={() => store.shell.closeModal()}
            accessibilityLabel="Close this preview"
            accessibilityHint="">
            <Text type="button-lg" style={pal.text}>
              Close
            </Text>
          </Button>
        </View>
      </View>
    </View>
  )
})

const styles = StyleSheet.create({
  headerWrapper: {
    height: 440,
  },
  buttonsContainer: {
    height: 120,
  },
  buttons: {
    flexDirection: 'row',
    gap: 8,
    paddingHorizontal: 14,
    paddingTop: 16,
  },
  button: {
    flex: 2,
    flexDirection: 'row',
    justifyContent: 'center',
    paddingVertical: 12,
  },
  buttonWide: {
    flex: 3,
  },
})