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
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView
import io.fabric.sdk.android.Fabric
import kotlin.concurrent.thread
import kotlinx.android.synthetic.main.activity_main.*
import timber.log.Timber
class RoomParkMainActivity(
) : BaseRoomParkActivity()
......@@ -41,6 +42,8 @@ class RoomParkMainActivity(
@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_view_divider) lateinit var bottomShadow: View
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
......@@ -53,42 +56,38 @@ class RoomParkMainActivity(
setSupportActionBar(topAppBar)
hideAll()
router = Conductor.attachRouter(this, conductorContainer, savedInstanceState)
thread(start=true ) {
Thread.sleep(1000L)
runOnUiThread{
router.setRoot(RouterTransaction.with(SplashScreenController()))
}
}
// snackbarProvider.bindRootView(rootView = coordinatorLayout)
}
override fun displayBackButton(show: Boolean) {
supportActionBar?.setDisplayHomeAsUpEnabled(show)
}
override fun hideAll() {
appBar.visibility=Toolbar.INVISIBLE
bottomNavigation.visibility = Toolbar.GONE
val params = coordinatorLayout.layoutParams as CoordinatorLayout.LayoutParams
bottomNavigation.visibility = BottomNavigationView.GONE
bottomShadow.visibility = View.GONE
Timber.e(" lay params : ${appBar.layoutParams.javaClass}")
val params:CoordinatorLayout.LayoutParams = conductor_container.layoutParams as CoordinatorLayout.LayoutParams
params.behavior = null
coordinatorLayout.requestLayout()
conductor_container.requestLayout()
}
override fun showAll() {
appBar.setExpanded(false,false)
collapsingToolbarLayout.visibility= View.VISIBLE
bottomNavigation.visibility = Toolbar.VISIBLE
bottomShadow.visibility = View.VISIBLE
appBar.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()
coordinatorLayout.requestLayout()
conductor_container.requestLayout()
}
override fun appBarScrollable(allow: Boolean) {
......
......@@ -18,7 +18,6 @@ import com.biganto.visual.roompark.di.dagger.ActivityModule
import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import com.hannesdorfmann.mosby3.mvi.MviBasePresenter
import io.reactivex.disposables.CompositeDisposable
import timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 28.05.2018.
......@@ -37,12 +36,13 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
protected val detachDisposable = CompositeDisposable()
abstract override fun createPresenter(): P
abstract var injectedPresenter:P
override fun createPresenter(): P = injectedPresenter
@LayoutRes
protected abstract fun getLayoutId(): Int
lateinit var toolBar: ICollapsingToolBar
lateinit var snackbar: ISnackBarProvider
......@@ -53,16 +53,6 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
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) {
super.onContextAvailable(context)
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
import DaggerSplashScreenComponent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -9,6 +8,9 @@ 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
......@@ -29,6 +31,9 @@ class SplashScreenController :
@Inject
lateinit var tb: ICollapsingToolBar
@Inject
override lateinit var injectedPresenter: SplashScreenPresenter
// @Inject
// lateinit var snacky:ISnackBarProvider
......@@ -46,7 +51,6 @@ class SplashScreenController :
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val v = super.onCreateView(inflater, container)
snackbar.showSnackBar("AZZZA", Snackbar.LENGTH_LONG)
return v
}
......@@ -64,16 +68,15 @@ class SplashScreenController :
private fun render(viewState: SplashScreenViewState.ToScreen){
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")
}
@Inject
lateinit var _p : SplashScreenPresenter
override fun createPresenter(): SplashScreenPresenter = _p
override fun getLayoutId(): Int = R.layout.splash_screen
......
package com.biganto.visual.roompark.presentation.screen.splash
import android.content.Context
import com.biganto.visual.roompark.base.ICollapsingToolBar
......@@ -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.PerScreen
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.BindsInstance
import dagger.Component
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.
// */
//
//@PerScreen
//@Component(dependencies = [AppComponent::class])
//interface SplashComponent {
// @Provides
// fun presenter(): SplashScreenPresenter
//}
//
//
@PerScreen
@Component(
modules = [SplashScreenModule::class],
......@@ -45,7 +27,7 @@ interface SplashScreenComponent {
fun create(
appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity
):SplashScreenComponent
): SplashScreenComponent
}
val presenter: SplashScreenPresenter
......@@ -60,19 +42,10 @@ abstract class SplashScreenModule{
@Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context
@PerScreen
@Binds
abstract fun provideAuth(contract: AuthContractModule): AuthContract
// @Binds
// abstract fun provideContext(activity: Activity): Context
// @Binds
// abstract fun provideSnack(snack:ISnackBarProvider) : ISnackBarProvider
@PerScreen
@Binds
abstract fun provideToolbar(activitiy: RoomParkMainActivity): ICollapsingToolBar
......
......@@ -11,8 +11,8 @@ import javax.inject.Inject
class SplashScreenPresenter @Inject constructor(
var acitivityContext: RoomParkMainActivity
,val interactor: SplashInteractor
private val acitivityContext: RoomParkMainActivity
, private val interactor: SplashInteractor
// ,var context:Context
)
: 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 @@
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_gradient_height"
android:layout_gravity="bottom"
android:background="@drawable/botttom_bar_shadow" />
android:background="@drawable/botttom_bar_shadow"
android:visibility="invisible" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
......@@ -97,14 +98,13 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:fitsSystemWindows="true"
android:visibility="visible"
android:visibility="gone"
app:elevation="0dp"
app:itemBackground="@color/colorCommonBackground"
app:itemHorizontalTranslationEnabled="false"
app:itemIconTint="@drawable/bottom_navigation_icon_selector"
app:labelVisibilityMode="labeled"
app:menu="@menu/bottom_navigation_menu"
tools:visibility="invisible">
app:menu="@menu/bottom_navigation_menu">
</com.google.android.material.bottomnavigation.BottomNavigationView>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/linearLayout">
</LinearLayout>
\ No newline at end of file
<ImageView
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