/
WeatherPage.js
73 lines (66 loc) · 1.56 KB
/
WeatherPage.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
import React, {
Component,
PropTypes,
} from 'react';
import {
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import Color from '../services/color';
import Header from '../components/Header';
import WeatherGraph from './WeatherGraph';
// eslint-disable-next-line react/prefer-stateless-function
export default class WeatherPage extends Component {
static propTypes = {
changeAddress: PropTypes.func.isRequired,
name: PropTypes.string.isRequired,
data: PropTypes.object.isRequired,
}
render() {
const {
name,
changeAddress,
data: graphData,
} = this.props;
const graphProps = {};
graphProps.data = graphData.daily.data;
graphProps.xAccessor = (d) => new Date(d.time * 1000);
graphProps.yAccessor = (d) => d.temperatureMax;
return (
<View style={styles.container}>
<Header>
<TouchableOpacity
style={styles.headerButton}
onPress={changeAddress}
>
<Text style={styles.headerText}>
{name}
</Text>
</TouchableOpacity>
</Header>
<View style={styles.content}>
<WeatherGraph {...graphProps} />
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Color.White,
},
headerButton: {
paddingBottom: 5,
borderBottomWidth: 1,
borderBottomColor: Color.BlueDark,
},
content: {
flex: 1,
flexDirection: 'column',
justifyContent: 'space-around',
alignItems: 'center',
},
});