From 7430890d03a7b206f51cb16da051c07f34a0521a Mon Sep 17 00:00:00 2001 From: Ksenia Lebedeva Date: Fri, 13 Sep 2024 16:55:41 +0200 Subject: [PATCH] added pin prompt --- src/components/Dialpad.tsx | 17 +++++++++++------ src/components/steps/InitializationScreen.tsx | 15 ++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/components/Dialpad.tsx b/src/components/Dialpad.tsx index 152663c..30200a6 100644 --- a/src/components/Dialpad.tsx +++ b/src/components/Dialpad.tsx @@ -7,12 +7,13 @@ import DialpadPin from "./DialpadPin"; const { width, height } = Dimensions.get("window"); type DialpadProps = { + prompt: string; onCancelFunc: () => void; - onNextFunc: (p?: any) => void; + onNextFunc: (p?: any) => boolean; }; const Dialpad: FC = props => { - const {onNextFunc, onCancelFunc} = props; + const {prompt, onNextFunc, onCancelFunc} = props; const dialPadContent = [1, 2, 3, 4, 5, 6, 7, 8, 9, "", 0, "X"]; const dialPadSize = width * 0.2; const dialPadTextSize = dialPadSize * 0.36; @@ -21,8 +22,6 @@ const Dialpad: FC = props => { const pinContainerSize = width / 2; const pinSize = pinContainerSize / pinLength; - - const updateCode = (item: never) => { if (item === "X") { setCode((prev) => prev.slice(0, -1)); @@ -34,17 +33,23 @@ const Dialpad: FC = props => { } } + const onNext = () => { + if (!onNextFunc(code.join(''))) { + setCode([]); + } + } + return ( - Create PIN + {prompt} Enter your secure six-digit code - + )}; diff --git a/src/components/steps/InitializationScreen.tsx b/src/components/steps/InitializationScreen.tsx index cbd0787..38fbd40 100644 --- a/src/components/steps/InitializationScreen.tsx +++ b/src/components/steps/InitializationScreen.tsx @@ -20,8 +20,8 @@ const InitializationScreen: FC = props => { const insertPin = (p: string) => { onChangePin(p); - console.log(p); setStep(PinSteps.RepeatPin); + return true; } const isSamePin = (p: string) => { @@ -29,17 +29,18 @@ const InitializationScreen: FC = props => { } const submitPin = (p: string) => { - if(isSamePin(p)) { - onPressFunc(pin); - } else { - console.log("err"); + if(!isSamePin(p)) { + return false; } + + onPressFunc(pin); + return true; } return ( - { step == PinSteps.InsertPin && } - { step == PinSteps.RepeatPin && setStep(PinSteps.InsertPin)} onNextFunc={submitPin}> } + { step == PinSteps.InsertPin && } + { step == PinSteps.RepeatPin && setStep(PinSteps.InsertPin)} onNextFunc={submitPin}> } )};