From ab44e04e5a8d2ccb560bc8d80a4733d00ed2ea5a Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Sat, 10 Jul 2021 14:24:08 +0500 Subject: [PATCH] convert login dialog to ActionSheet --- apps/mobile/src/components/Input/index.js | 1 + .../src/components/LoginDialog/index.js | 213 +++++++----------- .../src/components/SimpleList/header.js | 8 +- .../components/SimpleList/sectionheader.js | 12 +- apps/mobile/src/components/TagItem/index.js | 5 +- 5 files changed, 95 insertions(+), 144 deletions(-) diff --git a/apps/mobile/src/components/Input/index.js b/apps/mobile/src/components/Input/index.js index 9ae133361..5fda67e23 100644 --- a/apps/mobile/src/components/Input/index.js +++ b/apps/mobile/src/components/Input/index.js @@ -285,6 +285,7 @@ const Input = ({ 0 ? ( Object.keys(ERRORS_LIST).map(error => ( { const [error, setError] = useState(false); const [focused, setFocused] = useState(false); const [confirm, setConfirm] = useState(false); - const insets = useSafeAreaInsets(); + const actionSheetRef = useRef(); const _email = useRef(); const _pass = useRef(); const _username = useRef(); @@ -188,31 +190,34 @@ const LoginDialog = () => { async function open(mode) { setMode(mode ? mode : MODES.login); + if (mode === MODES.sessionExpired) { let user = await db.user.getUser(); email = user.email; } setStatus(null); setVisible(true); + await sleep(10); + actionSheetRef.current?.show(); } const close = () => { if (loading) return; + actionSheetRef.current?.hide(); _email.current?.clear(); _pass.current?.clear(); _passConfirm.current?.clear(); _username.current?.clear(); - - // email = null; - // password = null; confirmPassword = null; oldPassword = null; - setVisible(false); + email = null; + password = null; setUserConsent(false); setError(false); setLoading(false); setStatus(null); setMode(MODES.login); + setVisible(false); }; const loginUser = async () => { @@ -396,17 +401,21 @@ const LoginDialog = () => { setFocused(!focused); setTimeout(() => { _email.current?.focus(); - //setFocused(!focused); }, 50); }; return !visible ? null : ( - { + onClose={close} + onOpen={() => { setTimeout(() => { if (MODES.sessionExpired === mode) { _pass.current?.focus(); @@ -457,49 +466,8 @@ const LoginDialog = () => { if (!current.showLoader) { setStatus(null); } - }}> - - - {status} - - {current.loading} - {!current.showLoader ? null : ( - - {'\n'} - Do not close the app. - - )} - - - - {!current.showLoader ? ( -