From 953e7312400faf2d251247f9d8a64bbea990fdbd Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 28 Jul 2020 11:19:39 +0200 Subject: [PATCH] Removed VStack - only caused navigation problems and NavigationView (has been replaced by UINavigationController as rootViewController); fixed intend --- .../BankingiOSApp/ContentView.swift | 116 +++++++++--------- 1 file changed, 56 insertions(+), 60 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift index ac04efec..17b4f816 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift @@ -20,68 +20,64 @@ struct ContentView: View { var body: some View { -// NavigationView { -// VStack { - TabView(selection: $selection) { - AccountsTab(data: data) - .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) - - VStack { - NavigationLink(destination: TransferMoneyDialog()) { - Text("Show transfer money dialog") - } - - NavigationLink(destination: TransferMoneyDialog().onDisappear(perform: { - NSLog("Disappearing NavigationLink") // TODO: remove - self.selectedTransferMoneyOption = 0 - }), tag: 1, selection: $selectedTransferMoneyOption) { - EmptyView() - } - - SheetPresenter(presentingSheet: $showTransferMoneyOptionsActionSheet, content: - ActionSheet( - title: Text(""), - buttons: [ - .default(Text("Show transfer money dialog")) { self.selectedTransferMoneyOption = 1 }, - .cancel() - ] - ) - ) - } - // } - .tabItem { - VStack { - Image(systemName: "plus.circle.fill") - } - } - .tag(1) - + TabView(selection: $selection) { + + /* First tab: Accounts */ + + AccountsTab(data: data) + .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) + + /* Second tab: 'New' action sheet button */ + + VStack { + NavigationLink(destination: TransferMoneyDialog()) { + Text("Show transfer money dialog") } - .navigationBarHidden(false) - .navigationBarTitle(navigationBarTitle) - .navigationBarItems(leading: leadingNavigationBarItem) - -// } - //.hideNavigationBar() - //.navigationViewStyle(StackNavigationViewStyle()) // see https://stackoverflow.com/questions/59338711/swiftui-bug-navigationview-and-list-not-showing-on-ipad-simulator-only -// } + NavigationLink(destination: TransferMoneyDialog().onDisappear(perform: { + NSLog("Disappearing NavigationLink") // TODO: remove + self.selectedTransferMoneyOption = 0 + }), tag: 1, selection: $selectedTransferMoneyOption) { + EmptyView() + } + + SheetPresenter(presentingSheet: $showTransferMoneyOptionsActionSheet, content: + ActionSheet( + title: Text(""), + buttons: [ + .default(Text("Show transfer money dialog")) { self.selectedTransferMoneyOption = 1 }, + .cancel() + ] + ) + ) + } + .tabItem { + VStack { + Image(systemName: "plus.circle.fill") + } + } + .tag(1) + + } + .navigationBarHidden(false) + .navigationBarTitle(navigationBarTitle) + .navigationBarItems(leading: leadingNavigationBarItem) } }