// DM_1 : Desenvolvimento Mobile - 1
//App.js
import React, {Component} from 'react';
import {View, Text, StyleSheet, TouchableOpacity} from 'react-native';
import Descricao from './Descricao';
export default class App extends Component {
constructor(props){
super(props)
this.state = {
contador : 0,
texto: 'pontos',
}
}
_pressedNumber = ()=>{
this.setState({
contador: this.state.contador + 1
})
}
render(){
return (
<View style={styles.container}>
<TouchableOpacity onPress={this._pressedNumber}>
<Text style={styles.fonte}>{this.state.contador}</Text>
</TouchableOpacity>
<Descricao texto={'pontos'}/>
</View>
)
}
}
const styles = StyleSheet.create({
container:{
flex:1,
justifyContent:"center",
alignitens:"center",
backgroundColor: "black"
},
fonte:{
justifyContent:"center",
alignitens: "center",
fontSize:150,
color:"white"
},
})
//*******************************
// Descricao.js
import React, {Component} from 'react';
import {View, Text, StyleSheet, TonchableOpacity} from 'react-native';
export default class Descricao extends Component{
constuctor(props){
super(props)
this.state = {
descricao: this.props.texto
}
}
render(){
return (
<View styles={styles.Container}>
<Text styles={styles.estilo_texto}>{this.state.descricao}</Text>
</View>
)
}
}
const styles = StyleSheet.create({
estilo_texto:{
justifyContent:"center",
alignitens: "center",
fontSize:30,
color:"white",
}
})
Comentários
Postar um comentário