forked from sallar/lunchify-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Venue.js
139 lines (125 loc) · 3.55 KB
/
Venue.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* @author Sallar Kaboli <[email protected]>
* @date 27.05.2015
*/
'use strict';
/**
* Required Modules
*/
var React = require('react-native'),
Helpers = require('../utils/Helpers'),
Icon = require('react-native-vector-icons/MaterialIcons'),
HTMLView = require('react-native-htmlview'),
Screen = require('Dimensions').get('window'),
{Stylesheet, VenueStyles, ListStyles} = require('../utils/Styles');
var {
View,
Text,
Component,
TouchableHighlight,
ListView,
ScrollView,
Image,
} = React;
var baseDataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1.id !== r2.id
});
/**
* Venues View
*/
class VenueView extends Component {
constructor(props) {
super(props);
this.state = {
venue: props.data.venue,
rawMenu: props.data.menu,
dataSource: baseDataSource
};
}
componentDidMount() {
this.setState({
dataSource: baseDataSource.cloneWithRows(this.state.rawMenu)
});
}
renderHeader() {
return (
<View style={VenueStyles.header}>
<Text style={[Stylesheet.text, VenueStyles.headerText]}>
Sodexo Keilaranta 1
</Text>
</View>
)
}
renderMeal(meal) {
return(
<VenueItemView meal={meal} />
)
}
renderList() {
if(this.state.rawMenu.length > 0) {
return (
<View style={Stylesheet.flex}>
<ListView
automaticallyAdjustContentInsets={false}
dataSource={this.state.dataSource}
renderRow={this.renderMeal.bind(this)}
/>
</View>
);
} else {
return (
<View style={[Stylesheet.flex, Stylesheet.flexCenter]}>
<Text style={Stylesheet.text}>This Venue is Closed Today.</Text>
</View>
);
}
}
render() {
return (
<View style={Stylesheet.flex}>
<Image
source={require('image!placeholder')}
resizeMode="cover"
style={{
width: Screen.width,
height: 200
}}/>
{this.renderList()}
</View>
);
}
}
class VenueItemView extends Component{
render() {
var {meal} = this.props;
var name = meal.name ? meal.name : meal.name_alt,
nameAlt = meal.name ? meal.name_alt : null,
nameAltView = (<View></View>);
if(nameAlt) {
nameAltView = (
<HTMLView
value={"<span>" + nameAlt + "</span>"}
stylesheet={VenueStyles.textStyles}
/>
);
}
return (
<View style={Stylesheet.white}>
<View style={[ListStyles.row, ListStyles.itemRowFree]}>
<View style={ListStyles.infoCell}>
<HTMLView
value={"<p>" + name+ "</p>"}
stylesheet={VenueStyles.textStyles} />
<View style={VenueStyles.Main.spacer}></View>
{nameAltView}
</View>
</View>
<View style={ListStyles.cellBorder} />
</View>
)
}
}
/**
* Export
*/
module.exports = VenueView;