-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
64 lines (60 loc) · 1.49 KB
/
App.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react';
import { Text, View, Image, TouchableHighlight } from 'react-native';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {uri: require('./my-icon.png'),
is_cool: false,
is_fancy: false
}
}
changeLogo() {
if (this.state.is_cool == false && this.state.is_fancy == false) {
this.setState({
uri: require('./my-icon-sunglasses.png'),
is_cool: true,
is_fancy: false
});
} else if (this.state.is_cool == true && this.state.is_fancy == false) {
this.setState({
uri: require('./my-icon-hat.png'),
is_cool: true,
is_fancy: true
});
} else {
this.setState({
uri: require('./my-icon.png'),
is_cool: false,
is_fancy: false
});
}
console.log('\nis_cool: ' + this.state.is_cool + '\nis_fancy: ' + this.state.is_fancy);
}
render() {
return (
<View style={styles.container}>
<TouchableHighlight onPress={() => this.changeLogo()}>
<Image
source={this.state.uri}
style={styles.logoStyle}
/>
</TouchableHighlight>
</View>
);
}
}
const styles = {
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'blue',
},
logoStyle: {
width: 400,
height: 400,
marginLeft: 10,
marginRight: 5,
alignSelf: 'center',
}
};