Why can't I redirect on my homepage after the correct login?

29 Views Asked by At

After the correct login, I would like to move from loginpageview() to the homepageview().

Button(action: {
    if username == "admin" && password == "1234" {
        isLoggedIn = true
        NavigationLink(
            destination: LoginView().navigationBarBackButtonHidden(true), label: {
                Text("Login")
                    .font(.headline)
                    .foregroundColor(.white)
                    .padding()
                    .frame(width: 200, height: 50)
                    .background(Color(red: 0.35, green: 0.47, blue: 0.51))
                    .cornerRadius(10)
                    .shadow(color: Color.black.opacity(0.1), radius: 2, x: 5, y: 2)
                    .overlay(
                        RoundedRectangle(cornerRadius: 20)
                            .stroke(.white, lineWidth: 2)
                    )
                    .offset(y:-20)
            })
    } else {
        showInvalidCredentialsAlert = true
    }
})
0

There are 0 best solutions below