Skip to content

Commit

Permalink
Simplify token view
Browse files Browse the repository at this point in the history
  • Loading branch information
vikmeup committed Mar 21, 2018
1 parent bf1141c commit 8e2d740
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Trust/Tokens/ViewControllers/TokenViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TokenViewController: UIViewController {
private var tableView = UITableView()

private lazy var header: TokenHeaderView = {
let view = TokenHeaderView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 250))
let view = TokenHeaderView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 264))
return view
}()

Expand Down
7 changes: 1 addition & 6 deletions Trust/Tokens/ViewControllers/TokensViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TokensViewController: UIViewController {

lazy var header: TokensHeaderView = {
let header = TokensHeaderView(frame: .zero)
header.amountLabel.text = viewModel.headerBalance ?? "--"
header.amountLabel.text = viewModel.headerBalance
header.amountLabel.textColor = viewModel.headerBalanceTextColor
header.backgroundColor = viewModel.headerBackgroundColor
header.amountLabel.font = viewModel.headerBalanceFont
Expand Down Expand Up @@ -51,13 +51,9 @@ class TokensViewController: UIViewController {
}()

let tableView: UITableView

let refreshControl = UIRefreshControl()

weak var delegate: TokensViewControllerDelegate?

var etherFetchTimer: Timer?

let intervalToETHRefresh = 10.0

init(
Expand Down Expand Up @@ -106,7 +102,6 @@ class TokensViewController: UIViewController {
sheduleBalanceUpdate()
NotificationCenter.default.addObserver(self, selector: #selector(TokensViewController.stopTimer), name: .UIApplicationWillResignActive, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(TokensViewController.restartTimer), name: .UIApplicationDidBecomeActive, object: nil)

}

override func viewWillAppear(_ animated: Bool) {
Expand Down
14 changes: 1 addition & 13 deletions Trust/Tokens/ViewModels/TokenViewCellViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,7 @@ struct TokenViewCellViewModel {
}

var currencyAmount: String? {
return TokensLayout.cell.currencyAmount(for: ticker, token: token)
}

var percentChange: String? {
return TokensLayout.cell.percentChange(for: ticker)
}

var percentChangeColor: UIColor {
return TokensLayout.cell.percentChangeColor(for: ticker)
}

var percentChangeFont: UIFont {
return UIFont.systemFont(ofSize: 12, weight: .light)
return TokensLayout.cell.totalFiatAmount(for: ticker, token: token)
}

var amountFont: UIFont {
Expand Down
2 changes: 1 addition & 1 deletion Trust/Tokens/ViewModels/TokenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class TokenViewModel {
}

var fiatAmountFont: UIFont {
return UIFont.systemFont(ofSize: 15, weight: .regular)
return UIFont.systemFont(ofSize: 16, weight: .regular)
}

var currencyAmount: String? {
Expand Down
5 changes: 2 additions & 3 deletions Trust/Tokens/ViewModels/TokensViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class TokensViewModel: NSObject {
var tokensObserver: NotificationToken?
let address: Address

var headerBalance: String? {
return amount
var headerBalance: String {
return amount ?? "0.00"
}

var headerBalanceTextColor: UIColor {
Expand Down Expand Up @@ -96,7 +96,6 @@ class TokensViewModel: NSObject {
tokens.forEach { token in
totalAmount += amount(for: token)
}
guard totalAmount != 0 else { return "--" }
return CurrencyFormatter.formatter.string(from: NSNumber(value: totalAmount))
}

Expand Down
6 changes: 4 additions & 2 deletions Trust/Tokens/Views/TokenHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TokenHeaderView: UIView {
marketPriceStack.axis = .horizontal
marketPriceStack.spacing = 5

let rightStackView = UIStackView(arrangedSubviews: [amountStack, marketPriceStack])
let rightStackView = UIStackView(arrangedSubviews: [marketPriceStack])
rightStackView.translatesAutoresizingMaskIntoConstraints = false
rightStackView.axis = .vertical
rightStackView.alignment = .center
Expand All @@ -83,7 +83,9 @@ class TokenHeaderView: UIView {
container.addArrangedSubview(.spacer(height: StyleLayout.sideMargin * 2))
container.addArrangedSubview(imageView)
container.addArrangedSubview(.spacer(height: 12))
container.addArrangedSubview(rightStackView)
container.addArrangedSubview(amountLabel)
container.addArrangedSubview(fiatAmountLabel)
//container.addArrangedSubview(rightStackView)
container.addArrangedSubview(.spacer(height: 10))
container.addArrangedSubview(buttonsView)

Expand Down
10 changes: 1 addition & 9 deletions Trust/Tokens/Views/TokenViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class TokenViewCell: UITableViewCell {
let amountLabel = UILabel()
let currencyAmountLabel = UILabel()
let symbolImageView = TokenImageView()
let percentChange = UILabel()

private struct Layout {
static let imageSize: CGFloat = 54
Expand All @@ -36,15 +35,12 @@ class TokenViewCell: UITableViewCell {
currencyAmountLabel.translatesAutoresizingMaskIntoConstraints = false
currencyAmountLabel.textAlignment = .right

percentChange.translatesAutoresizingMaskIntoConstraints = false
percentChange.textAlignment = .right

let leftStackView = UIStackView(arrangedSubviews: [titleLabel])
leftStackView.translatesAutoresizingMaskIntoConstraints = false
leftStackView.axis = .vertical
leftStackView.spacing = 12

let rightBottomStackView = UIStackView(arrangedSubviews: [currencyAmountLabel, percentChange])
let rightBottomStackView = UIStackView(arrangedSubviews: [currencyAmountLabel])
rightBottomStackView.translatesAutoresizingMaskIntoConstraints = false
rightBottomStackView.axis = .horizontal
rightBottomStackView.spacing = 5
Expand Down Expand Up @@ -97,10 +93,6 @@ class TokenViewCell: UITableViewCell {
currencyAmountLabel.textColor = TokensLayout.cell.currencyAmountTextColor
currencyAmountLabel.font = viewModel.currencyAmountFont

percentChange.text = viewModel.percentChange
percentChange.textColor = viewModel.percentChangeColor
percentChange.font = viewModel.percentChangeFont

symbolImageView.kf.setImage(
with: viewModel.imageUrl,
placeholder: viewModel.placeholderImage
Expand Down

0 comments on commit 8e2d740

Please sign in to comment.