Skip to content

Commit

Permalink
Fix layout of double send transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
mNizhurin committed Dec 10, 2020
1 parent d941543 commit da4e30f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ThemeKit

class TransactionCell: ClaudeThemeCell {
private let typeIconImageView = UIImageView()
private let doubleSpendImageView = UIImageView()

private let dateLabel = UILabel()

Expand All @@ -31,16 +30,6 @@ class TransactionCell: ClaudeThemeCell {
typeIconImageView.setContentCompressionResistancePriority(.required, for: .horizontal)
typeIconImageView.setContentHuggingPriority(.required, for: .horizontal)

wrapperView.addSubview(doubleSpendImageView)
doubleSpendImageView.snp.makeConstraints { maker in
maker.leading.equalToSuperview().offset(CGFloat.margin4x)
maker.bottom.equalToSuperview().inset(CGFloat.margin3x)
}
doubleSpendImageView.image = UIImage(named: "double_send_20")
doubleSpendImageView.setContentCompressionResistancePriority(.required, for: .horizontal)
doubleSpendImageView.setContentHuggingPriority(.required, for: .horizontal)
doubleSpendImageView.isHidden = true

wrapperView.addSubview(dateLabel)
dateLabel.snp.makeConstraints { maker in
maker.leading.equalTo(typeIconImageView.snp.trailing).offset(CGFloat.margin16)
Expand Down Expand Up @@ -121,8 +110,6 @@ class TransactionCell: ClaudeThemeCell {
dateLabel.text = DateHelper.instance.formatTransactionDate(from: item.date).uppercased()
amountLabel.text = ValueFormatter.instance.format(coinValue: item.coinValue, fractionPolicy: .threshold(high: 0.01, low: 0))

doubleSpendImageView.isHidden = item.conflictingTxHash == nil

if let value = item.currencyValue?.nonZero, let formattedValue = ValueFormatter.instance.format(currencyValue: value, fractionPolicy: .threshold(high: 1000, low: 0.01)) {
currencyAmountLabel.text = formattedValue
} else {
Expand Down Expand Up @@ -167,14 +154,14 @@ class TransactionCell: ClaudeThemeCell {
processingView.isHidden = true

case .pending:
processingView.bind(type: item.type, progress: 0)
processingView.bind(type: item.type, progress: 0, hideDoubleSpendImage: item.conflictingTxHash == nil)
processingView.startAnimating()
processingView.isHidden = false

statusView.isHidden = true

case .processing(let progress):
processingView.bind(type: item.type, progress: progress)
processingView.bind(type: item.type, progress: progress, hideDoubleSpendImage: item.conflictingTxHash == nil)
processingView.startAnimating()
processingView.isHidden = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import UIKit
import SnapKit

class TransactionProcessingView: UIView {
private let doubleSpendImageView = UIImageView()
private let barsProgressView = BarsProgressView(color: .themeGray50, inactiveColor: .themeSteel20)
private let processingLabel = UILabel()

private var doubleSpendIconSizeConstraint: Constraint?
private var doubleSpendIconRightMarginConstraint: Constraint?

init() {
super.init(frame: .zero)

Expand All @@ -15,9 +19,21 @@ class TransactionProcessingView: UIView {

barsProgressView.set(barsCount: BarsProgressView.progressStepsCount)

addSubview(doubleSpendImageView)
doubleSpendImageView.snp.makeConstraints { maker in
maker.leading.equalTo(barsProgressView.snp.trailing).offset(CGFloat.margin16)
maker.centerY.equalTo(barsProgressView)
doubleSpendIconSizeConstraint = maker.size.equalTo(0).constraint
}

doubleSpendImageView.image = UIImage(named: "double_send_20")
doubleSpendImageView.setContentCompressionResistancePriority(.required, for: .horizontal)
doubleSpendImageView.setContentHuggingPriority(.required, for: .horizontal)
doubleSpendImageView.isHidden = true

addSubview(processingLabel)
processingLabel.snp.makeConstraints { maker in
maker.leading.equalTo(barsProgressView.snp.trailing).offset(CGFloat.margin16)
doubleSpendIconRightMarginConstraint = maker.leading.equalTo(doubleSpendImageView.snp.trailing).offset(0).constraint
maker.trailing.equalToSuperview()
maker.centerY.equalTo(barsProgressView)
}
Expand All @@ -31,7 +47,7 @@ class TransactionProcessingView: UIView {
fatalError("init(coder:) has not been implemented")
}

func bind(type: TransactionType, progress: Double) {
func bind(type: TransactionType, progress: Double, hideDoubleSpendImage: Bool) {
let text: String
let filledColor: UIColor

Expand All @@ -47,6 +63,10 @@ class TransactionProcessingView: UIView {
processingLabel.text = text
barsProgressView.set(filledColor: filledColor)
barsProgressView.set(progress: progress)

doubleSpendImageView.isHidden = hideDoubleSpendImage
doubleSpendIconSizeConstraint?.update(offset: hideDoubleSpendImage ? 0 : 20)
doubleSpendIconRightMarginConstraint?.update(offset: hideDoubleSpendImage ? 0 : CGFloat.margin4)
}

func startAnimating() {
Expand Down

0 comments on commit da4e30f

Please sign in to comment.