Skip to content

Instantly share code, notes, and snippets.

@chapeljuice
Created May 11, 2017 20:43
Show Gist options
  • Save chapeljuice/316cb72432bf0d3ff90ca93349b85570 to your computer and use it in GitHub Desktop.
Save chapeljuice/316cb72432bf0d3ff90ca93349b85570 to your computer and use it in GitHub Desktop.
import React from 'react'
import { Image, ListView, ScrollView, Text, TouchableOpacity, View } from 'react-native'
import styles from './Styles/ReservationCardStyle'
import { connect } from 'react-redux'
import Icon from 'react-native-vector-icons/FontAwesome'
import ButtonCTA from '../Components/ButtonCTA'
import CheckInStatus from '../Components/CheckInStatus'
class ReservationCard extends React.Component {
render() {
return (
<View style={styles.card}>
<View style={styles.copyContainer}>
<Text style={styles.cardTitle}>{this.props.dataSource.title}</Text>
</View>
</View>
)
}
}
const mapStateToProps = (state) => {
return {
dataSource: state.dataSource
}
}
const mapDispatchToProps = (dispatch) => {
return {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(ReservationCard)
import React from 'react'
import { ListView, Text } from 'react-native'
import { connect } from 'react-redux'
import ReservationCard from '../Components/ReservationCard'
import styles from './Styles/ReservationCardListStyle'
var reservationData = require('../Fixtures/reservations.json');
class ReservationCardList extends React.Component {
constructor(props) {
super(props);
this.state = {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
};
}
componentDidMount() {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(reservationData.reservations)
});
}
render () {
return (
<ListView
style={styles.container}
dataSource={this.state.dataSource}
renderRow={(data) => <ReservationCard {...data} />} />
)
}
}
const mapStateToProps = (state) => {
return {
}
}
const mapDispatchToProps = (dispatch) => {
return {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(ReservationCardList)
{
"reservations": [
{
"title": "Cabin on the Ridge"
},
{
"title": "Aux Pied des Pistes"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment