Learn Courses My Dashboard

How to change the view when tap sign in button?

@State private var email = ""
@State private var password = ""
@EnvironmentObject var session:SessionStore
@EnvironmentObject var viewRouter:ViewRouter

func signIn(email: email, password: password) { (result, error) in
    if let error = error {
        self.error = error.localizedDescription}
    else {
        self.email = ""
        self.password = ""
    }
}


var body: some View {
    
    if (error != "") {
        Text(error)
    }
    
    Button(action: {
        signIn()
        viewRouter.currentPage = .entrypage
        
    }, label: {
        Text("Sign In")
    })
    
}


When I tap Sign in button view change no matter if email and password are empty. I want to make condition when email or password are empty to show error and otherwise to sign in and change the view.```

put this

inside this

so

1 Like

if (result.success) { Error: Value of type ‘AuthDataResult?’ has no member ‘success’
viewRouter.currentPage = .entrypage

oh sorry not sure what it returns just assumed, check what functions or attributes “results” has by dot notation (just put a “.”) and it will automatically show a list of possible functions and attributes