Color Dynamic
continuous-integration/drone/push Build is passing Details

master
Augustin 1 year ago
parent 02831c88a8
commit 6d05efe58c

@ -18,8 +18,8 @@ export const getImageSource = (weatherType) => {
if (temperature < 10) { if (temperature < 10) {
return '#00aaff'; // Bleu pour les températures froides return '#00aaff'; // Bleu pour les températures froides
} else if (temperature > 30) { } else if (temperature > 30) {
return '#ff4500'; // Rouge pour les températures chaudes return '#fde880'; // Rouge pour les températures chaudes
} else { } else {
return '#000000'; // Noir par défaut return '#adcac0'; // Noir par défaut
} }
}; };

@ -4,6 +4,7 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { getWeathersIconList } from '../thunk/thunkListWeatherIcon'; import { getWeathersIconList } from '../thunk/thunkListWeatherIcon';
import { City, Weather } from '../data/stub'; import { City, Weather } from '../data/stub';
import { getTemperatureColor } from './ImageWeatherType';
type MeteoProps = { type MeteoProps = {
city : City, city : City,
@ -19,7 +20,8 @@ export function WeatherCard(props: MeteoProps) {
}; };
loadWeathersIcons(); loadWeathersIcons();
}, [dispatch]); }, [dispatch]);
const temperatureColor = getTemperatureColor(props.weather.temperature);
//console.log(hh[0]._imageUri); //console.log(hh[0]._imageUri);
return ( return (
@ -35,7 +37,7 @@ export function WeatherCard(props: MeteoProps) {
source= {{ uri: data.filter(() => source= {{ uri: data.filter(() =>
props.weather.weatherType props.weather.weatherType
)[0]._imageUri }} )[0]._imageUri }}
style={styles.image} style={[styles.image, {backgroundColor: temperatureColor}]}
/> />
<Text style={styles.title} > {props.weather.weatherType} </Text> <Text style={styles.title} > {props.weather.weatherType} </Text>
</View> </View>
@ -107,7 +109,7 @@ const styles = StyleSheet.create({
}, },
image: { image: {
width: 80, width: 80,
backgroundColor: 'blue',
height: 80, height: 80,
borderRadius: 15, borderRadius: 15,
}, },

Loading…
Cancel
Save