For Bugged
For Bugged

Reputation: 35

SwiftUI Navigation between different VIEWS

How can we navigate between independent screens (no option to go back) without modal or navigationview (list) approach?

Is there a way to do this?

Upvotes: 2

Views: 984

Answers (1)

Glenn Posadas
Glenn Posadas

Reputation: 13281

Welcome to Stackoverflow. Yes, there are ways to do that.

One great reference you can have is this Medium article: https://medium.com/swlh/customize-your-navigations-with-swiftui-173a72cd8a04

Its implementation of modalLink is not that complex to implement.

struct ContentView : View {
    @State var isPresented = false

    var body: some View {

        VStack {
            Button(action: {
                print("Button tapped")
                self.isPresented.toggle()
            }) {
               Text("LOGIN")
               .font(.headline)
               .foregroundColor(.white)
               .padding()
               .frame(width: 220, height: 60)
               .background(Color.green)
               .cornerRadius(15.0)
            }
        }.modalLink(isPresented: self.$isPresented, linkType: ModalTransition.fullScreenModal, destination: {
            DestinationView()
        })
    }
}

enter image description here

Upvotes: 2

Related Questions