This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
55 lines (52 loc) · 1.43 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity
} from 'react-native';
class example extends Component {
constructor(props) {
super(props);
this.state = {
greeting: undefined
};
}
render() {
if (this.state.greeting) return this.renderAfterButton();
return (
<View testID='welcome' style={{flex: 1, paddingTop: 20, justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 25, marginBottom: 30}}>
Welcome
</Text>
<TouchableOpacity testID='hello_button' onPress={this.onButtonPress.bind(this, 'Hello')}>
<Text style={{color: 'blue', marginBottom: 20}}>Say Hello</Text>
</TouchableOpacity>
<TouchableOpacity testID='world_button' onPress={this.onButtonPress.bind(this, 'World')}>
<Text style={{color: 'blue', marginBottom: 20}}>Say World</Text>
</TouchableOpacity>
</View>
);
}
renderAfterButton() {
return (
<View style={{flex: 1, paddingTop: 20, justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 25}}>
{this.state.greeting}!!!
</Text>
</View>
);
}
onButtonPress(greeting) {
this.setState({
greeting: greeting
});
}
}
AppRegistry.registerComponent('example', () => example);