Skip to content

Commit

Permalink
Proper handling for opening transactions screen
Browse files Browse the repository at this point in the history
  • Loading branch information
vikmeup committed Mar 22, 2018
1 parent 237d211 commit 9caac8c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
12 changes: 12 additions & 0 deletions Trust/Extensions/UINavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@ extension UINavigationController {
navigationBar.tintAdjustmentMode = .normal
navigationBar.tintAdjustmentMode = .automatic
}

@discardableResult
static func openFormSheet(for controller: UIViewController, in navigationController: UINavigationController) -> UIViewController {
if UIDevice.current.userInterfaceIdiom == .pad {
let nav = UINavigationController(rootViewController: controller)
nav.modalPresentationStyle = .formSheet
navigationController.present(nav, animated: true, completion: nil)
} else {
navigationController.pushViewController(controller, animated: true)
}
return controller
}
}
7 changes: 6 additions & 1 deletion Trust/Tokens/Coordinators/TokensCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ extension TokensCoordinator: TokenViewControllerDelegate {
}

func didPress(transaction: Transaction, in controller: UIViewController) {
TransactionCoordinator.openTransaction(transaction, in: navigationController, session: session)
let controller = TransactionViewController(
session: session,
transaction: transaction
)
controller.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(dismiss))
UINavigationController.openFormSheet(for: controller, in: navigationController)
}
}
26 changes: 6 additions & 20 deletions Trust/Transactions/Coordinators/TransactionCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,6 @@ class TransactionCoordinator: Coordinator {
return controller
}

static func openTransaction(
_ transaction: Transaction,
in navigationController: UINavigationController,
session: WalletSession
) {
let controller = TransactionViewController(
session: session,
transaction: transaction
)
if UIDevice.current.userInterfaceIdiom == .pad {
let nav = UINavigationController(rootViewController: controller)
nav.modalPresentationStyle = .formSheet
controller.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(dismiss))
navigationController.present(nav, animated: true, completion: nil)
} else {
navigationController.pushViewController(controller, animated: true)
}
}

@objc func dismiss() {
navigationController.dismiss(animated: true, completion: nil)
}
Expand Down Expand Up @@ -128,7 +109,12 @@ extension TransactionCoordinator: TransactionsViewControllerDelegate {
}

func didPressTransaction(transaction: Transaction, in viewController: TransactionsViewController) {
TransactionCoordinator.openTransaction(transaction, in: navigationController, session: session)
let controller = TransactionViewController(
session: session,
transaction: transaction
)
controller.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(dismiss))
UINavigationController.openFormSheet(for: controller, in: navigationController)
}

func didPressDeposit(for account: Wallet, sender: UIView, in viewController: TransactionsViewController) {
Expand Down

0 comments on commit 9caac8c

Please sign in to comment.