can someone please help me with this issue? I'm trying to detect the issue for like 2 hours now.
I want to switch view from LoginView() to RegistrationView() when button("Test") in LoginView() is pressed. I did try this solution but it does nothing. Any help is welcomed... i have no idea how to change to registrationView()
struct mainView: View {
@State var show = false
var body: some View {
return Group {
if show {
RegistrationView()
}
}
}
}
struct LoginView : View {
@Binding var show: Bool
@StateObject private var loginVM = LoginViewModel()
var body: some View {
ZStack {BGimg()
if !loginVM.isAuthenticated {
VStack() {
.ignoresSafeArea(.all)
UsernameTextField(username: $loginVM.username)
PasswordSecureField(password: $loginVM.password)
ForgotPassword()
Button(action: loginVM.login) {
LoginButtonContent()
})
Button("Test") {
show.toggle()
}
}
.navigationBarHidden(false)
}
else if loginVM.isAuthenticated {
Home()
.navigationBarItems(trailing:
Button(action: loginVM.signout) {
Text("Sign out")
}
)
}
}
}
struct LoginView_Previews: PreviewProvider {
static var previews: some View {
LoginView()
.previewDevice("iPhone 12 Pro")
}
}