parent
db2c45d692
commit
76577e9a66
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 194 KiB |
@ -1,58 +1,58 @@
|
||||
import React from "react";
|
||||
import React, { useState, useSyncExternalStore } from "react";
|
||||
import { View, StyleSheet, Text, Button, TouchableHighlight, Image } from "react-native";
|
||||
import { City } from "../data/stub";
|
||||
import { City, getCurrentWeather, Weather } from "../data/stub";
|
||||
|
||||
|
||||
type VilleProps = {
|
||||
city: City
|
||||
city: City,
|
||||
fav: City
|
||||
}
|
||||
|
||||
|
||||
export function VilleCompopo(props: VilleProps){
|
||||
const weather = getCurrentWeather(props.city.name);
|
||||
return (
|
||||
<View>
|
||||
<View style={styles.container}>
|
||||
<View style={styles.bothtext}>
|
||||
<Text style={styles.title}>{props.city.name}</Text>
|
||||
<Text>{props.city.latitude} - {props.city.longitude}</Text>
|
||||
</View>
|
||||
<TouchableHighlight>
|
||||
<Image source={{uri: "http://simpleicon.com/wp-content/uploads/star.svg"}}/>
|
||||
<View style={{flex: 1, flexDirection: "row"}}>
|
||||
<View style={styles.bothtext}>
|
||||
<Text style={styles.title}>{props.city.name}</Text>
|
||||
<Text>{props.city.latitude} - {props.city.longitude}</Text>
|
||||
</View>
|
||||
<Text style={styles.temperature}>{weather?.temperature}</Text>
|
||||
<TouchableHighlight /*onPress={() => props.fav = this.city}*/>
|
||||
<Image source={ props.city==props.fav ? require('../assets/yellowstar.png') : require('../assets/blackstar.png')} style={styles.button}/>
|
||||
</TouchableHighlight>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.separator}/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
marginHorizontal: "5%",
|
||||
backgroundColor: "darksalmon",
|
||||
margin: 5,
|
||||
marginVertical: 5,
|
||||
borderRadius: 15,
|
||||
width: "90%"
|
||||
},
|
||||
separator: {
|
||||
marginVertical: 4,
|
||||
backgroundColor: "rgba(255,255,255,0.3)",
|
||||
height: 1,
|
||||
width: '90%',
|
||||
},
|
||||
teaserImage: {
|
||||
width: 50,
|
||||
height: 50,
|
||||
width: "90%",
|
||||
alignSelf: 'center'
|
||||
},
|
||||
title: {
|
||||
fontWeight: "bold",
|
||||
fontSize: 18
|
||||
},
|
||||
bothtext: {
|
||||
width: "80%",
|
||||
margin: 10
|
||||
},
|
||||
temperature: {
|
||||
marginTop: 20,
|
||||
fontSize: 18,
|
||||
fontWeight: "bold"
|
||||
},
|
||||
button: {
|
||||
color: "black"
|
||||
height: 30,
|
||||
width: 30,
|
||||
marginTop: 13,
|
||||
alignSelf: "flex-end",
|
||||
margin: 5
|
||||
}
|
||||
});
|
Loading…
Reference in new issue