I have a problem, after I register a new user, the app goes back to the main menu (using a NavigationLink), then if I choose one of the options in the menu, in the next view I have 2 navigation bars.
Im working with NavigationView in the MainView.
struct ContentView: View {
var body: some View {
NavigationView {
MainView()
}
}
}
struct MainView: View {
var body: some View {
VStack {
NavigationLink(
destination: AuthView(),
label: {
Text("Sesion")
})
}
}
}
struct AuthView: View {
@State private var email: String = ""
@State private var password: String = ""
let lightGreyColor = Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0, opacity: 1.0)
var body: some View {
VStack() {
NavigationLink(
destination: RegisterView(),
label: {
Text("Registrarse")
.font(.headline)
.foregroundColor(.white)
.padding()
.frame(width: 200, height: 60)
.background(Color.green)
.cornerRadius(15.0)
})
}
}
.padding()
.navigationBarTitle("Autenticacion")
.navigationBarTitleDisplayMode(.inline)
}
struct RegisterView: View {
@ObservedObject var registerController = RegisterController()
@State private var showingRegistrationAlert = false
@State var navigateNext = false
let lightGreyColor = Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0, opacity: 1.0)
var body: some View {
VStack {
VStack(alignment: .leading) {
Spacer()
NavigationLink(destination: ContentView(), isActive:$navigateNext) {
Text("")
}
Button(action: { if registerController.validateRegistration() {
showingRegistrationAlert.toggle()
}}) {
Text("Enviar registro")
}
.alert(isPresented: $showingRegistrationAlert) {
Alert(title: Text("Se registro correctamente"), dismissButton: .default(Text("Ok"), action: {
navigateNext.toggle()
}))
}
.padding()
.navigationBarTitle(Text("Registracion"), displayMode: .inline)
}
}
I tried to put the less code possible, sorry if it's a lot.
