Skip to content

Commit

Permalink
fix(rn): add container to contact modals
Browse files Browse the repository at this point in the history
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
  • Loading branch information
90dy committed Jun 7, 2019
1 parent 723c584 commit 5151fa5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 62 deletions.
29 changes: 18 additions & 11 deletions client/react-native/app/view/screen/Contacts/ContactCardModal.js
Expand Up @@ -7,6 +7,7 @@ import {
ModalScreen,
} from '@berty/component'
import { withNavigation } from 'react-navigation'
import { Store } from '@berty/container'

const modalWidth = 320

Expand All @@ -23,17 +24,23 @@ class ContactCardModal extends React.Component {
}

return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ModalScreen
showDismiss
width={modalWidth}
footer={
<ContactIdentityActions data={data} modalWidth={modalWidth} />
}
>
<ContactIdentity data={data} />
</ModalScreen>
</View>
<Store.Entity.Contact id={data.id}>
{data => (
<View
style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
>
<ModalScreen
showDismiss
width={modalWidth}
footer={
<ContactIdentityActions data={data} modalWidth={modalWidth} />
}
>
<ContactIdentity data={data} />
</ModalScreen>
</View>
)}
</Store.Entity.Contact>
)
}
}
Expand Down
100 changes: 49 additions & 51 deletions client/react-native/app/view/screen/Contacts/Detail/Detail.js
Expand Up @@ -5,7 +5,7 @@ import React, { PureComponent } from 'react'

import { Avatar, Header, Menu, Screen } from '@berty/component'
import { colors } from '@berty/common/constants'
import { withRelayContext } from '@berty/relay/context'
import { withStoreContext } from '@berty/store/context'
import { Store } from '@berty/container'
import { withGoBack } from '@berty/component/BackActionProvider'

Expand Down Expand Up @@ -56,7 +56,7 @@ class DetailsBase extends PureComponent {

deleteContact = async () => {
try {
await this.props.context.contactRemove({
await this.props.context.node.service.contactRemove({
id: this.props.navigation.getParam('id'),
})
this.props.goBack(null)
Expand All @@ -70,61 +70,59 @@ class DetailsBase extends PureComponent {
const id = navigation.getParam('id')
return (
<Store.Entity.Contact id={id}>
{data =>
(
<Screen>
<Menu absolute>
<Menu.Header
icon={<Avatar data={data} size={78} />}
title={data.overrideDisplayName || data.displayName}
{data => (
<Screen>
<Menu absolute>
<Menu.Header
icon={<Avatar data={data} size={78} />}
title={data.overrideDisplayName || data.displayName}
/>
<Menu.Section>
<Menu.Item
icon='message-circle'
title={t('contacts.send-message')}
onPress={() => console.log('Send')}
/>
<Menu.Section>
<Menu.Item
icon='message-circle'
title={t('contacts.send-message')}
onPress={() => console.log('Send')}
/>
<Menu.Item
icon='phone'
title={t('contacts.call')}
onPress={() => console.log('Call')}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
icon='eye'
title={t('contacts.view-pub-key')}
onPress={() =>
navigation.navigate('modal/contacts/card', data)
}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
icon='slash'
title={t('contacts.block')}
color={colors.error}
onPress={() => this.blockConfirm()}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
icon='slash'
title={t('contacts.delete')}
color={colors.error}
onPress={this.deleteContact}
/>
</Menu.Section>
</Menu>
</Screen>
)
}
<Menu.Item
icon='phone'
title={t('contacts.call')}
onPress={() => console.log('Call')}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
icon='eye'
title={t('contacts.view-pub-key')}
onPress={() =>
navigation.navigate('modal/contacts/card', data)
}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
icon='slash'
title={t('contacts.block')}
color={colors.error}
onPress={() => this.blockConfirm()}
/>
</Menu.Section>
<Menu.Section>
<Menu.Item
icon='slash'
title={t('contacts.delete')}
color={colors.error}
onPress={this.deleteContact}
/>
</Menu.Section>
</Menu>
</Screen>
)}
</Store.Entity.Contact>
)
}
}

const Details = withGoBack(withRelayContext(withNamespaces()(DetailsBase)))
const Details = withGoBack(withStoreContext(withNamespaces()(DetailsBase)))

Details.navigationOptions = ({ navigation }) => ({
header: (
Expand Down

0 comments on commit 5151fa5

Please sign in to comment.