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 { var body: some View {
// NavigationView { TabView(selection: $selection) {
// VStack {
TabView(selection: $selection) { /* First tab: Accounts */
AccountsTab(data: data)
.onAppear { AccountsTab(data: data)
// due to a SwiftUI bug this cannot be set in AccountsTab directly, so i have to do it here .onAppear {
self.navigationBarTitle = "Accounts" // due to a SwiftUI bug this cannot be set in AccountsTab directly, so i have to do it here
self.leadingNavigationBarItem = AnyView(UpdateButton { _ in self.navigationBarTitle = "Accounts"
self.presenter.updateAccountsTransactionsAsync { _ in } self.leadingNavigationBarItem = AnyView(UpdateButton { _ in
}) self.presenter.updateAccountsTransactionsAsync { _ in }
} })
.onDisappear { }
self.leadingNavigationBarItem = nil .onDisappear {
} self.leadingNavigationBarItem = nil
.tabItem { }
VStack { .tabItem {
Image("first") VStack {
Text("Accounts") Image("first")
} Text("Accounts")
} }
.tag(0) }
.tag(0)
VStack {
NavigationLink(destination: TransferMoneyDialog()) { /* Second tab: 'New' action sheet button */
Text("Show transfer money dialog")
} VStack {
NavigationLink(destination: TransferMoneyDialog()) {
NavigationLink(destination: TransferMoneyDialog().onDisappear(perform: { Text("Show transfer money dialog")
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)
NavigationLink(destination: TransferMoneyDialog().onDisappear(perform: {
// } NSLog("Disappearing NavigationLink") // TODO: remove
//.hideNavigationBar() self.selectedTransferMoneyOption = 0
//.navigationViewStyle(StackNavigationViewStyle()) // see https://stackoverflow.com/questions/59338711/swiftui-bug-navigationview-and-list-not-showing-on-ipad-simulator-only }), 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)
} }
} }