An advanced Ethereum/EVM mobile wallet
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
alpha-wallet-ios/Trust/Transfer/Coordinators/RequestCoordinator.swift

58 lines
2.1 KiB

// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import UIKit
protocol RequestCoordinatorDelegate: class {
func didCancel(in coordinator: RequestCoordinator)
}
class RequestCoordinator: Coordinator {
let session: WalletSession
let navigationController: UINavigationController
var coordinators: [Coordinator] = []
weak var delegate: RequestCoordinatorDelegate?
lazy var requestViewController: RequestViewController = {
return self.makeRequestViewController()
}()
private lazy var viewModel: RequestViewModel = {
return .init(account: session.account, config: session.config)
}()
init(
navigationController: UINavigationController = UINavigationController(),
session: WalletSession
) {
self.navigationController = navigationController
self.navigationController.modalPresentationStyle = .formSheet
self.session = session
}
func start() {
navigationController.viewControllers = [requestViewController]
}
func makeRequestViewController() -> RequestViewController {
let controller = RequestViewController(viewModel: viewModel)
controller.navigationItem.titleView = BalanceTitleView.make(from: self.session, .ether(destination: .none))
controller.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(dismiss))
controller.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(share(_:)))
return controller
}
@objc func share(_ sender: UIBarButtonItem) {
let activityViewController = UIActivityViewController(
activityItems: [
viewModel.shareMyAddressText,
],
applicationActivities: nil
)
activityViewController.popoverPresentationController?.barButtonItem = sender
navigationController.present(activityViewController, animated: true, completion: nil)
}
@objc func dismiss() {
delegate?.didCancel(in: self)
}
}