diff --git a/Trust/Accounts/Coordinators/AccountsCoordinator.swift b/Trust/Accounts/Coordinators/AccountsCoordinator.swift index 834a39e29..decbfa383 100644 --- a/Trust/Accounts/Coordinators/AccountsCoordinator.swift +++ b/Trust/Accounts/Coordinators/AccountsCoordinator.swift @@ -68,10 +68,15 @@ class AccountsCoordinator: Coordinator { func importOrCreateWallet(entryPoint: WalletEntryPoint) { let coordinator = WalletCoordinator(keystore: keystore) + if entryPoint == .createInstantWallet { + coordinator.navigationController = navigationController + } coordinator.delegate = self addCoordinator(coordinator) - coordinator.start(entryPoint) - navigationController.present(coordinator.navigationController, animated: true, completion: nil) + let showUI = coordinator.start(entryPoint) + if showUI { + navigationController.present(coordinator.navigationController, animated: true, completion: nil) + } } func showCreateWallet() { @@ -136,9 +141,14 @@ extension AccountsCoordinator: AccountsViewControllerDelegate { extension AccountsCoordinator: WalletCoordinatorDelegate { func didFinish(with account: Wallet, in coordinator: WalletCoordinator) { delegate?.didAddAccount(account: account, in: self) - accountsViewController.fetch() - coordinator.navigationController.dismiss(animated: true, completion: nil) - removeCoordinator(coordinator) + if let delegate = delegate { + self.removeCoordinator(coordinator) + self.delegate?.didSelectAccount(account: account, in: self) + } else { + accountsViewController.fetch() + coordinator.navigationController.dismiss(animated: true, completion: nil) + self.removeCoordinator(coordinator) + } } func didFail(with error: Error, in coordinator: WalletCoordinator) { diff --git a/Trust/Wallet/Coordinators/WalletCoordinator.swift b/Trust/Wallet/Coordinators/WalletCoordinator.swift index c68bb7dd4..1ab3c33b9 100644 --- a/Trust/Wallet/Coordinators/WalletCoordinator.swift +++ b/Trust/Wallet/Coordinators/WalletCoordinator.swift @@ -11,7 +11,7 @@ protocol WalletCoordinatorDelegate: class { class WalletCoordinator: Coordinator { - let navigationController: UINavigationController + var navigationController: UINavigationController weak var delegate: WalletCoordinatorDelegate? var entryPoint: WalletEntryPoint? let keystore: Keystore @@ -26,7 +26,7 @@ class WalletCoordinator: Coordinator { self.keystore = keystore } - //Return true if proceed + ///Return true if caller should proceed to show UI (`navigationController`) func start(_ entryPoint: WalletEntryPoint) -> Bool { self.entryPoint = entryPoint switch entryPoint { @@ -42,6 +42,7 @@ class WalletCoordinator: Coordinator { navigationController.viewControllers = [controller] case .createInstantWallet: createInstantWallet() + return false case .backupWallet: if let type = keystore.recentlyUsedWallet?.type, case let .real(account) = type { guard !Config().isWalletAddresseAlreadyPromptedForBackUp(address: account.address.eip55String) else { return false } @@ -69,6 +70,7 @@ class WalletCoordinator: Coordinator { let wallet = Wallet(type: WalletType.real(account)) self.delegate?.didFinish(with: wallet, in: self) case .failure(let error): + //TODO this wouldn't work since navigationController isn't shown anymore self.navigationController.displayError(error: error) } self.navigationController.hideLoading(animated: false)