|
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 | +) |
2 | 69 |
|
3 | 70 | export default class List extends PureComponent {
|
| 71 | + static navigationOptions = ({ navigation }) => ({ |
| 72 | + header: <Header navigation={navigation} />, |
| 73 | + tabBarVisible: true, |
| 74 | + }) |
4 | 75 | 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 | + ) |
6 | 96 | }
|
7 | 97 | }
|
0 commit comments