No Description

PincodeScreen.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React from "react";
  2. import { StyleSheet, View, Text, Button } from 'react-native';
  3. import { globalStyles } from "../styles/global";
  4. import SmoothPinCodeInput from 'react-native-smooth-pincode-input';
  5. const pin = 1234;
  6. //comentario
  7. export default class App extends React.Component {
  8. pressHandler = () => {
  9. {/*Dentro del parentesis va el path al screen para redirigir*/}
  10. this.props.navigation.navigate('test')
  11. }
  12. state = {
  13. code: '',
  14. pincode: false,
  15. };
  16. pinInput = React.createRef();
  17. _checkCode = (code) => {
  18. if (code != pin) {
  19. this.pinInput.current.shake()
  20. .then(() => this.setState({ code: '' }));
  21. } else {
  22. this.setState({ pincode: true});
  23. }
  24. }
  25. render() {
  26. const { code } = this.state;
  27. const { pincode } = this.state;
  28. return (
  29. <View style={globalStyles.container}>
  30. {/* Pin container */}
  31. <View style={globalStyles.section}>
  32. <Text style={globalStyles.titleText}>Entra el Pin de la mocion</Text>
  33. <SmoothPinCodeInput
  34. ref={this.pinInput}
  35. value={code}
  36. onTextChange={code => this.setState({ code })}
  37. onFulfill={this._checkCode}
  38. onBackspace={() => console.log('No more back.')}
  39. />
  40. </View>
  41. <View style={globalStyles.container}>
  42. { pincode && <Button title='Ir a mocion' onPress={this.pressHandler} />}
  43. </View>
  44. </View>
  45. );
  46. }
  47. }