diff --git a/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj b/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj index e051ddc2..e166f1fd 100644 --- a/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj +++ b/ui/BankingiOSApp/BankingiOSApp.xcodeproj/project.pbxproj @@ -48,6 +48,9 @@ 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 */; }; + 36BE069124CEF52800CBBB68 /* UpdateButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE069024CEF52800CBBB68 /* UpdateButton.swift */; }; + 36BE06B324CF133400CBBB68 /* JsonEncoderSerializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE06B224CF133400CBBB68 /* JsonEncoderSerializer.swift */; }; + 36BE06B524CF85A300CBBB68 /* AmountLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36BE06B424CF85A300CBBB68 /* AmountLabel.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 */; }; @@ -139,6 +142,9 @@ 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 = ""; }; + 36BE069024CEF52800CBBB68 /* UpdateButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateButton.swift; sourceTree = ""; }; + 36BE06B224CF133400CBBB68 /* JsonEncoderSerializer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsonEncoderSerializer.swift; sourceTree = ""; }; + 36BE06B424CF85A300CBBB68 /* AmountLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmountLabel.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; }; @@ -295,6 +301,7 @@ 36FC92D524B3A3BA002B12E9 /* NSUrlWebClient.swift */, 36BCF87524BF114F005BEC29 /* UrlSessionWebClient.swift */, 36BCF86B24BA5E72005BEC29 /* DispatchQueueAsyncRunner.swift */, + 36BE06B224CF133400CBBB68 /* JsonEncoderSerializer.swift */, ); path = fints4k; sourceTree = ""; @@ -312,6 +319,8 @@ 36BE068824CE288800CBBB68 /* CollapsibleText.swift */, 36BE068A24CE3B0400CBBB68 /* SwiftExtensions.swift */, 36BE068C24CE41E700CBBB68 /* Styles.swift */, + 36BE069024CEF52800CBBB68 /* UpdateButton.swift */, + 36BE06B424CF85A300CBBB68 /* AmountLabel.swift */, ); path = ui; sourceTree = ""; @@ -505,9 +514,11 @@ 36FC92A124B39A05002B12E9 /* BankingiOSApp.xcdatamodeld in Sources */, 36BCF89324C25BC3005BEC29 /* Mapper.swift in Sources */, 36FC92D724B3A3BA002B12E9 /* NSUrlWebClient.swift in Sources */, + 36BE06B324CF133400CBBB68 /* JsonEncoderSerializer.swift in Sources */, 36BCF89524C31F02005BEC29 /* AppData.swift in Sources */, 36BE065B24CA4B3500CBBB68 /* SelectBankDialog.swift in Sources */, 36BE068924CE288800CBBB68 /* CollapsibleText.swift in Sources */, + 36BE06B524CF85A300CBBB68 /* AmountLabel.swift in Sources */, 36BCF88324C098BB005BEC29 /* BankListItem.swift in Sources */, 36BCF88D24C1C1EA005BEC29 /* TransferMoneyDialog.swift in Sources */, 36E7BA1424B3D05C00757859 /* ViewExtensions.swift in Sources */, @@ -528,6 +539,7 @@ 366FA4DA24C472A90094F009 /* Extensions.swift in Sources */, 366FA4D824C46B160094F009 /* AutoCompleteList.swift in Sources */, 36BE068F24CEE1BD00CBBB68 /* AllBanksListItem.swift in Sources */, + 36BE069124CEF52800CBBB68 /* UpdateButton.swift in Sources */, 366FA4DC24C479120094F009 /* BankInfoListItem.swift in Sources */, 36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */, 36BCF88524C098C8005BEC29 /* BankAccountListItem.swift in Sources */, diff --git a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift index 1a027fb5..27516cd7 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift @@ -8,10 +8,17 @@ struct ContentView: View { @State private var selection = 0 + @State private var navigationBarTitle = "" + + @State private var leadingNavigationBarItem: AnyView? = nil + @State private var showTransferMoneyOptionsActionSheet = false @State private var selectedTransferMoneyOption: Int? = 0 + @Inject private var presenter: BankingPresenterSwift + + // TODO: remove again private let enterTanState: EnterTanState @@ -40,13 +47,23 @@ struct ContentView: View { VStack { TabView(selection: $selection) { AccountsTab(data: data) - .tabItem { - VStack { - Image("first") - Text("Accounts") - } + .onAppear { + // due to a SwiftUI bug this cannot be set in AccountsTab directly, so i have to do it here + self.navigationBarTitle = "Accounts" + self.leadingNavigationBarItem = AnyView(UpdateButton { _ in + self.presenter.updateAccountsTransactionsAsync { _ in } + }) + } + .onDisappear { + self.leadingNavigationBarItem = nil + } + .tabItem { + VStack { + Image("first") + Text("Accounts") } - .tag(0) + } + .tag(0) // actionSheet(isPresented: $showTransferMoneyOptionsActionSheet) { // ActionSheet( @@ -113,6 +130,9 @@ struct ContentView: View { .tag(2) } + .navigationBarHidden(false) + .navigationBarTitle(navigationBarTitle) + .navigationBarItems(leading: leadingNavigationBarItem) } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/UpdateButton.swift b/ui/BankingiOSApp/BankingiOSApp/ui/UpdateButton.swift new file mode 100644 index 00000000..d3e39a2d --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/UpdateButton.swift @@ -0,0 +1,35 @@ +import SwiftUI + + +struct UpdateButton: View { + + private let action: (Any?) -> Void + + private let actionParameter: Any? + + + init(_ action: @escaping (Any?) -> Void) { + self.init(actionParameter: nil, action) + } + + init(actionParameter: Any? = nil, _ action: @escaping (Any?) -> Void) { + self.action = action + + self.actionParameter = actionParameter + } + + + var body: some View { + Button( + action: { self.action(self.actionParameter) }, + label: { Image(systemName: "arrow.2.circlepath") } + ) + } +} + + +struct UpdateButton_Previews: PreviewProvider { + static var previews: some View { + UpdateButton( { _ in } ) + } +} diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift index 5d43078d..1c1982cc 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift @@ -79,10 +79,7 @@ struct AccountTransactionsDialog: View { } } .showNavigationBarTitle(LocalizedStringKey(title)) - .navigationBarItems(trailing: Button( - action: { self.retrieveTransactions() }, - label: { Image(systemName: "arrow.2.circlepath") } - )) + .navigationBarItems(trailing: UpdateButton { _ in self.retrieveTransactions() }) } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift index 1d21761f..f09f2fd4 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift @@ -7,7 +7,7 @@ struct AccountsTab: View { @Inject private var presenter: BankingPresenterSwift @ObservedObject var data: AppData - + var body: some View { VStack { @@ -29,7 +29,6 @@ struct AccountsTab: View { Spacer() } - .hideNavigationBar() } }