Navigation in a complex multiview app in SwiftUI

207 views Asked by At

I am creating quite a complex Multiview SwiftUI app. Is there any way to create several separate files for each ContentView and navigate between them or do I have to put everything into the main ContentView file?

What I tried and looks the best for now is:

import SwiftUI
import Combine

(...)
     
struct SomeOtherContentViewInAnotherFile: View {
            
            @State var isPresenting = false
            
        
        (...)
        
        var body: some View {
        NavigationView{
    VStack{
        
        (...)
                    
         Button("Go Back"){
                        isPresenting = true
                    }
                    NavigationLink(destination:ContentView(), isActive: $isPresenting)
                    
                    }.padding() }
        }
        }

But it throws out the following error:

"Missing argument for parameter #1 in call
Insert '<#LocalizedStringKey#>, '"

Can you help?

0

There are 0 answers