I am currently using a tabview to allow my app to scroll horizontally. At the end of the tabview the user ends up on a register page where they can either click login or sign up. When they click either I want to direct them to a new view where they can't scroll back to register page. Currently after they click login or sign up a new view pops up, but you can still scroll back to the previous pages in the tabview. Any help would be greatly appreciated.
Code:
struct ContentView: View {
var body: some View {
HStack {
TabView {
ForEach(0..<5) {i in
if(i == 0) {
FirstPageView()
} else if(i == 1) {
SecondPageView()
} else if(i == 2) {
ThirdPageView()
} else {
RegisterView()
}
}
}.tabViewStyle(PageTabViewStyle())
}
}
}
Register View:
struct RegisterView: View {
var body: some View {
let screen = UIScreen.main.bounds
let screen_width = screen.size.width
let screen_height = screen.size.height
let theme_color =
Color(hue: 0.636, saturation: 0.646, brightness: 0.994)
NavigationView{
VStack(alignment: .leading){
Text("Investing App.")
.foregroundColor(theme_color)
.fontWeight(.bold)
.font(.system(size:screen_width/8))
.padding(.leading)
Text("Start investing")
.fontWeight(.bold)
.font(.system(size:screen_width/8))
.padding(.leading)
Text("today.")
.fontWeight(.bold)
.font(.system(size:screen_width/8))
.padding(.leading)
NavigationLink(
destination: SignUpView(),
label: {
Text("Login")
.fontWeight(.bold)
.font(.system(size:screen_width/25))
.frame(width: screen_width/5, height: screen_width/9, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.padding(.horizontal, screen_width/3)
.overlay(
RoundedRectangle(cornerRadius: 100)
.stroke(lineWidth: 1)
)
})
.frame(maxWidth: .infinity, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.offset(y:screen_height/2.5)
NavigationLink(
destination: SignUpView(),
label: {
Text("Sign Up")
.fontWeight(.bold)
.font(.system(size:screen_width/25))
.frame(width: screen_width/5, height: screen_width/9, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.padding(.horizontal, screen_width/3)
.overlay(
RoundedRectangle(cornerRadius: 100)
.stroke(lineWidth: 1)
)
})
.frame(maxWidth: .infinity, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.offset(y:screen_height/5)
}
.padding()
.offset(y: -screen_height/4+42.4)
.frame(width: screen_width, height: screen_height/2, alignment: .leading)
.navigationBarHidden(true)
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
Thank you!