Last active
June 10, 2017 01:19
-
-
Save james2406/f00b0ce6af989774850c69e0cdd9f720 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { StyleSheet, Text, Button, SectionList, TouchableOpacity } from 'react-native'; | |
class Collections extends Component { | |
static renderHeader(title) { | |
return ( | |
<Text style={styles.header}>{title}</Text> | |
); | |
} | |
renderItem(item) { | |
return ( | |
<TouchableOpacity key={item.id} style={styles.item} onPress={() => {} /> | |
); | |
} | |
render() { | |
const { collections } = this.props; | |
return ( | |
<SectionList | |
style={styles.container} | |
contentContainerStyle={styles.list} | |
sections={[ | |
{ key: 0, title: 'Your collections', data: collections.default }, | |
{ key: 1, title: 'Collections you\'e created (' + collections.custom.length + ')', data: collections.custom }, | |
]} | |
renderSectionHeader={({ section }) => Collections.renderHeader(section.title)} | |
renderItem={({ item }) => this.renderItem(item)} | |
removeClippedSubviews={false} | |
/> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
}, | |
list: { | |
flexDirection: 'row', | |
flexWrap: 'wrap', | |
justifyContent: 'space-between', | |
marginRight: 10, | |
marginLeft: 10, | |
}, | |
header: { | |
minWidth: '100%', | |
paddingTop: 20, | |
paddingBottom: 10, | |
fontWeight: 'bold', | |
color: colors.medium, | |
}, | |
item: { | |
minWidth: '48%', | |
height: 170, | |
marginBottom: 15, | |
padding: 10, | |
backgroundColor: 'white', | |
}, | |
itemTitle: {}, | |
itemSubtitle: { | |
color: colors.medium, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment