Merge branch 'master' into switch-to-new-account-immediately

pull/259/head
James Sangalli 7 years ago committed by GitHub
commit 6d05d7a5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      Trust/InCoordinator.swift
  2. 16
      Trust/Sell/ViewControllers/EnterSellTicketsPriceQuantityViewController.swift
  3. 25
      Trust/Transactions/Coordinators/TicketsCoordinator.swift
  4. 1
      Trust/Wallet/Coordinators/WalletCoordinator.swift

@ -342,7 +342,8 @@ class InCoordinator: Coordinator {
let ticketsCoordinator = TicketsCoordinator(
session: session,
keystore: keystore,
tokensStorage: tokenStorage
tokensStorage: tokenStorage,
ethPrice: ethPrice
)
addCoordinator(ticketsCoordinator)
ticketsCoordinator.token = token

@ -25,6 +25,7 @@ class EnterSellTicketsPriceQuantityViewController: UIViewController {
let nextButton = UIButton(type: .system)
var viewModel: EnterSellTicketsPriceQuantityViewControllerViewModel!
var paymentFlow: PaymentFlow
var ethPrice: Subscribable<Double>
var totalEthCost: Double {
if let ethCostPerTicket = Double(pricePerTicketField.ethCost) {
let quantity = Double(quantityStepper.value)
@ -44,9 +45,10 @@ class EnterSellTicketsPriceQuantityViewController: UIViewController {
}
weak var delegate: EnterSellTicketsPriceQuantityViewControllerDelegate?
init(storage: TokensDataStore, paymentFlow: PaymentFlow) {
init(storage: TokensDataStore, paymentFlow: PaymentFlow, ethPrice: Subscribable<Double>) {
self.storage = storage
self.paymentFlow = paymentFlow
self.ethPrice = ethPrice
super.init(nibName: nil, bundle: nil)
navigationItem.rightBarButtonItem = UIBarButtonItem(image: R.image.location(), style: .plain, target: self, action: #selector(showInfo))
@ -70,9 +72,15 @@ class EnterSellTicketsPriceQuantityViewController: UIViewController {
dollarCostLabel.translatesAutoresizingMaskIntoConstraints = false
pricePerTicketField.translatesAutoresizingMaskIntoConstraints = false
//TODO is there a better way to get the price?
if let rates = storage.tickers, let ticker = rates.values.first(where: { $0.symbol == "ETH" }), let price = Double(ticker.price) {
pricePerTicketField.ethToDollarRate = price
if let value = ethPrice.value {
pricePerTicketField.ethToDollarRate = value
} else {
ethPrice.subscribe { value in
//TODO good to test if there's a leak here if user has already cancelled before this
if let value = value {
self.pricePerTicketField.ethToDollarRate = value
}
}
}
pricePerTicketField.delegate = self

@ -40,17 +40,20 @@ class TicketsCoordinator: NSObject, Coordinator {
let tokensStorage: TokensDataStore
let navigationController: UINavigationController
var coordinators: [Coordinator] = []
var ethPrice: Subscribable<Double>
init(
session: WalletSession,
navigationController: UINavigationController = NavigationController(),
keystore: Keystore,
tokensStorage: TokensDataStore
tokensStorage: TokensDataStore,
ethPrice: Subscribable<Double>
) {
self.session = session
self.keystore = keystore
self.navigationController = navigationController
self.tokensStorage = tokensStorage
self.ethPrice = ethPrice
}
func start() {
@ -150,14 +153,14 @@ class TicketsCoordinator: NSObject, Coordinator {
viewController.navigationController?.pushViewController(vc, animated: true)
}
private func showQuantityViewController(for ticketHolder: TicketHolder,
in viewController: RedeemTicketsViewController) {
private func showEnterQuantityViewController(for ticketHolder: TicketHolder,
in viewController: RedeemTicketsViewController) {
let quantityViewController = makeRedeemTicketsQuantitySelectionViewController(for: ticketHolder)
viewController.navigationController?.pushViewController(quantityViewController, animated: true)
}
private func showQuantityViewController(for ticketHolder: TicketHolder,
in viewController: SellTicketsViewController) {
private func showEnterPriceQuantityViewController(for ticketHolder: TicketHolder,
in viewController: SellTicketsViewController) {
let vc = makeEnterSellTicketsPriceQuantityViewController(for: ticketHolder, paymentFlow: viewController.paymentFlow)
viewController.navigationController?.pushViewController(vc, animated: true)
}
@ -193,7 +196,7 @@ class TicketsCoordinator: NSObject, Coordinator {
}
private func makeEnterSellTicketsPriceQuantityViewController(for ticketHolder: TicketHolder, paymentFlow: PaymentFlow) -> EnterSellTicketsPriceQuantityViewController {
let controller = EnterSellTicketsPriceQuantityViewController(storage: tokensStorage, paymentFlow: paymentFlow)
let controller = EnterSellTicketsPriceQuantityViewController(storage: tokensStorage, paymentFlow: paymentFlow, ethPrice: ethPrice)
let viewModel = EnterSellTicketsPriceQuantityViewControllerViewModel(ticketHolder: ticketHolder)
controller.configure(viewModel: viewModel)
controller.delegate = self
@ -239,8 +242,8 @@ class TicketsCoordinator: NSObject, Coordinator {
return controller
}
private func showQuantityViewController(for ticketHolder: TicketHolder,
in viewController: TransferTicketsViewController) {
private func showEnterQuantityViewController(for ticketHolder: TicketHolder,
in viewController: TransferTicketsViewController) {
let quantityViewController = makeTransferTicketsQuantitySelectionViewController(for: ticketHolder, paymentFlow: viewController.paymentFlow)
viewController.navigationController?.pushViewController(quantityViewController, animated: true)
}
@ -354,7 +357,7 @@ extension TicketsCoordinator: TicketsViewControllerDelegate {
extension TicketsCoordinator: RedeemTicketsViewControllerDelegate {
func didSelectTicketHolder(ticketHolder: TicketHolder, in viewController: RedeemTicketsViewController) {
showQuantityViewController(for: ticketHolder, in: viewController)
showEnterQuantityViewController(for: ticketHolder, in: viewController)
}
func didPressViewInfo(in viewController: RedeemTicketsViewController) {
@ -374,7 +377,7 @@ extension TicketsCoordinator: RedeemTicketsQuantitySelectionViewControllerDelega
extension TicketsCoordinator: SellTicketsViewControllerDelegate {
func didSelectTicketHolder(ticketHolder: TicketHolder, in viewController: SellTicketsViewController) {
showQuantityViewController(for: ticketHolder, in: viewController)
showEnterPriceQuantityViewController(for: ticketHolder, in: viewController)
}
func didPressViewInfo(in viewController: SellTicketsViewController) {
@ -414,7 +417,7 @@ extension TicketsCoordinator: SetSellTicketsExpiryDateViewControllerDelegate {
extension TicketsCoordinator: TransferTicketsViewControllerDelegate {
func didSelectTicketHolder(ticketHolder: TicketHolder, in viewController: TransferTicketsViewController) {
showQuantityViewController(for: ticketHolder, in: viewController)
showEnterQuantityViewController(for: ticketHolder, in: viewController)
}
func didPressViewInfo(in viewController: TransferTicketsViewController) {

@ -125,6 +125,7 @@ extension WalletCoordinator: WelcomeViewControllerDelegate {
extension WalletCoordinator: ImportWalletViewControllerDelegate {
func didImportAccount(account: Wallet, in viewController: ImportWalletViewController) {
Config().addToWalletAddressesAlreadyPromptedForBackup(address: account.address.eip55String)
didCreateAccount(account: account)
}
}

Loading…
Cancel
Save