BlueWallet/ios/BlueWalletWatch Extension/Objects/TransactionTableRow.swift
Marcos Rodriguez Velez 29ed39a599 REF: Foundation for watchOS app
Smaller PR
2024-11-20 02:30:31 -04:00

66 lines
1.7 KiB
Swift

//
// TransactionTableRow.swift
// BlueWalletWatch Extension
//
// Created by Marcos Rodriguez on 3/10/19.
//
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 {
if type == .pending || type == .pending_transaction {
transactionTimeLabel.setText("Pending...")
} else {
transactionTimeLabel.setText(newValue)
}
}
}
var type: TransactionType = .pending {
willSet {
if (newValue == .pending_transaction || newValue == .pending) {
transactionTypeImage.setImage(UIImage(named: "pendingConfirmation"))
} else if (newValue == .received) {
transactionTypeImage.setImage(UIImage(named: "receivedArrow"))
} else if (newValue == .sent) {
transactionTypeImage.setImage(UIImage(named: "sentArrow"))
} else {
transactionTypeImage.setImage(nil)
}
}
}
}
// TransactionTableRow extension for configuration
extension TransactionTableRow {
func configure(with transaction: Transaction) {
amount = transaction.amount
type = transaction.type
memo = transaction.memo
time = transaction.time
}
}