Commit 99cecf5f authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

estate resotre model

parent 817a65ce
......@@ -80,7 +80,7 @@ class ChooseTourDialogController : Controller {
.subscribe(::onTourClicked)
)
view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
// view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
view.setOnClickListener { handleBack() }
return view
......
package com.biganto.visual.roompark.presentation.screen.estate
import android.annotation.SuppressLint
import android.net.Uri
import android.os.Bundle
import android.view.View
......@@ -262,6 +263,7 @@ class EstateScreenController :
is EstateScreenViewState.SomeError -> render(viewState)
is EstateScreenViewState.ShowEstateInfo -> render(viewState)
is EstateScreenViewState.ToursLoaded -> render(viewState)
is EstateScreenViewState.RestoreView -> render(viewState)
}
}
......@@ -277,40 +279,12 @@ class EstateScreenController :
private var estateModel : EstateModel? = null
private fun render(viewState: EstateScreenViewState.LoadEstate) {
estateModel = viewState.estate
toolBar.setToolbar(
null, StatusToolbarModel(StatusState.AVAILABLE,null, null)
)
flatTitle.text = resources?.getString(viewState.estate.type.typeShortString()
,viewState.estate.number)
siteLink.setGone(viewState.estate.url == null)
viewState.estate.url?.let {url ->
siteLink.setOnClickListener{
activity?.startUrl(url)
}
setEstateInfo(viewState.estate)
}
startTour.setGone(viewState.estate.multitourId == null)
startTourDivider.setGone(viewState.estate.multitourId == null)
viewState.estate.multitourPreview?.let {
Glide.with(tourScreen)
.load(it)
.into(tourScreen)
}
when(viewState.estate.type){
FlatType.FLAT -> {
flatTypeView.setGone(false)
infoTabDivicder.setGone(false)
explicationTab.setGone(false)
}
else -> {
flatTypeView.setGone(true)
infoTabDivicder.setGone(true)
explicationTab.setGone(true)
}
}
private fun render(viewState: EstateScreenViewState.RestoreView) {
setEstateInfo(viewState.restore.estate)
}
......@@ -395,6 +369,7 @@ class EstateScreenController :
}
@SuppressLint("SetJavaScriptEnabled")
private fun render(viewState: EstateScreenViewState.LoadPlan) {
planWebView.settings.javaScriptEnabled = true
planWebView.clearCache(true)
......@@ -402,11 +377,51 @@ class EstateScreenController :
planWebView.loadUrl(uri)
}
private fun setEstateInfo(estateModel: EstateModel?){
toolBar.setToolbar(
null, StatusToolbarModel(StatusState.AVAILABLE,null, null)
)
estateModel?.let {estate ->
flatTitle.text = resources?.getString(estate.type.typeShortString()
,estate.number)
}
siteLink.setGone(estateModel?.url == null)
estateModel?.url?.let {url ->
siteLink.setOnClickListener{
activity?.startUrl(url)
}
}
startTour.setGone(estateModel?.multitourId == null)
startTourDivider.setGone(estateModel?.multitourId == null)
estateModel?.multitourPreview?.let {
Glide.with(tourScreen)
.load(it)
.into(tourScreen)
}
when(estateModel?.type){
FlatType.FLAT -> {
flatTypeView.setGone(false)
infoTabDivicder.setGone(false)
explicationTab.setGone(false)
}
else -> {
flatTypeView.setGone(true)
infoTabDivicder.setGone(true)
explicationTab.setGone(true)
}
}
}
private fun getComponent() = DaggerEstateScreenComponent.factory()
.create(RoomParkApplication.component,activity as RoomParkMainActivity
,args.getInt(SELECTED_ESTATE_ID_KEY))
.inject(this)
override fun getLayoutId(): Int = R.layout.flat_full_card_screen
......
......@@ -30,11 +30,6 @@ class EstateScreenPresenter @Inject constructor(
)
: BigantoBasePresenter<EstateScreen, EstateScreenViewState>() {
private var planList: List<PlanPresetModel>? = null
private var estate: EstateModel? = null
private var showType: InfoShowType = InfoShowType.COMMON_INFO
override fun defaultErrorViewStateHandler() =
{ e: ExceptionString -> EstateScreenViewState.SomeError(e) }
......@@ -43,18 +38,26 @@ class EstateScreenPresenter @Inject constructor(
interactor.getPlan(plan)
.map<EstateScreenViewState> { EstateScreenViewState.LoadPlan(it) }
private var restoreModel = RestoreModel(null,null)
override fun detachView() {
super.detachView()
restoreStateObservable.accept(EstateScreenViewState.RestoreView(restoreModel))
}
override fun bindIntents() {
val prefetchCards = interactor.getEstate(estateId)
.doOnNext { estate = it.copy() }
.doOnNext { restoreModel.estate = it.copy() }
.map { EstateScreenViewState.LoadEstate(it) }
val fetchPlans = interactor.getPlanTypes(estateId)
.doOnNext { planList = it.toList() }
.doOnNext {restoreModel.planList = it.toList() }
.map { EstateScreenViewState.LoadPlanTypes(it) }
val fetchPlan = intent(EstateScreen::planTypesTabSelected)
.map { planList?.get(it) }
.map { restoreModel.planList?.get(it) }
.flatMap { planPreset ->
interactor.getPlan(planPreset)
.map<EstateScreenViewState> { plan -> EstateScreenViewState.LoadPlan(plan) }
......@@ -67,9 +70,9 @@ class EstateScreenPresenter @Inject constructor(
Observable.just<EstateScreenViewState>(
EstateScreenViewState.ShowEstateInfo(
showType
, if (showType == InfoShowType.COMMON_INFO)
mapCommonInfo(estate?.commonInfo)
restoreModel.showType
, if (restoreModel.showType == InfoShowType.COMMON_INFO)
mapCommonInfo(restoreModel.estate?.commonInfo)
else mapCommonInfo(planPreset.explication)
)
)
......@@ -78,48 +81,48 @@ class EstateScreenPresenter @Inject constructor(
val switchSizes = intent(EstateScreen::switchSizes)
.map { pair ->
val plan = planList?.first { it.planId == pair.first }
val plan = restoreModel.planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Sizes>(pair.second)
plan
}.flatMap(::getPlan)
val switchFurn = intent(EstateScreen::switchFurniture)
.map { pair ->
val plan = planList?.first { it.planId == pair.first }
val plan = restoreModel.planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Furniture>(pair.second)
plan
}.flatMap(::getPlan)
val switchWalls = intent(EstateScreen::switchWalls)
.map { pair ->
val plan = planList?.first { it.planId == pair.first }
val plan = restoreModel.planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Walls>(pair.second)
plan
}.flatMap(::getPlan)
val switchElectric = intent(EstateScreen::switchElectric)
.map { pair ->
val plan = planList?.first { it.planId == pair.first }
val plan = restoreModel.planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Electric>(pair.second)
plan
}.flatMap(::getPlan)
val showInfo = intent(EstateScreen::showCommonInfo)
.doOnNext { showType = InfoShowType.COMMON_INFO }
.map { estate?.commonInfo }
.doOnNext { restoreModel.showType = InfoShowType.COMMON_INFO }
.map { restoreModel.estate?.commonInfo }
.map(::mapCommonInfo)
.map { EstateScreenViewState.ShowEstateInfo(showType, it) }
.map { EstateScreenViewState.ShowEstateInfo(restoreModel.showType, it) }
val showExplication = intent(EstateScreen::showExplication)
.doOnNext { showType = InfoShowType.EXPLICATIONS }
.map { planList?.get(it)?.explication }
.doOnNext { restoreModel.showType = InfoShowType.EXPLICATIONS }
.map { restoreModel.planList?.get(it)?.explication }
.map(::mapCommonInfo)
.map { EstateScreenViewState.ShowEstateInfo(showType, it) }
.map { EstateScreenViewState.ShowEstateInfo(restoreModel.showType, it) }
val onStartTours = intent(EstateScreen::tourCardClicked)
.map { estate }
.map { restoreModel.estate }
.flatMap {estate -> toursInteractor.getEstateTourList(estate)
.map { EstateScreenViewState.ToursLoaded(it) }
}
......@@ -202,3 +205,8 @@ enum class InfoShowType{
COMMON_INFO,
EXPLICATIONS
}
data class RestoreModel(var planList: List<PlanPresetModel>? = null,
var estate: EstateModel? = null,
var showType: InfoShowType = InfoShowType.COMMON_INFO)
\ No newline at end of file
......@@ -21,4 +21,5 @@ sealed class EstateScreenViewState : BigantoBaseViewState() {
class SomeError(val exception: ExceptionString) : EstateScreenViewState()
class ShowEstateInfo(val showType: InfoShowType, val info:List<DisplayInfoModel>) : EstateScreenViewState()
class ToursLoaded(val tours:List<TourModel>) : EstateScreenViewState()
class RestoreView(val restore:RestoreModel) : EstateScreenViewState()
}
\ No newline at end of file
......@@ -59,10 +59,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cancelDownloadButton"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
app:layout_constraintTop_toBottomOf="@+id/downloadProgress" android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="32dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.24000001" style="@style/CancelTextDownloader" android:padding="4dp"
app:layout_constraintVertical_bias="0.24000001" style="@style/CancelTextDownloader"
android:padding="8dp"
android:paddingStart="8dp" android:paddingEnd="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -5,8 +5,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/playTourCardOpacityLight"
android:backgroundTintMode="src_atop"
android:clickable="true"
android:focusableInTouchMode="true">
android:focusable="true">
<com.google.android.material.card.MaterialCardView
android:layout_width="0dp"
......@@ -42,10 +43,9 @@
android:layout_alignParentEnd="true"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:clickable="true"
android:clickable="false"
android:contentDescription="@string/content_description_close"
android:focusable="true"
android:focusableInTouchMode="true"
android:focusable="false"
android:scaleType="fitXY"
android:src="@drawable/ic_close_circled"
app:layout_constraintEnd_toEndOf="parent"
......
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