BlueWallet/ios/BlueWalletWatch Extension/Objects/TransactionTableRow.swift

73 lines
1.7 KiB
Swift
Raw Normal View History

2019-05-02 16:33:03 -04:00
//
// TransactionTableRow.swift
// BlueWalletWatch Extension
//
// Created by Marcos Rodriguez on 3/10/19.
2024-01-25 00:39:01 -04:00
2019-05-02 16:33:03 -04:00
//
import WatchKit
class TransactionTableRow: NSObject {
@IBOutlet private weak var transactionAmountLabel: WKInterfaceLabel!
@IBOutlet private weak var transactionMemoLabel: WKInterfaceLabel!
@IBOutlet private weak var transactionTimeLabel: WKInterfaceLabel!
@IBOutlet private weak var transactionTypeImage: WKInterfaceImage!
static let identifier: String = "TransactionTableRow"
var amount: String = "" {
willSet {
transactionAmountLabel.setText(newValue)
}
}
var memo: String = "" {
willSet {
transactionMemoLabel.setText(newValue)
}
}
var time: String = "" {
willSet {
2024-11-30 12:49:35 -05:00
if type == .pending {
transactionTimeLabel.setText("Pending...")
} else {
transactionTimeLabel.setText(newValue)
}
2019-05-02 16:33:03 -04:00
}
}
var type: TransactionType = .pending {
2019-05-02 16:33:03 -04:00
willSet {
2024-11-30 12:49:35 -05:00
if newValue == .pending {
2019-05-02 16:33:03 -04:00
transactionTypeImage.setImage(UIImage(named: "pendingConfirmation"))
2024-11-30 12:49:35 -05:00
} else if newValue == .received {
2019-05-02 16:33:03 -04:00
transactionTypeImage.setImage(UIImage(named: "receivedArrow"))
2024-11-30 12:49:35 -05:00
} else if newValue == .sent {
2019-05-02 16:33:03 -04:00
transactionTypeImage.setImage(UIImage(named: "sentArrow"))
} else {
transactionTypeImage.setImage(nil)
}
}
}
}
2024-01-25 00:39:01 -04:00
// TransactionTableRow extension for configuration
extension TransactionTableRow {
func configure(with transaction: Transaction) {
2024-11-30 12:49:35 -05:00
amount = "\(transaction.amount)"
2024-01-25 00:39:01 -04:00
type = transaction.type
2024-11-30 12:49:35 -05:00
2024-01-25 00:39:01 -04:00
memo = transaction.memo
2024-11-30 12:49:35 -05:00
let formatter = DateFormatter()
formatter.dateStyle = .short
formatter.timeStyle = .short
time = formatter.string(from: transaction.time)
2024-01-25 00:39:01 -04:00
}
}