From 52ce8a49b422a511a2ef8ec9ec4cb6f48109c241 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 19 Oct 2023 13:24:35 +1100 Subject: [PATCH] replace old seed screen with updated recovery password screen --- Session/Home/HomeVC.swift | 17 +++++++++-------- Session/Settings/RecoveryPasswordView.swift | 13 +++++-------- Session/Settings/SettingsViewModel.swift | 21 ++++++++++----------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/Session/Home/HomeVC.swift b/Session/Home/HomeVC.swift index 0a48b2c89..a7bf43470 100644 --- a/Session/Home/HomeVC.swift +++ b/Session/Home/HomeVC.swift @@ -808,12 +808,14 @@ final class HomeVC: BaseVC, SessionUtilRespondingViewController, UITableViewData // MARK: - Interaction func handleContinueButtonTapped(from seedReminderView: SeedReminderView) { - let targetViewController: UIViewController = { - if let seedVC: SeedVC = try? SeedVC() { - return StyledNavigationController(rootViewController: seedVC) + if let recoveryPasswordView: RecoveryPasswordView = try? RecoveryPasswordView() { + let viewController: SessionHostingViewController = SessionHostingViewController(rootView: recoveryPasswordView) + viewController.setNavBarTitle("recovery_password_title".localized()) + self.navigationController?.pushViewController(viewController, animated: true) { + Storage.shared.writeAsync { db in db[.hasViewedSeed] = true } } - - return ConfirmationModal( + } else { + let targetViewController: UIViewController = ConfirmationModal( info: ConfirmationModal.Info( title: "ALERT_ERROR_TITLE".localized(), body: .text("LOAD_RECOVERY_PASSWORD_ERROR".localized()), @@ -821,9 +823,8 @@ final class HomeVC: BaseVC, SessionUtilRespondingViewController, UITableViewData cancelStyle: .alert_text ) ) - }() - - present(targetViewController, animated: true, completion: nil) + present(targetViewController, animated: true, completion: nil) + } } func show( diff --git a/Session/Settings/RecoveryPasswordView.swift b/Session/Settings/RecoveryPasswordView.swift index 69dc305e7..7da766ec7 100644 --- a/Session/Settings/RecoveryPasswordView.swift +++ b/Session/Settings/RecoveryPasswordView.swift @@ -9,22 +9,19 @@ struct RecoveryPasswordView: View { @EnvironmentObject var host: HostWrapper @State private var copied: Bool = false - @State private var showQRCode: Bool = true + @State private var showQRCode: Bool = false private let mnemonic: String - private let flow: Onboarding.Flow static private let cornerRadius: CGFloat = 13 static private let backgroundCornerRadius: CGFloat = 17 - static private let buttonWidth: CGFloat = 120 + static private let buttonWidth: CGFloat = 130 - public init(flow: Onboarding.Flow) throws { + public init() throws { self.mnemonic = try Identity.mnemonic() - self.flow = flow } - public init(hardcode: String, flow: Onboarding.Flow) { + public init(hardcode: String) { self.mnemonic = hardcode - self.flow = flow } var body: some View { @@ -241,6 +238,6 @@ struct RecoveryPasswordView: View { struct RecoveryPasswordView_Previews: PreviewProvider { static var previews: some View { - RecoveryPasswordView(hardcode: "Voyage urban toyed maverick peculiar tuxedo penguin tree grass building listen speak withdraw terminal plane ", flow: .register) + RecoveryPasswordView(hardcode: "Voyage urban toyed maverick peculiar tuxedo penguin tree grass building listen speak withdraw terminal plane ") } } diff --git a/Session/Settings/SettingsViewModel.swift b/Session/Settings/SettingsViewModel.swift index ffb933dc6..9589701c8 100644 --- a/Session/Settings/SettingsViewModel.swift +++ b/Session/Settings/SettingsViewModel.swift @@ -420,17 +420,17 @@ class SettingsViewModel: SessionTableViewModel, NavigationItemSource, Navigatabl SessionCell.Info( id: .recoveryPhrase, leftAccessory: .icon( - UIImage(named: "icon_recovery")? + UIImage(named: "SessionShield")? .withRenderingMode(.alwaysTemplate) ), - title: "vc_settings_recovery_phrase_button_title".localized(), + title: "recovery_password_title".localized(), onTap: { - let targetViewController: UIViewController = { - if let modal: SeedModal = try? SeedModal() { - return modal - } - - return ConfirmationModal( + if let recoveryPasswordView: RecoveryPasswordView = try? RecoveryPasswordView() { + let viewController: SessionHostingViewController = SessionHostingViewController(rootView: recoveryPasswordView) + viewController.setNavBarTitle("recovery_password_title".localized()) + self?.transitionToScreen(viewController) + } else { + let targetViewController: UIViewController = ConfirmationModal( info: ConfirmationModal.Info( title: "ALERT_ERROR_TITLE".localized(), body: .text("LOAD_RECOVERY_PASSWORD_ERROR".localized()), @@ -438,9 +438,8 @@ class SettingsViewModel: SessionTableViewModel, NavigationItemSource, Navigatabl cancelStyle: .alert_text ) ) - }() - - self?.transitionToScreen(targetViewController, transitionType: .present) + self?.transitionToScreen(targetViewController, transitionType: .present) + } } ), SessionCell.Info(