Merge pull request #654 from alpha-wallet/open-all-urls-in-dapp-browser

Open all remote URLs in a new dapp browser instance
pull/666/head
James Sangalli 6 years ago committed by GitHub
commit bbd0f7ad28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      AlphaWallet.xcodeproj/project.pbxproj
  2. 4
      AlphaWallet/AlphaWalletHelp/ViewControllers/HelpContentsViewController.swift
  3. 36
      AlphaWallet/AlphaWalletHelp/ViewControllers/HelpViewController.swift
  4. 12
      AlphaWallet/AppCoordinator.swift
  5. 15
      AlphaWallet/AppDelegate.swift
  6. 8
      AlphaWallet/Browser/Coordinators/BrowserCoordinator.swift
  7. 1
      AlphaWallet/Browser/Types/BrowserAction.swift
  8. 2
      AlphaWallet/Browser/ViewControllers/BrowserViewController.swift
  9. 11
      AlphaWallet/Browser/ViewControllers/MasterBrowserViewController.swift
  10. 12
      AlphaWallet/Browser/Views/BrowserNavigationBar.swift
  11. 9
      AlphaWallet/Core/Types/CanOpenContractWebPage.swift
  12. 14
      AlphaWallet/Deposit/Coordinators/DepositCoordinator.swift
  13. 6
      AlphaWallet/Extensions/UIViewController.swift
  14. 63
      AlphaWallet/InCoordinator.swift
  15. 16
      AlphaWallet/Market/Coordinators/UniversalLinkCoordinator.swift
  16. 7
      AlphaWallet/Market/ViewControllers/ImportMagicTokenViewController.swift
  17. 5
      AlphaWallet/Redeem/ViewControllers/RedeemTokenCardQuantitySelectionViewController.swift
  18. 7
      AlphaWallet/Redeem/ViewControllers/RedeemTokenViewController.swift
  19. 26
      AlphaWallet/Redeem/ViewControllers/TokenCardRedemptionViewController.swift
  20. 5
      AlphaWallet/Sell/ViewControllers/EnterSellTokensCardPriceQuantityViewController.swift
  21. 7
      AlphaWallet/Sell/ViewControllers/SellTokensCardViewController.swift
  22. 5
      AlphaWallet/Sell/ViewControllers/SetSellTokensCardExpiryDateViewController.swift
  23. 16
      AlphaWallet/Settings/Coordinators/SettingsCoordinator.swift
  24. 23
      AlphaWallet/Settings/ViewControllers/SettingsViewController.swift
  25. 41
      AlphaWallet/Tokens/ViewControllers/StaticHTMLViewController.swift
  26. 7
      AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift
  27. 61
      AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift
  28. 33
      AlphaWallet/Transactions/Coordinators/TransactionCoordinator.swift
  29. 11
      AlphaWallet/Transactions/ViewControllers/TransactionViewController.swift
  30. 5
      AlphaWallet/Transfer/ViewControllers/ChooseTokenCardTransferModeViewController.swift
  31. 5
      AlphaWallet/Transfer/ViewControllers/SetTransferTokensCardExpiryDateViewController.swift
  32. 5
      AlphaWallet/Transfer/ViewControllers/TransferTokensCardQuantitySelectionViewController.swift
  33. 6
      AlphaWallet/Transfer/ViewControllers/TransferTokensCardViaWalletAddressViewController.swift
  34. 7
      AlphaWallet/Transfer/ViewControllers/TransferTokensCardViewController.swift
  35. 29
      AlphaWalletTests/Coordinators/DepositCoordinatorTests.swift

@ -359,6 +359,7 @@
5E7C7793AB6B577906F2BCA3 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7AFE9AF9FE6B58C925D4 /* SettingsViewController.swift */; };
5E7C77A8425E0AFAB11F1FCD /* PromptBackupCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7ADD0FBE8708A6E98AF8 /* PromptBackupCoordinator.swift */; };
5E7C77AD9FAAC18211B6F355 /* TransferTokensCardQuantitySelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7419F47CC8B2996AA8F9 /* TransferTokensCardQuantitySelectionViewController.swift */; };
5E7C77D5AD018763345D8DD5 /* CanOpenContractWebPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7D674F6B2415FB5552B0 /* CanOpenContractWebPage.swift */; };
5E7C77E844D710D7AFBC58D4 /* RequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C74DCC21272EC231A20E2 /* RequestViewController.swift */; };
5E7C7813019A111443A542CA /* TokenListFormatTableViewCellWithoutCheckbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7C781CCE43B6451671B9 /* TokenListFormatTableViewCellWithoutCheckbox.swift */; };
5E7C782410321CE6CEE68275 /* AssetDefinitionDiskBackingStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E7C7BF5551BF64D2AE8AD66 /* AssetDefinitionDiskBackingStore.swift */; };
@ -999,6 +1000,7 @@
5E7C7D46C7CABC31A7477F37 /* GenerateTransferMagicLinkViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GenerateTransferMagicLinkViewController.swift; sourceTree = "<group>"; };
5E7C7D4F7C566EDD30EF1C19 /* HowDoITransferETHIntoMyWalletInfoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HowDoITransferETHIntoMyWalletInfoViewController.swift; sourceTree = "<group>"; };
5E7C7D5F3CAE69CF932AB236 /* LockPasscodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LockPasscodeViewController.swift; sourceTree = "<group>"; };
5E7C7D674F6B2415FB5552B0 /* CanOpenContractWebPage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CanOpenContractWebPage.swift; sourceTree = "<group>"; };
5E7C7D69938F484C2A186FAE /* URLViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = URLViewModel.swift; path = Protocols/URLViewModel.swift; sourceTree = "<group>"; };
5E7C7E2486CDE31871C98FC7 /* TransferTokensCardViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransferTokensCardViewModel.swift; sourceTree = "<group>"; };
5E7C7E24936CC2190D2A16C2 /* OnboardingPageViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingPageViewModel.swift; sourceTree = "<group>"; };
@ -2204,6 +2206,7 @@
children = (
29E9CFD11FE737FE00017744 /* TrustRealmConfiguration.swift */,
29F1C85720036926003780D8 /* AppTracker.swift */,
5E7C7D674F6B2415FB5552B0 /* CanOpenContractWebPage.swift */,
);
path = Types;
sourceTree = "<group>";
@ -3878,6 +3881,7 @@
5E7C7EC725C711F5EA12CB1C /* History.swift in Sources */,
5E7C7226D3B95E63ED9EDD33 /* FetchAssetDefinitionsCoordinator.swift in Sources */,
5E7C767C9166726E96ED4C07 /* DelegateContract.swift in Sources */,
5E7C77D5AD018763345D8DD5 /* CanOpenContractWebPage.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -5,8 +5,8 @@ import UIKit
class HelpContentsViewController: StaticHTMLViewController {
let banner = ContactUsBannerView()
override init() {
super.init()
override init(delegate: StaticHTMLViewControllerDelegate?) {
super.init(delegate: delegate)
banner.delegate = self
banner.translatesAutoresizingMaskIntoConstraints = false

@ -2,18 +2,23 @@
import UIKit
protocol HelpViewControllerDelegate: class, CanOpenURL {
}
class HelpViewController: UIViewController {
let tableView = UITableView()
let banner = ContactUsBannerView()
let rows: [(title: String, controller: UIViewController)] = [
(title: R.string.localizable.aHelpContentsWhatIsETH(), controller: WhatIsEthereumInfoViewController()),
(title: R.string.localizable.aHelpContentsHowDoIGetMyMoney(), controller: HowDoIGetMyMoneyInfoViewController()),
(title: R.string.localizable.aHelpContentsHowDoITransferETHIntoMyWallet(), controller: HowDoITransferETHIntoMyWalletInfoViewController()),
(title: R.string.localizable.aHelpContentsPrivacyPolicy(), controller: PrivacyPolicyViewController()),
(title: R.string.localizable.aHelpContentsTermsOfService(), controller: TermsOfServiceViewController()),
lazy var rows: [(title: String, controller: UIViewController)] = [
(title: R.string.localizable.aHelpContentsWhatIsETH(), controller: WhatIsEthereumInfoViewController(delegate: self)),
(title: R.string.localizable.aHelpContentsHowDoIGetMyMoney(), controller: HowDoIGetMyMoneyInfoViewController(delegate: self)),
(title: R.string.localizable.aHelpContentsHowDoITransferETHIntoMyWallet(), controller: HowDoITransferETHIntoMyWalletInfoViewController(delegate: self)),
(title: R.string.localizable.aHelpContentsPrivacyPolicy(), controller: PrivacyPolicyViewController(delegate: self)),
(title: R.string.localizable.aHelpContentsTermsOfService(), controller: TermsOfServiceViewController(delegate: self)),
]
weak var delegate: HelpViewControllerDelegate?
init() {
init(delegate: HelpViewControllerDelegate?) {
self.delegate = delegate
super.init(nibName: nil, bundle: nil)
title = R.string.localizable.aHelpNavigationTitle()
@ -86,3 +91,20 @@ extension HelpViewController: ContactUsBannerViewDelegate {
present(viewController, animated: true, completion: nil)
}
}
extension HelpViewController: StaticHTMLViewControllerDelegate {
}
extension HelpViewController: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}

@ -142,6 +142,18 @@ class AppCoordinator: NSObject, Coordinator {
func createInitialWallet() {
WalletCoordinator(keystore: keystore).createInitialWallet()
}
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
inCoordinator?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
inCoordinator?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
inCoordinator?.didPressOpenWebPage(url, in: viewController)
}
}
//Disable creating and importing wallets from welcome screen

@ -114,6 +114,21 @@ extension AppDelegate: UniversalLinkCoordinatorDelegate {
}
}
//TODO remove this once AppDelegate no longer implements UniversalLinkCoordinatorDelegate. i.e. when we move UniversalLinkCoordinator management into InCoordinator
extension AppDelegate: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
appCoordinator.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
appCoordinator.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
appCoordinator.didPressOpenWebPage(url, in: viewController)
}
}
extension AppDelegate: UniversalLinkInPasteboardCoordinatorDelegate {
func importUniversalLink(url: URL, for coordinator: UniversalLinkInPasteboardCoordinator) {
guard universalLinkCoordinator == nil else { return }

@ -9,6 +9,7 @@ import WebKit
protocol BrowserCoordinatorDelegate: class {
func didSentTransaction(transaction: SentTransaction, in coordinator: BrowserCoordinator)
func didPressCloseButton(in coordinator: BrowserCoordinator)
}
final class BrowserCoordinator: NSObject, Coordinator {
@ -247,6 +248,8 @@ extension BrowserCoordinator: BrowserViewControllerDelegate {
enableToolbar = true
rootViewController.select(viewType: .browser)
rootViewController.browserViewController.goHome()
case .close:
delegate?.didPressCloseButton(in: self)
case .more(let sender):
presentMoreOptions(sender: sender)
case .enter(let string):
@ -254,8 +257,9 @@ extension BrowserCoordinator: BrowserViewControllerDelegate {
openURL(url)
case .goBack:
rootViewController.browserViewController.webView.goBack()
default: break
}
case .beginEditing:
break
}
case .changeURL(let url):
handleToolbar(for: url)
}

@ -6,6 +6,7 @@ import UIKit
enum BrowserNavigation {
case goBack
case more(sender: UIView)
case close
case home
case enter(String)
case beginEditing

@ -253,6 +253,8 @@ extension BrowserViewController: BrowserNavigationBarDelegate {
break
case .more:
break
case .close:
stopLoading()
case .home:
break
case .enter:

@ -66,6 +66,17 @@ final class MasterBrowserViewController: UIViewController {
setupView()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navigationController = navigationController, navigationController.isBeingPresented {
browserViewController.browserNavBar?.closeButton.isHidden = false
} else if isBeingPresented {
browserViewController.browserNavBar?.closeButton.isHidden = false
} else {
browserViewController.browserNavBar?.closeButton.isHidden = true
}
}
func select(viewType: BookmarksViewType) {
segmentController.selectedSegmentIndex = viewType.rawValue
updateView()

@ -10,6 +10,7 @@ final class BrowserNavigationBar: UINavigationBar {
let textField = UITextField()
let moreButton = UIButton()
let closeButton = UIButton()
let homeButton = UIButton()
let backButton = UIButton()
weak var browserDelegate: BrowserNavigationBarDelegate?
@ -44,6 +45,12 @@ final class BrowserNavigationBar: UINavigationBar {
moreButton.setImage(R.image.toolbarMenu(), for: .normal)
moreButton.addTarget(self, action: #selector(moreAction(_:)), for: .touchUpInside)
closeButton.translatesAutoresizingMaskIntoConstraints = false
closeButton.isHidden = true
closeButton.setTitle(R.string.localizable.done(), for: .normal)
closeButton.addTarget(self, action: #selector(closeAction(_:)), for: .touchUpInside)
closeButton.setContentCompressionResistancePriority(.required, for: .horizontal)
homeButton.translatesAutoresizingMaskIntoConstraints = false
homeButton.setImage(R.image.browserHome()?.withRenderingMode(.alwaysTemplate), for: .normal)
homeButton.addTarget(self, action: #selector(homeAction(_:)), for: .touchUpInside)
@ -53,6 +60,7 @@ final class BrowserNavigationBar: UINavigationBar {
backButton.addTarget(self, action: #selector(goBackAction), for: .touchUpInside)
let stackView = UIStackView(arrangedSubviews: [
closeButton,
homeButton,
.spacerWidth(),
backButton,
@ -91,6 +99,10 @@ final class BrowserNavigationBar: UINavigationBar {
browserDelegate?.did(action: .home)
}
@objc private func closeAction(_ sender: UIView) {
browserDelegate?.did(action: .close)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

@ -0,0 +1,9 @@
//Copyright © 2018 Stormbird PTE. LTD.
import UIKit
protocol CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController)
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController)
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController)
}

@ -4,18 +4,24 @@ import Foundation
import TrustKeystore
import UIKit
protocol DepositCoordinatorDelegate: class, CanOpenURL {
}
class DepositCoordinator: Coordinator {
let navigationController: UINavigationController
let account: Wallet
var coordinators: [Coordinator] = []
weak var delegate: DepositCoordinatorDelegate?
init(
navigationController: UINavigationController,
account: Wallet
account: Wallet,
delegate: DepositCoordinatorDelegate?
) {
self.navigationController = navigationController
self.account = account
self.delegate = delegate
}
func start(from barButtonItem: UIBarButtonItem? = .none) {
@ -63,20 +69,20 @@ class DepositCoordinator: Coordinator {
let widget = CoinbaseBuyWidget(
address: account.address.description
)
navigationController.openURL(widget.url)
delegate?.didPressOpenWebPage(widget.url, in: navigationController)
}
func showShapeShift() {
let widget = ShapeShiftBuyWidget(
address: account.address.description
)
navigationController.openURL(widget.url)
delegate?.didPressOpenWebPage(widget.url, in: navigationController)
}
func showChangelly() {
let widget = ChangellyBuyWidget(
address: account.address.description
)
navigationController.openURL(widget.url)
delegate?.didPressOpenWebPage(widget.url, in: navigationController)
}
}

@ -63,12 +63,6 @@ extension UIViewController {
MBProgressHUD.hide(for: view, animated: animated)
}
func openURL(_ url: URL) {
let controller = SFSafariViewController(url: url)
// Don't attempt to change tint colors for SFSafariViewController. It doesn't well correctly especially because the controller sets more than 1 color for the title
present(controller, animated: true, completion: nil)
}
public var isVisible: Bool {
if isViewLoaded {
return view.window != nil

@ -444,21 +444,62 @@ extension InCoordinator: TokensCardCoordinatorDelegate {
}
func didPressViewRedemptionInfo(in viewController: UIViewController) {
let controller = TokenCardRedemptionInfoViewController()
let controller = TokenCardRedemptionInfoViewController(delegate: self)
viewController.navigationController?.pushViewController(controller, animated: true)
}
func didPressViewContractWebPage(for token: TokenObject, in viewController: UIViewController) {
let url = config.server.etherscanContractDetailsWebPageURL(for: token.contract)
viewController.openURL(url)
}
func didPressViewEthereumInfo(in viewController: UIViewController) {
let controller = WhatIsEthereumInfoViewController()
let controller = WhatIsEthereumInfoViewController(delegate: self)
viewController.navigationController?.pushViewController(controller, animated: true)
}
}
extension InCoordinator: CanOpenURL {
private func open(url: URL, in viewController: UIViewController) {
guard let account = keystore.recentlyUsedWallet else { return }
//TODO duplication of code to set up a BrowserCoordinator when creating the application's tabbar
let migration = MigrationInitializer(account: keystore.recentlyUsedWallet!, chainID: config.chainID)
migration.perform()
let web3 = self.web3()
web3.start()
let realm = self.realm(for: migration.config)
let tokensStorage = TokensDataStore(realm: realm, account: account, config: config, web3: web3, assetDefinitionStore: assetDefinitionStore)
let balanceCoordinator = GetBalanceCoordinator(config: config)
let balance = BalanceCoordinator(wallet: account, config: config, storage: tokensStorage)
let session = WalletSession(
account: account,
config: config,
web3: web3,
balanceCoordinator: balance
)
let browserCoordinator = BrowserCoordinator(session: session, keystore: keystore, sharedRealm: realm)
browserCoordinator.delegate = self
browserCoordinator.start()
addCoordinator(browserCoordinator)
let controller = browserCoordinator.navigationController
browserCoordinator.openURL(url)
viewController.present(controller, animated: true, completion: nil)
}
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
let url = config.server.etherscanContractDetailsWebPageURL(for: contract)
open(url: url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
open(url: url, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
open(url: url, in: viewController)
}
}
extension InCoordinator: TransactionCoordinatorDelegate {
func didPress(for type: PaymentFlow, in coordinator: TransactionCoordinator) {
showPaymentFlow(for: type)
@ -654,6 +695,11 @@ extension InCoordinator: BrowserCoordinatorDelegate {
func didSentTransaction(transaction: SentTransaction, in coordinator: BrowserCoordinator) {
handlePendingTransaction(transaction: transaction)
}
func didPressCloseButton(in coordinator: BrowserCoordinator) {
coordinator.navigationController.dismiss(animated: true)
removeCoordinator(coordinator)
}
}
struct NoTokenError: LocalizedError {
@ -661,3 +707,6 @@ struct NoTokenError: LocalizedError {
return R.string.localizable.aWalletNoTokens()
}
}
extension InCoordinator: StaticHTMLViewControllerDelegate {
}

@ -7,7 +7,7 @@ import Realm
import TrustKeystore
import web3swift
protocol UniversalLinkCoordinatorDelegate: class {
protocol UniversalLinkCoordinatorDelegate: class, CanOpenURL {
func viewControllerForPresenting(in coordinator: UniversalLinkCoordinator) -> UIViewController?
func completed(in coordinator: UniversalLinkCoordinator)
func importPaidSignedOrder(signedOrder: SignedOrder, tokenObject: TokenObject, completion: @escaping (Bool) -> Void)
@ -396,6 +396,20 @@ extension UniversalLinkCoordinator: ImportMagicTokenViewControllerDelegate {
}
}
extension UniversalLinkCoordinator: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}
extension UniversalLinkCoordinator: PromptBackupCoordinatorDelegate {
func viewControllerForPresenting(in coordinator: PromptBackupCoordinator) -> UIViewController? {
return delegate?.viewControllerForPresenting(in: self)

@ -3,7 +3,7 @@
import UIKit
import Alamofire
protocol ImportMagicTokenViewControllerDelegate: class {
protocol ImportMagicTokenViewControllerDelegate: class, CanOpenURL {
func didPressDone(in viewController: ImportMagicTokenViewController)
func didPressImport(in viewController: ImportMagicTokenViewController)
}
@ -270,11 +270,10 @@ class ImportMagicTokenViewController: UIViewController, OptionalTokenVerifiableS
func showContractWebPage() {
if case .main = config.server {
guard let url = url else { return }
openURL(url)
delegate?.didPressViewContractWebPage(url, in: self)
} else {
guard let contract = contract else { return }
let url = config.server.etherscanContractDetailsWebPageURL(for: contract)
openURL(url)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
}

@ -8,10 +8,9 @@
import UIKit
protocol RedeemTokenCardQuantitySelectionViewControllerDelegate: class {
protocol RedeemTokenCardQuantitySelectionViewControllerDelegate: class, CanOpenURL {
func didSelectQuantity(token: TokenObject, ticketHolder: TokenHolder, in viewController: RedeemTokenCardQuantitySelectionViewController)
func didPressViewInfo(in viewController: RedeemTokenCardQuantitySelectionViewController)
func didPressViewContractWebPage(in viewController: RedeemTokenCardQuantitySelectionViewController)
}
class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVerifiableStatusViewController {
@ -133,7 +132,7 @@ class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVer
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
func configure(viewModel newViewModel: RedeemTokenCardQuantitySelectionViewModel? = nil) {

@ -8,10 +8,9 @@
import UIKit
protocol RedeemTokenViewControllerDelegate: class {
protocol RedeemTokenViewControllerDelegate: class, CanOpenURL {
func didSelectTicketHolder(token: TokenObject, ticketHolder: TokenHolder, in viewController: RedeemTokenViewController)
func didPressViewInfo(in viewController: RedeemTokenViewController)
func didPressViewContractWebPage(in viewController: RedeemTokenViewController)
func didTapURL(url: URL, in viewController: RedeemTokenViewController)
}
@ -124,7 +123,7 @@ class RedeemTokenViewController: UIViewController, TokenVerifiableStatusViewCont
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
private func animateRowHeightChanges(for indexPaths: [IndexPath], in tableview: UITableView) {
@ -165,6 +164,6 @@ extension RedeemTokenViewController: UITableViewDelegate, UITableViewDataSource
extension RedeemTokenViewController: BaseTokenListFormatTableViewCellDelegate {
func didTapURL(url: URL) {
delegate?.didTapURL(url: url, in: self)
delegate?.didPressOpenWebPage(url, in: self)
}
}

@ -8,6 +8,9 @@
import UIKit
protocol TokenCardRedemptionViewControllerDelegate: class, CanOpenURL {
}
class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatusViewController {
let config: Config
@ -22,6 +25,7 @@ class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatus
var session: WalletSession
private let token: TokenObject
let redeemListener = RedeemEventListener()
weak var delegate: TokenCardRedemptionViewControllerDelegate?
init(config: Config, session: WalletSession, token: TokenObject, viewModel: TokenCardRedemptionViewModel) {
self.config = config
@ -123,13 +127,12 @@ class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatus
}
func showInfo() {
let controller = TokenCardRedemptionInfoViewController()
let controller = TokenCardRedemptionInfoViewController(delegate: self)
navigationController?.pushViewController(controller, animated: true)
}
func showContractWebPage() {
let url = session.config.server.etherscanContractDetailsWebPageURL(for: viewModel.token.contract)
openURL(url)
delegate?.didPressViewContractWebPage(forContract: viewModel.token.contract, in: self)
}
private func showSuccessMessage() {
@ -175,3 +178,20 @@ class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatus
ticketView.stateLabel.isHidden = true
}
}
extension TokenCardRedemptionViewController: StaticHTMLViewControllerDelegate {
}
extension TokenCardRedemptionViewController: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}

@ -3,10 +3,9 @@
import UIKit
import BigInt
protocol EnterSellTokensCardPriceQuantityViewControllerDelegate: class {
protocol EnterSellTokensCardPriceQuantityViewControllerDelegate: class, CanOpenURL {
func didEnterSellTicketsPriceQuantity(token: TokenObject, ticketHolder: TokenHolder, ethCost: Ether, in viewController: EnterSellTokensCardPriceQuantityViewController)
func didPressViewInfo(in viewController: EnterSellTokensCardPriceQuantityViewController)
func didPressViewContractWebPage(in viewController: EnterSellTokensCardPriceQuantityViewController)
}
class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVerifiableStatusViewController {
@ -268,7 +267,7 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
func configure(viewModel newViewModel: EnterSellTokensCardPriceQuantityViewControllerViewModel? = nil) {

@ -2,10 +2,9 @@
import UIKit
protocol SellTokensCardViewControllerDelegate: class {
protocol SellTokensCardViewControllerDelegate: class, CanOpenURL {
func didSelectTicketHolder(ticketHolder: TokenHolder, in viewController: SellTokensCardViewController)
func didPressViewInfo(in viewController: SellTokensCardViewController)
func didPressViewContractWebPage(in viewController: SellTokensCardViewController)
func didTapURL(url: URL, in viewController: SellTokensCardViewController)
}
@ -118,7 +117,7 @@ class SellTokensCardViewController: UIViewController, TokenVerifiableStatusViewC
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
private func animateRowHeightChanges(for indexPaths: [IndexPath], in tableview: UITableView) {
@ -159,6 +158,6 @@ extension SellTokensCardViewController: UITableViewDelegate, UITableViewDataSour
extension SellTokensCardViewController: BaseTokenListFormatTableViewCellDelegate {
func didTapURL(url: URL) {
delegate?.didTapURL(url: url, in: self)
delegate?.didPressOpenWebPage(url, in: self)
}
}

@ -2,10 +2,9 @@
import UIKit
protocol SetSellTokensCardExpiryDateViewControllerDelegate: class {
protocol SetSellTokensCardExpiryDateViewControllerDelegate: class, CanOpenURL {
func didSetSellTicketsExpiryDate(ticketHolder: TokenHolder, linkExpiryDate: Date, ethCost: Ether, in viewController: SetSellTokensCardExpiryDateViewController)
func didPressViewInfo(in viewController: SetSellTokensCardExpiryDateViewController)
func didPressViewContractWebPage(in viewController: SetSellTokensCardExpiryDateViewController)
}
class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiableStatusViewController {
@ -255,7 +254,7 @@ class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiab
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
func configure(viewModel newViewModel: SetSellTokensCardExpiryDateViewControllerViewModel? = nil) {

@ -5,7 +5,7 @@ import Foundation
import TrustKeystore
import UIKit
protocol SettingsCoordinatorDelegate: class {
protocol SettingsCoordinatorDelegate: class, CanOpenURL {
func didRestart(with account: Wallet, in coordinator: SettingsCoordinator)
func didUpdateAccounts(in coordinator: SettingsCoordinator)
func didCancel(in coordinator: SettingsCoordinator)
@ -104,6 +104,20 @@ extension SettingsCoordinator: SettingsViewControllerDelegate {
}
}
extension SettingsCoordinator: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}
extension SettingsCoordinator: AccountsCoordinatorDelegate {
func didAddAccount(account: Wallet, in coordinator: AccountsCoordinator) {
delegate?.didUpdateAccounts(in: self)

@ -6,7 +6,7 @@ import Eureka
import StoreKit
import MessageUI
protocol SettingsViewControllerDelegate: class {
protocol SettingsViewControllerDelegate: class, CanOpenURL {
func didAction(action: AlphaWalletSettingsAction, in viewController: SettingsViewController)
}
@ -96,7 +96,7 @@ class SettingsViewController: FormViewController {
<<< AppFormAppearance.alphaWalletSettingsButton { row in
row.cellStyle = .value1
row.presentationMode = .show(controllerProvider: ControllerProvider<UIViewController>.callback {
let vc = HelpViewController()
let vc = HelpViewController(delegate: self)
return vc
}, onDismiss: { _ in
})
@ -152,7 +152,7 @@ class SettingsViewController: FormViewController {
if let localURL = type.localURL, UIApplication.shared.canOpenURL(localURL) {
UIApplication.shared.open(localURL, options: [:], completionHandler: .none)
} else {
self.openURL(type.remoteURL)
self.delegate?.didPressOpenWebPage(type.remoteURL, in: self)
}
}.cellSetup { cell, _ in
cell.imageView?.tintColor = Colors.appBackground
@ -187,3 +187,20 @@ class SettingsViewController: FormViewController {
return 0
}
}
extension SettingsViewController: HelpViewControllerDelegate {
}
extension SettingsViewController: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}

@ -2,11 +2,16 @@
import UIKit
protocol StaticHTMLViewControllerDelegate: class, CanOpenURL {
}
class StaticHTMLViewController: UIViewController {
let webView = UIWebView()
let footer = UIView()
weak var delegate: StaticHTMLViewControllerDelegate?
init() {
init(delegate: StaticHTMLViewControllerDelegate?) {
self.delegate = delegate
super.init(nibName: nil, bundle: nil)
view.backgroundColor = Colors.appBackground
@ -34,28 +39,28 @@ class StaticHTMLViewController: UIViewController {
footer.trailingAnchor.constraint(equalTo: view.trailingAnchor),
footer.heightAnchor.constraint(equalToConstant: footerHeight()),
footer.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
])
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func url() -> URL? {
return nil
}
func url() -> URL? {
return nil
}
func footerHeight() -> CGFloat {
return 0
}
func footerHeight() -> CGFloat {
return 0
}
}
extension StaticHTMLViewController: UIWebViewDelegate {
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if let url = request.url, url.absoluteString.hasPrefix("http") {
openURL(url)
return false
} else {
extension StaticHTMLViewController: UIWebViewDelegate {
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if let url = request.url, url.absoluteString.hasPrefix("http") {
delegate?.didPressOpenWebPage(url, in: self)
return false
} else {
return true
}
}

@ -11,13 +11,12 @@ import UIKit
import Result
import TrustKeystore
protocol TokensCardViewControllerDelegate: class {
protocol TokensCardViewControllerDelegate: class, CanOpenURL {
func didPressRedeem(token: TokenObject, in viewController: TokensCardViewController)
func didPressSell(for type: PaymentFlow, in viewController: TokensCardViewController)
func didPressTransfer(for type: PaymentFlow, ticketHolders: [TokenHolder], in viewController: TokensCardViewController)
func didCancel(in viewController: TokensCardViewController)
func didPressViewRedemptionInfo(in viewController: TokensCardViewController)
func didPressViewContractWebPage(in viewController: TokensCardViewController)
func didTapURL(url: URL, in viewController: TokensCardViewController)
}
@ -200,7 +199,7 @@ class TokensCardViewController: UIViewController, TokenVerifiableStatusViewContr
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: tokenObject.contract, in: self)
}
private func animateRowHeightChanges(for indexPaths: [IndexPath], in tableview: UITableView) {
@ -241,6 +240,6 @@ extension TokensCardViewController: UITableViewDelegate, UITableViewDataSource {
extension TokensCardViewController: BaseTokenListFormatTableViewCellDelegate {
func didTapURL(url: URL) {
delegate?.didTapURL(url: url, in: self)
delegate?.didPressOpenWebPage(url, in: self)
}
}

@ -13,7 +13,7 @@ import TrustKeystore
import MessageUI
import BigInt
protocol TokensCardCoordinatorDelegate: class {
protocol TokensCardCoordinatorDelegate: class, CanOpenURL {
func didPressTransfer(for type: PaymentFlow,
ticketHolders: [TokenHolder],
in coordinator: TokensCardCoordinator)
@ -24,7 +24,6 @@ protocol TokensCardCoordinatorDelegate: class {
func didCancel(in coordinator: TokensCardCoordinator)
func didPressViewRedemptionInfo(in: UIViewController)
func didPressViewEthereumInfo(in: UIViewController)
func didPressViewContractWebPage(for token: TokenObject, in viewController: UIViewController)
}
class TokensCardCoordinator: NSObject, Coordinator {
@ -248,6 +247,7 @@ class TokensCardCoordinator: NSObject, Coordinator {
let viewModel = TokenCardRedemptionViewModel(token: token, ticketHolder: ticketHolder)
let controller = TokenCardRedemptionViewController(config: session.config, session: session, token: token, viewModel: viewModel)
controller.configure()
controller.delegate = self
return controller
}
@ -378,10 +378,6 @@ extension TokensCardCoordinator: TokensCardViewControllerDelegate {
delegate?.didPressViewRedemptionInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: TokensCardViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
func didTapURL(url: URL, in viewController: TokensCardViewController) {
let controller = SFSafariViewController(url: url)
// Don't attempt to change tint colors for SFSafariViewController. It doesn't well correctly especially because the controller sets more than 1 color for the title
@ -398,10 +394,6 @@ extension TokensCardCoordinator: RedeemTokenViewControllerDelegate {
delegate?.didPressViewRedemptionInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: RedeemTokenViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
func didTapURL(url: URL, in viewController: RedeemTokenViewController) {
let controller = SFSafariViewController(url: url)
// Don't attempt to change tint colors for SFSafariViewController. It doesn't well correctly especially because the controller sets more than 1 color for the title
@ -417,10 +409,6 @@ extension TokensCardCoordinator: RedeemTokenCardQuantitySelectionViewControllerD
func didPressViewInfo(in viewController: RedeemTokenCardQuantitySelectionViewController) {
delegate?.didPressViewRedemptionInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: RedeemTokenCardQuantitySelectionViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
}
extension TokensCardCoordinator: SellTokensCardViewControllerDelegate {
@ -432,10 +420,6 @@ extension TokensCardCoordinator: SellTokensCardViewControllerDelegate {
delegate?.didPressViewEthereumInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: SellTokensCardViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
func didTapURL(url: URL, in viewController: SellTokensCardViewController) {
let controller = SFSafariViewController(url: url)
// Don't attempt to change tint colors for SFSafariViewController. It doesn't well correctly especially because the controller sets more than 1 color for the title
@ -451,10 +435,6 @@ extension TokensCardCoordinator: TransferTokenCardQuantitySelectionViewControlle
func didPressViewInfo(in viewController: TransferTokensCardQuantitySelectionViewController) {
delegate?.didPressViewRedemptionInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: TransferTokensCardQuantitySelectionViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
}
extension TokensCardCoordinator: EnterSellTokensCardPriceQuantityViewControllerDelegate {
@ -465,10 +445,6 @@ extension TokensCardCoordinator: EnterSellTokensCardPriceQuantityViewControllerD
func didPressViewInfo(in viewController: EnterSellTokensCardPriceQuantityViewController) {
delegate?.didPressViewEthereumInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: EnterSellTokensCardPriceQuantityViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
}
extension TokensCardCoordinator: SetSellTokensCardExpiryDateViewControllerDelegate {
@ -479,10 +455,6 @@ extension TokensCardCoordinator: SetSellTokensCardExpiryDateViewControllerDelega
func didPressViewInfo(in viewController: SetSellTokensCardExpiryDateViewController) {
delegate?.didPressViewEthereumInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: SetSellTokensCardExpiryDateViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
}
extension TokensCardCoordinator: TransferTokensCardViewControllerDelegate {
@ -502,10 +474,6 @@ extension TokensCardCoordinator: TransferTokensCardViewControllerDelegate {
delegate?.didPressViewRedemptionInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: TransferTokensCardViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
func didTapURL(url: URL, in viewController: TransferTokensCardViewController) {
let controller = SFSafariViewController(url: url)
// Don't attempt to change tint colors for SFSafariViewController. It doesn't well correctly especially because the controller sets more than 1 color for the title
@ -556,10 +524,6 @@ extension TokensCardCoordinator: ChooseTokenCardTransferModeViewControllerDelega
func didPressViewInfo(in viewController: ChooseTokenCardTransferModeViewController) {
delegate?.didPressViewRedemptionInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: ChooseTokenCardTransferModeViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
}
extension TokensCardCoordinator: SetTransferTokensCardExpiryDateViewControllerDelegate {
@ -570,10 +534,6 @@ extension TokensCardCoordinator: SetTransferTokensCardExpiryDateViewControllerDe
func didPressViewInfo(in viewController: SetTransferTokensCardExpiryDateViewController) {
delegate?.didPressViewRedemptionInfo(in: viewController)
}
func didPressViewContractWebPage(in viewController: SetTransferTokensCardExpiryDateViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
}
}
extension TokensCardCoordinator: GenerateTransferMagicLinkViewControllerDelegate {
@ -610,8 +570,21 @@ extension TokensCardCoordinator: TransferTokensCardViaWalletAddressViewControlle
func didPressViewInfo(in viewController: TransferTokensCardViaWalletAddressViewController) {
delegate?.didPressViewEthereumInfo(in: viewController)
}
}
extension TokensCardCoordinator: TokenCardRedemptionViewControllerDelegate {
}
extension TokensCardCoordinator: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressViewContractWebPage(in viewController: TransferTokensCardViaWalletAddressViewController) {
delegate?.didPressViewContractWebPage(for: viewController.viewModel.token, in: viewController)
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}

@ -5,7 +5,7 @@ import UIKit
import Result
import TrustKeystore
protocol TransactionCoordinatorDelegate: class {
protocol TransactionCoordinatorDelegate: class, CanOpenURL {
func didPress(for type: PaymentFlow, in coordinator: TransactionCoordinator)
func didCancel(in coordinator: TransactionCoordinator)
}
@ -79,8 +79,9 @@ class TransactionCoordinator: Coordinator {
func showTransaction(_ transaction: Transaction) {
let controller = TransactionViewController(
session: session,
transaction: transaction
session: session,
transaction: transaction,
delegate: self
)
if UIDevice.current.userInterfaceIdiom == .pad {
let nav = UINavigationController(rootViewController: controller)
@ -116,7 +117,8 @@ class TransactionCoordinator: Coordinator {
func showDeposit(for account: Wallet, from barButtonItem: UIBarButtonItem? = .none) {
let coordinator = DepositCoordinator(
navigationController: navigationController,
account: account
account: account,
delegate: self
)
coordinator.start(from: barButtonItem)
}
@ -138,7 +140,8 @@ extension TransactionCoordinator: TransactionsViewControllerDelegate {
func didPressDeposit(for account: Wallet, sender: UIView, in viewController: TransactionsViewController) {
let coordinator = DepositCoordinator(
navigationController: navigationController,
account: account
account: account,
delegate: self
)
coordinator.start(from: sender)
}
@ -147,3 +150,23 @@ extension TransactionCoordinator: TransactionsViewControllerDelegate {
delegate?.didCancel(in: self)
}
}
extension TransactionCoordinator: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}
extension TransactionCoordinator: TransactionViewControllerDelegate {
}
extension TransactionCoordinator: DepositCoordinatorDelegate {
}

@ -5,6 +5,9 @@ import StackViewController
import Result
import SafariServices
protocol TransactionViewControllerDelegate: class, CanOpenURL {
}
class TransactionViewController: UIViewController {
private lazy var viewModel: TransactionDetailsViewModel = {
@ -21,12 +24,16 @@ class TransactionViewController: UIViewController {
let session: WalletSession
let transaction: Transaction
weak var delegate: TransactionViewControllerDelegate?
init(
session: WalletSession,
transaction: Transaction
transaction: Transaction,
delegate: TransactionViewControllerDelegate?
) {
self.session = session
self.transaction = transaction
self.delegate = delegate
stackViewController.scrollView.alwaysBounceVertical = true
stackViewController.stackView.spacing = 10
@ -111,7 +118,7 @@ class TransactionViewController: UIViewController {
@objc func more() {
guard let url = viewModel.detailsURL else { return }
openURL(url)
delegate?.didPressOpenWebPage(url, in: self)
}
@objc func share(_ sender: UIBarButtonItem) {

@ -2,11 +2,10 @@
import UIKit
protocol ChooseTokenCardTransferModeViewControllerDelegate: class {
protocol ChooseTokenCardTransferModeViewControllerDelegate: class, CanOpenURL {
func didChooseTransferViaMagicLink(token: TokenObject, ticketHolder: TokenHolder, in viewController: ChooseTokenCardTransferModeViewController)
func didChooseTransferNow(token: TokenObject, ticketHolder: TokenHolder, in viewController: ChooseTokenCardTransferModeViewController)
func didPressViewInfo(in viewController: ChooseTokenCardTransferModeViewController)
func didPressViewContractWebPage(in viewController: ChooseTokenCardTransferModeViewController)
}
class ChooseTokenCardTransferModeViewController: UIViewController, TokenVerifiableStatusViewController {
@ -129,7 +128,7 @@ class ChooseTokenCardTransferModeViewController: UIViewController, TokenVerifiab
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
func configure(viewModel newViewModel: ChooseTokenCardTransferModeViewControllerViewModel? = nil) {

@ -2,10 +2,9 @@
import UIKit
protocol SetTransferTokensCardExpiryDateViewControllerDelegate: class {
protocol SetTransferTokensCardExpiryDateViewControllerDelegate: class, CanOpenURL {
func didPressNext(ticketHolder: TokenHolder, linkExpiryDate: Date, in viewController: SetTransferTokensCardExpiryDateViewController)
func didPressViewInfo(in viewController: SetTransferTokensCardExpiryDateViewController)
func didPressViewContractWebPage(in viewController: SetTransferTokensCardExpiryDateViewController)
}
class SetTransferTokensCardExpiryDateViewController: UIViewController, TokenVerifiableStatusViewController {
@ -236,7 +235,7 @@ class SetTransferTokensCardExpiryDateViewController: UIViewController, TokenVeri
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
override func viewDidLayoutSubviews() {

@ -2,10 +2,9 @@
import UIKit
protocol TransferTokenCardQuantitySelectionViewControllerDelegate: class {
protocol TransferTokenCardQuantitySelectionViewControllerDelegate: class, CanOpenURL {
func didSelectQuantity(token: TokenObject, ticketHolder: TokenHolder, in viewController: TransferTokensCardQuantitySelectionViewController)
func didPressViewInfo(in viewController: TransferTokensCardQuantitySelectionViewController)
func didPressViewContractWebPage(in viewController: TransferTokensCardQuantitySelectionViewController)
}
class TransferTokensCardQuantitySelectionViewController: UIViewController, TokenVerifiableStatusViewController {
@ -134,7 +133,7 @@ class TransferTokensCardQuantitySelectionViewController: UIViewController, Token
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
func configure(viewModel newViewModel: TransferTokensCardQuantitySelectionViewModel? = nil) {

@ -3,10 +3,9 @@
import UIKit
import QRCodeReaderViewController
protocol TransferTokensCardViaWalletAddressViewControllerDelegate: class {
protocol TransferTokensCardViaWalletAddressViewControllerDelegate: class, CanOpenURL {
func didEnterWalletAddress(ticketHolder: TokenHolder, to walletAddress: String, paymentFlow: PaymentFlow, in viewController: TransferTokensCardViaWalletAddressViewController)
func didPressViewInfo(in viewController: TransferTokensCardViaWalletAddressViewController)
func didPressViewContractWebPage(in viewController: TransferTokensCardViaWalletAddressViewController)
}
class TransferTokensCardViaWalletAddressViewController: UIViewController, TokenVerifiableStatusViewController, CanScanQRCode {
@ -126,8 +125,7 @@ class TransferTokensCardViaWalletAddressViewController: UIViewController, TokenV
}
func showContractWebPage() {
let url = config.server.etherscanContractDetailsWebPageURL(for: viewModel.token.contract)
openURL(url)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
func configure(viewModel newViewModel: TransferTokensCardViaWalletAddressViewControllerViewModel? = nil) {

@ -2,10 +2,9 @@
import UIKit
protocol TransferTokensCardViewControllerDelegate: class {
protocol TransferTokensCardViewControllerDelegate: class, CanOpenURL {
func didSelectTicketHolder(token: TokenObject, ticketHolder: TokenHolder, in viewController: TransferTokensCardViewController)
func didPressViewInfo(in viewController: TransferTokensCardViewController)
func didPressViewContractWebPage(in viewController: TransferTokensCardViewController)
func didTapURL(url: URL, in viewController: TransferTokensCardViewController)
}
@ -120,7 +119,7 @@ class TransferTokensCardViewController: UIViewController, TokenVerifiableStatusV
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(in: self)
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
private func animateRowHeightChanges(for indexPaths: [IndexPath], in tableview: UITableView) {
@ -161,6 +160,6 @@ extension TransferTokensCardViewController: UITableViewDelegate, UITableViewData
extension TransferTokensCardViewController: BaseTokenListFormatTableViewCellDelegate {
func didTapURL(url: URL) {
delegate?.didTapURL(url: url, in: self)
delegate?.didPressOpenWebPage(url, in: self)
}
}

@ -5,11 +5,13 @@ import XCTest
import SafariServices
class DepositCoordinatorTests: XCTestCase {
private var didCallOpenWebPage = false
func testStart() {
let coordinator = DepositCoordinator(
navigationController: FakeNavigationController(),
account: .make()
account: .make(),
delegate: nil
)
coordinator.start()
@ -20,22 +22,37 @@ class DepositCoordinatorTests: XCTestCase {
func testDepositCoinbase() {
let coordinator = DepositCoordinator(
navigationController: FakeNavigationController(),
account: .make()
account: .make(),
delegate: self
)
coordinator.showCoinbase()
XCTAssertTrue(coordinator.navigationController.presentedViewController is SFSafariViewController)
XCTAssertTrue(didCallOpenWebPage)
}
func testDepositShapeShift() {
let coordinator = DepositCoordinator(
navigationController: FakeNavigationController(),
account: .make()
account: .make(),
delegate: self
)
coordinator.showShapeShift()
XCTAssertTrue(didCallOpenWebPage)
}
}
extension DepositCoordinatorTests: DepositCoordinatorDelegate {
}
extension DepositCoordinatorTests: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
}
XCTAssertTrue(coordinator.navigationController.presentedViewController is SFSafariViewController)
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
didCallOpenWebPage = true
}
}

Loading…
Cancel
Save