ios – Shared view in a number of screens


I´m attempting to create a typical view on high of the toolbar (form of a notification) after the login is finished. This view solely be proven when the community is off.

I’ve the NavigationView declared within the login view:

@primary
struct iOSApp: App {
var physique: some Scene {
        WindowGroup {
           LoginView()           
        }
}

struct LoginView: View {
var physique: some View {
       ZStack{
        if !networkActive{
           CommonView()
         }// Do that as a result of i wanted the view on high of the toolbar and to be proven in all views
        NavigationView {
          //logic which ends up in the MainView after login efficiently
          //NavigationLink to MainView
     }
   }
 }
}
struct MainView: View {
  //It has to point out the CommonView when community is off

}
struct CommonView: View {
  //Frequent view

}

class CommonViewViewModel: ObservableObject{
   @Revealed var isActive = false

   //Different logic

}

I would like to point out the CommonView in all views and when click on on it navigate to a different display screen (all of this after the login is finished, not earlier than). Wasn’t in a position to obtain this with the answer above because the view shouldn’t be contained in the NavigationView and may’t navigate to a different view when tapped.

I additionally tried to wrap all views within the CommonView like this:

struct CommonView<Content material>: View the place Content material: View {

}

struct MainView: View {
  var physique: some View {
    CommonView{
      //Important view content material
    }

}

}

However i do not know if it is one of the best answer and in addition the Frequent view is beneath the toolbar

Any concepts?

Many thanks

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles