From 7a0829720153d7a281243c32c677a3a1c1b138af Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 17 Jun 2019 20:06:15 -0300 Subject: [PATCH 1/3] Reenvio codigo (inicio) --- src/Screens/Verification/verification.js | 36 ++++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/Screens/Verification/verification.js b/src/Screens/Verification/verification.js index f43aae9..8f1ee62 100644 --- a/src/Screens/Verification/verification.js +++ b/src/Screens/Verification/verification.js @@ -4,9 +4,9 @@ import { View, Text, StyleSheet, - Linking, TouchableOpacity, - BackHandler + BackHandler, + Alert } from "react-native" import LinearGradient from "react-native-linear-gradient" import CodeInput from "react-native-confirmation-code-input" @@ -16,7 +16,8 @@ export default class Verificacao extends Component { constructor() { super() this.state = { - code: "" + code: "", + confirmResult: null } } @@ -40,8 +41,11 @@ export default class Verificacao extends Component { confirmChoice = code => { const { navigation } = this.props - const confirmResult = navigation.getParam("confirmResultFirebase") - + const { confirmResult } = this.state + const cR = navigation.getParam("confirmResultFirebase") + if (!confirmResult) { + this.setState({ confirmResult: cR }) + } if (confirmResult && code.length) { confirmResult .confirm(code) @@ -64,6 +68,20 @@ export default class Verificacao extends Component { } } + reenviarCodigo = () => { + Alert.alert("Clicou", "clicou") + const { navigation } = this.props + const phoneNumber = navigation.getParam("phoneNumber") + + firebase + .auth() + .signInWithPhoneNumber(phoneNumber) + .then(_confirmResult => { + this.setState({ confirmResult: _confirmResult }) + }) + .catch(erro => Alert.alert("Erro", erro)) + } + render() { return ( @@ -96,9 +114,9 @@ export default class Verificacao extends Component { Não recebeu o código de verificação? - Linking.openURL("#")}> - Reenviar código - + + Reenviar código + ) @@ -127,7 +145,7 @@ const styles = StyleSheet.create({ }, text2: { marginLeft: 1, - color: "black", + color: "#007AFF", fontWeight: "bold" }, button: { From 035ee31eccaee6c553647fe1aecd542532df8545 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 17 Jun 2019 22:19:35 -0300 Subject: [PATCH 2/3] =?UTF-8?q?Refatora=C3=A7=C3=A3o=20completa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Screens/Verification/verification.js | 77 +++++++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/src/Screens/Verification/verification.js b/src/Screens/Verification/verification.js index 8f1ee62..9ef48e2 100644 --- a/src/Screens/Verification/verification.js +++ b/src/Screens/Verification/verification.js @@ -6,23 +6,30 @@ import { StyleSheet, TouchableOpacity, BackHandler, - Alert + Alert, + Image, + Dimensions } from "react-native" import LinearGradient from "react-native-linear-gradient" import CodeInput from "react-native-confirmation-code-input" import firebase from "react-native-firebase" +import unichatIcon from "../../assets/imgs/unichat-icon.png" export default class Verificacao extends Component { constructor() { super() this.state = { code: "", - confirmResult: null + confirmResult: null, + disableResend: true } } componentDidMount() { BackHandler.addEventListener("hardwareBackPress", this.handleBackPress) + setTimeout(() => { + this.setState({ disableResend: false }) + }, 60000) } componentWillUnmount() { @@ -72,19 +79,29 @@ export default class Verificacao extends Component { Alert.alert("Clicou", "clicou") const { navigation } = this.props const phoneNumber = navigation.getParam("phoneNumber") + Alert.alert("Numero", phoneNumber) + this.setState({ disableResend: true }) + setTimeout(() => { + this.setState({ disableResend: false }) + }, 60000) firebase .auth() .signInWithPhoneNumber(phoneNumber) - .then(_confirmResult => { - this.setState({ confirmResult: _confirmResult }) + .then(cR => { + this.setState({ confirmResult: cR }) }) .catch(erro => Alert.alert("Erro", erro)) } render() { + const { disableResend } = this.state + return ( + + + Entre com seu número de verificação @@ -114,20 +131,39 @@ export default class Verificacao extends Component { Não recebeu o código de verificação? - - Reenviar código + + {disableResend && ( + <> + Reenviar código + + )} + {!disableResend && ( + <> + Reenviar código + + )} + + + Caso o número seja do celular atual, o código será verificado + automaticamente + + ) } } +const largura = Dimensions.get("window").width + const styles = StyleSheet.create({ principal: { flex: 1, fontFamily: "OpenSans", - justifyContent: "center" }, containerText1: { marginBottom: 10, @@ -143,9 +179,17 @@ const styles = StyleSheet.create({ alignSelf: "center", flexDirection: "row" }, - text2: { + containerText3: { + marginTop: 50, + alignSelf: "center" + }, + text2_active: { marginLeft: 1, - color: "#007AFF", + color: "#007AFF" + }, + text2_inactive: { + marginLeft: 1, + color: "black", fontWeight: "bold" }, button: { @@ -162,8 +206,23 @@ const styles = StyleSheet.create({ fontSize: 25, color: "white" }, + text4: { + textAlign: "center", + fontSize: 12, + color: "gray" + }, touchable: { marginLeft: 40, marginRight: 40 + }, + icon: { + width: largura / 3, + height: largura / 3 + }, + logo: { + alignItems: "center", + justifyContent: "center", + height: (1/2)*largura, + top: 0 } }) From 441e11d8cfca3af36af8913e051b3476a156dcac Mon Sep 17 00:00:00 2001 From: Max Lima Date: Mon, 17 Jun 2019 22:47:38 -0300 Subject: [PATCH 3/3] Update verification.js --- src/Screens/Verification/verification.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Screens/Verification/verification.js b/src/Screens/Verification/verification.js index b12ad57..ec4fb6a 100644 --- a/src/Screens/Verification/verification.js +++ b/src/Screens/Verification/verification.js @@ -77,10 +77,8 @@ export default class Verificacao extends Component { } reenviarCodigo = () => { - Alert.alert("Clicou", "clicou") const { navigation } = this.props const phoneNumber = navigation.getParam("phoneNumber") - Alert.alert("Numero", phoneNumber) this.setState({ disableResend: true }) setTimeout(() => { this.setState({ disableResend: false })