Last active
December 4, 2020 17:08
-
-
Save adevone/780cba18cdcd6d5dc8d85a17a135631b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface LoginByPhoneView { | |
fun displayState(state: LoginByPhoneState) | |
} | |
enum class LoginByPhoneState { | |
Request, | |
Confirm | |
} | |
class LoginByPhonePresenter { | |
private var stateToApply: LoginByPhoneState? = null | |
private var view: LoginByPhoneView? = null | |
fun onViewCreated(view: LoginByPhoneView) { | |
this.view = view | |
if (stateToApply != null) { | |
view.displayState(stateToApply!!) | |
stateToApply = null | |
} | |
} | |
fun onViewDestroyed() { | |
this.view = null | |
} | |
fun onRequestCodeClick() { | |
launch { | |
val code = requestCodeRepository.execute() | |
if (view != null) { | |
view?.displayState(LoginByPhoneState.Confirm) | |
} else { | |
stateToApply = LoginByPhoneState.Confirm | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment