Commit f5ee4da1 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

resolve on error auth editText issue

parent 5d067764
......@@ -19,6 +19,7 @@ import com.biganto.visual.roompark.util.monades.ExceptionString
import com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import com.hannesdorfmann.mosby3.mvi.MviBasePresenter
import io.reactivex.disposables.CompositeDisposable
import timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 28.05.2018.
......@@ -47,7 +48,14 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
lateinit var toolBar: ICollapsingToolBar
lateinit var snackbar: ISnackBarProvider
override fun onAttach(view: View) {
Timber.d("On Attach")
super.onAttach(view)
}
override fun onDetach(view: View) {
Timber.d("On Detach")
detachDisposable.clear()
super.onDetach(view)
}
......
......@@ -12,9 +12,11 @@ import com.bluelinelabs.conductor.RouterTransaction
import com.google.android.material.button.MaterialButton
import com.google.android.material.textfield.TextInputLayout
import com.jakewharton.rxbinding3.view.clicks
import com.jakewharton.rxbinding3.widget.textChanges
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Inject
/**
......@@ -26,19 +28,24 @@ class AuthScreenController :
, AuthScreen
, AuthScreenPresenter>()
, AuthScreen {
override fun onViewBound(v: View) {
toolBar.hideAll()
bottomNavigation.hide()
}
@BindView(R.id.login_text_input) lateinit var loginInput:TextInputLayout
@BindView(R.id.password_text_input) lateinit var pwdInput:TextInputLayout
@BindView(R.id.sign_in_button) lateinit var signInButton:MaterialButton
override fun tryAuth(): Observable<AuthInputModel> =
signInButton.clicks()
.debounce (200L,TimeUnit.MILLISECONDS)
.doOnNext { signInButton.hideKeyboard() }
.map<AuthInputModel> {
AuthInputModel(
......@@ -52,6 +59,27 @@ class AuthScreenController :
getComponent()
}
override fun onAttach(view: View) {
super.onAttach(view)
detachDisposable.addAll(
loginInput.editText?.textChanges()
?.doOnNext { Timber.d("loginInput.isErrorEnabled ${loginInput.isErrorEnabled}")}
?.filter { loginInput.isErrorEnabled }
?.subscribe {
Timber.d("got key $it")
loginInput.isErrorEnabled = false
loginInput.error = null
signInButton.isEnabled=true
},
pwdInput.editText?.textChanges()
?.filter { pwdInput.isErrorEnabled }
?.subscribe { pwdInput.isErrorEnabled = false
signInButton.isEnabled=true
}
)
}
@Inject
lateinit var bottomNavigation: IBottomNavigation
......@@ -114,7 +142,6 @@ class AuthScreenController :
{strId -> loginInput.error = resources?.getString(strId)},
{message -> loginInput.error = message}
)
signInButton.isEnabled=true
}
private fun render(viewState: AuthScreenViewState.WrongPassword){
......@@ -124,10 +151,10 @@ class AuthScreenController :
{strId -> pwdInput.error = resources?.getString(strId)},
{message -> pwdInput.error = message}
)
signInButton.isEnabled=true
}
private fun render(viewState: AuthScreenViewState.SomeError) =
showError(viewState.exception)
......
......@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.auth
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.AuthInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
......@@ -18,6 +19,18 @@ class AuthScreenPresenter @Inject constructor(
)
: BigantoBasePresenter<AuthScreen, AuthScreenViewState>() {
override fun attachView(view: AuthScreen) {
super.attachView(view)
Timber.d("on AttachView")
restoreStateObservable.accept(AuthScreenViewState.Idle())
}
override fun detachView() {
super.detachView()
Timber.d("on DetachView")
restoreStateObservable }
override fun defaultErrorViewStateHandler() =
{e:ExceptionString -> AuthScreenViewState.SomeError(e)}
......@@ -38,8 +51,9 @@ class AuthScreenPresenter @Inject constructor(
.map { it }
.map<AuthScreenViewState> { AuthScreenViewState.SignedIn() }
.onErrorReturn{parseError(it)}
.startWith(Observable.just(AuthScreenViewState.Authorization()))
}
// .startWith(Observable.just(AuthScreenViewState.Authorization()))
val state = restoreStateObservable
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/colorAccent" />
<item android:color="@color/colorGray" />
<item android:state_enabled="false" android:color="@color/colorGray" />
<item android:color="@color/colorAccent" />
</selector>
\ No newline at end of file
......@@ -41,6 +41,7 @@
<style name="Auth.ErrorText" parent="TextAppearance.Design.Error">
<item name="android:textColor">@color/colorError</item>
<item name="android:textSize">@dimen/lite_notice</item>
</style>
<style name="Auth.EditText" parent="Widget.AppCompat.EditText">
......@@ -151,6 +152,7 @@
<style name="AuthButton.Enable">
<item name="android:text">"ВОЙТИ"</item>
<item name="android:textColor">@color/sign_in_button_selector</item>
<item name="strokeColor">@color/sign_in_button_selector</item>
</style>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment