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

added auth screen pattern

parent 230d45a8
...@@ -19,7 +19,8 @@ import com.google.android.material.appbar.AppBarLayout ...@@ -19,7 +19,8 @@ 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 kotlin.concurrent.thread import kotlinx.android.synthetic.main.activity_main.*
import timber.log.Timber
class RoomParkMainActivity( class RoomParkMainActivity(
) : BaseRoomParkActivity() ) : BaseRoomParkActivity()
...@@ -41,6 +42,8 @@ class RoomParkMainActivity( ...@@ -41,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)
...@@ -53,18 +56,11 @@ class RoomParkMainActivity( ...@@ -53,18 +56,11 @@ class RoomParkMainActivity(
setSupportActionBar(topAppBar) setSupportActionBar(topAppBar)
router = Conductor.attachRouter(this, conductorContainer, savedInstanceState) hideAll()
thread(start=true ) {
Thread.sleep(1000L)
runOnUiThread{
router.setRoot(RouterTransaction.with(SplashScreenController()))
}
}
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) {
...@@ -73,22 +69,25 @@ class RoomParkMainActivity( ...@@ -73,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) {
......
...@@ -18,7 +18,6 @@ import com.biganto.visual.roompark.di.dagger.ActivityModule ...@@ -18,7 +18,6 @@ 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 timber.log.Timber
/** /**
* Created by Vladislav Bogdashkin on 28.05.2018. * Created by Vladislav Bogdashkin on 28.05.2018.
...@@ -37,12 +36,13 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon ...@@ -37,12 +36,13 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
protected val detachDisposable = CompositeDisposable() protected val detachDisposable = CompositeDisposable()
abstract override fun createPresenter(): P abstract var injectedPresenter:P
override fun createPresenter(): P = injectedPresenter
@LayoutRes @LayoutRes
protected abstract fun getLayoutId(): Int protected abstract fun getLayoutId(): Int
lateinit var toolBar: ICollapsingToolBar lateinit var toolBar: ICollapsingToolBar
lateinit var snackbar: ISnackBarProvider lateinit var snackbar: ISnackBarProvider
...@@ -53,16 +53,6 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon ...@@ -53,16 +53,6 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
private var isInjected = false private var isInjected = false
override fun onRestoreViewState(view: View, savedViewState: Bundle) {
super.onRestoreViewState(view, savedViewState)
// try {
// ConductorInjection.inject(this)
// isInjected = true
// } catch (ignored: Throwable) {
// delay injection until onCreateView
// }
}
override fun onContextAvailable(context: Context) { override fun onContextAvailable(context: Context) {
super.onContextAvailable(context) super.onContextAvailable(context)
inject inject
......
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()
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.auth
import com.biganto.visual.roompark.conductor.BigantoBaseContract
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface AuthScreen : BigantoBaseContract<AuthScreenViewState> {
}
\ 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 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.snackbar.Snackbar
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class AuthScreenController :
BigantoBaseController<AuthScreenViewState
, AuthScreen
, AuthScreenPresenter>()
, AuthScreen {
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.ToScreen -> render(viewState)
}
}
private fun render(viewState: AuthScreenViewState.Idle){
}
private fun render(viewState: AuthScreenViewState.ToScreen){
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 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 ToScreen(val message:String) : AuthScreenViewState()
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash package com.biganto.visual.roompark.presentation.screen.splash
import DaggerSplashScreenComponent
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -9,6 +8,9 @@ import com.biganto.visual.roompark.base.ICollapsingToolBar ...@@ -9,6 +8,9 @@ import com.biganto.visual.roompark.base.ICollapsingToolBar
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.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import javax.inject.Inject import javax.inject.Inject
...@@ -29,6 +31,9 @@ class SplashScreenController : ...@@ -29,6 +31,9 @@ class SplashScreenController :
@Inject @Inject
lateinit var tb: ICollapsingToolBar lateinit var tb: ICollapsingToolBar
@Inject
override lateinit var injectedPresenter: SplashScreenPresenter
// @Inject // @Inject
// lateinit var snacky:ISnackBarProvider // lateinit var snacky:ISnackBarProvider
...@@ -46,7 +51,6 @@ class SplashScreenController : ...@@ -46,7 +51,6 @@ class SplashScreenController :
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val v = super.onCreateView(inflater, container) val v = super.onCreateView(inflater, container)
snackbar.showSnackBar("AZZZA", Snackbar.LENGTH_LONG)
return v return v
} }
...@@ -64,16 +68,15 @@ class SplashScreenController : ...@@ -64,16 +68,15 @@ class SplashScreenController :
private fun render(viewState: SplashScreenViewState.ToScreen){ private fun render(viewState: SplashScreenViewState.ToScreen){
snackbar.showSnackBar(viewState.message, Snackbar.LENGTH_LONG) snackbar.showSnackBar(viewState.message, Snackbar.LENGTH_LONG)
tb.appBar.setBackgroundColor(resources?.getColor(R.color.colorAccentSecondary)?:R.color.colorAccent) tb.hideAll()
router.pushController(RouterTransaction.with(AuthScreenController())
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())
)
// snacky.showSnackBar("lul") // snacky.showSnackBar("lul")
} }
@Inject
lateinit var _p : SplashScreenPresenter
override fun createPresenter(): SplashScreenPresenter = _p
override fun getLayoutId(): Int = R.layout.splash_screen override fun getLayoutId(): Int = R.layout.splash_screen
......
package com.biganto.visual.roompark.presentation.screen.splash
import android.content.Context import android.content.Context
import com.biganto.visual.roompark.base.ICollapsingToolBar import com.biganto.visual.roompark.base.ICollapsingToolBar
...@@ -6,34 +7,15 @@ import com.biganto.visual.roompark.di.dagger.AppComponent ...@@ -6,34 +7,15 @@ import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.AuthContractModule import com.biganto.visual.roompark.di.dagger.AuthContractModule
import com.biganto.visual.roompark.di.dagger.PerScreen 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 com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenPresenter
import dagger.Binds import dagger.Binds
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
import dagger.Module import dagger.Module
//package com.biganto.visual.roompark.presentation.screen.splash
//
//import com.biganto.visual.roompark.di.dagger.AppComponent
//import com.biganto.visual.roompark.di.dagger.PerScreen
//import dagger.Component
//import dagger.Provides
//
///** ///**
// * Created by Vladislav Bogdashkin on 30.09.2019. // * Created by Vladislav Bogdashkin on 30.09.2019.
// */ // */
//
//@PerScreen
//@Component(dependencies = [AppComponent::class])
//interface SplashComponent {
// @Provides
// fun presenter(): SplashScreenPresenter
//}
//
//
@PerScreen @PerScreen
@Component( @Component(
modules = [SplashScreenModule::class], modules = [SplashScreenModule::class],
...@@ -45,7 +27,7 @@ interface SplashScreenComponent { ...@@ -45,7 +27,7 @@ interface SplashScreenComponent {
fun create( fun create(
appComponent: AppComponent appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity ,@BindsInstance activity: RoomParkMainActivity
):SplashScreenComponent ): SplashScreenComponent
} }
val presenter: SplashScreenPresenter val presenter: SplashScreenPresenter
...@@ -60,19 +42,10 @@ abstract class SplashScreenModule{ ...@@ -60,19 +42,10 @@ abstract class SplashScreenModule{
@Binds @Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context abstract fun provideContext(activity: RoomParkMainActivity): Context
@PerScreen @PerScreen
@Binds @Binds
abstract fun provideAuth(contract: AuthContractModule): AuthContract abstract fun provideAuth(contract: AuthContractModule): AuthContract
// @Binds
// abstract fun provideContext(activity: Activity): Context
// @Binds
// abstract fun provideSnack(snack:ISnackBarProvider) : ISnackBarProvider
@PerScreen @PerScreen
@Binds @Binds
abstract fun provideToolbar(activitiy: RoomParkMainActivity): ICollapsingToolBar abstract fun provideToolbar(activitiy: RoomParkMainActivity): ICollapsingToolBar
......
...@@ -11,8 +11,8 @@ import javax.inject.Inject ...@@ -11,8 +11,8 @@ import javax.inject.Inject
class SplashScreenPresenter @Inject constructor( class SplashScreenPresenter @Inject constructor(
var acitivityContext: RoomParkMainActivity private val acitivityContext: RoomParkMainActivity
,val interactor: SplashInteractor , private val interactor: SplashInteractor
// ,var context:Context // ,var context:Context
) )
: BigantoBasePresenter<SplashScreen, SplashScreenViewState>() { : BigantoBasePresenter<SplashScreen, SplashScreenViewState>() {
......
<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>
......
<?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
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