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

added rxBinding

parent a9b08b91
...@@ -114,6 +114,10 @@ dependencies { ...@@ -114,6 +114,10 @@ dependencies {
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.5.0' compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.5.0'
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.0' kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.0'
//RxBinding
implementation "com.jakewharton.rxbinding3:rxbinding:$rxBindingVersion"
implementation "com.jakewharton.rxbinding3:rxbinding-recyclerview:$rxBindingVersion"
//Tests //Tests
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'
......
...@@ -11,4 +11,7 @@ class AuthInteractor @Inject constructor( ...@@ -11,4 +11,7 @@ class AuthInteractor @Inject constructor(
private val uc:AuthUseCase private val uc:AuthUseCase
){ ){
fun getAuth() = uc.validateAuth() fun getAuth() = uc.validateAuth()
fun authorizate(login:String, password:String) =
uc.authorizate(login,password)
} }
\ No newline at end of file
...@@ -14,6 +14,8 @@ class AuthUseCase @Inject constructor( ...@@ -14,6 +14,8 @@ class AuthUseCase @Inject constructor(
fun validateAuth() = Observable.just(true) fun validateAuth() = Observable.just(true)
fun authorizate(login:String,pwd:String) = authContract.signIn(login,pwd)
} }
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.auth package com.biganto.visual.roompark.presentation.screen.auth
import com.biganto.visual.roompark.conductor.BigantoBaseContract import com.biganto.visual.roompark.conductor.BigantoBaseContract
import io.reactivex.Observable
/** /**
* Created by Vladislav Bogdashkin on 30.09.2019. * Created by Vladislav Bogdashkin on 30.09.2019.
*/ */
interface AuthScreen : BigantoBaseContract<AuthScreenViewState> { interface AuthScreen : BigantoBaseContract<AuthScreenViewState> {
fun tryAuth(): Observable<AuthInputModel>
}
} data class AuthInputModel(val login:String, val pwd:String)
\ No newline at end of file \ No newline at end of file
...@@ -3,11 +3,16 @@ package com.biganto.visual.roompark.presentation.screen.auth ...@@ -3,11 +3,16 @@ package com.biganto.visual.roompark.presentation.screen.auth
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import butterknife.BindView
import com.biganto.visual.roompark.R 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.google.android.material.button.MaterialButton
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.google.android.material.textfield.TextInputLayout
import com.jakewharton.rxbinding3.view.clicks
import io.reactivex.Observable
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -20,6 +25,19 @@ class AuthScreenController : ...@@ -20,6 +25,19 @@ class AuthScreenController :
, AuthScreenPresenter>() , AuthScreenPresenter>()
, AuthScreen { , AuthScreen {
@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()
.map<AuthInputModel>{ AuthInputModel(loginInput.editText?.text?.toString()?:""
,pwdInput.editText?.text?.toString()?:"")}
override fun injectDependencies() { override fun injectDependencies() {
getComponent() getComponent()
} }
...@@ -52,7 +70,11 @@ class AuthScreenController : ...@@ -52,7 +70,11 @@ class AuthScreenController :
override fun render(viewState: AuthScreenViewState) { override fun render(viewState: AuthScreenViewState) {
when(viewState){ when(viewState){
is AuthScreenViewState.Idle -> render(viewState) is AuthScreenViewState.Idle -> render(viewState)
is AuthScreenViewState.ToScreen -> render(viewState) is AuthScreenViewState.Authorization -> render(viewState)
is AuthScreenViewState.SignedIn -> render(viewState)
is AuthScreenViewState.SignInError -> render(viewState)
} }
} }
...@@ -60,7 +82,16 @@ class AuthScreenController : ...@@ -60,7 +82,16 @@ class AuthScreenController :
} }
private fun render(viewState: AuthScreenViewState.ToScreen){ private fun render(viewState: AuthScreenViewState.Authorization){
toolBar.hideAll()
// snacky.showSnackBar("lul")
}
private fun render(viewState: AuthScreenViewState.SignedIn){
// snacky.showSnackBar("lul")
}
private fun render(viewState: AuthScreenViewState.SignInError){
snackbar.showSnackBar(viewState.message, Snackbar.LENGTH_LONG) snackbar.showSnackBar(viewState.message, Snackbar.LENGTH_LONG)
toolBar.hideAll() toolBar.hideAll()
// snacky.showSnackBar("lul") // snacky.showSnackBar("lul")
......
...@@ -14,7 +14,14 @@ class AuthScreenPresenter @Inject constructor( ...@@ -14,7 +14,14 @@ class AuthScreenPresenter @Inject constructor(
) )
: BigantoBasePresenter<AuthScreen, AuthScreenViewState>() { : BigantoBasePresenter<AuthScreen, AuthScreenViewState>() {
override fun bindIntents() { override fun bindIntents() {
val onAuth = intent(AuthScreen::tryAuth)
.flatMap { interactor.getAuth() }
val state = restoreStateObservable val state = restoreStateObservable
.mergeWith(interactor.getAuth() .mergeWith(interactor.getAuth()
.map { AuthScreenViewState.ToScreen(it.toString()) }) .map { AuthScreenViewState.ToScreen(it.toString()) })
......
...@@ -9,5 +9,7 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState ...@@ -9,5 +9,7 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState
sealed class AuthScreenViewState : BigantoBaseViewState() { sealed class AuthScreenViewState : BigantoBaseViewState() {
class Idle : AuthScreenViewState() class Idle : AuthScreenViewState()
class ToScreen(val message:String) : AuthScreenViewState() class Authorization : AuthScreenViewState()
class SignedIn : AuthScreenViewState()
class SignInError(val message:String) : AuthScreenViewState()
} }
\ No newline at end of file
...@@ -109,6 +109,7 @@ ...@@ -109,6 +109,7 @@
</FrameLayout> </FrameLayout>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/sign_in_button"
style="@style/AuthButton.Enable" style="@style/AuthButton.Enable"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -11,7 +11,7 @@ ext { ...@@ -11,7 +11,7 @@ ext {
// supportLibraryVersion = '1.1.0-alpha05' // supportLibraryVersion = '1.1.0-alpha05'
constrainLayoutVersion = '1.1.3' constrainLayoutVersion = '1.1.3'
// requeryVersion = '1.5.1' // requeryVersion = '1.5.1'
// rxBindingVersion = '2.1.1' rxBindingVersion = '3.0.0'
conductorVersion = '3.0.0-rc1' conductorVersion = '3.0.0-rc1'
materialVersion = '1.1.0-alpha10' materialVersion = '1.1.0-alpha10'
gradleVersion = '3.5.0' gradleVersion = '3.5.0'
......
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