-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeather.js
More file actions
35 lines (31 loc) · 1.3 KB
/
Weather.js
File metadata and controls
35 lines (31 loc) · 1.3 KB
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
import React from 'react'
import PropTypes from 'prop-types'
import { Text, View, StatusBar } from 'react-native';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { LinearGradient } from 'expo-linear-gradient';
import weatherOptions from './src/weatherOptions';
import styles from './styles/Weather';
function Weather({ temp, condition }) {
return (
<LinearGradient style={styles.container} colors={weatherOptions[condition].gradient}>
<StatusBar barStyle="light-content" />
<View style={styles.halfContainer}>
<MaterialCommunityIcons
size={96}
name={weatherOptions[condition]?.iconName || "weather-sunset"}
color="white"
/>
<Text style={styles.temp}>{temp}℃</Text>
</View>
<View style={{ ...styles.halfContainer, ...styles.textContainer }}>
<Text style={styles.title}>{weatherOptions[condition]?.title}</Text>
<Text style={styles.subtitle}>{weatherOptions[condition]?.subtitle}</Text>
</View>
</LinearGradient>
)
}
Weather.propTypes = {
temp: PropTypes.number.isRequired,
condition: PropTypes.oneOf(Object.keys(weatherOptions)).isRequired
};
export default Weather