Member-only story
Swipe Gesture Navigation with SwiftUI
When I first began to develop my application interface I liked the idea of being able to swipe through each view instead of clicking on a tab bar (ie Twitter)
When I scoured the web as a swiftUI noob I could not find very many pertinent posts on implementing such functionality, so I figured I’d write this up. Hopefully it helps someone out there looking to achieve a similar result. The following will (hopefully) be easy to follow for someone with no swiftUI experience and will dive into a few key concepts present in the framework. So without further ado, let's get into it.
For clarities sake, I think it’s important to create an enum value to track what view the user is currently on. This will be defined as follows:
Now we can begin to build the first center view
This will be the view that the application starts in. It will be simple for this tutorials sake but you get the idea. Once we get our view to appear we can add a thing called a @State variable. In SwiftUI, state variables represent values that change the way our application looks. Our first state variable will tell the application which view is currently being show. We will use the enum values that we described above.