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

deals card viewholder buttons

parent b1d17e78
...@@ -2,6 +2,8 @@ package com.biganto.visual.roompark.domain.model ...@@ -2,6 +2,8 @@ package com.biganto.visual.roompark.domain.model
data class DealPreviewModel( data class DealPreviewModel(
val id:String, val id:String,
val estateId:Int,
val tourId: Int?,
val type:FlatType, val type:FlatType,
val name:String, val name:String,
val building:Int?, val building:Int?,
...@@ -19,6 +21,8 @@ data class DealPreviewModel( ...@@ -19,6 +21,8 @@ data class DealPreviewModel(
){ ){
constructor(data:Pair<DealModel,List<StatusModel>>) : this( constructor(data:Pair<DealModel,List<StatusModel>>) : this(
data.first.id, data.first.id,
data.first.estate.id,
data.first.estate.multitourId,
data.first.estate.type, data.first.estate.type,
data.first.estate.number, data.first.estate.number,
data.first.estate.commonInfo?.building, data.first.estate.commonInfo?.building,
......
...@@ -15,9 +15,12 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController ...@@ -15,9 +15,12 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.domain.model.DealModel import com.biganto.visual.roompark.domain.model.DealModel
import com.biganto.visual.roompark.domain.model.typeDoubleString import com.biganto.visual.roompark.domain.model.typeDoubleString
import com.biganto.visual.roompark.domain.model.typeShortString import com.biganto.visual.roompark.domain.model.typeShortString
import com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
import com.biganto.visual.roompark.util.extensions.toRubly import com.biganto.visual.roompark.util.extensions.toRubly
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.clicks import com.jakewharton.rxbinding3.view.clicks
import com.jakewharton.rxbinding3.view.scrollChangeEvents import com.jakewharton.rxbinding3.view.scrollChangeEvents
...@@ -75,22 +78,32 @@ class DealScreenController : ...@@ -75,22 +78,32 @@ class DealScreenController :
@BindView(R.id.deal_payed_value_text_view) lateinit var dealPayed: MaterialTextView @BindView(R.id.deal_payed_value_text_view) lateinit var dealPayed: MaterialTextView
@BindView(R.id.deal_to_pay_value_text_view) lateinit var dealSumToPay: MaterialTextView @BindView(R.id.deal_to_pay_value_text_view) lateinit var dealSumToPay: MaterialTextView
private fun setToolbar(){
toolBar.setToolbar(HeaderToolbarModel( @BindView(R.id.flat_card_card_view)
true lateinit var toFlatView: View
,resources?.getString(R.string.deal_back_chevron_title)
,null @BindView(R.id.start_tour_card)
,null) lateinit var startTourView: View
private var servedDeal : DealModel? = null
override fun onAttach(view: View) {
super.onAttach(view)
detachDisposable.addAll(
toFlatView.clicks()
.map { servedDeal?.estate?.id?: -1000}
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
Timber.d("got card clicked $it")
router.pushController(
RouterTransaction.with(EstateScreenController(it))
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())
)
}
) )
toolBar.headerToolbarBack?.let {
detachDisposable.add(
it.clicks()
.doOnNext { Timber.d("clicked: 1") }
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe { handleBack() }
)
}
detachDisposable.add( detachDisposable.add(
dealContainer.scrollChangeEvents() dealContainer.scrollChangeEvents()
...@@ -119,6 +132,26 @@ class DealScreenController : ...@@ -119,6 +132,26 @@ class DealScreenController :
) )
} }
) )
toolBar.headerToolbarBack?.let {
detachDisposable.add(
it.clicks()
.doOnNext { Timber.d("clicked: 1") }
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe { handleBack() }
)
}
}
private fun setToolbar(){
toolBar.setToolbar(HeaderToolbarModel(
true
,resources?.getString(R.string.deal_back_chevron_title)
,null
,null)
)
} }
private fun bindRecycler() { private fun bindRecycler() {
...@@ -156,8 +189,7 @@ class DealScreenController : ...@@ -156,8 +189,7 @@ class DealScreenController :
private var dealModel:DealModel? = null private var dealModel:DealModel? = null
private fun render(viewState: DealScreenViewState.LoadDeal) { private fun render(viewState: DealScreenViewState.LoadDeal) {
servedDeal = viewState.estate
dealTitle.text = resources?.getString( dealTitle.text = resources?.getString(
viewState.estate.estate.type.typeDoubleString(), viewState.estate.estate.type.typeDoubleString(),
viewState.estate.estate.number viewState.estate.estate.number
......
...@@ -11,6 +11,7 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity ...@@ -11,6 +11,7 @@ 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.deal.DealScreenController import com.biganto.visual.roompark.presentation.screen.deal.DealScreenController
import com.biganto.visual.roompark.presentation.screen.deals.util.DealsListAdapter import com.biganto.visual.roompark.presentation.screen.deals.util.DealsListAdapter
import com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
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
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
...@@ -77,6 +78,25 @@ class DealsScreenController : ...@@ -77,6 +78,25 @@ class DealsScreenController :
.pushChangeHandler(FadeChangeHandler()) .pushChangeHandler(FadeChangeHandler())
.popChangeHandler(FadeChangeHandler()) .popChangeHandler(FadeChangeHandler())
) )
},
(dealsRecyclerView.adapter as DealsListAdapter)
.startFlat
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
Timber.d("got estate clicked $it")
router.pushController(
RouterTransaction.with(EstateScreenController(it!!))
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())
)
},
(dealsRecyclerView.adapter as DealsListAdapter)
.startTour
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
Timber.d("got tour clicked $it")
showMessage(R.string.tour_not_allowed)
} }
) )
} }
......
...@@ -7,7 +7,6 @@ import android.view.ViewGroup ...@@ -7,7 +7,6 @@ import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import butterknife.BindView import butterknife.BindView
import butterknife.ButterKnife
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.DealPreviewModel import com.biganto.visual.roompark.domain.model.DealPreviewModel
import com.biganto.visual.roompark.domain.model.StatusModel import com.biganto.visual.roompark.domain.model.StatusModel
...@@ -19,7 +18,10 @@ import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView ...@@ -19,7 +18,10 @@ import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.clicks
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import io.reactivex.Observable
import io.reactivex.subjects.PublishSubject
/** /**
* Created by Vladislav Bogdashkin on 16.10.2019. * Created by Vladislav Bogdashkin on 16.10.2019.
...@@ -28,6 +30,18 @@ import com.squareup.picasso.Picasso ...@@ -28,6 +30,18 @@ import com.squareup.picasso.Picasso
class DealsListAdapter : CommonRecyclerAdapter<DealViewHolder, DealPreviewModel>() { class DealsListAdapter : CommonRecyclerAdapter<DealViewHolder, DealPreviewModel>() {
override val vhKlazz = DealViewHolder::class override val vhKlazz = DealViewHolder::class
override fun getVhLayout() = R.layout.deal_card_viewholder override fun getVhLayout() = R.layout.deal_card_viewholder
private val onFlatClicked = PublishSubject.create<Int>()
private val onTourClickced = PublishSubject.create<Int>()
override fun onBindViewHolder(holder: DealViewHolder, position: Int) {
super.onBindViewHolder(holder, position)
holder.onStartFlatObs.subscribe(onFlatClicked)
holder.onStartTourObs.subscribe(onTourClickced)
}
val startFlat get() = onFlatClicked
val startTour get() = onTourClickced
} }
...@@ -37,6 +51,7 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi ...@@ -37,6 +51,7 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
@BindView(R.id.deal_card_header) lateinit var estateTitle: TextView @BindView(R.id.deal_card_header) lateinit var estateTitle: TextView
@BindView(R.id.common_info_block) lateinit var commonInfo:View @BindView(R.id.common_info_block) lateinit var commonInfo:View
@BindView(R.id.start_tour_button) lateinit var startTour:View @BindView(R.id.start_tour_button) lateinit var startTour:View
@BindView(R.id.flat_card_card_view) lateinit var startFlat:View
@BindView(R.id.info_ceil_1) lateinit var info1:View @BindView(R.id.info_ceil_1) lateinit var info1:View
@BindView(R.id.info_ceil_2) lateinit var info2:View @BindView(R.id.info_ceil_2) lateinit var info2:View
...@@ -53,17 +68,8 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi ...@@ -53,17 +68,8 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
@BindView(R.id.start_tour_image_view) lateinit var tourScreen:RoundedImageView @BindView(R.id.start_tour_image_view) lateinit var tourScreen:RoundedImageView
val onStartFlatObs: Observable<Int?> get() = startFlat.clicks().map { bindedModel.estateId }
private fun typeName(type:String) = when(type){ val onStartTourObs: Observable<Int?> get() = startTour.clicks().map { bindedModel.tourId }
"flat" -> "КВАРТИРА"
"parking" -> "МАШИНОМЕСТО"
"storage" -> "КЛАДОВКА"
else -> "ОБЪЕКТ"
}
init {
ButterKnife.bind(this, itemView)
}
override fun onViewBound(model: DealPreviewModel) { override fun onViewBound(model: DealPreviewModel) {
estateTitle.text = estateTitle.text =
......
...@@ -173,6 +173,15 @@ class EstateScreenController : ...@@ -173,6 +173,15 @@ class EstateScreenController :
@BindView(R.id.start_tour_card_divider) @BindView(R.id.start_tour_card_divider)
lateinit var startTourDivider: View lateinit var startTourDivider: View
@BindView(R.id.sizes_divider)
lateinit var sizesDivider: View
@BindView(R.id.electricity_divider)
lateinit var electricityDivider: View
@BindView(R.id.walls_divider)
lateinit var wallsDivider: View
@BindView(R.id.furniture_divider)
lateinit var furnitureDivider: View
private fun setToolbar(){ private fun setToolbar(){
toolBar.setToolbar(null, StatusToolbarModel()) toolBar.setToolbar(null, StatusToolbarModel())
...@@ -310,36 +319,44 @@ class EstateScreenController : ...@@ -310,36 +319,44 @@ class EstateScreenController :
} }
private fun planTypeSelected(plan:PlanPresetModel){ private fun planTypeSelected(plan:PlanPresetModel){
wallsContainer.visibility = View.GONE wallsContainer.setGone(true)
sizesContainer.visibility = View.GONE sizesContainer.setGone(true)
electricContainer.visibility = View.GONE electricContainer.setGone(true)
furnContainer.visibility = View.GONE furnContainer.setGone(true)
furnitureDivider.setGone(true)
wallsDivider.setGone(true)
sizesDivider.setGone(true)
electricityDivider.setGone(true)
plan.features.forEach { plan.features.forEach {
when(it){ when(it){
is FeatureModel.Furniture -> { is FeatureModel.Furniture -> {
furnContainer.visibility = View.VISIBLE furnContainer.setGone(false)
furnTitle.text = it.featureTitle furnTitle.text = it.featureTitle
furnSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked = furnSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked =
it.switchedOn it.switchedOn
furnitureDivider.setGone(false)
} }
is FeatureModel.Walls ->{ is FeatureModel.Walls ->{
wallsContainer.visibility = View.VISIBLE wallsContainer.setGone(false)
wallsTitle.text = it.featureTitle wallsTitle.text = it.featureTitle
wallsSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked = wallsSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked =
it.switchedOn it.switchedOn
wallsDivider.setGone(false)
} }
is FeatureModel.Sizes ->{ is FeatureModel.Sizes ->{
sizesContainer.visibility = View.VISIBLE sizesContainer.setGone(false)
sizesTitle.text = it.featureTitle sizesTitle.text = it.featureTitle
sizesSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked = sizesSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked =
it.switchedOn it.switchedOn
sizesDivider.setGone(false)
} }
is FeatureModel.Electric ->{ is FeatureModel.Electric ->{
electricContainer.visibility = View.VISIBLE electricContainer.setGone(false)
electricTitle.text = it.featureTitle electricTitle.text = it.featureTitle
electricSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked = electricSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked =
it.switchedOn it.switchedOn
electricityDivider.setGone(false)
} }
} }
} }
......
...@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.presentation.screen.estate.EstateScreenContro ...@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.presentation.screen.estate.EstateScreenContro
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
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
...@@ -46,7 +47,10 @@ class FavoritesScreenController : ...@@ -46,7 +47,10 @@ class FavoritesScreenController :
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe { .subscribe {
Timber.d("got card clicked $it") Timber.d("got card clicked $it")
router.pushController(RouterTransaction.with(EstateScreenController(it.id))) router.pushController(RouterTransaction.with(EstateScreenController(it.id))
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())
)
} }
) )
} }
......
...@@ -79,15 +79,19 @@ abstract class CommonViewHolder<M:Any>(itemView: View): RecyclerView.ViewHolder( ...@@ -79,15 +79,19 @@ abstract class CommonViewHolder<M:Any>(itemView: View): RecyclerView.ViewHolder(
fun bindModel(model: M){ fun bindModel(model: M){
ButterKnife.bind(this, itemView) ButterKnife.bind(this, itemView)
bindModel = model bindedModel = model
onViewBound(model) onViewBound(model)
} }
fun onClicked(): Observable<M> = itemView.clicks().map { bindModel } fun onClicked(): Observable<M> = itemView.clicks().map { bindedModel }
private lateinit var bindModel: M protected lateinit var bindedModel: M
} }
class PushListAdapter : CommonRecyclerAdapter<PushViewHolder,PushSwitchModel>() { class PushListAdapter : CommonRecyclerAdapter<PushViewHolder,PushSwitchModel>() {
override val vhKlazz: KClass<PushViewHolder> override val vhKlazz: KClass<PushViewHolder>
get() = PushViewHolder::class get() = PushViewHolder::class
......
...@@ -200,6 +200,7 @@ ...@@ -200,6 +200,7 @@
android:layout_marginEnd="16dp" /> android:layout_marginEnd="16dp" />
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/flat_card_card_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="64dp" android:layout_height="64dp"
android:layout_margin="16dp" android:layout_margin="16dp"
......
...@@ -245,11 +245,12 @@ ...@@ -245,11 +245,12 @@
<LinearLayout <LinearLayout
android:id="@+id/flat_card_card_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp" android:layout_marginTop="24dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:background="@color/colorCommonBackground" android:background="@color/colorCommonBackground"
android:weightSum="3"> android:weightSum="3">
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<include <include
android:id="@+id/include6" android:id="@+id/sizes_divider"
layout="@layout/horizontal_divider" layout="@layout/horizontal_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include6"> app:layout_constraintTop_toBottomOf="@+id/sizes_divider">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/sizes_switch_header" android:id="@+id/sizes_switch_header"
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
<include <include
android:id="@+id/include7" android:id="@+id/furniture_divider"
layout="@layout/horizontal_divider" layout="@layout/horizontal_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include7"> app:layout_constraintTop_toBottomOf="@+id/furniture_divider">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/furniture_switch_header" android:id="@+id/furniture_switch_header"
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
<include <include
android:id="@+id/include8" android:id="@+id/electricity_divider"
layout="@layout/horizontal_divider" layout="@layout/horizontal_divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include8"> app:layout_constraintTop_toBottomOf="@+id/electricity_divider">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/electricity_switch_header" android:id="@+id/electricity_switch_header"
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
<string name="estate_type_parking_short">М\\М %s</string> <string name="estate_type_parking_short">М\\М %s</string>
<string name="estate_type_store_short">КЛ.%s</string> <string name="estate_type_store_short">КЛ.%s</string>
<string name="estate_type_other_short">ОБ.%s</string> <string name="estate_type_other_short">ОБ.%s</string>
<string name="tour_not_allowed">Запуск туров пока недоступен!</string>
<!--endregion--> <!--endregion-->
</resources> </resources>
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