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

Base MVI pipeline developed and tested

parents 2bcdb6fa aa875bfc
...@@ -110,7 +110,13 @@ dependencies { ...@@ -110,7 +110,13 @@ dependencies {
//Rx Relay //Rx Relay
implementation "com.jakewharton.rxrelay2:rxrelay:$rxRelayVersion" implementation "com.jakewharton.rxrelay2:rxrelay:$rxRelayVersion"
//Assist Injected
compileOnly 'com.squareup.inject:assisted-inject-annotations-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'
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.base ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.base
import android.util.Log import android.util.Log
import com.biganto.visual.roompark.BuildConfig import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.DaggerAppComponent import com.biganto.visual.roompark.di.dagger.DaggerAppComponent
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
...@@ -14,10 +15,19 @@ import timber.log.Timber ...@@ -14,10 +15,19 @@ import timber.log.Timber
*/ */
class RoomParkApplication : DaggerApplication() { class RoomParkApplication : DaggerApplication() {
companion object {
lateinit var component: AppComponent
private set
}
override fun applicationInjector(): AndroidInjector<out DaggerApplication> { override fun applicationInjector(): AndroidInjector<out DaggerApplication> {
return DaggerAppComponent.builder() component = DaggerAppComponent.factory()
.context(this) .create(this) as AppComponent
.build() // .context(this)
// .build()
return component
} }
override fun onCreate() { override fun onCreate() {
......
...@@ -9,16 +9,18 @@ import butterknife.BindView ...@@ -9,16 +9,18 @@ import butterknife.BindView
import butterknife.ButterKnife import butterknife.ButterKnife
import com.biganto.visual.roompark.BuildConfig import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import com.biganto.visual.roompark.view_utils.app_bar.DragControlAppBarLayoutBehaviour import com.biganto.visual.roompark.view_utils.app_bar.DragControlAppBarLayoutBehaviour
import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import com.bluelinelabs.conductor.Conductor import com.bluelinelabs.conductor.Conductor
import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import io.fabric.sdk.android.Fabric import io.fabric.sdk.android.Fabric
import javax.inject.Inject import kotlinx.android.synthetic.main.activity_main.*
import timber.log.Timber
class RoomParkMainActivity( class RoomParkMainActivity(
) : BaseRoomParkActivity() ) : BaseRoomParkActivity()
...@@ -26,8 +28,10 @@ class RoomParkMainActivity( ...@@ -26,8 +28,10 @@ class RoomParkMainActivity(
,IConductorActivity ,IConductorActivity
,IBottomNavigation{ ,IBottomNavigation{
@Inject
lateinit var snackbarProvider: ISnackBarProvider
// @Inject
// lateinit var snackbarProvider: ISnackBarProvider
private lateinit var router: Router private lateinit var router: Router
...@@ -38,6 +42,8 @@ class RoomParkMainActivity( ...@@ -38,6 +42,8 @@ class RoomParkMainActivity(
@BindView(R.id.conductor_container) override lateinit var conductorContainer: ViewGroup @BindView(R.id.conductor_container) override lateinit var conductorContainer: ViewGroup
@BindView(R.id.bottom_navigation_view) override lateinit var bottomNavigation: BottomNavigationView @BindView(R.id.bottom_navigation_view) override lateinit var bottomNavigation: BottomNavigationView
@BindView(R.id.bottom_view_divider) lateinit var bottomShadow: View
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme) setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -50,9 +56,11 @@ class RoomParkMainActivity( ...@@ -50,9 +56,11 @@ class RoomParkMainActivity(
setSupportActionBar(topAppBar) setSupportActionBar(topAppBar)
hideAll()
router = Conductor.attachRouter(this, conductorContainer, savedInstanceState) router = Conductor.attachRouter(this, conductorContainer, savedInstanceState)
snackbarProvider.bindRootView(rootView = coordinatorLayout) router.setRoot(RouterTransaction.with(SplashScreenController()))
} }
override fun displayBackButton(show: Boolean) { override fun displayBackButton(show: Boolean) {
...@@ -61,22 +69,25 @@ class RoomParkMainActivity( ...@@ -61,22 +69,25 @@ class RoomParkMainActivity(
override fun hideAll() { override fun hideAll() {
appBar.visibility=Toolbar.INVISIBLE appBar.visibility=Toolbar.INVISIBLE
bottomNavigation.visibility = Toolbar.GONE bottomNavigation.visibility = BottomNavigationView.GONE
val params = coordinatorLayout.layoutParams as CoordinatorLayout.LayoutParams bottomShadow.visibility = View.GONE
Timber.e(" lay params : ${appBar.layoutParams.javaClass}")
val params:CoordinatorLayout.LayoutParams = conductor_container.layoutParams as CoordinatorLayout.LayoutParams
params.behavior = null params.behavior = null
coordinatorLayout.requestLayout() conductor_container.requestLayout()
} }
override fun showAll() { override fun showAll() {
appBar.setExpanded(false,false) appBar.setExpanded(false,false)
collapsingToolbarLayout.visibility= View.VISIBLE collapsingToolbarLayout.visibility= View.VISIBLE
bottomNavigation.visibility = Toolbar.VISIBLE bottomNavigation.visibility = Toolbar.VISIBLE
bottomShadow.visibility = View.VISIBLE
appBar.visibility= View.VISIBLE appBar.visibility= View.VISIBLE
topAppBar.visibility = View.VISIBLE topAppBar.visibility = View.VISIBLE
val params = coordinatorLayout.layoutParams as CoordinatorLayout.LayoutParams val params = conductor_container.layoutParams as CoordinatorLayout.LayoutParams
params.behavior = AppBarLayout.ScrollingViewBehavior() params.behavior = AppBarLayout.ScrollingViewBehavior()
coordinatorLayout.requestLayout() conductor_container.requestLayout()
} }
override fun appBarScrollable(allow: Boolean) { override fun appBarScrollable(allow: Boolean) {
......
...@@ -14,17 +14,15 @@ import com.biganto.visual.roompark.R ...@@ -14,17 +14,15 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.ICollapsingToolBar import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.mosby.mvi.BigantoMviController import com.biganto.visual.roompark.conductor.mosby.mvi.BigantoMviController
import com.biganto.visual.roompark.di.dagger.PerScreen import com.biganto.visual.roompark.di.dagger.ActivityModule
import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import com.hannesdorfmann.mosby3.mvi.MviBasePresenter import com.hannesdorfmann.mosby3.mvi.MviBasePresenter
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import javax.inject.Inject
/** /**
* Created by Vladislav Bogdashkin on 28.05.2018. * Created by Vladislav Bogdashkin on 28.05.2018.
*/ */
@PerScreen
abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseContract<VS>,P : MviBasePresenter<V,VS>> abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseContract<VS>,P : MviBasePresenter<V,VS>>
: BigantoMviController<V, P> { : BigantoMviController<V, P> {
...@@ -32,33 +30,44 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon ...@@ -32,33 +30,44 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
constructor(args: Bundle):super(args) constructor(args: Bundle):super(args)
protected val detachDisposable = CompositeDisposable() val inject by lazy { injectDependencies() }
abstract override fun createPresenter(): P protected abstract fun injectDependencies()
@LayoutRes protected val detachDisposable = CompositeDisposable()
protected abstract fun getLayoutId(): Int
@StringRes abstract var injectedPresenter:P
protected abstract fun getToolbarTitleId(): Int
override fun createPresenter(): P = injectedPresenter
@Inject @LayoutRes
private lateinit var roomParkActivity:RoomParkMainActivity protected abstract fun getLayoutId(): Int
protected val toolBar: ICollapsingToolBar = roomParkActivity lateinit var toolBar: ICollapsingToolBar
protected val snackbar: ISnackBarProvider = roomParkActivity.snackbarProvider lateinit var snackbar: ISnackBarProvider
override fun onDetach(view: View) { override fun onDetach(view: View) {
detachDisposable.clear() detachDisposable.clear()
super.onDetach(view) super.onDetach(view)
} }
private var isInjected = false
override fun onContextAvailable(context: Context) {
super.onContextAvailable(context)
inject
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val view = inflater.inflate(getLayoutId(), container, false) val view = inflater.inflate(getLayoutId(), container, false)
// instantiate the view // instantiate the view
ButterKnife.bind(this, view) ButterKnife.bind(this, view)
(activity as RoomParkMainActivity).let{
snackbar = ActivityModule.provideSnackBar(it)
toolBar = it
snackbar.bindRootView(toolBar.coordinatorLayout)
}
return view return view
} }
......
...@@ -4,6 +4,7 @@ import android.app.Activity ...@@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context import android.content.Context
import android.content.res.Resources import android.content.res.Resources
import com.biganto.visual.roompark.base.BaseRoomParkActivity import com.biganto.visual.roompark.base.BaseRoomParkActivity
import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import com.biganto.visual.roompark.view_utils.snackbar.SnackBarProvider import com.biganto.visual.roompark.view_utils.snackbar.SnackBarProvider
...@@ -30,28 +31,30 @@ abstract class ActivityModule { ...@@ -30,28 +31,30 @@ abstract class ActivityModule {
@JvmStatic @JvmStatic
@Provides @Provides
fun provideSnackBar(activity: Activity): ISnackBarProvider{ fun provideSnackBar(activity: Activity): ISnackBarProvider {
return SnackBarProvider(activity) return SnackBarProvider(activity)
} }
} }
} }
@Module @Module
abstract class AppActivityModule { abstract class AppActivityModule {
@Module @Module
internal interface MainActivityModule { internal interface MainActivityModule {
@Binds @Binds
fun bindMainActivity(activity: RoomParkMainActivity): Activity fun bindMainActivity(activity: RoomParkMainActivity): BaseRoomParkActivity
}
@Binds
fun bindMainActivityToolbar(activity: RoomParkMainActivity): ICollapsingToolBar
}
@Module @Module
internal interface BaseActivityModule { internal interface BaseActivityModule {
@Binds @Binds
fun bindBaseActivity(activity: BaseRoomParkActivity): Activity fun bindBaseActivity(activity: BaseRoomParkActivity): BaseRoomParkActivity
} }
......
package com.biganto.visual.roompark.di.dagger package com.biganto.visual.roompark.di.dagger
import android.app.Application
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import dagger.BindsInstance
import dagger.Component import dagger.Component
import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
...@@ -25,14 +23,15 @@ import javax.inject.Singleton ...@@ -25,14 +23,15 @@ import javax.inject.Singleton
AndroidSupportInjectionModule::class, AndroidSupportInjectionModule::class,
// MappingProvider::class, // MappingProvider::class,
ActivityModule::class, ActivityModule::class,
AppActivityModule ::class]) AppActivityModule ::class])
interface AppComponent : AndroidInjector<RoomParkApplication>{ interface AppComponent : AndroidInjector<RoomParkApplication>{
@Component.Builder @Component.Factory
interface Builder{ interface Factory:AndroidInjector.Factory<RoomParkApplication>{
@BindsInstance // @BindsInstance
fun context(application: Application): Builder // fun context(application: Application): Factory
// @BindsInstance // @BindsInstance
// fun retrofitModule(retrofit: RetrofitModule):Builder // fun retrofitModule(retrofit: RetrofitModule):Builder
...@@ -43,8 +42,9 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{ ...@@ -43,8 +42,9 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
// fun retrofit( // fun retrofit(
// retorfitModule: RetrofitModule):Builder // retorfitModule: RetrofitModule):Builder
//
// fun build(): AppComponent
fun build(): AppComponent
} }
......
package com.biganto.visual.roompark.di.dagger package com.biganto.visual.roompark.di.dagger
import com.biganto.visual.roompark.domain.contract.AuthContract
import com.biganto.visual.roompark.domain.model.AuthInfoModel
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Observable
import javax.inject.Inject
import javax.inject.Singleton
/** /**
* Created by Vladislav Bogdashkin on 13.06.2018. * Created by Vladislav Bogdashkin on 13.06.2018.
...@@ -26,11 +32,25 @@ class AppModule() { ...@@ -26,11 +32,25 @@ class AppModule() {
} }
class AuthContractModule @Inject constructor():AuthContract{
override fun signOut(): Completable = Completable.complete()
override fun signIn(email: String, password: String): Observable<AuthInfoModel> {
return Observable.just(AuthInfoModel("some tokan zzaza",1488, "hi4", "biganto@demo.ru"))
}
fun validateAuthState(): Observable<Boolean> = Observable.just(false)
}
@Module() @Module()
class DataModule() { class DataModule() {
@Provides
@Singleton
fun provideAuthContract() : AuthContract = AuthContractModule()
/* /*
@Provides @Provides
@Singleton @Singleton
......
...@@ -13,3 +13,8 @@ import javax.inject.Scope ...@@ -13,3 +13,8 @@ import javax.inject.Scope
@Scope @Scope
@Retention(AnnotationRetention.RUNTIME) @Retention(AnnotationRetention.RUNTIME)
annotation class PerScreen annotation class PerScreen
@Scope
@Retention(AnnotationRetention.RUNTIME)
annotation class ActivityScope
\ No newline at end of file
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.use_case.AuthUseCase
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 09.10.2019.
*/
class AuthInteractor @Inject constructor(
private val uc:AuthUseCase
){
fun getAuth() = uc.validateAuth()
fun authorizate(login:String, password:String) =
uc.authorizate(login,password)
}
\ No newline at end of file
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.use_case.AuthUseCase
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 09.10.2019.
*/
class SplashInteractor @Inject constructor(
private val uc:AuthUseCase
){
fun getAuth() = uc.validateAuth()
}
\ No newline at end of file
package com.biganto.visual.roompark.domain.use_case package com.biganto.visual.roompark.domain.use_case
import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.domain.contract.AuthContract import com.biganto.visual.roompark.domain.contract.AuthContract
import io.reactivex.Observable
import javax.inject.Inject
/** /**
* Created by Vladislav Bogdashkin on 24.09.2019. * Created by Vladislav Bogdashkin on 24.09.2019.
*/ */
@PerScreen class AuthUseCase @Inject constructor(
class AuthUseCase( private val authContract: AuthContract
val authContract: AuthContract
){ ){
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
import com.biganto.visual.roompark.conductor.BigantoBaseContract
import io.reactivex.Observable
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface AuthScreen : BigantoBaseContract<AuthScreenViewState> {
fun tryAuth(): Observable<AuthInputModel>
}
data class AuthInputModel(val login:String, val pwd:String)
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.auth
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import butterknife.BindView
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.google.android.material.button.MaterialButton
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
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class AuthScreenController :
BigantoBaseController<AuthScreenViewState
, AuthScreen
, AuthScreenPresenter>()
, 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() {
getComponent()
}
@Inject
override lateinit var injectedPresenter: AuthScreenPresenter
// @Inject
// lateinit var snacky:ISnackBarProvider
lateinit var rpActivity: RoomParkMainActivity
fun getComponent() = DaggerAuthScreenComponent
.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this)
// @Inject
// lateinit var ac: RoomParkMainActivity
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val v = super.onCreateView(inflater, container)
return v
}
override fun render(viewState: AuthScreenViewState) {
when(viewState){
is AuthScreenViewState.Idle -> render(viewState)
is AuthScreenViewState.Authorization -> render(viewState)
is AuthScreenViewState.SignedIn -> render(viewState)
is AuthScreenViewState.SignInError -> render(viewState)
}
}
private fun render(viewState: AuthScreenViewState.Idle){
}
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)
toolBar.hideAll()
// snacky.showSnackBar("lul")
}
override fun getLayoutId(): Int = R.layout.authentication_screen
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.auth
import android.content.Context
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.AuthContractModule
import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.domain.contract.AuthContract
import dagger.Binds
import dagger.BindsInstance
import dagger.Component
import dagger.Module
@PerScreen
@Component(
modules = [AuthScreenModule::class],
dependencies = [AppComponent::class])
interface AuthScreenComponent {
@Component.Factory
interface Factory{
fun create(
appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity
): AuthScreenComponent
}
val presenter: AuthScreenPresenter
fun inject(controller: AuthScreenController)
}
@Module
abstract class AuthScreenModule{
@PerScreen
@Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context
@PerScreen
@Binds
abstract fun provideAuth(contract: AuthContractModule): AuthContract
}
package com.biganto.visual.roompark.presentation.screen.auth
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.AuthInteractor
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class AuthScreenPresenter @Inject constructor(
private val interactor: AuthInteractor
)
: BigantoBasePresenter<AuthScreen, AuthScreenViewState>() {
override fun bindIntents() {
val onAuth = intent(AuthScreen::tryAuth)
.flatMap { interactor.getAuth() }
val state = restoreStateObservable
.mergeWith(interactor.getAuth()
.map { AuthScreenViewState.ToScreen(it.toString()) })
subscribeViewState(state.cast(AuthScreenViewState::class.java), AuthScreen::render)
}
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.auth
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
sealed class AuthScreenViewState : BigantoBaseViewState() {
class Idle : AuthScreenViewState()
class Authorization : AuthScreenViewState()
class SignedIn : AuthScreenViewState()
class SignInError(val message:String) : AuthScreenViewState()
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash
import com.biganto.visual.roompark.conductor.BigantoBaseContract
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface SplashScreen : BigantoBaseContract<SplashScreenViewState> {
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.ICollapsingToolBar
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.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.snackbar.Snackbar
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class SplashScreenController :
BigantoBaseController<SplashScreenViewState
, SplashScreen
, SplashScreenPresenter>()
, SplashScreen {
override fun injectDependencies() {
getComponent()
}
@Inject
lateinit var tb: ICollapsingToolBar
@Inject
override lateinit var injectedPresenter: SplashScreenPresenter
// @Inject
// lateinit var snacky:ISnackBarProvider
lateinit var rpActivity: RoomParkMainActivity
fun getComponent() = DaggerSplashScreenComponent
.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity)
.inject(this)
// @Inject
// lateinit var ac: RoomParkMainActivity
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val v = super.onCreateView(inflater, container)
return v
}
override fun render(viewState: SplashScreenViewState) {
when(viewState){
is SplashScreenViewState.Idle -> render(viewState)
is SplashScreenViewState.ToScreen -> render(viewState)
}
}
private fun render(viewState: SplashScreenViewState.Idle){
}
private fun render(viewState: SplashScreenViewState.ToScreen){
snackbar.showSnackBar(viewState.message, Snackbar.LENGTH_LONG)
tb.hideAll()
router.pushController(RouterTransaction.with(AuthScreenController())
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())
)
// snacky.showSnackBar("lul")
}
override fun getLayoutId(): Int = R.layout.splash_screen
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash
import android.content.Context
import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.AuthContractModule
import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.domain.contract.AuthContract
import dagger.Binds
import dagger.BindsInstance
import dagger.Component
import dagger.Module
///**
// * Created by Vladislav Bogdashkin on 30.09.2019.
// */
@PerScreen
@Component(
modules = [SplashScreenModule::class],
dependencies = [AppComponent::class])
interface SplashScreenComponent {
@Component.Factory
interface Factory{
fun create(
appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity
): SplashScreenComponent
}
val presenter: SplashScreenPresenter
fun inject(controller: SplashScreenController)
}
@Module
abstract class SplashScreenModule{
@PerScreen
@Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context
@PerScreen
@Binds
abstract fun provideAuth(contract: AuthContractModule): AuthContract
@PerScreen
@Binds
abstract fun provideToolbar(activitiy: RoomParkMainActivity): ICollapsingToolBar
}
package com.biganto.visual.roompark.presentation.screen.splash
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.SplashInteractor
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class SplashScreenPresenter @Inject constructor(
private val acitivityContext: RoomParkMainActivity
, private val interactor: SplashInteractor
// ,var context:Context
)
: BigantoBasePresenter<SplashScreen, SplashScreenViewState>() {
override fun bindIntents() {
val state = restoreStateObservable
.mergeWith(interactor.getAuth()
.map { SplashScreenViewState.ToScreen(it.toString()) })
subscribeViewState(state.cast(SplashScreenViewState::class.java), SplashScreen::render)
}
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
sealed class SplashScreenViewState : BigantoBaseViewState() {
class Idle : SplashScreenViewState()
class ToScreen(val message:String) : SplashScreenViewState()
}
\ No newline at end of file
...@@ -6,14 +6,14 @@ import androidx.core.content.ContextCompat ...@@ -6,14 +6,14 @@ import androidx.core.content.ContextCompat
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.view_utils.snackbar.SnackBarMessageType.* import com.biganto.visual.roompark.view_utils.snackbar.SnackBarMessageType.*
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import javax.inject.Inject
/** /**
* Created by Vladislav Bogdashkin on 06.05.2019. * Created by Vladislav Bogdashkin on 06.05.2019.
*/ */
class SnackBarProvider @Inject constructor(val activity: Activity) : ISnackBarProvider {
class SnackBarProvider constructor(val activity: Activity) : ISnackBarProvider {
override val isRootBounded: Boolean override val isRootBounded: Boolean
get() = rootView != null get() = rootView != null
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="21.3dp"
android:height="38.5dp"
android:viewportWidth="21.3"
android:viewportHeight="38.5">
<path
android:pathData="M8.6,8.6h4.3V21.4H8.6ZM2.1,2.1H19.2V27.8H8.6V23.5H15V6.4H6.4V23.5H2.1ZM0,0V25.7H6.4V38.5H8.5V29.9H21.3V0Z"
android:fillColor="#217f79"/>
</vector>
...@@ -86,7 +86,8 @@ ...@@ -86,7 +86,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_gradient_height" android:layout_height="@dimen/bottom_gradient_height"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="@drawable/botttom_bar_shadow" /> android:background="@drawable/botttom_bar_shadow"
android:visibility="invisible" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
...@@ -97,14 +98,13 @@ ...@@ -97,14 +98,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:visibility="visible" android:visibility="gone"
app:elevation="0dp" app:elevation="0dp"
app:itemBackground="@color/colorCommonBackground" app:itemBackground="@color/colorCommonBackground"
app:itemHorizontalTranslationEnabled="false" app:itemHorizontalTranslationEnabled="false"
app:itemIconTint="@drawable/bottom_navigation_icon_selector" app:itemIconTint="@drawable/bottom_navigation_icon_selector"
app:labelVisibilityMode="labeled" app:labelVisibilityMode="labeled"
app:menu="@menu/bottom_navigation_menu" app:menu="@menu/bottom_navigation_menu">
tools:visibility="invisible">
</com.google.android.material.bottomnavigation.BottomNavigationView> </com.google.android.material.bottomnavigation.BottomNavigationView>
......
...@@ -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"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"> xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/linearLayout">
</LinearLayout> <ImageView
\ No newline at end of file android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/splashBackground"
tools:layout_editor_absoluteX="174dp" tools:layout_editor_absoluteY="540dp" android:scaleType="centerCrop"/>
<ImageView
android:layout_width="32dp"
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_onlyr"
android:id="@+id/imageView3"
app:layout_constraintEnd_toEndOf="@+id/splashBackground"
app:layout_constraintStart_toStartOf="@+id/splashBackground" app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="8dp" app:layout_constraintTop_toTopOf="@+id/splashBackground"
android:layout_marginBottom="8dp" android:layout_marginEnd="8dp"/>
<TextView
style="@style/Header_TextView.Main_Header"
android:text="РУМЯНЦЕВО-ПАРК"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/logo_header" android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/imageView3"
app:layout_constraintStart_toStartOf="@+id/imageView3" app:layout_constraintEnd_toEndOf="@+id/imageView3"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -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