-
Notifications
You must be signed in to change notification settings - Fork 0
/
FlightsPage.js
105 lines (92 loc) · 2.66 KB
/
FlightsPage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import React, {Component} from "react";
import {RecyclerListView, LayoutProvider, DataProvider} from "recyclerlistview";
import {View, Dimensions, Text} from "react-native";
import FlightCard from "./FlightCard";
import HotelCard from "./HotelCard";
import TopWidget from "./TopWidget";
import { connect } from 'react-redux'
let {height, width} = Dimensions.get('window');
class FlightsPageComponent extends Component {
constructor(args) {
super(args);
this._layoutProvider = new LayoutProvider((i) => {
return this.props.dataProvider.getDataForIndex(i).type;
}, (type, dim) => {
switch (type) {
case "HOTEL_ITEM":
dim.width = width;
dim.height = 83;
break;
case "FL_ITEM":
dim.width = width;
dim.height = 80;
break;
case "HEADER":
dim.width = width;
dim.height = 300;
break;
default:
dim.width = width;
dim.height = 0;
}
});
this._renderRow = this._renderRow.bind(this);
}
_renderRow(type, data) {
switch (type) {
case "HOTEL_ITEM":
return <HotelCard/>
case "FL_ITEM":
return <FlightCard data={data}/>;
case "HEADER":
return <TopWidget data={data}/>;
default:
return null;
}
}
render() {
return <View style={styles.container}>
<View style={styles.header}>
<Text style={styles.headerText}>Travel Mate</Text>
</View>
<RecyclerListView rowRenderer={this._renderRow} dataProvider={this.props.dataProvider}
layoutProvider={this._layoutProvider}/>
</View>
}
}
const styles = {
container: {
flex: 1,
},
header:{
height: 65,
backgroundColor:'orange',
alignItems:"center",
flexDirection:"row",
elevation:4
},
headerText:{
color:'white',
fontSize:18,
marginLeft: 16,
paddingBottom:3
},
backIcon:{
height:23,
width:23,
marginLeft:16
}
}
const mapStateToProps = state => {
console.log('state',state);
return {
dataProvider: new DataProvider((r1, r2) => {
console.log(' r1 !== r2', r1 !== r2,r1,r2);
return r1 !== r2
}).cloneWithRows(state)
}
}
const FlightsPage = connect(
mapStateToProps
)(FlightsPageComponent)
export default FlightsPage