-
Notifications
You must be signed in to change notification settings - Fork 1
/
Contact.js
43 lines (41 loc) · 984 Bytes
/
Contact.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
import { StyleSheet, Text, View, Image, Button } from 'react-native';
import {useState} from 'react'
export default function Contact({name, phoneNumber, totalAge, setTotalAge}) {
const [age, setAge] = useState(0);
function makeMeOlder(){
setAge(age + 1)
setTotalAge(totalAge + 1);
}
return (
<View style={styles.contact}>
<Image style={styles.image} source={require('./assets/avatar.png')} />
<View style={styles.details}>
<Text style={styles.name}>{name}</Text>
<Text>Age: {age}</Text>
<Text>{phoneNumber}</Text>
<Button title="Grow Me" onPress={makeMeOlder} />
</View>
</View>
)
}
const styles = StyleSheet.create({
contact: {
margin: 20,
padding: 10,
flexDirection: 'row',
borderWidth: 1,
borderColor: '#999',
borderRadius: 10,
},
details: {
marginLeft: 20,
},
image: {
height: 100,
width: 100,
},
name: {
fontSize: 18,
fontWeight: 'bold'
}
})