1

enter image description hereI have build a side menu with 4 cases and one of the is the Home

struct SideMenuSwitchView: View {
    
    private let viewModel: SideMenuViewModel
    
    init(viewmodel: SideMenuViewModel) {
        self.viewModel = viewmodel
    }

    
    var body: some View {
        switch viewModel {
        case .Home:
             HomeView()
        case .Users:
             UsersView()
        case .TODOs:
             TODOsView()
        case .AboutUs:
             AboutUsView()
        }
    }
}

that this option is already my default screen. With my code I call the items of side menu view and one case is the Home that is same as default screen. (Default screen = Home and presents an API)

 ForEach(SideMenuViewModel.allCases, id: \.self) { option in
                NavigationLink(destination: SideMenuSwitchView(viewmodel: option) , label: {SideMenuOptionView(viewModel: option)})
            }

I am going in a new link for Home, so I have 2 separate views with the same info.

How can I make HomeView Navigation Link option return as default screen? enter image description here

enter image description here

georgekak
  • 73
  • 11

1 Answers1

0

I do not understand your problem entirely, you need to share where is the first view that you are presenting.

But I suggest you add this to your HomeView and your problem will be solved

switch viewModel {
    case .Home:
         HomeView()
            .navigationBarHidden(true)
    case .Users:
         UsersView()
    case .TODOs:
         TODOsView()
    case .AboutUs:
         AboutUsView()
    }
Anas Alhalabi
  • 104
  • 1
  • 7