fix wallet presentation

pull/2790/head
Vladyslav shepitko 3 years ago
parent 5fde504bcb
commit 50d9cff3fa
  1. 49
      AlphaWallet/AppCoordinator.swift
  2. 13
      AlphaWallet/InCoordinator.swift

@ -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
} }
} }

@ -138,6 +138,7 @@ class InCoordinator: NSObject, Coordinator {
tabBarController.tabBar.isTranslucent = false tabBarController.tabBar.isTranslucent = false
return tabBarController return tabBarController
}() }()
private let accountsCoordinator: AccountsCoordinator
init( init(
navigationController: UINavigationController = UINavigationController(), navigationController: UINavigationController = UINavigationController(),
@ -148,7 +149,8 @@ class InCoordinator: NSObject, Coordinator {
appTracker: AppTracker = AppTracker(), appTracker: AppTracker = AppTracker(),
analyticsCoordinator: AnalyticsCoordinator, analyticsCoordinator: AnalyticsCoordinator,
urlSchemeCoordinator: UrlSchemeCoordinatorType, urlSchemeCoordinator: UrlSchemeCoordinatorType,
promptBackupCoordinator: PromptBackupCoordinator promptBackupCoordinator: PromptBackupCoordinator,
accountsCoordinator: AccountsCoordinator
) { ) {
self.navigationController = navigationController self.navigationController = navigationController
self.wallet = wallet self.wallet = wallet
@ -159,6 +161,7 @@ class InCoordinator: NSObject, Coordinator {
self.assetDefinitionStore = assetDefinitionStore self.assetDefinitionStore = assetDefinitionStore
self.urlSchemeCoordinator = urlSchemeCoordinator self.urlSchemeCoordinator = urlSchemeCoordinator
self.promptBackupCoordinator = promptBackupCoordinator self.promptBackupCoordinator = promptBackupCoordinator
self.accountsCoordinator = accountsCoordinator
//Disabled for now. Refer to function's comment //Disabled for now. Refer to function's comment
//self.assetDefinitionStore.enableFetchXMLForContractInPasteboard() //self.assetDefinitionStore.enableFetchXMLForContractInPasteboard()
@ -166,7 +169,7 @@ class InCoordinator: NSObject, Coordinator {
} }
deinit { deinit {
XMLHandler.callForAssetAttributeCoordinators = nil // XMLHandler.callForAssetAttributeCoordinators = nil
//NOTE: Clear all smart contract calls //NOTE: Clear all smart contract calls
clearSmartContractCallsCache() clearSmartContractCallsCache()
} }
@ -414,7 +417,13 @@ class InCoordinator: NSObject, Coordinator {
setupTabBarController() setupTabBarController()
showTabBar(animated: animated)
}
func showTabBar(animated: Bool) {
navigationController.setViewControllers([accountsCoordinator.accountsViewController], animated: false)
navigationController.pushViewController(tabBarController, animated: animated) navigationController.pushViewController(tabBarController, animated: animated)
navigationController.setNavigationBarHidden(true, animated: true) navigationController.setNavigationBarHidden(true, animated: true)
let inCoordinatorViewModel = InCoordinatorViewModel() let inCoordinatorViewModel = InCoordinatorViewModel()

Loading…
Cancel
Save