You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

72 lines
1.6 KiB

/**
* 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)