Extracted AccountTransactionListItem

This commit is contained in:
dankito 2020-07-26 18:34:16 +02:00
parent 330b40a9d6
commit 615c8e214d
2 changed files with 38 additions and 16 deletions

View File

@ -0,0 +1,37 @@
import SwiftUI
import BankingUiSwift
struct AccountTransactionListItem: View {
let transaction: AccountTransaction
@Inject private var presenter: BankingPresenterSwift
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(transaction.bookingText ?? "")
if transaction.showOtherPartyName {
Text(transaction.otherPartyName ?? "")
}
Text(transaction.usage)
}
Spacer()
VStack(alignment: .trailing) {
Text(self.presenter.formatAmount(amount: transaction.amount))
//Text(transaction.valueDate)
}
}
}
}
struct AccountTransactionListItem_Previews: PreviewProvider {
static var previews: some View {
AccountTransactionListItem(transaction: AccountTransaction(bankAccount: previewBanks[0].accounts[0], otherPartyName: "Marieke Musterfrau", unparsedUsage: "Vielen Dank für Ihre Mühen", amount: CommonBigDecimal(double: 1234.56), valueDate: CommonDate(year: 2020, month: .march, day_: 27), bookingText: "SEPA Überweisung"))
}
}

View File

@ -14,22 +14,7 @@ struct AccountTransactionsDialog: View {
var body: some View { var body: some View {
List(transactions.sorted(by: { $0.valueDate.date > $1.valueDate.date } ), id: \.technicalId) { transaction in List(transactions.sorted(by: { $0.valueDate.date > $1.valueDate.date } ), id: \.technicalId) { transaction in
HStack { AccountTransactionListItem(transaction: transaction)
VStack(alignment: .leading) {
Text(transaction.bookingText ?? "")
if transaction.showOtherPartyName {
Text(transaction.otherPartyName ?? "")
}
Text(transaction.usage)
}
Spacer()
VStack(alignment: .trailing) {
Text(self.presenter.formatAmount(amount: transaction.amount))
//Text(transaction.valueDate)
}
}
} }
.showNavigationBarTitle(LocalizedStringKey(title)) .showNavigationBarTitle(LocalizedStringKey(title))
.navigationBarHidden(false) .navigationBarHidden(false)