Skip to content

Commit 127cc7e

Browse files
committed
feat(rn): chats list screen
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
1 parent c11b9f1 commit 127cc7e

File tree

4 files changed

+95
-6
lines changed

4 files changed

+95
-6
lines changed
Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,97 @@
1-
import { PureComponent } from 'react'
1+
import React, { PureComponent } from 'react'
2+
import { FlatList, TouchableOpacity } from 'react-native'
3+
import { Screen, Flex, Text, Separator } from '../../Library'
4+
import { colors } from '../../../constants'
5+
import {
6+
marginLeft,
7+
paddingLeft,
8+
paddingRight,
9+
padding,
10+
borderBottom,
11+
} from '../../../styles'
12+
13+
const genChats = (
14+
title = [
15+
'Myla Maldonado',
16+
'Graeme Kenny',
17+
'Sienna-Rose Carter',
18+
'Marcos Odonnell',
19+
'Arnold Puckett',
20+
'Chay Blake',
21+
'Katarina Rosario',
22+
'Amy-Louise Chaney',
23+
'Janet Steele',
24+
'Rodney Ayala',
25+
]
26+
) =>
27+
title.map((t, k) => ({
28+
id: k.toString(),
29+
title: t,
30+
}))
31+
32+
const Header = ({ navigation }) => (
33+
<Flex.Rows
34+
size={1}
35+
style={[
36+
{ backgroundColor: colors.white, height: 72 },
37+
borderBottom,
38+
padding,
39+
]}
40+
>
41+
<Flex.Cols size={1} align='start' space='between'>
42+
<Text icon='feather-users' large color={colors.black}>
43+
Contacts
44+
</Text>
45+
</Flex.Cols>
46+
</Flex.Rows>
47+
)
48+
const Item = ({ data: { id, title }, navigation }) => (
49+
<TouchableOpacity
50+
onPress={() => navigation.push('Detail', { id })}
51+
style={{
52+
backgroundColor: colors.white,
53+
paddingVertical: 16,
54+
height: 71,
55+
}}
56+
>
57+
<Flex.Cols align='left' style={{ marginLeft }}>
58+
<Flex.Rows size={1} align='left'>
59+
<Text color={colors.black} left middle>
60+
{title}
61+
</Text>
62+
<Text color={colors.subtleGrey} tiny>
63+
Last message sent 3 hours ago ...
64+
</Text>
65+
</Flex.Rows>
66+
</Flex.Cols>
67+
</TouchableOpacity>
68+
)
269

370
export default class List extends PureComponent {
71+
static navigationOptions = ({ navigation }) => ({
72+
header: <Header navigation={navigation} />,
73+
tabBarVisible: true,
74+
})
475
render () {
5-
return null
76+
const { navigation } = this.props
77+
return (
78+
<Screen style={[{ backgroundColor: colors.white }]}>
79+
<FlatList
80+
data={genChats()}
81+
style={[paddingLeft, paddingRight]}
82+
ItemSeparatorComponent={({ highlighted }) => (
83+
<Separator highlighted={highlighted} />
84+
)}
85+
renderItem={data => (
86+
<Item
87+
key={data.id}
88+
data={data.item}
89+
separators={data.separators}
90+
navigation={navigation}
91+
/>
92+
)}
93+
/>
94+
</Screen>
95+
)
696
}
797
}

client/react-native/common/components/Screens/Chats/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { createStackNavigator } from 'react-navigation'
1+
import { createSubStackNavigator } from '../../../helpers/react-navigation'
22
import List from './List'
33
import Detail from './Detail'
44

5-
export default createStackNavigator(
5+
export default createSubStackNavigator(
66
{
77
List,
88
Detail,

client/react-native/common/components/Screens/Contacts/Detail.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default class Detail extends PureComponent {
55
tabBarVisible: false,
66
})
77
render () {
8-
console.log(this.props)
98
return null
109
}
1110
}

client/react-native/common/components/Screens/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export default createBottomTabNavigator(
1010
Settings,
1111
},
1212
{
13-
initialRouteName: 'Contacts',
13+
initialRouteName: 'Chats',
1414
}
1515
)

0 commit comments

Comments
 (0)