From 6b3e4b65c308707572a9edb5b2047a9d95eb7458 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 27 Jul 2020 12:12:41 +0200 Subject: [PATCH] Added convenience constructors for bank and bank accounts; settings now selected accounts so that we can use presenter.searchSelectedAccountTransactions() --- .../ui/views/AccountTransactionsDialog.swift | 16 ++++++++++++++-- .../ui/views/BankAccountListItem.swift | 2 +- .../BankingiOSApp/ui/views/BankListItem.swift | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift index be97332b..0f0f211a 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift @@ -28,9 +28,21 @@ struct AccountTransactionsDialog: View { @Inject private var presenter: BankingPresenterSwift + + init(bank: Customer) { + self.init(title: bank.displayName, transactions: bank.accounts.flatMap { $0.bookedTransactions }, balance: bank.balance) + + presenter.selectedAccount(customer: bank) + } - init(title: String, transactions: [AccountTransaction], balance: CommonBigDecimal) { + init(account: BankAccount) { + self.init(title: account.displayName, transactions: account.bookedTransactions, balance: account.balance) + + presenter.selectedBankAccount(bankAccount: account) + } + + fileprivate init(title: String, transactions: [AccountTransaction], balance: CommonBigDecimal) { self.title = title self.allTransactions = transactions @@ -66,7 +78,7 @@ struct AccountTransactionsDialog: View { private func filterTransactions(_ query: String) { - self.filteredTransactions = presenter.searchAccountTransactions(query: query, transactions: allTransactions) + self.filteredTransactions = presenter.searchSelectedAccountTransactions(query: query) self.balanceOfFilteredTransactions = query.isEmpty ? balanceOfAllTransactions : filteredTransactions.sumAmounts() } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift index 4dc62a34..1508d36d 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift @@ -14,7 +14,7 @@ struct BankAccountListItem : View { Spacer() }.frame(height: 35) - NavigationLink(destination: AccountTransactionsDialog(title: account.displayName, transactions: account.bookedTransactions, balance: account.balance)) { + NavigationLink(destination: AccountTransactionsDialog(account: account)) { EmptyView() } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift index c0f442a5..9f871054 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift @@ -17,7 +17,7 @@ struct BankListItem : View { Spacer() }.frame(height: 35) - NavigationLink(destination: AccountTransactionsDialog(title: bank.displayName, transactions: bank.accounts.flatMap { $0.bookedTransactions }, balance: bank.balance)) { + NavigationLink(destination: AccountTransactionsDialog(bank: bank)) { EmptyView() } }