-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstat_menu.js
86 lines (76 loc) · 1.84 KB
/
stat_menu.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
import React, {Component} from "react";
import {StyleSheet, Text, TouchableOpacity, View} from "react-native";
import {connect} from "react-redux";
import {toggleInfoModalVisibility} from "./actions";
export const STAT_MENU_HEIGHT = 40;
export class StatMenu extends Component {
constructor(props) {
super(props);
this.handleInfoPress = this.handleInfoPress.bind(this);
}
handleInfoPress() {
this.props.onToggleModalVisibility();
}
render() {
return (
<View style={[styles.container]}>
<Text style={styles.text}>
<Text style={{fontWeight: "bold"}}>{this.props.activeVehicles}</Text>{" "}
active vehicles
</Text>
<TouchableOpacity
style={styles.infoButton}
onPress={this.handleInfoPress}>
<Text style={styles.infoButtonIcon}>?</Text>
</TouchableOpacity>
</View>
);
}
}
export function mapStateToProps(state) {
return {
activeVehicles: state.vehicles ? state.vehicles.length : 0
};
}
function mapDispatchToProps(dispatch) {
return {
onToggleModalVisibility: visible => {
dispatch(toggleInfoModalVisibility());
}
};
}
export default connect(mapStateToProps, mapDispatchToProps)(StatMenu);
const styles = StyleSheet.create({
container: {
backgroundColor: "#34495e",
bottom: 0,
height: STAT_MENU_HEIGHT,
left: 0,
position: "absolute",
right: 0,
shadowColor: "#000",
shadowOffset: {width: 0, height: -2},
shadowOpacity: 0.2,
shadowRadius: 2,
zIndex: 51
},
infoButton: {
flex: 0,
position: "absolute",
right: 5,
zIndex: 99
},
infoButtonIcon: {
color: "#EFEFEF",
fontFamily: "Allerta Stencil",
fontSize: 22,
marginRight: 20,
marginTop: 4
},
text: {
color: "#ecf0f1",
fontSize: 16,
padding: 8,
paddingLeft: 15
}
});