about summary refs log tree commit diff
path: root/src/view/screens/Contacts.tsx
blob: 21943a10a78a1bd2255be68fbafa8f4d9eb5f957 (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
import React, {useEffect, useState, useRef} from 'react'
import {StyleSheet, TextInput, View} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {ProfileFollows as ProfileFollowsComponent} from '../com/profile/ProfileFollows'
import {Selector} from '../com/util/Selector'
import {Text} from '../com/util/text/Text'
import {colors} from 'lib/styles'
import {ScreenParams} from '../routes'
import {useStores} from 'state/index'
import {useAnimatedValue} from 'lib/hooks/useAnimatedValue'

export const Contacts = ({navIdx, visible}: ScreenParams) => {
  const store = useStores()
  const selectorInterp = useAnimatedValue(0)

  useEffect(() => {
    if (visible) {
      store.nav.setTitle(navIdx, 'Contacts')
    }
  }, [store, visible, navIdx])

  const [searchText, onChangeSearchText] = useState('')
  const inputRef = useRef<TextInput | null>(null)

  return (
    <View>
      <View style={styles.section}>
        <Text testID="contactsTitle" style={styles.title}>
          Contacts
        </Text>
      </View>
      <View style={styles.section}>
        <View style={styles.searchContainer}>
          <FontAwesomeIcon
            icon="magnifying-glass"
            size={16}
            style={styles.searchIcon}
          />
          <TextInput
            testID="contactsTextInput"
            ref={inputRef}
            value={searchText}
            style={styles.searchInput}
            placeholder="Search"
            placeholderTextColor={colors.gray4}
            onChangeText={onChangeSearchText}
          />
        </View>
      </View>
      <Selector
        items={['All', 'Following', 'Scenes']}
        selectedIndex={0}
        panX={selectorInterp}
      />
      {!!store.me.handle && <ProfileFollowsComponent name={store.me.handle} />}
    </View>
  )
}

const styles = StyleSheet.create({
  section: {
    backgroundColor: colors.white,
  },
  title: {
    fontSize: 30,
    fontWeight: 'bold',
    paddingHorizontal: 12,
    paddingVertical: 6,
  },

  searchContainer: {
    flexDirection: 'row',
    backgroundColor: colors.gray1,
    paddingHorizontal: 8,
    paddingVertical: 8,
    marginHorizontal: 10,
    marginBottom: 6,
    borderRadius: 4,
  },
  searchIcon: {
    color: colors.gray5,
    marginRight: 8,
  },
  searchInput: {
    flex: 1,
    color: colors.black,
  },
})