/
List.js
96 lines (91 loc) · 2.6 KB
/
List.js
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
90
91
92
93
94
95
96
import { Image } from 'react-native'
import React, { PureComponent } from 'react'
import { Flex, Header, Screen, Text } from '../../Library'
import { Pagination } from '../../../relay'
import { borderBottom, marginLeft, padding } from '../../../styles'
import { colors } from '../../../constants'
import { fragments } from '../../../graphql'
const Item = fragments.Contact(
({
data: {
id,
overrideDisplayName,
displayName,
overrideDisplayStatus,
displayStatus,
},
navigation,
}) => (
<Flex.Cols
align='center'
onPress={() => {
navigation.push('contacts/detail', {
contact: {
id,
overrideDisplayName,
displayName,
},
})
}}
style={[{ height: 72 }, padding, borderBottom]}
>
<Flex.Rows size={1} align='center'>
<Image
style={{ width: 40, height: 40, borderRadius: 20, margin: 4 }}
source={{
uri: 'https://api.adorable.io/avatars/40/' + id + '.png',
}}
/>
</Flex.Rows>
<Flex.Rows size={7} align='stretch' justify='center' style={[marginLeft]}>
<Text color={colors.black} left middle>
{overrideDisplayName || displayName}
</Text>
{overrideDisplayStatus || overrideDisplayName ? (
<Text color={colors.subtleGrey} tiny middle left>
{overrideDisplayStatus || displayStatus}
</Text>
) : null}
</Flex.Rows>
</Flex.Cols>
)
)
export default class ContactList extends PureComponent {
static navigationOptions = ({ navigation }) => ({
header: (
<Header
navigation={navigation}
title='Contacts'
titleIcon='feather-users'
rightBtnIcon='user-plus'
onPressRightBtn={() => navigation.push('contacts/add')}
searchBar
searchHandler={navigation.getParam('searchHandler')}
/>
),
tabBarVisible: true,
})
searchHandler = search => this.setState({ search })
render () {
const {
screenProps: {
context: { queries, subscriptions },
},
} = this.props
return (
<Screen style={{ backgroundColor: colors.white }}>
<Pagination
direction='forward'
query={queries.ContactList.graphql}
variables={queries.ContactList.defaultVariables}
fragment={fragments.ContactList}
alias='ContactList'
subscriptions={[subscriptions.contactRequest]}
renderItem={props => (
<Item {...props} navigation={this.props.navigation} />
)}
/>
</Screen>
)
}
}