From 17fd1b047412c7883df35e184d5410484688b548 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 27 Jul 2020 13:38:27 +0200 Subject: [PATCH] Implemented AllBanksListItem --- .../BankingiOSApp.xcodeproj/project.pbxproj | 4 +++ .../Base.lproj/Localizable.strings | 1 + .../de.lproj/Localizable.strings | 1 + .../persistence/Extensions.swift | 9 +++++ .../ui/views/AccountTransactionsDialog.swift | 6 ++++ .../ui/views/AllBanksListItem.swift | 33 +++++++++++++++++++ 6 files changed, 54 insertions(+) create mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift diff --git a/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj b/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj index e0527604..e051ddc2 100644 --- a/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj +++ b/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj @@ -47,6 +47,7 @@ 36BE068924CE288800CBBB68 /* CollapsibleText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE068824CE288800CBBB68 /* CollapsibleText.swift */; }; 36BE068B24CE3B0400CBBB68 /* SwiftExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE068A24CE3B0400CBBB68 /* SwiftExtensions.swift */; }; 36BE068D24CE41E700CBBB68 /* Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE068C24CE41E700CBBB68 /* Styles.swift */; }; + 36BE068F24CEE1BD00CBBB68 /* AllBanksListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE068E24CEE1BD00CBBB68 /* AllBanksListItem.swift */; }; 36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */; }; 36FC929C24B39A05002B12E9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929B24B39A05002B12E9 /* AppDelegate.swift */; }; 36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36FC929D24B39A05002B12E9 /* SceneDelegate.swift */; }; @@ -137,6 +138,7 @@ 36BE068824CE288800CBBB68 /* CollapsibleText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollapsibleText.swift; sourceTree = ""; }; 36BE068A24CE3B0400CBBB68 /* SwiftExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftExtensions.swift; sourceTree = ""; }; 36BE068C24CE41E700CBBB68 /* Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Styles.swift; sourceTree = ""; }; + 36BE068E24CEE1BD00CBBB68 /* AllBanksListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllBanksListItem.swift; sourceTree = ""; }; 36E7BA1324B3D05C00757859 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = ""; }; 36E7BA1824B9E70C00757859 /* xcode-frameworks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "xcode-frameworks"; path = "../../tools/BankFinder/build/xcode-frameworks"; sourceTree = ""; }; 36FC929824B39A05002B12E9 /* BankingiOSApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BankingiOSApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -319,6 +321,7 @@ children = ( 36FC92DB24B3A4A0002B12E9 /* AccountsTab.swift */, 36FC92EE24B3BB81002B12E9 /* AddAccountDialog.swift */, + 36BE068E24CEE1BD00CBBB68 /* AllBanksListItem.swift */, 36BCF88224C098BB005BEC29 /* BankListItem.swift */, 36BCF88424C098C8005BEC29 /* BankAccountListItem.swift */, 36BCF88A24C0BD2D005BEC29 /* AccountTransactionsDialog.swift */, @@ -524,6 +527,7 @@ 36BCF88724C0A310005BEC29 /* PreviewData.swift in Sources */, 366FA4DA24C472A90094F009 /* Extensions.swift in Sources */, 366FA4D824C46B160094F009 /* AutoCompleteList.swift in Sources */, + 36BE068F24CEE1BD00CBBB68 /* AllBanksListItem.swift in Sources */, 366FA4DC24C479120094F009 /* BankInfoListItem.swift in Sources */, 36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */, 36BCF88524C098C8005BEC29 /* BankAccountListItem.swift in Sources */, diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings index dff088ed..46a5505a 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings @@ -10,6 +10,7 @@ "Bank" = "Bank"; "Account" = "Account"; "Accounts" = "Accounts"; +"All accounts" = "All accounts"; "Add account" = "Add account"; diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings index d5f33403..9a092bcb 100644 --- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings @@ -10,6 +10,7 @@ "Bank" = "Bank"; "Account" = "Konto"; "Accounts" = "Konten"; +"All accounts" = "Alle Konten"; "Add account" = "Konto hinzufügen"; diff --git a/ui/BankingiOSApp/BankingiOSApp/persistence/Extensions.swift b/ui/BankingiOSApp/BankingiOSApp/persistence/Extensions.swift index 4dabde71..ac92eaa9 100644 --- a/ui/BankingiOSApp/BankingiOSApp/persistence/Extensions.swift +++ b/ui/BankingiOSApp/BankingiOSApp/persistence/Extensions.swift @@ -21,6 +21,15 @@ extension AccountTransaction : Identifiable { } + +extension Array where Element == Customer { + + func sumBalances() -> CommonBigDecimal { + return CommonBigDecimal(decimal_: self.map { $0.balance.decimal }.sum()) + } + +} + extension Array where Element == AccountTransaction { func sumAmounts() -> CommonBigDecimal { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift index 6956b8ca..f3d20a7c 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift @@ -29,6 +29,12 @@ struct AccountTransactionsDialog: View { @Inject private var presenter: BankingPresenterSwift + + init(allBanks: [Customer]) { + self.init(title: "All accounts", transactions: allBanks.flatMap { $0.accounts }.flatMap { $0.bookedTransactions }, balance: allBanks.sumBalances()) + + presenter.selectedAllBankAccounts() + } init(bank: Customer) { self.init(title: bank.displayName, transactions: bank.accounts.flatMap { $0.bookedTransactions }, balance: bank.balance) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift new file mode 100644 index 00000000..bbec0d01 --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift @@ -0,0 +1,33 @@ +import SwiftUI +import BankingUiSwift + + +struct AllBanksListItem: View { + + let banks: [Customer] + + + var body: some View { + Section { + ZStack { + HStack { + Text("All accounts") + .font(.headline) + + Spacer() + }.frame(height: 35) + + NavigationLink(destination: LazyView(AccountTransactionsDialog(allBanks: self.banks))) { + EmptyView() + } + } + } + } +} + + +struct AllBanksListItem_Previews: PreviewProvider { + static var previews: some View { + AllBanksListItem(banks: previewBanks) + } +}