Implemented showing either booking text or other party name

This commit is contained in:
dankito 2020-07-26 19:06:25 +02:00
parent b2b11b17bd
commit 0ece2b1bf5
1 changed files with 16 additions and 4 deletions

View File

@ -22,10 +22,8 @@ struct AccountTransactionListItem: View {
var body: some View { var body: some View {
HStack { HStack {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text(transaction.bookingText ?? "") Text(getTransactionLabel(transaction))
if transaction.showOtherPartyName {
Text(transaction.otherPartyName ?? "")
}
Text(transaction.usage) Text(transaction.usage)
} }
@ -40,6 +38,20 @@ struct AccountTransactionListItem: View {
} }
} }
} }
private func getTransactionLabel(_ transaction: AccountTransaction) -> String {
if transaction.bookingText?.localizedCaseInsensitiveCompare("Bargeldauszahlung") == ComparisonResult.orderedSame {
return transaction.bookingText ?? ""
}
if transaction.showOtherPartyName {
return transaction.otherPartyName ?? ""
}
return transaction.bookingText ?? ""
}
} }
struct AccountTransactionListItem_Previews: PreviewProvider { struct AccountTransactionListItem_Previews: PreviewProvider {