mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
Cleanup up this screen
This commit is contained in:
parent
9724c1b8ce
commit
acd5b656d2
5 changed files with 13 additions and 9 deletions
|
@ -113,13 +113,14 @@ class SoftLogoutController @Inject constructor(
|
||||||
loginPasswordFormItem {
|
loginPasswordFormItem {
|
||||||
id("passwordForm")
|
id("passwordForm")
|
||||||
stringProvider(host.stringProvider)
|
stringProvider(host.stringProvider)
|
||||||
|
passwordValue(state.enteredPassword)
|
||||||
passwordShown(state.passwordShown)
|
passwordShown(state.passwordShown)
|
||||||
submitEnabled(state.submitEnabled)
|
submitEnabled(state.enteredPassword.isNotEmpty())
|
||||||
onPasswordEdited { host.listener?.passwordEdited(it) }
|
onPasswordEdited { host.listener?.passwordEdited(it) }
|
||||||
errorText((state.asyncLoginAction as? Fail)?.error?.let { host.errorFormatter.toHumanReadable(it) })
|
errorText((state.asyncLoginAction as? Fail)?.error?.let { host.errorFormatter.toHumanReadable(it) })
|
||||||
passwordRevealClickListener { host.listener?.revealPasswordClicked() }
|
passwordRevealClickListener { host.listener?.revealPasswordClicked() }
|
||||||
forgetPasswordClickListener { host.listener?.forgetPasswordClicked() }
|
forgetPasswordClickListener { host.listener?.forgetPasswordClicked() }
|
||||||
submitClickListener { password -> host.listener?.signinSubmit(password) }
|
submitClickListener { host.listener?.submit() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is LoginMode.Sso -> {
|
is LoginMode.Sso -> {
|
||||||
|
@ -164,7 +165,7 @@ class SoftLogoutController @Inject constructor(
|
||||||
interface Listener {
|
interface Listener {
|
||||||
fun retry()
|
fun retry()
|
||||||
fun passwordEdited(password: String)
|
fun passwordEdited(password: String)
|
||||||
fun signinSubmit(password: String)
|
fun submit()
|
||||||
fun signinFallbackSubmit()
|
fun signinFallbackSubmit()
|
||||||
fun clearData()
|
fun clearData()
|
||||||
fun forgetPasswordClicked()
|
fun forgetPasswordClicked()
|
||||||
|
|
|
@ -107,9 +107,9 @@ class SoftLogoutFragment @Inject constructor(
|
||||||
softLogoutViewModel.handle(SoftLogoutAction.PasswordChanged(password))
|
softLogoutViewModel.handle(SoftLogoutAction.PasswordChanged(password))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun signinSubmit(password: String) {
|
override fun submit() = withState(softLogoutViewModel) { state ->
|
||||||
cleanupUi()
|
cleanupUi()
|
||||||
softLogoutViewModel.handle(SoftLogoutAction.SignInAgain(password))
|
softLogoutViewModel.handle(SoftLogoutAction.SignInAgain(state.enteredPassword))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun signinFallbackSubmit() = withState(loginViewModel) { state ->
|
override fun signinFallbackSubmit() = withState(loginViewModel) { state ->
|
||||||
|
|
|
@ -138,7 +138,7 @@ class SoftLogoutViewModel @AssistedInject constructor(
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
asyncLoginAction = Uninitialized,
|
asyncLoginAction = Uninitialized,
|
||||||
submitEnabled = action.password.isNotBlank()
|
enteredPassword = action.password
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ data class SoftLogoutViewState(
|
||||||
val userDisplayName: String,
|
val userDisplayName: String,
|
||||||
val hasUnsavedKeys: Boolean,
|
val hasUnsavedKeys: Boolean,
|
||||||
val passwordShown: Boolean = false,
|
val passwordShown: Boolean = false,
|
||||||
val submitEnabled: Boolean = false
|
val enteredPassword: String = ""
|
||||||
) : MvRxState {
|
) : MvRxState {
|
||||||
|
|
||||||
fun isLoading(): Boolean {
|
fun isLoading(): Boolean {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||||
import im.vector.app.core.epoxy.addTextChangedListenerOnce
|
import im.vector.app.core.epoxy.addTextChangedListenerOnce
|
||||||
import im.vector.app.core.epoxy.onClick
|
import im.vector.app.core.epoxy.onClick
|
||||||
|
import im.vector.app.core.epoxy.setValueOnce
|
||||||
import im.vector.app.core.extensions.showPassword
|
import im.vector.app.core.extensions.showPassword
|
||||||
import im.vector.app.core.platform.SimpleTextWatcher
|
import im.vector.app.core.platform.SimpleTextWatcher
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
|
@ -39,13 +40,14 @@ import im.vector.app.core.ui.views.RevealPasswordImageView
|
||||||
@EpoxyModelClass(layout = R.layout.item_login_password_form)
|
@EpoxyModelClass(layout = R.layout.item_login_password_form)
|
||||||
abstract class LoginPasswordFormItem : VectorEpoxyModel<LoginPasswordFormItem.Holder>() {
|
abstract class LoginPasswordFormItem : VectorEpoxyModel<LoginPasswordFormItem.Holder>() {
|
||||||
|
|
||||||
|
@EpoxyAttribute var passwordValue: String = ""
|
||||||
@EpoxyAttribute var passwordShown: Boolean = false
|
@EpoxyAttribute var passwordShown: Boolean = false
|
||||||
@EpoxyAttribute var submitEnabled: Boolean = false
|
@EpoxyAttribute var submitEnabled: Boolean = false
|
||||||
@EpoxyAttribute var errorText: String? = null
|
@EpoxyAttribute var errorText: String? = null
|
||||||
@EpoxyAttribute lateinit var stringProvider: StringProvider
|
@EpoxyAttribute lateinit var stringProvider: StringProvider
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var passwordRevealClickListener: ClickListener? = null
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var passwordRevealClickListener: ClickListener? = null
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var forgetPasswordClickListener: ClickListener? = null
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var forgetPasswordClickListener: ClickListener? = null
|
||||||
@EpoxyAttribute var submitClickListener: ((String) -> Unit)? = null
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var submitClickListener: ClickListener? = null
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var onPasswordEdited: TextListener? = null
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var onPasswordEdited: TextListener? = null
|
||||||
|
|
||||||
private val textChangeListener = object : SimpleTextWatcher() {
|
private val textChangeListener = object : SimpleTextWatcher() {
|
||||||
|
@ -63,7 +65,8 @@ abstract class LoginPasswordFormItem : VectorEpoxyModel<LoginPasswordFormItem.Ho
|
||||||
holder.passwordReveal.onClick(passwordRevealClickListener)
|
holder.passwordReveal.onClick(passwordRevealClickListener)
|
||||||
holder.forgetPassword.onClick(forgetPasswordClickListener)
|
holder.forgetPassword.onClick(forgetPasswordClickListener)
|
||||||
holder.submit.isEnabled = submitEnabled
|
holder.submit.isEnabled = submitEnabled
|
||||||
holder.submit.setOnClickListener { submitClickListener?.invoke(holder.passwordField.text.toString()) }
|
holder.submit.onClick(submitClickListener)
|
||||||
|
holder.setValueOnce(holder.passwordField, passwordValue)
|
||||||
holder.passwordField.addTextChangedListenerOnce(textChangeListener)
|
holder.passwordField.addTextChangedListenerOnce(textChangeListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue