-
Notifications
You must be signed in to change notification settings - Fork 375
/
Detail.js
130 lines (126 loc) · 3.55 KB
/
Detail.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import React, { PureComponent } from 'react'
import { Image, ActionSheetIOS, Platform, Alert } from 'react-native'
import { Menu, Header, Screen } from '../../../Library'
import { colors } from '../../../../constants'
import { shareLinkOther, extractPublicKeyFromId } from '../../../../helpers/contacts'
export default class Detail extends PureComponent {
static navigationOptions = ({ navigation }) => ({
header: (
<Header
navigation={navigation}
title='Contact details'
rightBtnIcon={'edit-2'}
onPressRightBtn={() =>
navigation.push('detail/edit', {
contact: navigation.getParam('contact'),
})
}
backBtn
/>
),
})
blockContact = () => {
console.log('Block')
}
blockConfirm = () => {
if (Platform.OS === 'ios') {
ActionSheetIOS.showActionSheetWithOptions(
{
options: ['Block this contact', 'Cancel'],
destructiveButtonIndex: 0,
cancelButtonIndex: 1,
},
buttonIndex => {
if (buttonIndex === 1) {
this.blockContact()
}
}
)
} else if (Platform.OS === 'android') {
Alert.alert(
'Confirm',
'Are you sure you want to block this contact?',
[
{
text: 'Block it (not implem.)',
onPress: () => this.blockContact(),
style: 'destructive',
},
{
text: 'Cancel',
onPress: () => this.blockContact(),
style: 'cancel',
},
],
{ cancelable: false }
)
} else {
console.warn('TODO: implement alert')
this.blockContact()
}
}
render () {
const { navigation } = this.props
const contact = navigation.getParam('contact')
return (
<Screen>
<Menu absolute>
<Menu.Header
icon={
<Image
style={{ width: 78, height: 78, borderRadius: 39 }}
source={{
uri:
'https://api.adorable.io/avatars/285/' +
contact.id +
'.png',
}}
/>
}
title={contact.overrideDisplayName || contact.displayName}
/>
<Menu.Section>
<Menu.Item
icon='message-circle'
title='Send a message (not implem.)'
onPress={() => console.log('Send')}
/>
<Menu.Item
icon='phone'
title='Call (not implem.)'
onPress={() => console.log('Call')}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
icon='eye'
title='View public key'
onPress={() =>
navigation.push('detail/publickey', {
id: extractPublicKeyFromId(contact.id),
displayName: contact.displayName,
})
}
/>
<Menu.Item
icon='share'
title='Share this contact'
onPress={() => shareLinkOther({
id: extractPublicKeyFromId(contact.id),
displayName: contact.displayName,
})}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
icon='slash'
title='Block this contact'
color={colors.error}
onPress={() => this.blockConfirm()}
/>
</Menu.Section>
</Menu>
</Screen>
)
}
}