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

refactoring

parent 5d7e5a33
...@@ -63,24 +63,22 @@ class AuthScreenController : ...@@ -63,24 +63,22 @@ class AuthScreenController :
super.onAttach(view) super.onAttach(view)
detachDisposable.addAll( detachDisposable.addAll(
loginInput.editText?.textChanges() loginInput.editText?.textChanges()
?.doOnNext { Timber.d("loginInput.isErrorEnabled ${loginInput.isErrorEnabled}")}
?.filter { loginInput.isErrorEnabled } ?.filter { loginInput.isErrorEnabled }
?.subscribe { ?.subscribe {
Timber.d("got key $it")
loginInput.isErrorEnabled = false loginInput.isErrorEnabled = false
loginInput.error = null loginInput.error = null
signInButton.isEnabled=true signInButton.isEnabled=true
}, },
pwdInput.editText?.textChanges() pwdInput.editText?.textChanges()
?.filter { pwdInput.isErrorEnabled } ?.filter { pwdInput.isErrorEnabled }
?.subscribe { pwdInput.isErrorEnabled = false ?.subscribe {
pwdInput.isErrorEnabled = false
pwdInput.error = null
signInButton.isEnabled=true signInButton.isEnabled=true
} }
) )
} }
@Inject @Inject
lateinit var bottomNavigation: IBottomNavigation lateinit var bottomNavigation: IBottomNavigation
...@@ -97,9 +95,6 @@ class AuthScreenController : ...@@ -97,9 +95,6 @@ class AuthScreenController :
.create(RoomParkApplication.component,activity as RoomParkMainActivity) .create(RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this) .inject(this)
// @Inject
// lateinit var ac: RoomParkMainActivity
override fun render(viewState: AuthScreenViewState) { override fun render(viewState: AuthScreenViewState) {
super.render(viewState) super.render(viewState)
Timber.d("Render state $viewState") Timber.d("Render state $viewState")
...@@ -115,7 +110,11 @@ class AuthScreenController : ...@@ -115,7 +110,11 @@ class AuthScreenController :
} }
private fun render(viewState: AuthScreenViewState.Idle){ private fun render(viewState: AuthScreenViewState.Idle){
loginInput.isErrorEnabled = false
loginInput.error = null
pwdInput.isErrorEnabled = false
pwdInput.error = null
signInButton.isEnabled=true
} }
private fun render(viewState: AuthScreenViewState.Authorization){ private fun render(viewState: AuthScreenViewState.Authorization){
...@@ -154,9 +153,10 @@ class AuthScreenController : ...@@ -154,9 +153,10 @@ class AuthScreenController :
} }
private fun render(viewState: AuthScreenViewState.SomeError) {
private fun render(viewState: AuthScreenViewState.SomeError) =
showError(viewState.exception) showError(viewState.exception)
signInButton.isEnabled=true
}
override fun getLayoutId(): Int = R.layout.authentication_screen override fun getLayoutId(): Int = R.layout.authentication_screen
......
...@@ -19,24 +19,11 @@ class AuthScreenPresenter @Inject constructor( ...@@ -19,24 +19,11 @@ class AuthScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<AuthScreen, AuthScreenViewState>() { : 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() = override fun defaultErrorViewStateHandler() =
{e:ExceptionString -> AuthScreenViewState.SomeError(e)} {e:ExceptionString -> AuthScreenViewState.SomeError(e)}
override fun vsByCode(code: Int): (ExceptionString) -> AuthScreenViewState = override fun vsByCode(code: Int): (ExceptionString) -> AuthScreenViewState =
when (code) { when (code) {
101 -> {e:ExceptionString -> AuthScreenViewState.SignInError(e)}
111 -> {e:ExceptionString -> AuthScreenViewState.WrongLogin(e)} 111 -> {e:ExceptionString -> AuthScreenViewState.WrongLogin(e)}
112 -> {e:ExceptionString -> AuthScreenViewState.WrongPassword(e)} 112 -> {e:ExceptionString -> AuthScreenViewState.WrongPassword(e)}
else -> {e:ExceptionString -> AuthScreenViewState.SomeError(e)} else -> {e:ExceptionString -> AuthScreenViewState.SomeError(e)}
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorSecondary">@color/colorAccent</item> <item name="colorSecondary">@color/colorAccent</item>
<item name="colorSecondaryVariant">@color/colorAccentSecondary</item> <item name="colorSecondaryVariant">@color/colorAccentSecondary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorAccentSecondary</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="materialCardViewStyle">@style/Widget.Biganto.MaterialCardView</item> <item name="materialCardViewStyle">@style/Widget.Biganto.MaterialCardView</item>
......
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