Skip to content

Instantly share code, notes, and snippets.

@dantejauregui
Last active May 14, 2017 22:15
Show Gist options
  • Save dantejauregui/659b4815c2ce7f7d2346e1dd95ff0f0c to your computer and use it in GitHub Desktop.
Save dantejauregui/659b4815c2ce7f7d2346e1dd95ff0f0c to your computer and use it in GitHub Desktop.
reactNative1 created by dantejauregui - https://repl.it/HxUR/4
import React from 'react';
import { StyleSheet, Text, View, Button, TextInput } from 'react-native';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
numero: 0,
boxNumber: 0
};
}
dante() {
this.setState({
numero: parseInt(this.state.numero) + parseInt(this.state.boxNumber),
});
this.setState({
boxNumber: 0
});
}
resetear() {
this.setState({
numero: 0
});
}
render() {
return (
<View style={styles.container}>
<Text style={{textAlign: 'center'}}>Selecciona varios números y adiciona asi más y más números:</Text>
<TextInput
style={{height: 40, width: 160, borderColor: 'gray', borderWidth: 1, textAlign: 'center', margin: 25}}
onChangeText={(n) => this.setState({boxNumber: n})}
value={this.state.boxNumber}
keyboardType={'numeric'}
/>
<View style={{alignItems: 'stretch', flexDirection: 'row', height: 40, marginBottom: 10, justifyContent: "space-between", width: 200}}>
<Button
onPress={this.dante.bind(this)}
title="Adiciona N°"
color="#841584"
accessibilityLabel="Learn more about this purple button"
style={{marginBottom: 10}}
/>
<Button
onPress={this.resetear.bind(this)}
title="Resetea"
color="#2f2f2f"
accessibilityLabel="Learn more about this purple button"
/>
</View>
{/*<TouchableOpacity onPress={this.dante.bind(this)}>
<Image
style={styles.button}
source={require('./myButton.png')}
/>
</TouchableOpacity>*/}
<Text style={{marginTop: 25, fontSize: 20}}>{this.state.numero}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
marginTop: 0,
marginBottom: 50
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment