Skip to content

Commit

Permalink
feat(rn): added Choice screen, added Request and RequestValidation an…
Browse files Browse the repository at this point in the history
…d improved QR Code screen
  • Loading branch information
aeddi committed Sep 10, 2018
1 parent 3be65f1 commit e10d398
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 12 deletions.
Expand Up @@ -3,6 +3,6 @@ import { Text } from '../../../Library'

export default class ByBump extends PureComponent {
render () {
return <Text>Hello World !</Text>
return <Text>Bump!</Text>
}
}
@@ -1,7 +1,41 @@
import { PureComponent } from 'react'
import createTabNavigator from 'react-navigation-deprecated-tab-navigator/src/createTabNavigator'
import { colors } from '../../../../constants'
import {
borderBottom,
} from '../../../../styles'

export default class ByQRCode extends PureComponent {
class ByQRCode extends PureComponent {
render () {
return null
}
}

export default createTabNavigator(
{
'Scan a QR code': ByQRCode,
'View my QR code': ByQRCode,
},
{
initialRouteName: 'Scan a QR code',
swipeEnabled: true,
animationEnabled: true,
tabBarPosition: 'top',

tabBarOptions: {
labelStyle: {
color: colors.black,
},
indicatorStyle: {
backgroundColor: colors.black,
},
style: [
{
backgroundColor: colors.white,
borderTopWidth: 0,
},
borderBottom,
],
},
}
)
@@ -1,7 +1,84 @@
import { PureComponent } from 'react'
import React, { PureComponent } from 'react'
import { TouchableOpacity } from 'react-native'
import { Text, Flex } from '../../../Library'
import { colors } from '../../../../constants'
import {
padding,
borderTop,
} from '../../../../styles'

export default class Choice extends PureComponent {
render () {
return null
const { navigation } = this.props
return (
<Flex.Cols
size={1}
style={[
{ backgroundColor: colors.white },
borderTop,
]}
>
<Flex.Rows
size={1}
align='center' space='evenly'
style={[
padding,
]}
>
<Item
color={colors.blue}
name='Bump'
link='ByBump'
navigation={navigation}
/>
<Item
color={colors.red}
name='Scan a QR Code'
link='ByQRCode'
navigation={navigation}
/>
<Item
color={colors.orange}
name='Enter a public key'
link='ByPublicKey'
navigation={navigation}
/>
<Item
color={colors.yellow}
name='Pending contact requests'
link='Request'
navigation={navigation}
/>
</Flex.Rows>
</Flex.Cols>
)
}
}

const Item = ({
color,
name,
link,
navigation,
}) => (
<TouchableOpacity
onPress={() => navigation.push(link)}
style={[{
borderRadius: 8,
height: 100,
width: 300,
backgroundColor: color,
justifyContent: 'center',
alignItems: 'center',
}]}
>
<Text
style={[{
fontSize: 30,
color: colors.white,
}]}
>
{ name }
</Text>
</TouchableOpacity>
)
@@ -0,0 +1,77 @@
import React, { PureComponent } from 'react'
import { FlatList, TouchableOpacity, Image } from 'react-native'
import { Screen, Flex, Text, Separator } from '../../../Library'
import { colors } from '../../../../constants'
import {
borderTop,
marginHorizontal,
} from '../../../../styles'
import { QueryReducer } from '../../../../relay'
import { queries } from '../../../../graphql'

const Item = ({
data: { id, displayName, overrideDisplayName },
navigation,
}) => (
<TouchableOpacity
onPress={() => navigation.push('RequestValidation', { id })}
style={[
{
backgroundColor: colors.white,
paddingVertical: 16,
height: 71,
},
marginHorizontal,
]}
>
<Flex.Cols align='left'>
<Flex.Rows size={1} align='left' style={{ marginLeft: 30 }}>
<Image
style={{ width: 40, height: 40, borderRadius: 50 }}
source={{
uri:
'https://api.adorable.io/avatars/285/' +
(overrideDisplayName || displayName) +
'.png',
}}
/>
</Flex.Rows>
<Flex.Rows size={6} align='left' style={{ marginLeft: 14 }}>
<Text color={colors.black} left middle>
{overrideDisplayName || displayName}
</Text>
<Text color={colors.subtleGrey} tiny>
Request received 3 hours ago ...
</Text>
</Flex.Rows>
</Flex.Cols>
</TouchableOpacity>
)

export default class Request extends PureComponent {
render () {
const { navigation } = this.props
return (
<Screen style={[{ backgroundColor: colors.white }, borderTop]}>
<QueryReducer query={queries.ContactList}>
{(state, retry) => (
<FlatList
data={([].concat(state.data.ContactList || [])).filter(entry => entry.status === 'RequestedMe')}
ItemSeparatorComponent={({ highlighted }) => (
<Separator highlighted={highlighted} />)} refreshing={state.type === state.loading}
onRefresh={retry}
renderItem={data => (
<Item
key={data.id}
data={data.item}
separators={data.separators}
navigation={navigation}
/>
)}
/>
)}
</QueryReducer>
</Screen>
)
}
}
@@ -0,0 +1,71 @@
import React, { PureComponent } from 'react'
import { TouchableOpacity } from 'react-native'
import { Text, Flex } from '../../../Library'
import { colors } from '../../../../constants'
import {
borderTop,
padding,
} from '../../../../styles'

export default class RequestValidation extends PureComponent {
render () {
return (
<Flex.Cols
size={1}
style={[
{ backgroundColor: colors.white },
borderTop,
]}
>
<Flex.Rows
size={1}
align='center' space='evenly'
style={[
padding,
]}
>
<TouchableOpacity
onPress={() => console.log('Accept')}
style={[{
borderRadius: 8,
height: 100,
width: 300,
backgroundColor: colors.blue,
justifyContent: 'center',
alignItems: 'center',
}]}
>
<Text
style={[{
fontSize: 30,
color: colors.white,
}]}
>
Accept
</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => console.log('Decline')}
style={[{
borderRadius: 8,
height: 100,
width: 300,
backgroundColor: colors.red,
justifyContent: 'center',
alignItems: 'center',
}]}
>
<Text
style={[{
fontSize: 30,
color: colors.white,
}]}
>
Decline
</Text>
</TouchableOpacity>
</Flex.Rows>
</Flex.Cols>
)
}
}
Expand Up @@ -3,6 +3,8 @@ import Choice from './Choice'
import ByBump from './ByBump'
import ByPublicKey from './ByPublicKey'
import ByQRCode from './ByQRCode'
import Request from './Request'
import RequestValidation from './RequestValidation'

import React from 'react'
import { Text, Button } from '../../../Library'
Expand All @@ -12,10 +14,12 @@ export default createSubStackNavigator(
ByBump,
ByPublicKey,
ByQRCode,
Request,
RequestValidation,
Choice,
},
{
initialRouteName: 'ByPublicKey',
initialRouteName: 'Choice',
navigationOptions: params => ({
headerTitle: (
<Text icon='user-plus' color='black' padding medium>
Expand Down
Expand Up @@ -16,4 +16,3 @@ export default createStackNavigator(
},
{ initialRouteName: '1' }
)

3 changes: 3 additions & 0 deletions client/react-native/common/constants/colors.js
Expand Up @@ -3,6 +3,9 @@ export default {
white: '#ffffff',
black: '#000000',
blue: '#2D6FE2',
red: '#E94E6B',
orange: '#F7B352',
yellow: '#F7E552',

grey1: '#243132',
grey2: '#314243',
Expand Down
1 change: 1 addition & 0 deletions client/react-native/common/graphql/queries/ContactList.js
Expand Up @@ -6,6 +6,7 @@ export default graphql`
id
displayName
overrideDisplayName
status
}
}
`
12 changes: 6 additions & 6 deletions core/api/node/graphql/converts.go
Expand Up @@ -12,12 +12,12 @@ import (
func convertContactStatus(value entity.Contact_Status) *model.BertyEntityContactStatus {
ret, ok := map[entity.Contact_Status]model.BertyEntityContactStatus{
entity.Contact_Unknown: model.BertyEntityContactStatusUnknown,
entity.Contact_IsFriend: model.BertyEntityContactStatusUnknown,
entity.Contact_IsTrustedFriend: model.BertyEntityContactStatusUnknown,
entity.Contact_IsRequested: model.BertyEntityContactStatusUnknown,
entity.Contact_RequestedMe: model.BertyEntityContactStatusUnknown,
entity.Contact_IsBlocked: model.BertyEntityContactStatusUnknown,
entity.Contact_Myself: model.BertyEntityContactStatusUnknown,
entity.Contact_IsFriend: model.BertyEntityContactStatusIsFriend,
entity.Contact_IsTrustedFriend: model.BertyEntityContactStatusIsTrustedFriend,
entity.Contact_IsRequested: model.BertyEntityContactStatusIsRequested,
entity.Contact_RequestedMe: model.BertyEntityContactStatusRequestedMe,
entity.Contact_IsBlocked: model.BertyEntityContactStatusIsBlocked,
entity.Contact_Myself: model.BertyEntityContactStatusMyself,
}[value]

if !ok {
Expand Down

0 comments on commit e10d398

Please sign in to comment.