Page Switching

In SwiftUI, tapping the search button does not switch to the search page.

Both SrhView () and PutView () do not switch the page.


         .navigationBarTitle("Title", displayMode: .inline)
        .navigationBarItems(
          leading:
            Button(action: {
              SrhView()
          }) {
            Image(systemName: "magnifyingglass")
        },
          trailing:
            Button(action: {
              PutView()
            }, label: {Text("PUt")}
        ))
Writing an initialization code of Views in Button actions does not make sense.

Write a code to show other views using NavigationLink or sheet or something else, and change the @State variable for it.

Page Switching
 
 
Q