From 786b1d6a7a7c6c548c8fc632305d3961455a58c3 Mon Sep 17 00:00:00 2001 From: Deepak Sangle Date: Fri, 15 Dec 2023 16:18:24 +0530 Subject: [PATCH] copy otp added --- mobile-client/src/screens/HomePage.js | 24 ++++++++++++++++++------ mobile-client/src/screens/Login.js | 25 ++++++++++++++++++------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/mobile-client/src/screens/HomePage.js b/mobile-client/src/screens/HomePage.js index 3268f29..f523ee5 100644 --- a/mobile-client/src/screens/HomePage.js +++ b/mobile-client/src/screens/HomePage.js @@ -179,18 +179,30 @@ const HomePage = ({ route, navigation }) => { setBody(""); }; - const onSelectedEvent = (index) => { + const changeOpenEvents = (index) => { + return new Promise((resolve, reject)=> { + const temp = [...openEvents]; + temp[index] = !temp[index]; + setOpenEvents(temp); + resolve(); + }); + } + + const animate = (index) => { const updatedValue = animatedHeights[index]._value === 0 ? 1 : 0; Animated.timing(animatedHeights[index], { toValue: updatedValue, duration: 300, easing: Easing.linear, useNativeDriver: false, - }).start(()=> { - const temp = [...openEvents]; - temp[index] = !temp[index]; - setOpenEvents(temp); - }); + }).start() + } + + const onSelectedEvent = (index) => { + changeOpenEvents(index) + .then(() => { + animate(index); + }); }; const RenderAllEntries = () => { diff --git a/mobile-client/src/screens/Login.js b/mobile-client/src/screens/Login.js index 8a32d7f..4bc5df3 100644 --- a/mobile-client/src/screens/Login.js +++ b/mobile-client/src/screens/Login.js @@ -56,14 +56,25 @@ const Login = ({navigation}) => { } const setCorrectPasscode = (text, i) => { - if(text.length > 1) return; - const acceptedKeys = ['','0','1','2','3','4','5','6','7','8','9']; - if(!acceptedKeys.includes(text)) return; - if(text.length === 1 && i<3) { - passcodeRefs[i+1].current.focus(); - } + let index = 0; + console.log({text, i}); const new_passcode = [...passcode]; - new_passcode[i] = text; + if(text.length === 0) { + new_passcode[i] = ''; + setPasscode(new_passcode); + return; + } + while(text.length > index) { + const acceptedKeys = ['','0','1','2','3','4','5','6','7','8','9']; + if(!acceptedKeys.includes(text[index])) return; + new_passcode[i] = text[index]; + if(i<3) { + passcodeRefs[i+1].current.focus(); + } + else break; + i++; + index++; + } setPasscode(new_passcode); }