Remove lazy loading for settings coordinator

Adding extra tests
pull/2/head
Michael Scoff 7 years ago
parent 9498569c75
commit eb22260b44
  1. 21
      Trust/Transactions/Coordinators/TransactionCoordinator.swift
  2. 4
      TrustTests/Coordinators/TransactionCoordinatorTests.swift

@ -14,9 +14,8 @@ class TransactionCoordinator: Coordinator {
private let keystore: Keystore
let storage: TransactionsStorage
lazy var rootViewController: TransactionsViewController = {
let controller = self.makeTransactionsController(with: self.session.account)
return controller
lazy var transactionsViewController: TransactionsViewController = {
return self.makeTransactionsController(with: self.session.account)
}()
lazy var dataCoordinator: TransactionDataCoordinator = {
@ -29,10 +28,6 @@ class TransactionCoordinator: Coordinator {
weak var delegate: TransactionCoordinatorDelegate?
lazy var settingsCoordinator: SettingsCoordinator = {
return SettingsCoordinator()
}()
let session: WalletSession
let navigationController: UINavigationController
var coordinators: [Coordinator] = []
@ -63,9 +58,11 @@ class TransactionCoordinator: Coordinator {
}
@objc func showSettings() {
settingsCoordinator.start()
settingsCoordinator.delegate = self
navigationController.present(settingsCoordinator.navigationController, animated: true, completion: nil)
let coordinator = SettingsCoordinator()
coordinator.start()
coordinator.delegate = self
addCoordinator(coordinator)
navigationController.present(coordinator.navigationController, animated: true, completion: nil)
}
func showTokens(for account: Account) {
@ -111,7 +108,7 @@ class TransactionCoordinator: Coordinator {
}
@objc func didEnterForeground() {
rootViewController.fetch()
transactionsViewController.fetch()
}
@objc func dismiss() {
@ -143,6 +140,7 @@ class TransactionCoordinator: Coordinator {
extension TransactionCoordinator: SettingsCoordinatorDelegate {
func didUpdate(action: SettingsAction, in coordinator: SettingsCoordinator) {
removeCoordinator(coordinator)
switch action {
case .RPCServer:
restart(for: session.account)
@ -156,6 +154,7 @@ extension TransactionCoordinator: SettingsCoordinatorDelegate {
}
func didCancel(in coordinator: SettingsCoordinator) {
removeCoordinator(coordinator)
coordinator.navigationController.dismiss(animated: true, completion: nil)
}
}

@ -26,6 +26,7 @@ class TransactionCoordinatorTests: XCTestCase {
coordinator.showSettings()
XCTAssertTrue(coordinator.coordinators.first is SettingsCoordinator)
XCTAssertTrue((coordinator.navigationController.presentedViewController as? UINavigationController)?.viewControllers[0] is SettingsViewController)
}
@ -40,6 +41,7 @@ class TransactionCoordinatorTests: XCTestCase {
let controller = (coordinator.navigationController.presentedViewController as? UINavigationController)?.viewControllers[0]
XCTAssertTrue(coordinator.coordinators.first is PaymentCoordinator)
XCTAssertTrue(controller is SendViewController)
}
@ -54,6 +56,7 @@ class TransactionCoordinatorTests: XCTestCase {
let controller = (coordinator.navigationController.presentedViewController as? UINavigationController)?.viewControllers[0]
XCTAssertTrue(coordinator.coordinators.first is PaymentCoordinator)
XCTAssertTrue(controller is RequestViewController)
}
@ -66,6 +69,7 @@ class TransactionCoordinatorTests: XCTestCase {
coordinator.showAccounts()
XCTAssertTrue(coordinator.coordinators.first is AccountsCoordinator)
XCTAssertTrue((coordinator.navigationController.presentedViewController as? UINavigationController)?.viewControllers[0] is AccountsViewController)
}
}

Loading…
Cancel
Save