-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeatherCard.js
44 lines (39 loc) · 945 Bytes
/
WeatherCard.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
import React from 'react';
import { View, Text, Image, StyleSheet } from 'react-native';
export default function WeatherCard({ weather }) {
const date = new Date(weather.dt * 1000);
return (
<View style={styles.card}>
<Text style={styles.date}>{date.toLocaleDateString()}</Text>
<Image
style={styles.icon}
source={{
uri: `https://openweathermap.org/img/wn/${weather.weather[0].icon}.png`,
}}
/>
<Text style={styles.temperature}>{Math.round(weather.temp.day)}°C</Text>
</View>
);
}
const styles = StyleSheet.create({
card: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
backgroundColor: '#e0e0e0',
borderRadius: 10,
padding: 20,
marginBottom: 10,
},
date: {
fontSize: 18,
},
icon: {
width: 50,
height: 50,
},
temperature: {
fontSize: 18,
fontWeight: 'bold',
},
});