-
Notifications
You must be signed in to change notification settings - Fork 0
/
Weather.js
153 lines (148 loc) · 4.26 KB
/
Weather.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
import React from "react";
import propTypes from "prop-types";
import { View, Text, StyleSheet, StatusBar } from "react-native";
import { MaterialIcons, MaterialCommunityIcons } from "@expo/vector-icons";
import { LinearGradient } from "expo-linear-gradient";
const weatherOptions = {
Thunderstorm: {
iconName: "weather-lightning",
gradient: ["#373B44", "#4286f4"],
title: "Thunderstorm in the house",
subtitle: "Actually, outside of the house"
},
Drizzle: {
iconName: "weather-hail",
gradient: ["#89F7FE", "#66A6FF"],
title: "Drizzle",
subtitle: "Is like rain, but gay 🏳️🌈"
},
Rain: {
iconName: "weather-rainy",
gradient: ["#00C6FB", "#005BEA"],
title: "Raining like a MF",
subtitle: "For more info look outside"
},
Snow: {
iconName: "weather-snowy",
gradient: ["#7DE2FC", "#B9B6E5"],
title: "Cold as balls",
subtitle: "Do you want to build a snowman? Fuck no."
},
Atmosphere: {
iconName: "weather-hail",
gradient: ["#89F7FE", "#66A6FF"]
},
Clear: {
iconName: "weather-sunny",
gradient: ["#FF7300", "#FEF253"],
title: "Sunny as fuck",
subtitle: "Go get your ass burnt"
},
Clouds: {
iconName: "weather-cloudy",
gradient: ["#D7D2CC", "#304352"],
title: "Clouds",
subtitle: "I know, fucking boring"
},
Mist: {
iconName: "weather-hail",
gradient: ["#4DA0B0", "#D39D38"],
title: "Mist!",
subtitle: "It's like you have no glasses on."
},
Dust: {
iconName: "weather-hail",
gradient: ["#4DA0B0", "#D39D38"],
title: "Dusty",
subtitle: "Thanks a lot China 🖕🏻"
},
Haze: {
iconName: "weather-hail",
gradient: ["#4DA0B0", "#D39D38"],
title: "Haze",
subtitle: "Just don't go outside."
}
};
export default function Weather({ temp, temp_max, temp_min, name, condition }) {
return (
<LinearGradient
colors={weatherOptions[condition].gradient}
style={styles.container}>
<StatusBar barStyle="light-content" />
<View style={styles.container}>
<View style={styles.location}>
<MaterialIcons
size={30}
name="my-location"
color="white"
/>
<Text style={styles.subtemp}> {name} </Text>
</View>
<View style={styles.weather}>
<MaterialCommunityIcons
size={96}
name={weatherOptions[condition].iconName}
color="white"
/>
<Text style={styles.temp}>{temp}°</Text>
<Text style={styles.subtemp}>{temp_min} (Min) ~ {temp_max} (Max)°</Text>
</View>
<View style={styles.info}>
<Text style={styles.title}>{weatherOptions[condition].title}</Text>
<Text style={styles.subtitle}>
{weatherOptions[condition].subtitle}
</Text>
</View>
</View>
</LinearGradient>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
location: {
flex: 1,
flexDirection: 'row',
justifyContent: "flex-start",
alignItems: "center",
paddingLeft: 10
},
weather: {
flex: 3,
justifyContent: "center",
alignItems: "center"
},
info: {
flex: 1,
justifyContent: "center",
alignItems: "center"
},
temp: {
fontSize: 32,
color: "white"
},
subtemp: {
fontSize: 20,
color: "white"
},
title: {
color: "white",
fontSize: 44,
fontWeight: "300",
marginBottom: 10,
textAlign: "left"
},
subtitle: {
fontWeight: "600",
color: "white",
fontSize: 24,
textAlign: "left"
},
textContainer: {
alignItems: "flex-start",
paddingHorizontal: 40,
justifyContent: "center",
flex: 1
}
})