Skip to content

Instantly share code, notes, and snippets.

@ecavalcanti
Created June 22, 2017 12:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecavalcanti/695b4cf46c80388dfe52b1b2816f7c4a to your computer and use it in GitHub Desktop.
Save ecavalcanti/695b4cf46c80388dfe52b1b2816f7c4a to your computer and use it in GitHub Desktop.
React Native - ActivityIndicator Overlay
import React, { Component } from 'react'
import { AppRegistry, View, Text, TextInput, StyleSheet, TouchableOpacity, ActivityIndicator } from 'react-native'
export default class App extends Component {
state = {
loading: false
}
renderLoading() {
if (this.state.loading) {
return (
<ActivityIndicator size="large" color="black" style={{
position:'absolute', left:0, right:0, bottom:0, top:0 }}/>
)
} else {
return null
}
}
render() {
return (
<View style={styles.container} >
<Text>Email</Text>
<TextInput style={styles.input} placeholder="Digite seu e-mail" />
<Text>Senha</Text>
<TextInput style={styles.input} placeholder="Digite sua senha" />
<TouchableOpacity style={styles.button} onPress={()=>this.setState({loading: true})}>
<Text style={{color:'white'}}>Enviar</Text>
</TouchableOpacity>
{this.renderLoading()}
</View>
)
}
}
const styles = StyleSheet.create({
input: {
height: 40
},
button: {
height: 34,
flexDirection: 'row',
backgroundColor: 'steelblue',
justifyContent: 'center',
alignItems: 'center'
},
container: {
flex: 1,
marginTop: 40,
marginHorizontal: 10,
justifyContent: 'center',
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment