Ok
thanks
I think we are not far from the result I expected
this is what I want to achieve?
when the app start it opens a MainView()
here is the MainView code
import SwiftUI
struct MainView: View {
var body: some View {
NavigationView {
VStack(spacing: 10) {
Spacer()
Text("Example en panne")
.font(.system(size: 40))
NavigationLink(destination: View1()
.navigationBarBackButtonHidden(true)
) {
VStack {
Image(systemName: "book")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 140, height: 140)
Text("Ma vue 1")
.font(.headline)
}
}
Spacer()
}
}
}
}
struct MainView_Previews: PreviewProvider {
static var previews: some View {
MainView()
}
}
from the MainView I call View1 or View2
Here is the code for View1
import SwiftUI
struct View1: View {
@State private var selectedTab = 0
@State private var showCopyright = false
var body: some View {
if showCopyright { // MUST BE INSIDE body
MainView() // Or whatever you call it ; it could also simply be a Text()
}
NavigationView {
TabView(selection: $selectedTab) {
maPage1()
.tabItem {
Image(systemName: "book")
Text("Page 1")
}
.tag(0)
maPage2()
.tabItem {
Image(systemName: "heart")
Text("Page 2")
}
.tag(1)
}
//.navigationBarTitleDisplayMode(.inline)
.navigationBarTitle("truc")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Menu {
Button(action: {
showCopyright = true // Show modal text for copyright
}) {
Label("Copyright", systemImage: "text.book.closed")
}
Button(action: {
// Go to HelpView
}) {
Label("HelpView", systemImage: "questionmark.circle")
}
} label: {
Image(systemName: "house")
}
}
}
}
}
}
and the CopyrightView is as such:
import SwiftUI
struct CopyrightView: View {
var body: some View {
Text("Here is the Copyright text en some details about the App")
}
}
struct CopyrightView_Previews: PreviewProvider {
static var previews: some View {
CopyrightView()
}
}
nothing fancy
the behavior I want:
when the app opens, It shows Mainview
when I click on the icon for View1 it opens View1
till now all is well
from View1 I want to click on the "house" icon in the contextual Menu to open MainView
the problem :
from the contextual Menu, it opens Mainview() now but but only on half of the screen,
the other part of the screen still show View1
Before I had nothing when I clicked on the icon for MainView in the contextual menu, now things get better
I hope I explain better
Thanks