-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCounterDisplay.js
186 lines (163 loc) · 3.96 KB
/
CounterDisplay.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//Presentational Component
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
Button,
SectionList,
} from 'react-native';
import MapView, { Marker } from 'react-native-maps';
const dataSource = [
{data:['Rating: 3 out of 5 stars', 'Amenities: toilet paper, mints'], Location:'Quincy Market'},
{data:['Rating:4 out of 5 stars', 'Amenities: coffee nearby'], Location:'Starbucks on Bolyston Ave'},
{data:['Rating:1 out of 5 stars', 'Amenities: in conveciance store'], Location:'7/11 on Comm Ave'}
]
class CounterDisplay extends Component{
constructor(props){
super(props);
return {
region: {
latitude: 42.348887,
longitude: -71.101606,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421
}
}
}
onRegionChange(region) {
this.setState({ region });
}
renderItem = ({item, index, section}) => {
return<Text key = {index} style={styles.infoText}>{item}</Text>
}
renderHeader = ({section:{Location}}) => {
return <Text style={styles.header}>{Location}</Text>
}
render() {
return (
<View style={styles.outerContainer}>
<View style ={styles.textStuff}>
<Text style={styles.label}>Bathrooms Nearby:</Text>
<Text style={styles.author}>By Will Munoz</Text>
</View>
<SectionList style={styles.info}
renderItem = {this.renderItem}
renderSectionHeader={this.renderHeader}
sections = {dataSource}
keyExtractor={(item, index) => item + index}/>
<MapView
region={this.state.region}
onRegionChange={this.onRegionChange}>
{this.state.markers.map(marker => (
<Marker
coordinate={marker.latlng}
title={marker.title}
description={marker.description}
/>
))}
</MapView>
<View style={styles.container}>
<View style={styles.countContainer}>
<Text style={styles.count}>{this.props.count}</Text>
</View>
<View style = {styles.options}>
<View style={styles.increment}>
<Button onPress={this.props.increment} title={'+'} color='black'/>
</View>
<View style={styles.decrement}>
<Button onPress={this.props.decrement} title={'-'} color='black'/>
</View>
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
outerContainer: {
backgroundColor: 'pink',
flex: 1,
flexDirection: 'column',
justifyContent: 'space-evenly',
alignItems: 'center'
},
textStuff:{
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center'
},
info:{
flex: 2,
flexDirection: 'row'
},
label: {
fontSize: 30,
color: 'purple'
},
author: {
fontSize: 15,
color: 'purple'
},
container: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center'
},
countContainer:{
height: 60,
width: 150,
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'center',
backgroundColor: 'skyblue',
borderRadius: 4,
borderWidth: 0.5,
borderColor: 'black'
},
count:{
color: 'black',
fontSize: 30
},
options:{
height: 60,
width: 50,
flexDirection: "column",
justifyContent: 'space-between'
},
increment:{
flex: 1,
borderRadius: 4,
borderWidth: 0.5,
borderColor: 'black',
backgroundColor: 'steelblue',
},
decrement:{
flex: 1,
borderRadius: 4,
borderWidth: 0.5,
borderColor: 'black',
backgroundColor: 'steelblue'
},
infoText:{
fontSize: 14,
color: 'purple'
},
header:{
fontSize: 20,
marginTop: 10,
color: 'purple',
fontWeight: 'bold'
},
map:{
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0
}
});
export default CounterDisplay;