Created
November 24, 2019 23:42
-
-
Save YKalashnikov/84d785d560f7b720b6985fa3284bf351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { View, Text, StyleSheet } from 'react-native'; | |
import { MaterialCommunityIcons } from '@expo/vector-icons'; | |
import PropTypes from 'prop-types'; | |
import { weatherConditions } from '../utils/WeatherConditions'; | |
const Weather = ({ weather, temperature }) => { | |
return ( | |
<View | |
style={[ | |
styles.weatherContainer, | |
{ backgroundColor: weatherConditions[weather].color } | |
]} | |
> | |
<View style={styles.headerContainer}> | |
<MaterialCommunityIcons | |
size={72} | |
name={weatherConditions[weather].icon} | |
color={'#fff'} | |
/> | |
<Text style={styles.tempText}>{temperature}˚</Text> | |
</View> | |
<View style={styles.bodyContainer}> | |
<Text style={styles.title}>{weatherConditions[weather].title}</Text> | |
<Text style={styles.subtitle}> | |
{weatherConditions[weather].subtitle} | |
</Text> | |
</View> | |
</View> | |
); | |
}; | |
Weather.propTypes = { | |
temperature: PropTypes.number.isRequired, | |
weather: PropTypes.string | |
}; | |
const styles = StyleSheet.create({ | |
weatherContainer: { | |
flex: 1 | |
}, | |
headerContainer: { | |
flex: 1, | |
flexDirection: 'row', | |
alignItems: 'center', | |
justifyContent: 'space-around' | |
}, | |
tempText: { | |
fontSize: 72, | |
color: '#fff' | |
}, | |
bodyContainer: { | |
flex: 2, | |
alignItems: 'flex-start', | |
justifyContent: 'flex-end', | |
paddingLeft: 25, | |
marginBottom: 40 | |
}, | |
title: { | |
fontSize: 60, | |
color: '#fff' | |
}, | |
subtitle: { | |
fontSize: 24, | |
color: '#fff' | |
} | |
}); | |
export default Weather; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment