From 10b495cdbe24de4634a38f98fedc133bd97db25c Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Wed, 25 Jun 2025 13:45:01 +0500 Subject: [PATCH] mobile: convert sheets with input to screens or simple modals --- .../app/components/auth/change-password.js | 32 ++++---------- apps/mobile/app/components/auth/login.js | 3 +- apps/mobile/app/components/auth/two-factor.js | 30 ++++++++----- apps/mobile/app/components/auth/use-login.js | 6 +-- .../mobile/app/components/dialog/functions.ts | 3 ++ apps/mobile/app/components/dialog/index.tsx | 10 ++++- apps/mobile/app/hooks/use-timer.ts | 9 +++- .../settings}/change-email/index.tsx | 44 ++++--------------- .../app/screens/settings/components.tsx | 6 ++- .../app/screens/settings/settings-data.tsx | 14 +++--- 10 files changed, 70 insertions(+), 87 deletions(-) rename apps/mobile/app/{components/sheets => screens/settings}/change-email/index.tsx (81%) diff --git a/apps/mobile/app/components/auth/change-password.js b/apps/mobile/app/components/auth/change-password.js index 321f22746..311ba41f9 100644 --- a/apps/mobile/app/components/auth/change-password.js +++ b/apps/mobile/app/components/auth/change-password.js @@ -17,26 +17,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +import { strings } from "@notesnook/intl"; import React, { useRef, useState } from "react"; import { View } from "react-native"; import { db } from "../../common/database"; -import { - eSendEvent, - presentSheet, - ToastManager -} from "../../services/event-manager"; +import BackupService from "../../services/backup"; +import { eSendEvent, ToastManager } from "../../services/event-manager"; +import Navigation from "../../services/navigation"; import { useUserStore } from "../../stores/use-user-store"; -import { eCloseSheet, eOpenRecoveryKeyDialog } from "../../utils/events"; -import DialogHeader from "../dialog/dialog-header"; +import { eOpenRecoveryKeyDialog } from "../../utils/events"; +import { DefaultAppStyles } from "../../utils/styles"; +import { Dialog } from "../dialog"; import { Button } from "../ui/button"; import Input from "../ui/input"; import { Notice } from "../ui/notice"; -import Seperator from "../ui/seperator"; -import { Dialog } from "../dialog"; -import BackupService from "../../services/backup"; -import { sleep } from "../../utils/time"; -import { strings } from "@notesnook/intl"; -import { DefaultAppStyles } from "../../utils/styles"; export const ChangePassword = () => { const passwordInputRef = useRef(); @@ -85,8 +79,7 @@ export const ChangePassword = () => { context: "global" }); setLoading(false); - eSendEvent(eCloseSheet); - await sleep(300); + Navigation.goBack(); eSendEvent(eOpenRecoveryKeyDialog); } catch (e) { setLoading(false); @@ -108,9 +101,6 @@ export const ChangePassword = () => { }} > - - - { @@ -160,9 +150,3 @@ export const ChangePassword = () => { ); }; - -ChangePassword.present = () => { - presentSheet({ - component: - }); -}; diff --git a/apps/mobile/app/components/auth/login.js b/apps/mobile/app/components/auth/login.js index 0efee870a..6b75f44fe 100644 --- a/apps/mobile/app/components/auth/login.js +++ b/apps/mobile/app/components/auth/login.js @@ -39,6 +39,7 @@ import { hideAuth } from "./common"; import { ForgotPassword } from "./forgot-password"; import { useLogin } from "./use-login"; import { DefaultAppStyles } from "../../utils/styles"; +import { Dialog } from "../dialog"; const LoginSteps = { emailAuth: 1, @@ -89,7 +90,7 @@ export const Login = ({ changeMode }) => { return ( <> - + { const { colors } = useThemeColors(); @@ -46,7 +43,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo, onCancel }) => { method: mfaInfo?.primaryMethod, isPrimary: true }); - const { seconds, start } = useTimer(currentMethod.method); + const { seconds, start, reset } = useTimer(currentMethod.method); const [loading, setLoading] = useState(false); const inputRef = useRef(); const [sending, setSending] = useState(false); @@ -62,7 +59,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo, onCancel }) => { }, (result) => { if (result) { - eSendEvent(eCloseSheet, "two_factor_verify"); + eSendEvent(eCloseSimpleDialog, "two_factor_verify"); } setLoading(false); } @@ -133,6 +130,12 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo, onCancel }) => { {