Implemented filtering account transactions

This commit is contained in:
dankito 2020-07-27 00:05:55 +02:00
parent 6c82a63d64
commit 4ffb68eba4
3 changed files with 53 additions and 10 deletions

View File

@ -456,13 +456,17 @@ open class BankingPresenter(
open fun searchSelectedAccountTransactions(query: String): List<AccountTransaction> { open fun searchSelectedAccountTransactions(query: String): List<AccountTransaction> {
return searchAccountTransactions(query, selectedBankAccountsAccountTransactions)
}
open fun searchAccountTransactions(query: String, transactions: List<AccountTransaction>): List<AccountTransaction> {
val queryLowercase = query.trim().toLowerCase() val queryLowercase = query.trim().toLowerCase()
if (queryLowercase.isEmpty()) { if (queryLowercase.isEmpty()) {
return selectedBankAccountsAccountTransactions return transactions
} }
return selectedBankAccountsAccountTransactions.filter { return transactions.filter {
it.otherPartyName?.toLowerCase()?.contains(queryLowercase) == true it.otherPartyName?.toLowerCase()?.contains(queryLowercase) == true
|| it.usage.toLowerCase().contains(queryLowercase) || it.usage.toLowerCase().contains(queryLowercase)
|| it.bookingText?.toLowerCase()?.contains(queryLowercase) == true || it.bookingText?.toLowerCase()?.contains(queryLowercase) == true

View File

@ -12,7 +12,6 @@
366FA4DC24C479120094F009 /* BankInfoListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4DB24C479120094F009 /* BankInfoListItem.swift */; }; 366FA4DC24C479120094F009 /* BankInfoListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4DB24C479120094F009 /* BankInfoListItem.swift */; };
366FA4E024C4924A0094F009 /* RemitteeListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4DF24C4924A0094F009 /* RemitteeListItem.swift */; }; 366FA4E024C4924A0094F009 /* RemitteeListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4DF24C4924A0094F009 /* RemitteeListItem.swift */; };
366FA4E224C4ED6C0094F009 /* EnterTanDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4E124C4ED6C0094F009 /* EnterTanDialog.swift */; }; 366FA4E224C4ED6C0094F009 /* EnterTanDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4E124C4ED6C0094F009 /* EnterTanDialog.swift */; };
366FA4E424C4F2C70094F009 /* AppState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4E324C4F2C70094F009 /* AppState.swift */; };
366FA4E624C6EBF40094F009 /* EnterTanState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4E524C6EBF40094F009 /* EnterTanState.swift */; }; 366FA4E624C6EBF40094F009 /* EnterTanState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4E524C6EBF40094F009 /* EnterTanState.swift */; };
36BCF85424BA0C54005BEC29 /* BankList.json in Resources */ = {isa = PBXBuildFile; fileRef = 36BCF85324BA0C54005BEC29 /* BankList.json */; }; 36BCF85424BA0C54005BEC29 /* BankList.json in Resources */ = {isa = PBXBuildFile; fileRef = 36BCF85324BA0C54005BEC29 /* BankList.json */; };
36BCF85824BA4274005BEC29 /* BankingUiCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF85524BA41EE005BEC29 /* BankingUiCommon.framework */; }; 36BCF85824BA4274005BEC29 /* BankingUiCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 36BCF85524BA41EE005BEC29 /* BankingUiCommon.framework */; };
@ -44,6 +43,8 @@
36BE065924CA3CAB00CBBB68 /* UIKitSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE065824CA3CAB00CBBB68 /* UIKitSearchBar.swift */; }; 36BE065924CA3CAB00CBBB68 /* UIKitSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE065824CA3CAB00CBBB68 /* UIKitSearchBar.swift */; };
36BE065B24CA4B3500CBBB68 /* SelectBankDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE065A24CA4B3500CBBB68 /* SelectBankDialog.swift */; }; 36BE065B24CA4B3500CBBB68 /* SelectBankDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE065A24CA4B3500CBBB68 /* SelectBankDialog.swift */; };
36BE065D24CB08FC00CBBB68 /* LazyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE065C24CB08FB00CBBB68 /* LazyView.swift */; }; 36BE065D24CB08FC00CBBB68 /* LazyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE065C24CB08FB00CBBB68 /* LazyView.swift */; };
36BE066524CDE62800CBBB68 /* AccountTransactionListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE066424CDE62800CBBB68 /* AccountTransactionListItem.swift */; };
36BE068924CE288800CBBB68 /* CollapsibleText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE068824CE288800CBBB68 /* CollapsibleText.swift */; };
36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */; }; 36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */; };
36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929B24B39A05002B12E9 /* AppDelegate.swift */; }; 36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929B24B39A05002B12E9 /* AppDelegate.swift */; };
36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929D24B39A05002B12E9 /* SceneDelegate.swift */; }; 36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929D24B39A05002B12E9 /* SceneDelegate.swift */; };
@ -104,7 +105,6 @@
366FA4DB24C479120094F009 /* BankInfoListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankInfoListItem.swift; sourceTree = "<group>"; }; 366FA4DB24C479120094F009 /* BankInfoListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankInfoListItem.swift; sourceTree = "<group>"; };
366FA4DF24C4924A0094F009 /* RemitteeListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemitteeListItem.swift; sourceTree = "<group>"; }; 366FA4DF24C4924A0094F009 /* RemitteeListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemitteeListItem.swift; sourceTree = "<group>"; };
366FA4E124C4ED6C0094F009 /* EnterTanDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnterTanDialog.swift; sourceTree = "<group>"; }; 366FA4E124C4ED6C0094F009 /* EnterTanDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnterTanDialog.swift; sourceTree = "<group>"; };
366FA4E324C4F2C70094F009 /* AppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppState.swift; sourceTree = "<group>"; };
366FA4E524C6EBF40094F009 /* EnterTanState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnterTanState.swift; sourceTree = "<group>"; }; 366FA4E524C6EBF40094F009 /* EnterTanState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnterTanState.swift; sourceTree = "<group>"; };
36BCF85324BA0C54005BEC29 /* BankList.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = BankList.json; path = ../../../tools/BankFinder/src/commonMain/resources/BankList.json; sourceTree = "<group>"; }; 36BCF85324BA0C54005BEC29 /* BankList.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = BankList.json; path = ../../../tools/BankFinder/src/commonMain/resources/BankList.json; sourceTree = "<group>"; };
36BCF85524BA41EE005BEC29 /* BankingUiCommon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BankingUiCommon.framework; path = "../BankingUiCommon/build/xcode-frameworks/BankingUiCommon.framework"; sourceTree = "<group>"; }; 36BCF85524BA41EE005BEC29 /* BankingUiCommon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BankingUiCommon.framework; path = "../BankingUiCommon/build/xcode-frameworks/BankingUiCommon.framework"; sourceTree = "<group>"; };
@ -131,6 +131,8 @@
36BE065824CA3CAB00CBBB68 /* UIKitSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitSearchBar.swift; sourceTree = "<group>"; }; 36BE065824CA3CAB00CBBB68 /* UIKitSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitSearchBar.swift; sourceTree = "<group>"; };
36BE065A24CA4B3500CBBB68 /* SelectBankDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectBankDialog.swift; sourceTree = "<group>"; }; 36BE065A24CA4B3500CBBB68 /* SelectBankDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectBankDialog.swift; sourceTree = "<group>"; };
36BE065C24CB08FB00CBBB68 /* LazyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyView.swift; sourceTree = "<group>"; }; 36BE065C24CB08FB00CBBB68 /* LazyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyView.swift; sourceTree = "<group>"; };
36BE066424CDE62800CBBB68 /* AccountTransactionListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountTransactionListItem.swift; sourceTree = "<group>"; };
36BE068824CE288800CBBB68 /* CollapsibleText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollapsibleText.swift; sourceTree = "<group>"; };
36E7BA1324B3D05C00757859 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = "<group>"; }; 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = "<group>"; };
36E7BA1824B9E70C00757859 /* xcode-frameworks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "xcode-frameworks"; path = "../../tools/BankFinder/build/xcode-frameworks"; sourceTree = "<group>"; }; 36E7BA1824B9E70C00757859 /* xcode-frameworks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "xcode-frameworks"; path = "../../tools/BankFinder/build/xcode-frameworks"; sourceTree = "<group>"; };
36FC929824B39A05002B12E9 /* BankingiOSApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BankingiOSApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36FC929824B39A05002B12E9 /* BankingiOSApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BankingiOSApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -193,7 +195,6 @@
36BCF89024C25971005BEC29 /* CoreDataBankingPersistence.swift */, 36BCF89024C25971005BEC29 /* CoreDataBankingPersistence.swift */,
36BCF89224C25BC3005BEC29 /* Mapper.swift */, 36BCF89224C25BC3005BEC29 /* Mapper.swift */,
36BCF89424C31F02005BEC29 /* AppData.swift */, 36BCF89424C31F02005BEC29 /* AppData.swift */,
366FA4E324C4F2C70094F009 /* AppState.swift */,
366FA4D924C472A90094F009 /* Extensions.swift */, 366FA4D924C472A90094F009 /* Extensions.swift */,
366FA4E524C6EBF40094F009 /* EnterTanState.swift */, 366FA4E524C6EBF40094F009 /* EnterTanState.swift */,
); );
@ -302,6 +303,7 @@
36BCF88824C0A7D7005BEC29 /* Message.swift */, 36BCF88824C0A7D7005BEC29 /* Message.swift */,
36BCF88E24C1DFF7005BEC29 /* SheetPresenter.swift */, 36BCF88E24C1DFF7005BEC29 /* SheetPresenter.swift */,
366FA4D724C46B160094F009 /* AutoCompleteList.swift */, 366FA4D724C46B160094F009 /* AutoCompleteList.swift */,
36BE068824CE288800CBBB68 /* CollapsibleText.swift */,
); );
path = ui; path = ui;
sourceTree = "<group>"; sourceTree = "<group>";
@ -314,6 +316,7 @@
36BCF88224C098BB005BEC29 /* BankListItem.swift */, 36BCF88224C098BB005BEC29 /* BankListItem.swift */,
36BCF88424C098C8005BEC29 /* BankAccountListItem.swift */, 36BCF88424C098C8005BEC29 /* BankAccountListItem.swift */,
36BCF88A24C0BD2D005BEC29 /* AccountTransactionsDialog.swift */, 36BCF88A24C0BD2D005BEC29 /* AccountTransactionsDialog.swift */,
36BE066424CDE62800CBBB68 /* AccountTransactionListItem.swift */,
36BCF88C24C1C1EA005BEC29 /* TransferMoneyDialog.swift */, 36BCF88C24C1C1EA005BEC29 /* TransferMoneyDialog.swift */,
366FA4DB24C479120094F009 /* BankInfoListItem.swift */, 366FA4DB24C479120094F009 /* BankInfoListItem.swift */,
366FA4DF24C4924A0094F009 /* RemitteeListItem.swift */, 366FA4DF24C4924A0094F009 /* RemitteeListItem.swift */,
@ -494,6 +497,7 @@
36FC92D724B3A3BA002B12E9 /* NSUrlWebClient.swift in Sources */, 36FC92D724B3A3BA002B12E9 /* NSUrlWebClient.swift in Sources */,
36BCF89524C31F02005BEC29 /* AppData.swift in Sources */, 36BCF89524C31F02005BEC29 /* AppData.swift in Sources */,
36BE065B24CA4B3500CBBB68 /* SelectBankDialog.swift in Sources */, 36BE065B24CA4B3500CBBB68 /* SelectBankDialog.swift in Sources */,
36BE068924CE288800CBBB68 /* CollapsibleText.swift in Sources */,
36BCF88324C098BB005BEC29 /* BankListItem.swift in Sources */, 36BCF88324C098BB005BEC29 /* BankListItem.swift in Sources */,
36BCF88D24C1C1EA005BEC29 /* TransferMoneyDialog.swift in Sources */, 36BCF88D24C1C1EA005BEC29 /* TransferMoneyDialog.swift in Sources */,
36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */, 36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */,
@ -513,10 +517,10 @@
366FA4DA24C472A90094F009 /* Extensions.swift in Sources */, 366FA4DA24C472A90094F009 /* Extensions.swift in Sources */,
366FA4D824C46B160094F009 /* AutoCompleteList.swift in Sources */, 366FA4D824C46B160094F009 /* AutoCompleteList.swift in Sources */,
366FA4DC24C479120094F009 /* BankInfoListItem.swift in Sources */, 366FA4DC24C479120094F009 /* BankInfoListItem.swift in Sources */,
366FA4E424C4F2C70094F009 /* AppState.swift in Sources */,
36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */, 36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */,
36BCF88524C098C8005BEC29 /* BankAccountListItem.swift in Sources */, 36BCF88524C098C8005BEC29 /* BankAccountListItem.swift in Sources */,
36FC92EF24B3BB81002B12E9 /* AddAccountDialog.swift in Sources */, 36FC92EF24B3BB81002B12E9 /* AddAccountDialog.swift in Sources */,
36BE066524CDE62800CBBB68 /* AccountTransactionListItem.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -4,21 +4,56 @@ import BankingUiSwift
struct AccountTransactionsDialog: View { struct AccountTransactionsDialog: View {
var title: String private var title: String
var transactions: [AccountTransaction] private var allTransactions: [AccountTransaction]
@State private var filteredTransactions: [AccountTransaction]
@State private var searchText = ""
private var searchTextBinding: Binding<String> {
Binding<String>(
get: { self.searchText },
set: {
self.searchText = $0
self.filterTransactions($0)
})
}
@Inject private var presenter: BankingPresenterSwift @Inject private var presenter: BankingPresenterSwift
init(title: String, transactions: [AccountTransaction]) {
self.title = title
self.allTransactions = transactions
self._filteredTransactions = State(initialValue: transactions)
}
var body: some View { var body: some View {
List(transactions.sorted(by: { $0.valueDate.date > $1.valueDate.date } ), id: \.technicalId) { transaction in Form {
AccountTransactionListItem(transaction) Section {
UIKitSearchBar(text: searchTextBinding)
}
Section {
List(filteredTransactions.sorted(by: { $0.valueDate.date > $1.valueDate.date } ), id: \.technicalId) { transaction in
AccountTransactionListItem(transaction)
}
}
} }
.showNavigationBarTitle(LocalizedStringKey(title)) .showNavigationBarTitle(LocalizedStringKey(title))
.navigationBarHidden(false) .navigationBarHidden(false)
} }
private func filterTransactions(_ query: String) {
self.filteredTransactions = presenter.searchAccountTransactions(query: query, transactions: allTransactions)
}
} }