Merge branch 'master' into fix-crash-when-tap-on-awallet-custom-url-scheme

pull/385/head
James Sangalli 7 years ago committed by GitHub
commit 2930fd2d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Trust/Accounts/Coordinators/AccountsCoordinator.swift
  2. 16
      Trust/AppCoordinator.swift
  3. 9
      Trust/AppDelegate.swift
  4. 4
      Trust/InCoordinator.swift
  5. 2
      Trust/Localization/en.lproj/redeemInfo.html
  6. 15
      Trust/Localization/zh-Hans.lproj/redeemInfo.html
  7. 32
      Trust/Market/Coordinators/UniversalLinkCoordinator.swift
  8. 18
      Trust/Market/ViewModels/ImportTicketViewControllerViewModel.swift
  9. 1
      Trust/Redeem/ViewControllers/RedeemTicketsViewController.swift
  10. 1
      Trust/Redeem/ViewControllers/TicketRedemptionViewController.swift
  11. 1
      Trust/Sell/ViewControllers/SellTicketsViewController.swift
  12. 2
      Trust/Sell/Views/AmountTextField.swift
  13. 2
      Trust/Settings/Types/Config.swift
  14. 2
      Trust/Settings/ViewControllers/SettingsViewController.swift
  15. 6
      Trust/Style/AppStyle.swift
  16. 2
      Trust/Tokens/Helpers/TicketAdaptor.swift
  17. 1
      Trust/Tokens/ViewControllers/TicketsViewController.swift
  18. 2
      Trust/Transactions/Coordinators/TicketsCoordinator.swift
  19. 6
      Trust/Transactions/Coordinators/TransactionDataCoordinator.swift
  20. 1
      Trust/Transactions/ViewControllers/TransactionsViewController.swift
  21. 4
      Trust/Transactions/ViewModels/TransactionViewModel.swift
  22. 4
      Trust/Transfer/Coordinators/TransferTicketsCoordinator.swift
  23. 2
      Trust/Transfer/ViewControllers/SendViewController.swift
  24. 1
      Trust/Transfer/ViewControllers/TransferTicketsViewController.swift
  25. 4
      Trust/Transfer/ViewModels/ConfirmPaymentDetailsViewModel.swift
  26. 4
      Trust/Wallet/Coordinators/InitialWalletCreationCoordinator.swift
  27. 9
      Trust/Wallet/Coordinators/WalletCoordinator.swift
  28. 6
      Trust/Wallet/ViewControllers/ImportWalletViewController.swift

@ -69,7 +69,7 @@ class AccountsCoordinator: Coordinator {
func importOrCreateWallet(entryPoint: WalletEntryPoint) { func importOrCreateWallet(entryPoint: WalletEntryPoint) {
let coordinator = WalletCoordinator(keystore: keystore) let coordinator = WalletCoordinator(keystore: keystore)
if case let .createInstantWallet = entryPoint { if case .createInstantWallet = entryPoint {
coordinator.navigationController = navigationController coordinator.navigationController = navigationController
} }
coordinator.delegate = self coordinator.delegate = self
@ -144,7 +144,7 @@ extension AccountsCoordinator: WalletCoordinatorDelegate {
delegate?.didAddAccount(account: account, in: self) delegate?.didAddAccount(account: account, in: self)
if let delegate = delegate { if let delegate = delegate {
self.removeCoordinator(coordinator) self.removeCoordinator(coordinator)
self.delegate?.didSelectAccount(account: account, in: self) delegate.didSelectAccount(account: account, in: self)
} else { } else {
accountsViewController.fetch() accountsViewController.fetch()
coordinator.navigationController.dismiss(animated: true, completion: nil) coordinator.navigationController.dismiss(animated: true, completion: nil)

@ -6,7 +6,7 @@ import UIKit
import BigInt import BigInt
class AppCoordinator: NSObject, Coordinator { class AppCoordinator: NSObject, Coordinator {
let navigationController: UINavigationController let navigationController: UINavigationController
lazy var welcomeViewController: WelcomeViewController = { lazy var welcomeViewController: WelcomeViewController = {
let controller = WelcomeViewController() let controller = WelcomeViewController()
controller.delegate = self controller.delegate = self
@ -70,6 +70,16 @@ class AppCoordinator: NSObject, Coordinator {
coordinator.start() coordinator.start()
addCoordinator(coordinator) addCoordinator(coordinator)
} }
func closeWelcomeWindow() {
guard navigationController.viewControllers.contains(welcomeViewController) else {
return
}
navigationController.dismiss(animated: true, completion: nil)
if let wallet = keystore.recentlyUsedWallet {
showTransactions(for: wallet)
}
}
func inializers() { func inializers() {
var paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .allDomainsMask, true).flatMap { URL(fileURLWithPath: $0) } var paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .allDomainsMask, true).flatMap { URL(fileURLWithPath: $0) }
@ -122,6 +132,10 @@ class AppCoordinator: NSObject, Coordinator {
coordinator.start() coordinator.start()
addCoordinator(coordinator) addCoordinator(coordinator)
} }
func createInitialWallet() {
WalletCoordinator(keystore: keystore).createInitialWallet()
}
} }
//Disable creating and importing wallets from welcome screen //Disable creating and importing wallets from welcome screen

@ -61,15 +61,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
func application(_ application: UIApplication, func application(_ application: UIApplication,
continue userActivity: NSUserActivity, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool { restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
appCoordinator.createInitialWallet()
appCoordinator.closeWelcomeWindow()
let url = userActivity.webpageURL let url = userActivity.webpageURL
universalLinkCoordinator = UniversalLinkCoordinator() universalLinkCoordinator = UniversalLinkCoordinator()
universalLinkCoordinator.ethPrice = appCoordinator.ethPrice universalLinkCoordinator.ethPrice = appCoordinator.ethPrice
universalLinkCoordinator.ethBalance = appCoordinator.ethBalance universalLinkCoordinator.ethBalance = appCoordinator.ethBalance
universalLinkCoordinator.delegate = self universalLinkCoordinator.delegate = self
universalLinkCoordinator.start() universalLinkCoordinator.start()
let handled = universalLinkCoordinator.handleUniversalLink(url: url) let handled = universalLinkCoordinator.handleUniversalLink(url: url)
//TODO: if we handle other types of URLs, check if handled==false, then we pass the url to another handlers //TODO: if we handle other types of URLs, check if handled==false, then we pass the url to another handlers
return true return true
} }
} }

@ -103,8 +103,7 @@ class InCoordinator: Coordinator {
guard let tokens = tokensModel, let eth = tokens.first(where: { $0 == etherToken }) else { guard let tokens = tokensModel, let eth = tokens.first(where: { $0 == etherToken }) else {
return return
} }
var ticker = tokensStorage.coinTicker(for: eth) if let ticker = tokensStorage.coinTicker(for: eth) {
if let ticker = ticker {
self?.ethPrice.value = Double(ticker.price) self?.ethPrice.value = Double(ticker.price)
} else { } else {
tokensStorage.updatePricesAfterComingOnline() tokensStorage.updatePricesAfterComingOnline()
@ -324,7 +323,6 @@ class InCoordinator: Coordinator {
} }
//TODO do we need to pass these (especially tokenStorage) to showTransferViewController(for:ticketHolders:) to make sure storage is synchronized? //TODO do we need to pass these (especially tokenStorage) to showTransferViewController(for:ticketHolders:) to make sure storage is synchronized?
let session = transactionCoordinator.session let session = transactionCoordinator.session
let tokenStorage = transactionCoordinator.tokensStorage
switch (paymentFlow, session.account.type) { switch (paymentFlow, session.account.type) {
case (.send, .real), (.request, _): case (.send, .real), (.request, _):

@ -59,7 +59,7 @@ a:link, a:active, a:visited {
<body> <body>
<h1>Redemption Location</h1> <h1>Redemption Location</h1>
<p class="centered">Smolenskaya Square 3, Floor 10, Moscow, Russia, 121099</p> <p class="centered">Smolenskaya Square 3, Floor 10, Moscow, Russia, 121099</p>
<p class="centered">12 June - 14 July, 9:00 am - 5:00 pm on non-match days and 9.00am - 11.00am on match days</p> <p class="centered">12 June - 14 July, 9:00 am - 5:00 pm on non-match days and 9.00 am - 11.00 am on match days</p>
<p class="centered">Please note that the office is closed on the 14th of June</p> <p class="centered">Please note that the office is closed on the 14th of June</p>
<p class="centered">Telephone: (00) 7 (495) 771-71-58</p> <p class="centered">Telephone: (00) 7 (495) 771-71-58</p>
<br> <br>

@ -57,18 +57,15 @@ a:link, a:active, a:visited {
</style> </style>
</head> </head>
<body> <body>
<h1>Redemption Locations</h1> <h1>门票兑换处地址</h1>
<p class="centered">Moscow Marriott Royal Aurora Hotel</p> <p class="centered">Smolenskaya Square 3, Floor 10, Moscow, Russia, 121099</p>
<p class="centered">1st-10th June, 9:00-18:00</p> <p class="centered">开放时间:6月12日 - 7月14号</p>
<p class="centered">非比赛日9:00 am - 5:00 pm,比赛日 9.00 am - 11.00 am</p>
<p class="centered">注意:6月4号兑换处不开放</p>
<p class="centered">联系电话: (00) 7 (495) 771-71-58</p>
<br> <br>
<p class="centered"><img src="non_asset_catalog_redemption_location.png"></p> <p class="centered"><img src="non_asset_catalog_redemption_location.png"></p>
<br> <br>
<p class="centered">Moscow Marriott Royal Aurora Hotel</p>
<p class="centered">Petrovka St-Bld 11, Moscow,</p>
<p class="centered">gorod Moskva, Russia, 107031</p>
<br>
<p class="centered">+7 495 937-10-00</p>
<br>
<hr> <hr>
</body> </body>
</html> </html>

@ -4,6 +4,7 @@ import Foundation
import Alamofire import Alamofire
import BigInt import BigInt
import Realm import Realm
import TrustKeystore
protocol UniversalLinkCoordinatorDelegate: class { protocol UniversalLinkCoordinatorDelegate: class {
func viewControllerForPresenting(in coordinator: UniversalLinkCoordinator) -> UIViewController? func viewControllerForPresenting(in coordinator: UniversalLinkCoordinator) -> UIViewController?
@ -18,6 +19,7 @@ class UniversalLinkCoordinator: Coordinator {
var ethPrice: Subscribable<Double>? var ethPrice: Subscribable<Double>?
var ethBalance: Subscribable<BigInt>? var ethBalance: Subscribable<BigInt>?
var hasCompleted = false var hasCompleted = false
var addressOfNewWallet: String?
func start() { func start() {
preparingToImportUniversalLink() preparingToImportUniversalLink()
@ -39,7 +41,7 @@ class UniversalLinkCoordinator: Coordinator {
"v": signature.substring(from: 128), "v": signature.substring(from: 128),
"r": "0x" + signature.substring(with: Range(uncheckedBounds: (0, 64))), "r": "0x" + signature.substring(with: Range(uncheckedBounds: (0, 64))),
"s": "0x" + signature.substring(with: Range(uncheckedBounds: (64, 128))), "s": "0x" + signature.substring(with: Range(uncheckedBounds: (64, 128))),
"networkId": Config.init().chainID.description "networkId": Config().chainID.description
] ]
if isForTransfer { if isForTransfer {
@ -51,7 +53,8 @@ class UniversalLinkCoordinator: Coordinator {
func handlePaidUniversalLink(signedOrder: SignedOrder, ticketHolder: TicketHolder) -> Bool { func handlePaidUniversalLink(signedOrder: SignedOrder, ticketHolder: TicketHolder) -> Bool {
//TODO localize //TODO localize
if let viewController = delegate?.viewControllerForPresenting(in: self) { //TODO improve. Not an obvious link between the variables used in the if-statement and the body
if delegate?.viewControllerForPresenting(in: self) != nil {
if let vc = importTicketViewController { if let vc = importTicketViewController {
vc.signedOrder = signedOrder vc.signedOrder = signedOrder
vc.tokenObject = TokenObject(contract: signedOrder.order.contractAddress, vc.tokenObject = TokenObject(contract: signedOrder.order.contractAddress,
@ -94,7 +97,8 @@ class UniversalLinkCoordinator: Coordinator {
func usePaymentServerForFreeTransferLinks(signedOrder: SignedOrder, ticketHolder: TicketHolder) -> Bool { func usePaymentServerForFreeTransferLinks(signedOrder: SignedOrder, ticketHolder: TicketHolder) -> Bool {
let parameters = createHTTPParametersForPaymentServer(signedOrder: signedOrder, isForTransfer: true) let parameters = createHTTPParametersForPaymentServer(signedOrder: signedOrder, isForTransfer: true)
let query = Constants.paymentServer let query = Constants.paymentServer
if let viewController = delegate?.viewControllerForPresenting(in: self) { //TODO improve. Not an obvious link between the variables used in the if-statement and the body
if delegate?.viewControllerForPresenting(in: self) != nil {
if let vc = importTicketViewController { if let vc = importTicketViewController {
vc.query = query vc.query = query
vc.parameters = parameters vc.parameters = parameters
@ -110,12 +114,12 @@ class UniversalLinkCoordinator: Coordinator {
} }
//Returns true if handled //Returns true if handled
func handleUniversalLink(url: URL?) -> Bool { func handleUniversalLink(url: URL?) -> Bool {
let matchedPrefix = (url?.description.contains(UniversalLinkHandler().urlPrefix))! let matchedPrefix = (url?.description.contains(UniversalLinkHandler().urlPrefix))!
guard matchedPrefix else { guard matchedPrefix else {
return false return false
} }
let signedOrder = UniversalLinkHandler().parseUniversalLink(url: (url?.absoluteString)!) let signedOrder = UniversalLinkHandler().parseUniversalLink(url: (url?.absoluteString)!)
getTicketDetailsAndEcRecover(signedOrder: signedOrder) { result in getTicketDetailsAndEcRecover(signedOrder: signedOrder) { result in
if let goodResult = result { if let goodResult = result {
@ -123,7 +127,7 @@ class UniversalLinkCoordinator: Coordinator {
if let balance = self.ethBalance { if let balance = self.ethBalance {
balance.subscribeOnce { value in balance.subscribeOnce { value in
if value > signedOrder.order.price { if value > signedOrder.order.price {
let success = self.handlePaidUniversalLink(signedOrder: signedOrder, ticketHolder: goodResult) let _ = self.handlePaidUniversalLink(signedOrder: signedOrder, ticketHolder: goodResult)
} else { } else {
if let price = self.ethPrice { if let price = self.ethPrice {
if price.value == nil { if price.value == nil {
@ -143,7 +147,7 @@ class UniversalLinkCoordinator: Coordinator {
} }
} }
} else { } else {
let success = self.usePaymentServerForFreeTransferLinks( let _ = self.usePaymentServerForFreeTransferLinks(
signedOrder: signedOrder, signedOrder: signedOrder,
ticketHolder: goodResult ticketHolder: goodResult
) )
@ -290,16 +294,15 @@ class UniversalLinkCoordinator: Coordinator {
} }
} }
if let vc = self.importTicketViewController { //TODO improve. Not an obvious link between the variables used in the if-statement and the body
if let vc = self.importTicketViewController, vc.viewModel != nil {
// TODO handle http response // TODO handle http response
print(result) print(result)
if let vc = self.importTicketViewController, var viewModel = vc.viewModel { if successful {
if successful { self.showImportSuccessful()
self.showImportSuccessful() } else {
} else { //TODO Pass in error message
//TODO Pass in error message self.showImportError(errorMessage: R.string.localizable.aClaimTicketFailedTitle())
self.showImportError(errorMessage: R.string.localizable.aClaimTicketFailedTitle())
}
} }
} }
} }
@ -312,6 +315,7 @@ class UniversalLinkCoordinator: Coordinator {
} }
private func convert(ethCost: BigUInt) -> Decimal { private func convert(ethCost: BigUInt) -> Decimal {
//TODO extract constant. Used elsewhere too
let divideAmount = Decimal(string: "1000000000000000000")! let divideAmount = Decimal(string: "1000000000000000000")!
let etherCostDecimal = Decimal(string: ethCost.description)! / divideAmount let etherCostDecimal = Decimal(string: ethCost.description)! / divideAmount
return etherCostDecimal return etherCostDecimal

@ -59,7 +59,7 @@ struct ImportTicketViewControllerViewModel {
var ticketCount: String { var ticketCount: String {
guard let ticketHolder = ticketHolder else { return "" } guard let ticketHolder = ticketHolder else { return "" }
if case let .validating = state { if case .validating = state {
return "" return ""
} else { } else {
return "x\(ticketHolder.tickets.count)" return "x\(ticketHolder.tickets.count)"
@ -68,7 +68,7 @@ struct ImportTicketViewControllerViewModel {
var city: String { var city: String {
guard let ticketHolder = ticketHolder else { return "" } guard let ticketHolder = ticketHolder else { return "" }
if case let .validating = state { if case .validating = state {
return "" return ""
} else { } else {
return ticketHolder.city return ticketHolder.city
@ -77,7 +77,7 @@ struct ImportTicketViewControllerViewModel {
var category: String { var category: String {
guard let ticketHolder = ticketHolder else { return "" } guard let ticketHolder = ticketHolder else { return "" }
if case let .validating = state { if case .validating = state {
return "" return ""
} else { } else {
return String(ticketHolder.category) return String(ticketHolder.category)
@ -86,7 +86,7 @@ struct ImportTicketViewControllerViewModel {
var time: String { var time: String {
guard let ticketHolder = ticketHolder else { return "" } guard let ticketHolder = ticketHolder else { return "" }
if case let .validating = state { if case .validating = state {
return "" return ""
} else { } else {
return ticketHolder.date.format("hh:mm", overrideWithTimezoneIdentifier: ticketHolder.timeZoneIdentifier) return ticketHolder.date.format("hh:mm", overrideWithTimezoneIdentifier: ticketHolder.timeZoneIdentifier)
@ -95,7 +95,7 @@ struct ImportTicketViewControllerViewModel {
var teams: String { var teams: String {
guard let ticketHolder = ticketHolder else { return "" } guard let ticketHolder = ticketHolder else { return "" }
if case let .validating = state { if case .validating = state {
return "" return ""
} else { } else {
return R.string.localizable.aWalletTicketTokenMatchVs(ticketHolder.countryA, ticketHolder.countryB) return R.string.localizable.aWalletTicketTokenMatchVs(ticketHolder.countryA, ticketHolder.countryB)
@ -109,7 +109,7 @@ struct ImportTicketViewControllerViewModel {
var venue: String { var venue: String {
guard let ticketHolder = ticketHolder else { return "" } guard let ticketHolder = ticketHolder else { return "" }
if case let .validating = state { if case .validating = state {
return "" return ""
} else { } else {
return ticketHolder.venue return ticketHolder.venue
@ -118,7 +118,7 @@ struct ImportTicketViewControllerViewModel {
var date: String { var date: String {
guard let ticketHolder = ticketHolder else { return "" } guard let ticketHolder = ticketHolder else { return "" }
if case let .validating = state { if case .validating = state {
return "" return ""
} else { } else {
return ticketHolder.date.format("dd MMM yyyy", overrideWithTimezoneIdentifier: ticketHolder.timeZoneIdentifier) return ticketHolder.date.format("dd MMM yyyy", overrideWithTimezoneIdentifier: ticketHolder.timeZoneIdentifier)
@ -126,7 +126,7 @@ struct ImportTicketViewControllerViewModel {
} }
var showTicketRowIcons: Bool { var showTicketRowIcons: Bool {
if case let .validating = state { if case .validating = state {
return false return false
} else { } else {
return true return true
@ -149,7 +149,7 @@ struct ImportTicketViewControllerViewModel {
} }
var statusColor: UIColor { var statusColor: UIColor {
if case let .failed = state { if case .failed = state {
return Colors.appRed return Colors.appRed
} else { } else {
return UIColor(red: 20, green: 20, blue: 20) return UIColor(red: 20, green: 20, blue: 20)

@ -139,7 +139,6 @@ extension RedeemTicketsViewController: UITableViewDelegate, UITableViewDataSourc
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let ticketHolder = viewModel.item(for: indexPath)
let changedIndexPaths = viewModel.toggleSelection(for: indexPath) let changedIndexPaths = viewModel.toggleSelection(for: indexPath)
animateRowHeightChanges(for: changedIndexPaths, in: tableView) animateRowHeightChanges(for: changedIndexPaths, in: tableView)
} }

@ -47,7 +47,6 @@ class TicketRedemptionViewController: UIViewController {
stackView.translatesAutoresizingMaskIntoConstraints = false stackView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stackView) view.addSubview(stackView)
let xMargin = CGFloat(16)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
titleLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30), titleLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
titleLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30), titleLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),

@ -135,7 +135,6 @@ extension SellTicketsViewController: UITableViewDelegate, UITableViewDataSource
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let ticketHolder = viewModel.item(for: indexPath)
let changedIndexPaths = viewModel.toggleSelection(for: indexPath) let changedIndexPaths = viewModel.toggleSelection(for: indexPath)
animateRowHeightChanges(for: changedIndexPaths, in: tableView) animateRowHeightChanges(for: changedIndexPaths, in: tableView)
} }

@ -18,7 +18,7 @@ class AmountTextField: UIControl {
} }
var ethToDollarRate: Double? = nil { var ethToDollarRate: Double? = nil {
didSet { didSet {
if let ethToDollarRate = ethToDollarRate { if let _ = ethToDollarRate {
updateAlternatePricingDisplay() updateAlternatePricingDisplay()
} }
} }

@ -111,7 +111,7 @@ struct Config {
case .rinkeby: return "https://rinkeby.trustwalletapp.com" case .rinkeby: return "https://rinkeby.trustwalletapp.com"
case .poa: return "https://poa.trustwalletapp.com" case .poa: return "https://poa.trustwalletapp.com"
case .sokol: return "https://trust-sokol.herokuapp.com" case .sokol: return "https://trust-sokol.herokuapp.com"
case .custom(let custom): case .custom:
return "" // Enable? make optional return "" // Enable? make optional
} }
}() }()

@ -29,8 +29,6 @@ class SettingsViewController: FormViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
let account = session.account
view.backgroundColor = Colors.appBackground view.backgroundColor = Colors.appBackground
tableView.separatorStyle = .none tableView.separatorStyle = .none
tableView.backgroundColor = Colors.appBackground tableView.backgroundColor = Colors.appBackground

@ -7,9 +7,7 @@ import Eureka
func applyStyle() { func applyStyle() {
if #available(iOS 11, *) { if #available(iOS 11, *) {
if #available(iOS 11, *) { UIBarButtonItem.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self]).tintColor = Colors.appBackground
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self]).tintColor = Colors.appBackground
}
} else { } else {
UINavigationBar.appearance().isTranslucent = false UINavigationBar.appearance().isTranslucent = false
} }
@ -21,7 +19,7 @@ func applyStyle() {
UINavigationBar.appearance().backIndicatorTransitionMaskImage = R.image.backWhite() UINavigationBar.appearance().backIndicatorTransitionMaskImage = R.image.backWhite()
UINavigationBar.appearance().titleTextAttributes = [ UINavigationBar.appearance().titleTextAttributes = [
.foregroundColor: Colors.appWhite, .foregroundColor: Colors.appWhite,
.font: Fonts.light(size: 25) .font: Fonts.light(size: 25) as Any
] ]
//We could have set the backBarButtonItem with an empty title for every view controller, but we don't have a place to do it for Eureka view controllers. Using appearance here, while a hack is still more convenient though, since we don't have to do it for every view controller instance //We could have set the backBarButtonItem with an empty title for every view controller, but we don't have a place to do it for Eureka view controllers. Using appearance here, while a hack is still more convenient though, since we don't have to do it for every view controller instance

@ -58,7 +58,7 @@ class TicketAdaptor {
var results = results var results = results
if var previousRange = results.last, let previousTicket = previousRange.last, previousTicket.seatId + 1 == ticket.seatId { if var previousRange = results.last, let previousTicket = previousRange.last, previousTicket.seatId + 1 == ticket.seatId {
previousRange.append(ticket) previousRange.append(ticket)
results.popLast() let _ = results.popLast()
results.append(previousRange) results.append(previousRange)
return results return results
} else { } else {

@ -203,7 +203,6 @@ extension TicketsViewController: UITableViewDelegate, UITableViewDataSource {
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let ticketHolder = viewModel.item(for: indexPath)
let changedIndexPaths = viewModel.toggleDetailsVisible(for: indexPath) let changedIndexPaths = viewModel.toggleDetailsVisible(for: indexPath)
animateRowHeightChanges(for: changedIndexPaths, in: tableView) animateRowHeightChanges(for: changedIndexPaths, in: tableView)
} }

@ -512,7 +512,7 @@ extension TicketsCoordinator: TransferTicketsViaWalletAddressViewControllerDeleg
} }
//Defensive. Should already be checked before this //Defensive. Should already be checked before this
guard let address = Address(string: walletAddress) else { guard let _ = Address(string: walletAddress) else {
return self.navigationController.displayError(error: Errors.invalidAddress) return self.navigationController.displayError(error: Errors.invalidAddress)
} }

@ -143,8 +143,8 @@ class TransactionDataCoordinator {
Session.send(EtherServiceRequest(batch: BatchFactory().create(request))) { [weak self] result in Session.send(EtherServiceRequest(batch: BatchFactory().create(request))) { [weak self] result in
guard let `self` = self else { return } guard let `self` = self else { return }
switch result { switch result {
case .success(let parsedTransaction): case .success:
// NSLog("parsedTransaction \(parsedTransaction)") // NSLog("parsedTransaction \(_parsedTransaction)")
if transaction.date > Date().addingTimeInterval(Config.deleyedTransactionInternalSeconds) { if transaction.date > Date().addingTimeInterval(Config.deleyedTransactionInternalSeconds) {
self.update(state: .completed, for: transaction) self.update(state: .completed, for: transaction)
self.update(items: [transaction]) self.update(items: [transaction])
@ -156,7 +156,7 @@ class TransactionDataCoordinator {
// TODO: Think about the logic to handle pending transactions. // TODO: Think about the logic to handle pending transactions.
guard let error = error as? JSONRPCError else { return } guard let error = error as? JSONRPCError else { return }
switch error { switch error {
case .responseError(let code, let message, _): case .responseError:
// NSLog("code \(code), error: \(message)") // NSLog("code \(code), error: \(message)")
self.delete(transactions: [transaction]) self.delete(transactions: [transaction])
case .resultObjectParseError: case .resultObjectParseError:

@ -84,7 +84,6 @@ class TransactionsViewController: UIViewController {
reflectActionButtonsVisibility() reflectActionButtonsVisibility()
let separatorThickness = CGFloat(1)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),

@ -64,7 +64,7 @@ struct TransactionViewModel {
let amount = NSAttributedString( let amount = NSAttributedString(
string: amountWithSign(for: value.amount), string: amountWithSign(for: value.amount),
attributes: [ attributes: [
.font: Fonts.regular(size: 24), .font: Fonts.regular(size: 24) as Any,
.foregroundColor: amountTextColor, .foregroundColor: amountTextColor,
] ]
) )
@ -72,7 +72,7 @@ struct TransactionViewModel {
let currency = NSAttributedString( let currency = NSAttributedString(
string: " " + value.symbol, string: " " + value.symbol,
attributes: [ attributes: [
.font: Fonts.regular(size: 16) .font: Fonts.regular(size: 16) as Any
] ]
) )

@ -91,6 +91,7 @@ class TransferTicketsCoordinator: Coordinator {
case .success: case .success:
self.sendTransaction(with: configurator) self.sendTransaction(with: configurator)
case .failure(let error): case .failure(let error):
//TODO use the error object or remove it from the case-statement
self.processFailed() self.processFailed()
} }
} }
@ -106,9 +107,10 @@ class TransferTicketsCoordinator: Coordinator {
sendTransactionCoordinator.send(transaction: unsignedTransaction) { [weak self] result in sendTransactionCoordinator.send(transaction: unsignedTransaction) { [weak self] result in
if let celf = self { if let celf = self {
switch result { switch result {
case .success(let type): case .success:
celf.processSuccessful() celf.processSuccessful()
case .failure(let error): case .failure(let error):
//TODO use the error object or remove it from the case-statement
celf.processFailed() celf.processFailed()
} }
} }

@ -465,7 +465,7 @@ class SendViewController: UIViewController {
self.headerViewModel.currencyAmount = self.session.balanceCoordinator.viewModel.currencyAmount self.headerViewModel.currencyAmount = self.session.balanceCoordinator.viewModel.currencyAmount
self.headerViewModel.currencyAmountWithoutSymbol = self.session.balanceCoordinator.viewModel.currencyAmountWithoutSymbol self.headerViewModel.currencyAmountWithoutSymbol = self.session.balanceCoordinator.viewModel.currencyAmountWithoutSymbol
if let viewModel = self.viewModel { if let viewModel = self.viewModel {
configure(viewModel: self.viewModel) configure(viewModel: viewModel)
} }
default: default:
break break

@ -135,7 +135,6 @@ extension TransferTicketsViewController: UITableViewDelegate, UITableViewDataSou
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let ticketHolder = viewModel.item(for: indexPath)
let changedIndexPaths = viewModel.toggleSelection(for: indexPath) let changedIndexPaths = viewModel.toggleSelection(for: indexPath)
animateRowHeightChanges(for: changedIndexPaths, in: tableView) animateRowHeightChanges(for: changedIndexPaths, in: tableView)
} }

@ -122,7 +122,7 @@ struct ConfirmPaymentDetailsViewModel {
let amount = NSAttributedString( let amount = NSAttributedString(
string: amountWithSign(for: string), string: amountWithSign(for: string),
attributes: [ attributes: [
.font: Fonts.regular(size: 28), .font: Fonts.regular(size: 28) as Any,
.foregroundColor: amountTextColor, .foregroundColor: amountTextColor,
] ]
) )
@ -130,7 +130,7 @@ struct ConfirmPaymentDetailsViewModel {
let currency = NSAttributedString( let currency = NSAttributedString(
string: " \(transaction.transferType.symbol(server: config.server))", string: " \(transaction.transferType.symbol(server: config.server))",
attributes: [ attributes: [
.font: Fonts.regular(size: 20), .font: Fonts.regular(size: 20) as Any,
] ]
) )
return amount + currency return amount + currency

@ -41,14 +41,14 @@ class InitialWalletCreationCoordinator: Coordinator {
func showCreateWallet() { func showCreateWallet() {
let coordinator = WalletCoordinator(navigationController: self.navigationController, keystore: keystore) let coordinator = WalletCoordinator(navigationController: self.navigationController, keystore: keystore)
coordinator.delegate = self coordinator.delegate = self
coordinator.start(entryPoint) let _ = coordinator.start(entryPoint)
addCoordinator(coordinator) addCoordinator(coordinator)
} }
func presentImportWallet() { func presentImportWallet() {
let coordinator = WalletCoordinator(keystore: keystore) let coordinator = WalletCoordinator(keystore: keystore)
coordinator.delegate = self coordinator.delegate = self
coordinator.start(entryPoint) let _ = coordinator.start(entryPoint)
navigationController.present(coordinator.navigationController, animated: true, completion: nil) navigationController.present(coordinator.navigationController, animated: true, completion: nil)
addCoordinator(coordinator) addCoordinator(coordinator)
} }

@ -14,7 +14,7 @@ class WalletCoordinator: Coordinator {
var navigationController: UINavigationController var navigationController: UINavigationController
weak var delegate: WalletCoordinatorDelegate? weak var delegate: WalletCoordinatorDelegate?
var entryPoint: WalletEntryPoint? var entryPoint: WalletEntryPoint?
let keystore: Keystore var keystore: Keystore
var coordinators: [Coordinator] = [] var coordinators: [Coordinator] = []
init( init(
@ -61,6 +61,13 @@ class WalletCoordinator: Coordinator {
controller.delegate = self controller.delegate = self
navigationController.pushViewController(controller, animated: true) navigationController.pushViewController(controller, animated: true)
} }
func createInitialWallet() {
if !keystore.hasWallets {
let account = keystore.createAccount(password: PasswordGenerator.generateRandom())
keystore.recentlyUsedWallet = Wallet(type: WalletType.real(account))
}
}
func createInstantWallet() { func createInstantWallet() {
navigationController.displayLoading(text: R.string.localizable.walletCreateInProgress(), animated: false) navigationController.displayLoading(text: R.string.localizable.walletCreateInProgress(), animated: false)

@ -211,8 +211,6 @@ class ImportWalletViewController: UIViewController {
return validatePrivateKey() return validatePrivateKey()
case .watch: case .watch:
return validateWatch() return validateWatch()
default:
return true
} }
} }
@ -325,8 +323,6 @@ class ImportWalletViewController: UIViewController {
privateKeyTextView.value = string privateKeyTextView.value = string
case .watch: case .watch:
watchAddressTextField.value = string watchAddressTextField.value = string
default:
return
} }
} }
@ -450,8 +446,6 @@ extension ImportWalletViewController: ImportWalletTabBarDelegate {
showPrivateKeyControlsOnly() showPrivateKeyControlsOnly()
case .watch: case .watch:
showWatchControlsOnly() showWatchControlsOnly()
default:
break
} }
} }
} }

Loading…
Cancel
Save