-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForgotPasswordPresenter.kt
48 lines (38 loc) · 1.17 KB
/
ForgotPasswordPresenter.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.bamtech.multisport.mobile.onboarding
import com.bamtech.multisport.mobile.onboarding.ui.ForgotPasswordView
import com.bamtech.multisport.mobile.onboarding.utils.Validator
import javax.inject.Inject
/**
* Created by ugoamanoh on 8/10/17.
*/
class ForgotPasswordPresenter @Inject constructor(private val validator: Validator) {
private lateinit var view: ForgotPasswordView
fun attachView(view: ForgotPasswordView) {
this.view = view
view.showEnterEmailView()
}
fun onSubmit(email: String) {
view.hideKeyboard()
view.showEmailSentView(email)
}
fun onEmailTextChanged(text: CharSequence?) {
if (!text.isNullOrEmpty()) {
if (!validateEmail(text.toString())) {
view.showEmailError()
view.disableSubmitButton()
} else {
view.hideEmailError()
view.enableSubmitButton()
}
}
}
private fun validateEmail(email: String): Boolean {
return validator.validateEmail(email);
}
fun toolbarNavigationClicked() {
view.dismiss()
}
fun onLoginClicked() {
view.dismiss()
}
}