0

Newbie here..

I've been watching a few tutorials on NavigationStack and had a question..

How do I implement a very simple navigation to a second view?

I have 2 buttons - a 'Play' button that should navigate to 'GameView' and an 'Options' button that should navigate to 'OptionsView'

What is the simplest way of implementing this? Most of the videos talk about passing a value and data types etc - which seems too complex for what I need to do..

Can I still use NavigationLink(destination,label)? or will it be deprecated?

Thank you!

struct MenuView: View {
    var body: some View {
        
        NavigationStack {
            ZStack {
                
                BackgroundComponent()
                
                VStack{
                    
                    Spacer()
                    
                    MainTitle(text: "Test")
                    
                    Spacer()
                    
                    NavigationLink(destination: {
                        GameView()
                    }, label: {
                        PrimaryButton(text: "PLAY")
                    })
                    
                    NavigationLink {
                        OptionsView()
                    } label: {
                        PrimaryButton(text: "OPTIONS")
                    }
                
                    
                }.padding()
            }
        }
    }
}
TheDoctor
  • 13
  • 4
  • Is your code working or not? `NavigationLink` will not be deprecated, not yet: https://developer.apple.com/documentation/swiftui/navigationlink – Alexnnd Jul 07 '23 at 15:30

0 Answers0