2

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?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much! That's what I was looking for. Can we also animate those transitions between states?
@ForBugged absolutely. However I believe you will need to use MenuView for that. See the finished project of the reference I gave you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.