No Description

PincodeScreen.js 1.6KB

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