Removed VStack - only caused navigation problems and NavigationView (has been replaced by UINavigationController as rootViewController); fixed intend

This commit is contained in:
dankito 2020-07-28 11:19:39 +02:00
parent 9572ae0206
commit 953e731240
1 changed files with 56 additions and 60 deletions

View File

@ -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)
}
}