Commit 2c600827 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

add deal screen blank, fix imports

parent 76a81cd5
package com.biganto.visual.roompark.presentation.screen.deal
import com.biganto.visual.roompark.conductor.BigantoBaseContract
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface DealScreen : BigantoBaseContract<DealScreenViewState> {
}
package com.biganto.visual.roompark.presentation.screen.deal
import android.os.Bundle
import android.view.View
import androidx.core.os.bundleOf
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.textview.MaterialTextView
import timber.log.Timber
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
const val SELECTED_ESTATE_ID_KEY = "SELECTED_ESTATE_INDEX"
class DealScreenController :
BigantoBaseController<DealScreenViewState
, DealScreen
, DealScreenPresenter>
, DealScreen {
constructor(args: Bundle):super(args)
constructor(id: Int) : super(bundleOf(SELECTED_ESTATE_ID_KEY to id))
override fun injectDependencies() {
getComponent()
}
@Inject
override lateinit var injectedPresenter: DealScreenPresenter
@BindView(R.id.explication_tab)
lateinit var explicationTab: MaterialTextView
private fun setToolbar(){
toolBar.showAll()
toolBar.appBar.setExpanded(false,false)
toolBar.collapsingToolbarLayout.title = "СДЕЛКА"
toolBar.appBar.liftOnScrollTargetViewId = R.id.favorites_cards_recycler_view
toolBar.appBar.setLiftable(true)
toolBar.appBarScrollable(false)
// planTypesTabLayout.
}
private fun bindRecycler() {
}
override fun onViewBound(v: View) {
setToolbar()
bindRecycler()
}
override fun render(viewState: DealScreenViewState) {
super.render(viewState)
Timber.d("Render state $viewState")
when(viewState){
is DealScreenViewState.Idle -> render(viewState)
is DealScreenViewState.LoadDeal -> render(viewState)
is DealScreenViewState.SomeError -> render(viewState)
}
}
private fun render(viewState: DealScreenViewState.Idle){
}
private fun render(viewState: DealScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: DealScreenViewState.LoadDeal) {
}
private fun getComponent() = DaggerDealScreenComponent.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity
,args.getInt(SELECTED_ESTATE_ID_KEY))
.inject(this)
override fun getLayoutId(): Int = R.layout.deal_scren
}
package com.biganto.visual.roompark.presentation.screen.deal
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.PerScreen
import com.biganto.visual.roompark.presentation.screen.estate.DealScreenComponent
import com.biganto.visual.roompark.presentation.screen.estate.DealScreenController
import com.biganto.visual.roompark.presentation.screen.estate.DealScreenModule
import com.biganto.visual.roompark.presentation.screen.estate.DealScreenPresenter
import dagger.Binds
import dagger.BindsInstance
import dagger.Component
import dagger.Module
import javax.inject.Named
@PerScreen
@Component(
modules = [DealScreenModule::class],
dependencies = [AppComponent::class])
interface DealScreenComponent {
@Component.Factory
interface Factory{
fun create(
appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity
,@BindsInstance @Named(SELECTED_ESTATE_ID_KEY) selectedDealId:Int
): DealScreenComponent
}
val presenter: DealScreenPresenter
fun inject(controller: DealScreenController)
}
@Module
abstract class DealScreenModule{
@PerScreen
@Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context
}
package com.biganto.visual.roompark.presentation.screen.deal
import android.content.Context
import androidx.annotation.StringRes
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.DealInteractor
import com.biganto.visual.roompark.domain.model.*
import com.biganto.visual.roompark.presentation.screen.deal.DealScreen
import com.biganto.visual.roompark.presentation.screen.estate.DealScreen
import com.biganto.visual.roompark.presentation.screen.estate.DealScreenViewState
import com.biganto.visual.roompark.presentation.screen.estate.InfoShowType
import com.biganto.visual.roompark.presentation.screen.estate.util.DisplayInfoModel
import com.biganto.visual.roompark.util.extensions.toRubly
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
import javax.inject.Inject
import javax.inject.Named
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class DealScreenPresenter @Inject constructor(
private val interactor: DealInteractor,
private val context: Context,
@Named(SELECTED_ESTATE_ID_KEY) private val estateId:Int
)
: BigantoBasePresenter<DealScreen, DealScreenViewState>() {
private var planList: List<PlanPresetModel>? = null
private var estate: DealModel? = null
private var showType: InfoShowType = InfoShowType.COMMON_INFO
override fun defaultErrorViewStateHandler() =
{ e: ExceptionString -> DealScreenViewState.SomeError(e) }
private fun getPlan(plan: PlanPresetModel): Observable<DealScreenViewState> =
interactor.getPlan(plan)
.map<DealScreenViewState> { DealScreenViewState.LoadPlan(it) }
override fun bindIntents() {
val prefetchCards = interactor.getDeal(estateId)
.doOnNext { estate = it.copy() }
.map { DealScreenViewState.LoadDeal(it) }
val state = restoreStateObservable
.mergeWith(prefetchCards)
.doOnError { Timber.e(it) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
subscribeViewState(state.cast(DealScreenViewState::class.java), DealScreen::render)
}
private fun langString(@StringRes id:Int) = context.resources.getString(id)
private fun langString(@StringRes id:Int,vararg args:Any) =
context.resources.getString(id,*args)
}
package com.biganto.visual.roompark.presentation.screen.deal
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.DealModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.presentation.screen.estate.DealScreenViewState
import com.biganto.visual.roompark.presentation.screen.estate.util.DisplayInfoModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
sealed class DealScreenViewState : BigantoBaseViewState() {
class Idle : DealScreenViewState()
class LoadDeal(val estate:DealModel) : DealScreenViewState()
class SomeError(val exception: ExceptionString) : DealScreenViewState()
}
\ No newline at end of file
...@@ -94,7 +94,7 @@ class EstateScreenController : ...@@ -94,7 +94,7 @@ class EstateScreenController :
constructor(args: Bundle):super(args) constructor(args: Bundle):super(args)
constructor(id: Int) : super(bundleOf(SELECTED_ESTATE_ID_KEY to id)) constructor(id: Int) : super(bundleOf(com.biganto.visual.roompark.presentation.screen.deal.SELECTED_ESTATE_ID_KEY to id))
override fun injectDependencies() { override fun injectDependencies() {
getComponent() getComponent()
...@@ -278,7 +278,7 @@ class EstateScreenController : ...@@ -278,7 +278,7 @@ class EstateScreenController :
private fun getComponent() = DaggerEstateScreenComponent.factory() private fun getComponent() = DaggerEstateScreenComponent.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity .create(RoomParkApplication.component,activity as RoomParkMainActivity
,args.getInt(SELECTED_ESTATE_ID_KEY)) ,args.getInt(com.biganto.visual.roompark.presentation.screen.deal.SELECTED_ESTATE_ID_KEY))
.inject(this) .inject(this)
override fun getLayoutId(): Int = R.layout.flat_full_card_screen override fun getLayoutId(): Int = R.layout.flat_full_card_screen
......
...@@ -22,7 +22,7 @@ interface EstateScreenComponent { ...@@ -22,7 +22,7 @@ interface EstateScreenComponent {
fun create( fun create(
appComponent: AppComponent appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity ,@BindsInstance activity: RoomParkMainActivity
,@BindsInstance @Named(SELECTED_ESTATE_ID_KEY) selectedEstateId:Int ,@BindsInstance @Named(com.biganto.visual.roompark.presentation.screen.deal.SELECTED_ESTATE_ID_KEY) selectedEstateId:Int
): EstateScreenComponent ): EstateScreenComponent
} }
......
...@@ -24,7 +24,7 @@ import javax.inject.Named ...@@ -24,7 +24,7 @@ import javax.inject.Named
class EstateScreenPresenter @Inject constructor( class EstateScreenPresenter @Inject constructor(
private val interactor: EstateInteractor, private val interactor: EstateInteractor,
private val context: Context, private val context: Context,
@Named(SELECTED_ESTATE_ID_KEY) private val estateId:Int @Named(com.biganto.visual.roompark.presentation.screen.deal.SELECTED_ESTATE_ID_KEY) private val estateId:Int
) )
: BigantoBasePresenter<EstateScreen, EstateScreenViewState>() { : BigantoBasePresenter<EstateScreen, EstateScreenViewState>() {
...@@ -66,7 +66,7 @@ class EstateScreenPresenter @Inject constructor( ...@@ -66,7 +66,7 @@ class EstateScreenPresenter @Inject constructor(
EstateScreenViewState.ShowEstateInfo( EstateScreenViewState.ShowEstateInfo(
showType showType
,if (showType==InfoShowType.COMMON_INFO) ,if (showType== InfoShowType.COMMON_INFO)
mapCommonInfo(estate?.commonInfo) mapCommonInfo(estate?.commonInfo)
else mapCommonInfo(planPreset.explication) else mapCommonInfo(planPreset.explication)
) )
......
...@@ -18,5 +18,5 @@ sealed class EstateScreenViewState : BigantoBaseViewState() { ...@@ -18,5 +18,5 @@ sealed class EstateScreenViewState : BigantoBaseViewState() {
class PlanTypeSelected(val item:PlanPresetModel) : EstateScreenViewState() class PlanTypeSelected(val item:PlanPresetModel) : EstateScreenViewState()
class LoadPlan(val planBody:String) : EstateScreenViewState() class LoadPlan(val planBody:String) : EstateScreenViewState()
class SomeError(val exception: ExceptionString) : EstateScreenViewState() class SomeError(val exception: ExceptionString) : EstateScreenViewState()
class ShowEstateInfo(val showType:InfoShowType,val info:List<DisplayInfoModel>) : EstateScreenViewState() class ShowEstateInfo(val showType: InfoShowType, val info:List<DisplayInfoModel>) : EstateScreenViewState()
} }
\ No newline at end of file
...@@ -8,7 +8,7 @@ import com.biganto.visual.roompark.R ...@@ -8,7 +8,7 @@ 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.biganto.visual.roompark.presentation.screen.estate.EstateScreenController import com.biganto.visual.roompark.presentation.screen.deal.EstateScreenController
import com.biganto.visual.roompark.presentation.screen.favorites.util.FavoritesListAdapter import com.biganto.visual.roompark.presentation.screen.favorites.util.FavoritesListAdapter
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
......
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