mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 17:35:54 +03:00
fixing login/account creation errors showing when navigating to another screen
- was caused by the lost focus callback being triggered by onPause, fixed by only triggering if the current view is in the resumed state
This commit is contained in:
parent
99de618bed
commit
f40cf13048
3 changed files with 11 additions and 4 deletions
|
@ -78,10 +78,15 @@ fun TextInputLayout.setOnImeDoneListener(action: () -> Unit) {
|
|||
}
|
||||
}
|
||||
|
||||
fun TextInputLayout.setOnFocusLostListener(action: () -> Unit) {
|
||||
/**
|
||||
* Set a listener for when the input has lost focus, such as moving to the another input field.
|
||||
* The listener is only called when the view is in a resumed state to avoid triggers when exiting a screen.
|
||||
*/
|
||||
fun TextInputLayout.setOnFocusLostListener(lifecycleOwner: LifecycleOwner, action: () -> Unit) {
|
||||
lifecycleOwner.lifecycle
|
||||
editText().setOnFocusChangeListener { _, hasFocus ->
|
||||
when (hasFocus) {
|
||||
false -> action()
|
||||
false -> lifecycleOwner.lifecycleScope.launchWhenResumed { action() }
|
||||
else -> {
|
||||
// do nothing
|
||||
}
|
||||
|
|
|
@ -63,7 +63,9 @@ class FtueAuthCombinedLoginFragment @Inject constructor(
|
|||
views.loginRoot.realignPercentagesToParent()
|
||||
views.editServerButton.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.EditServerSelection)) }
|
||||
views.loginPasswordInput.setOnImeDoneListener { submit() }
|
||||
views.loginInput.setOnFocusLostListener { viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content())) }
|
||||
views.loginInput.setOnFocusLostListener(viewLifecycleOwner) {
|
||||
viewModel.handle(OnboardingAction.UserNameEnteredAction.Login(views.loginInput.content()))
|
||||
}
|
||||
views.loginForgotPassword.debouncedClicks { viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnForgetPasswordClicked)) }
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
|
|||
views.createAccountEntryFooter.text = ""
|
||||
}
|
||||
|
||||
views.createAccountInput.setOnFocusLostListener {
|
||||
views.createAccountInput.setOnFocusLostListener(viewLifecycleOwner) {
|
||||
viewModel.handle(OnboardingAction.UserNameEnteredAction.Registration(views.createAccountInput.content()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue