Merge pull request #3079 from vladyslav-iosdev/#3078

Refactor: Improve updating `walletSummaryView` view #3078
pull/3080/head
Vladyslav Shepitko 3 years ago committed by GitHub
commit 1c67f8bc8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      AlphaWallet/Tokens/ViewControllers/TokensViewController.swift

@ -261,12 +261,11 @@ class TokensViewController: UIViewController {
}
blockieImageView.addTarget(self, action: #selector(blockieButtonSelected), for: .touchUpInside)
subscriptionKey = walletSummarySubscription.subscribe { [weak self] balance in
guard let strongSelf = self, let balance = balance else { return }
TokensViewController.reloadWalletSummaryView(walletSummaryView, with: walletSummarySubscription.value)
subscriptionKey = walletSummarySubscription.subscribe { [weak walletSummaryView] balance in
DispatchQueue.main.async {
let summary = WalletSummary(balances: [balance])
strongSelf.walletSummaryView.configure(viewModel: .init(summary: summary, alignment: .center))
guard let view = walletSummaryView else { return }
TokensViewController.reloadWalletSummaryView(view, with: balance)
}
}
}
@ -412,6 +411,11 @@ class TokensViewController: UIViewController {
tableViewHeader.bounds.size.height = size.height
tableView.tableHeaderView = tableViewHeader
}
private static func reloadWalletSummaryView(_ walletSummaryView: WalletSummaryView, with balance: WalletBalance?) {
let summary = balance.map { WalletSummary(balances: [$0]) }
walletSummaryView.configure(viewModel: .init(summary: summary, alignment: .center))
}
}
extension TokensViewController: StatefulViewController {

Loading…
Cancel
Save