Commit 5d067764 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

logout

auth view fix
toolabr hide on splash and auth screens
fix some repostiory behaviour
parent a25d3111
...@@ -58,7 +58,10 @@ class UserHolder @Inject constructor(val context : Context) : ILocalStore ...@@ -58,7 +58,10 @@ class UserHolder @Inject constructor(val context : Context) : ILocalStore
} }
override fun setRecentUser(uuid: String?) = override fun setRecentUser(uuid: String?) =
Completable.fromCallable{userSession.set(uuid?:EMPTY_PREF_VALUE_KEY)} Completable.defer {
Completable.fromCallable { userSession.set(uuid ?: EMPTY_PREF_VALUE_KEY) }
.doOnComplete { Timber.d("complete save null value") }
}
} }
sealed class UserState{ sealed class UserState{
......
...@@ -5,6 +5,7 @@ import com.biganto.visual.roompark.domain.model.PushSwitchModel ...@@ -5,6 +5,7 @@ import com.biganto.visual.roompark.domain.model.PushSwitchModel
import com.biganto.visual.roompark.domain.model.SettingsModel import com.biganto.visual.roompark.domain.model.SettingsModel
import com.biganto.visual.roompark.domain.use_case.AuthUseCase import com.biganto.visual.roompark.domain.use_case.AuthUseCase
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -18,7 +19,7 @@ class SettingsInteractor @Inject constructor( ...@@ -18,7 +19,7 @@ class SettingsInteractor @Inject constructor(
fun fetchSettings(): Observable<SettingsModel> = Observable.just(sampleSettings) fun fetchSettings(): Observable<SettingsModel> = Observable.just(sampleSettings)
fun signOut() = auth.signOut() fun signOut() = auth.signOut().subscribeOn(Schedulers.io())
companion object{ companion object{
......
...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.auth ...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.auth
import android.view.View import android.view.View
import butterknife.BindView import butterknife.BindView
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.IBottomNavigation
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController import com.biganto.visual.roompark.conductor.BigantoBaseController
...@@ -26,14 +27,17 @@ class AuthScreenController : ...@@ -26,14 +27,17 @@ class AuthScreenController :
, AuthScreenPresenter>() , AuthScreenPresenter>()
, AuthScreen { , AuthScreen {
override fun onViewBound(v: View) { override fun onViewBound(v: View) {
toolBar.hideAll()
bottomNavigation.hide()
} }
@BindView(R.id.login_text_input) lateinit var loginInput:TextInputLayout @BindView(R.id.login_text_input) lateinit var loginInput:TextInputLayout
@BindView(R.id.password_text_input) lateinit var pwdInput:TextInputLayout @BindView(R.id.password_text_input) lateinit var pwdInput:TextInputLayout
@BindView(R.id.sign_in_button) lateinit var signInButton:MaterialButton @BindView(R.id.sign_in_button) lateinit var signInButton:MaterialButton
override fun tryAuth(): Observable<AuthInputModel> = override fun tryAuth(): Observable<AuthInputModel> =
Observable.defer {
signInButton.clicks() signInButton.clicks()
.doOnNext { signInButton.hideKeyboard() } .doOnNext { signInButton.hideKeyboard() }
.map<AuthInputModel> { .map<AuthInputModel> {
...@@ -43,12 +47,15 @@ class AuthScreenController : ...@@ -43,12 +47,15 @@ class AuthScreenController :
) )
} }
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
}
override fun injectDependencies() { override fun injectDependencies() {
getComponent() getComponent()
} }
@Inject
lateinit var bottomNavigation: IBottomNavigation
@Inject @Inject
override lateinit var injectedPresenter: AuthScreenPresenter override lateinit var injectedPresenter: AuthScreenPresenter
...@@ -74,6 +81,8 @@ class AuthScreenController : ...@@ -74,6 +81,8 @@ class AuthScreenController :
is AuthScreenViewState.SignedIn -> render(viewState) is AuthScreenViewState.SignedIn -> render(viewState)
is AuthScreenViewState.SignInError -> render(viewState) is AuthScreenViewState.SignInError -> render(viewState)
is AuthScreenViewState.SomeError -> render(viewState) is AuthScreenViewState.SomeError -> render(viewState)
is AuthScreenViewState.WrongLogin -> render(viewState)
is AuthScreenViewState.WrongPassword -> render(viewState)
} }
} }
...@@ -99,6 +108,8 @@ class AuthScreenController : ...@@ -99,6 +108,8 @@ class AuthScreenController :
private fun render(viewState: AuthScreenViewState.WrongLogin){ private fun render(viewState: AuthScreenViewState.WrongLogin){
// showError(viewState.exception) // showError(viewState.exception)
loginInput.isErrorEnabled = true
loginInput.errorIconDrawable = null
viewState.exception.selectHandler( viewState.exception.selectHandler(
{strId -> loginInput.error = resources?.getString(strId)}, {strId -> loginInput.error = resources?.getString(strId)},
{message -> loginInput.error = message} {message -> loginInput.error = message}
...@@ -107,6 +118,8 @@ class AuthScreenController : ...@@ -107,6 +118,8 @@ class AuthScreenController :
} }
private fun render(viewState: AuthScreenViewState.WrongPassword){ private fun render(viewState: AuthScreenViewState.WrongPassword){
pwdInput.isErrorEnabled = true
pwdInput.errorIconDrawable = null
viewState.exception.selectHandler( viewState.exception.selectHandler(
{strId -> pwdInput.error = resources?.getString(strId)}, {strId -> pwdInput.error = resources?.getString(strId)},
{message -> pwdInput.error = message} {message -> pwdInput.error = message}
......
package com.biganto.visual.roompark.presentation.screen.auth package com.biganto.visual.roompark.presentation.screen.auth
import android.content.Context import android.content.Context
import com.biganto.visual.roompark.base.IBottomNavigation
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
...@@ -43,4 +44,8 @@ abstract class AuthScreenModule{ ...@@ -43,4 +44,8 @@ abstract class AuthScreenModule{
@Binds @Binds
abstract fun provideAuth(contract: AuthContractModule): AuthContract abstract fun provideAuth(contract: AuthContractModule): AuthContract
@PerScreen
@Binds
abstract fun provideBottomNavigation(activitiy: RoomParkMainActivity): IBottomNavigation
} }
...@@ -37,7 +37,7 @@ class AuthScreenPresenter @Inject constructor( ...@@ -37,7 +37,7 @@ class AuthScreenPresenter @Inject constructor(
.doOnNext { Timber.d("auth returned $it") } .doOnNext { Timber.d("auth returned $it") }
.map { it } .map { it }
.map<AuthScreenViewState> { AuthScreenViewState.SignedIn() } .map<AuthScreenViewState> { AuthScreenViewState.SignedIn() }
// .onErrorReturn{parseError(it)} .onErrorReturn{parseError(it)}
} }
// .startWith(Observable.just(AuthScreenViewState.Authorization())) // .startWith(Observable.just(AuthScreenViewState.Authorization()))
......
...@@ -140,7 +140,6 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds) ...@@ -140,7 +140,6 @@ class HomeBottomNavigationController(@IdRes toPage: Int = R.id.tab_feeds)
val childRouter = getChildRouter(currentlySelectedItemId) val childRouter = getChildRouter(currentlySelectedItemId)
Timber.d("in back stack - ${childRouter?.backstackSize}") Timber.d("in back stack - ${childRouter?.backstackSize}")
if (childRouter != null) { if (childRouter != null) {
if (childRouter.backstackSize<2) return false if (childRouter.backstackSize<2) return false
if (childRouter.handleBack()) if (childRouter.handleBack())
......
...@@ -11,11 +11,12 @@ import com.biganto.visual.roompark.R ...@@ -11,11 +11,12 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.presentation.screen.auth.AuthScreenController
import com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListAdapter import com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter import com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import com.biganto.visual.roompark.util.extensions.bytesToSize import com.biganto.visual.roompark.util.extensions.bytesToSize
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.clicks import com.jakewharton.rxbinding3.view.clicks
import io.reactivex.Observable import io.reactivex.Observable
...@@ -35,7 +36,7 @@ class SettingsScreenController : ...@@ -35,7 +36,7 @@ class SettingsScreenController :
override fun signOut(): Observable<Int> = override fun signOut(): Observable<Int> =
signOutButton.clicks() signOutButton.clicks()
.map { 1 } .map { Timber.d("Clicked sign out button"); 1 }
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
override fun injectDependencies() { override fun injectDependencies() {
...@@ -119,7 +120,10 @@ class SettingsScreenController : ...@@ -119,7 +120,10 @@ class SettingsScreenController :
} }
private fun render(viewState: SettingsScreenViewState.SignOut){ private fun render(viewState: SettingsScreenViewState.SignOut){
router.setRoot(RouterTransaction.with(AuthScreenController())) router.setRoot(RouterTransaction.with(SplashScreenController())
.pushChangeHandler(FadeChangeHandler())
.popChangeHandler(FadeChangeHandler())
)
} }
......
...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.settings ...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.settings
import com.biganto.visual.roompark.conductor.BigantoBasePresenter import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.SettingsInteractor import com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import com.biganto.visual.roompark.util.monades.ExceptionString import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
...@@ -27,9 +28,12 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -27,9 +28,12 @@ class SettingsScreenPresenter @Inject constructor(
.map { SettingsScreenViewState.LoadSettingsList(it) } .map { SettingsScreenViewState.LoadSettingsList(it) }
val onSignOut = intent(SettingsScreen::signOut) val onSignOut = intent(SettingsScreen::signOut)
.flatMap { interactor.signOut() .flatMap {
.toObservable<SettingsScreenViewState>() interactor.signOut()
.map { SettingsScreenViewState.SignOut() }} .andThen(Observable.just<SettingsScreenViewState>(SettingsScreenViewState.SignOut()))
.onErrorReturn(::parseError)
}
val state = restoreStateObservable val state = restoreStateObservable
.mergeWith(fetchSettings) .mergeWith(fetchSettings)
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.splash ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.splash
import android.view.View import android.view.View
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.IBottomNavigation
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController import com.biganto.visual.roompark.conductor.BigantoBaseController
...@@ -23,6 +24,8 @@ class SplashScreenController : ...@@ -23,6 +24,8 @@ class SplashScreenController :
override fun onViewBound(v: View) { override fun onViewBound(v: View) {
toolBar.hideAll()
bottomNavigation.hide()
} }
override fun injectDependencies() { override fun injectDependencies() {
...@@ -46,6 +49,8 @@ class SplashScreenController : ...@@ -46,6 +49,8 @@ class SplashScreenController :
// @Inject // @Inject
// lateinit var ac: RoomParkMainActivity // lateinit var ac: RoomParkMainActivity
@Inject
lateinit var bottomNavigation: IBottomNavigation
override fun render(viewState: SplashScreenViewState) { override fun render(viewState: SplashScreenViewState) {
when(viewState){ when(viewState){
......
package com.biganto.visual.roompark.presentation.screen.splash package com.biganto.visual.roompark.presentation.screen.splash
import android.content.Context import android.content.Context
import com.biganto.visual.roompark.base.IBottomNavigation
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule import com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import com.biganto.visual.roompark.data.repository.db.requrey.DbModule import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
...@@ -50,4 +51,8 @@ abstract class SplashScreenModule{ ...@@ -50,4 +51,8 @@ abstract class SplashScreenModule{
// @Binds // @Binds
// abstract fun provideToolbar(activitiy: RoomParkMainActivity): ICollapsingToolBar // abstract fun provideToolbar(activitiy: RoomParkMainActivity): ICollapsingToolBar
@PerScreen
@Binds
abstract fun provideBottomNavigation(activitiy: RoomParkMainActivity): IBottomNavigation
} }
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLength="64" android:inputType="textEmailAddress"
android:maxLines="1" /> android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textPassword"
android:maxLength="64" android:maxLength="64"
android:maxLines="1" /> android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
......
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