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