|
|
@ -43,6 +43,8 @@ class AppCoordinator: NSObject, Coordinator { |
|
|
|
return coordinators.first { $0 is InCoordinator } as? InCoordinator |
|
|
|
return coordinators.first { $0 is InCoordinator } as? InCoordinator |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var pendingInCoordinator: InCoordinator? |
|
|
|
|
|
|
|
|
|
|
|
private lazy var accountsCoordinator: AccountsCoordinator = { |
|
|
|
private lazy var accountsCoordinator: AccountsCoordinator = { |
|
|
|
let coordinator = AccountsCoordinator( |
|
|
|
let coordinator = AccountsCoordinator( |
|
|
|
config: config, |
|
|
|
config: config, |
|
|
@ -126,7 +128,7 @@ class AppCoordinator: NSObject, Coordinator { |
|
|
|
migrateToStoringRawPrivateKeysInKeychain() |
|
|
|
migrateToStoringRawPrivateKeysInKeychain() |
|
|
|
|
|
|
|
|
|
|
|
if keystore.hasWallets { |
|
|
|
if keystore.hasWallets { |
|
|
|
showTransactions(wallet: keystore.currentWallet, animated: false) |
|
|
|
showTransactions(for: keystore.currentWallet, animated: false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
showInitialWalletCoordinator() |
|
|
|
showInitialWalletCoordinator() |
|
|
|
} |
|
|
|
} |
|
|
@ -166,7 +168,7 @@ class AppCoordinator: NSObject, Coordinator { |
|
|
|
coordinator.start() |
|
|
|
coordinator.start() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@discardableResult func _showTransactions(for wallet: Wallet, animated: Bool) -> InCoordinator { |
|
|
|
@discardableResult func showTransactions(for wallet: Wallet, animated: Bool) -> InCoordinator { |
|
|
|
if let coordinator = initialWalletCreationCoordinator { |
|
|
|
if let coordinator = initialWalletCreationCoordinator { |
|
|
|
removeCoordinator(coordinator) |
|
|
|
removeCoordinator(coordinator) |
|
|
|
} |
|
|
|
} |
|
|
@ -187,8 +189,9 @@ class AppCoordinator: NSObject, Coordinator { |
|
|
|
config: config, |
|
|
|
config: config, |
|
|
|
appTracker: appTracker, |
|
|
|
appTracker: appTracker, |
|
|
|
analyticsCoordinator: analyticsService, |
|
|
|
analyticsCoordinator: analyticsService, |
|
|
|
urlSchemeCoordinator: urlSchemeCoordinator, |
|
|
|
urlSchemeCoordinator: urlSchemeCoordinator, |
|
|
|
promptBackupCoordinator: promptBackupCoordinator |
|
|
|
promptBackupCoordinator: promptBackupCoordinator, |
|
|
|
|
|
|
|
accountsCoordinator: accountsCoordinator |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
coordinator.delegate = self |
|
|
|
coordinator.delegate = self |
|
|
@ -205,25 +208,8 @@ class AppCoordinator: NSObject, Coordinator { |
|
|
|
if let coordinator = inCoordinator { |
|
|
|
if let coordinator = inCoordinator { |
|
|
|
return coordinator |
|
|
|
return coordinator |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return showTransactions(wallet: keystore.currentWallet, animated: false) |
|
|
|
return showTransactions(for: keystore.currentWallet, animated: false) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//NOTE: Not sure how to call it right, rename with more appropriate name. |
|
|
|
|
|
|
|
private enum AccountsStartPoint { |
|
|
|
|
|
|
|
case withAccountsPresentation |
|
|
|
|
|
|
|
case skipAccounts |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@discardableResult private func showTransactions(wallet: Wallet, animated: Bool, accountsStartPoint: AccountsStartPoint = .withAccountsPresentation) -> InCoordinator { |
|
|
|
|
|
|
|
switch accountsStartPoint { |
|
|
|
|
|
|
|
case .withAccountsPresentation: |
|
|
|
|
|
|
|
accountsCoordinator.start() |
|
|
|
|
|
|
|
case .skipAccounts: |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return _showTransactions(for: wallet, animated: animated) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func initializers() { |
|
|
|
private func initializers() { |
|
|
@ -338,10 +324,10 @@ extension AppCoordinator: InitialWalletCreationCoordinatorDelegate { |
|
|
|
|
|
|
|
|
|
|
|
removeCoordinator(coordinator) |
|
|
|
removeCoordinator(coordinator) |
|
|
|
|
|
|
|
|
|
|
|
showTransactions(wallet: keystore.currentWallet, animated: false) |
|
|
|
showTransactions(for: keystore.currentWallet, animated: false) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private var pendingInCoordinator: InCoordinator? |
|
|
|
|
|
|
|
extension AppCoordinator: InCoordinatorDelegate { |
|
|
|
extension AppCoordinator: InCoordinatorDelegate { |
|
|
|
|
|
|
|
|
|
|
|
func didRestart(in coordinator: InCoordinator, wallet: Wallet) { |
|
|
|
func didRestart(in coordinator: InCoordinator, wallet: Wallet) { |
|
|
@ -350,7 +336,7 @@ extension AppCoordinator: InCoordinatorDelegate { |
|
|
|
coordinator.navigationController.dismiss(animated: true) //??Do we really need to do it here? |
|
|
|
coordinator.navigationController.dismiss(animated: true) //??Do we really need to do it here? |
|
|
|
removeCoordinator(coordinator) |
|
|
|
removeCoordinator(coordinator) |
|
|
|
|
|
|
|
|
|
|
|
showTransactions(wallet: keystore.currentWallet, animated: false, accountsStartPoint: .skipAccounts) |
|
|
|
showTransactions(for: keystore.currentWallet, animated: false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func didShowWallets(in coordinator: InCoordinator) { |
|
|
|
func didShowWallets(in coordinator: InCoordinator) { |
|
|
@ -467,7 +453,7 @@ extension AppCoordinator: UrlSchemeCoordinatorDelegate { |
|
|
|
extension AppCoordinator: AccountsCoordinatorDelegate { |
|
|
|
extension AppCoordinator: AccountsCoordinatorDelegate { |
|
|
|
|
|
|
|
|
|
|
|
func didAddAccount(account: Wallet, in coordinator: AccountsCoordinator) { |
|
|
|
func didAddAccount(account: Wallet, in coordinator: AccountsCoordinator) { |
|
|
|
//no-op |
|
|
|
coordinator.navigationController.dismiss(animated: true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func didDeleteAccount(account: Wallet, in coordinator: AccountsCoordinator) { |
|
|
|
func didDeleteAccount(account: Wallet, in coordinator: AccountsCoordinator) { |
|
|
@ -475,18 +461,19 @@ extension AppCoordinator: AccountsCoordinatorDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func didCancel(in coordinator: AccountsCoordinator) { |
|
|
|
func didCancel(in coordinator: AccountsCoordinator) { |
|
|
|
//no-op |
|
|
|
coordinator.navigationController.dismiss(animated: true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func didSelectAccount(account: Wallet, in coordinator: AccountsCoordinator) { |
|
|
|
func didSelectAccount(account: Wallet, in coordinator: AccountsCoordinator) { |
|
|
|
//NOTE: Push existing view controller to the app navigations stack |
|
|
|
//NOTE: Push existing view controller to the app navigation stack |
|
|
|
if let pendingCoordinator = pendingInCoordinator, keystore.currentWallet == account { |
|
|
|
if let pendingCoordinator = pendingInCoordinator, keystore.currentWallet == account { |
|
|
|
addCoordinator(coordinator) |
|
|
|
addCoordinator(coordinator) |
|
|
|
|
|
|
|
|
|
|
|
navigationController.pushViewController(pendingCoordinator.tabBarController, animated: true) |
|
|
|
pendingCoordinator.showTabBar(animated: true) |
|
|
|
navigationController.setNavigationBarHidden(true, animated: true) |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
showTransactions(wallet: account, animated: true, accountsStartPoint: .skipAccounts) |
|
|
|
showTransactions(for: account, animated: true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pendingInCoordinator = .none |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|