Commit 4c946d7f authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

show deal screen over press card

parent 30d496d2
......@@ -10,8 +10,6 @@ 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.biganto.visual.roompark.presentation.screen.deals.util.createStatusView
import com.biganto.visual.roompark.presentation.screen.deals.util.deployProgressView
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.google.android.material.textview.MaterialTextView
......
......@@ -4,10 +4,6 @@ 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
......
......@@ -8,8 +8,12 @@ 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.biganto.visual.roompark.presentation.screen.deal.DealScreenController
import com.biganto.visual.roompark.presentation.screen.deals.util.DealsListAdapter
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import io.reactivex.android.schedulers.AndroidSchedulers
import timber.log.Timber
import javax.inject.Inject
......@@ -28,17 +32,17 @@ class DealsScreenController :
}
@BindView(R.id.favorites_cards_recycler_view)
lateinit var favoritesRecyclerView: RecyclerView
lateinit var dealsRecyclerView: RecyclerView
private fun bindRecycler() {
favoritesRecyclerView.isNestedScrollingEnabled = true
favoritesRecyclerView.layoutManager =
dealsRecyclerView.isNestedScrollingEnabled = true
dealsRecyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
favoritesRecyclerView.adapter = DealsListAdapter()
favoritesRecyclerView.itemAnimator = null
dealsRecyclerView.adapter = DealsListAdapter()
dealsRecyclerView.itemAnimator = null
if (favoritesRecyclerView.itemDecorationCount == 0)
favoritesRecyclerView.addItemDecoration(
if (dealsRecyclerView.itemDecorationCount == 0)
dealsRecyclerView.addItemDecoration(
CeilsDecoration(1
, resources?.getDimensionPixelSize(R.dimen.ceil_grid_padding))
)
......@@ -51,7 +55,7 @@ class DealsScreenController :
toolBar.appBar.liftOnScrollTargetViewId = R.id.favorites_cards_recycler_view
toolBar.appBar.setLiftable(true)
toolBar.appBarScrollable(false)
favoritesRecyclerView.isNestedScrollingEnabled = false
dealsRecyclerView.isNestedScrollingEnabled = false
}
@Inject
......@@ -61,6 +65,19 @@ class DealsScreenController :
override fun onViewBound(v: View) {
setToolbar()
bindRecycler()
detachDisposable.addAll(
(dealsRecyclerView.adapter as DealsListAdapter)
.onItemClicked
.map { it.id.toInt() }
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
Timber.d("got card clicked $it")
router.pushController(RouterTransaction.with(DealScreenController(it))
.pushChangeHandler(FadeChangeHandler())
.popChangeHandler(FadeChangeHandler())
)
}
)
}
override fun render(viewState: DealsScreenViewState) {
......@@ -78,7 +95,7 @@ class DealsScreenController :
}
private fun render(viewState: DealsScreenViewState.DealsLoaded){
(favoritesRecyclerView.adapter as DealsListAdapter).addItems(viewState.items)
(dealsRecyclerView.adapter as DealsListAdapter).addItems(viewState.items)
}
private fun render(viewState: DealsScreenViewState.SomeError) =
......
......@@ -6,12 +6,13 @@ import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView
import butterknife.ButterKnife
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.StatusModel
import com.biganto.visual.roompark.presentation.screen.deals.DealPreviewModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
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.StatusProgressCeil
......@@ -21,31 +22,14 @@ import com.google.android.material.textview.MaterialTextView
* Created by Vladislav Bogdashkin on 16.10.2019.
*/
class DealsListAdapter : RecyclerView.Adapter<DealViewHolder>() {
private var list: MutableList<DealPreviewModel> = mutableListOf()
fun addItems(list:List<DealPreviewModel>){
this.list.clear()
this.list.addAll(list)
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DealViewHolder =
DealViewHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.deal_card_viewholder, parent, false)
)
override fun getItemCount(): Int = list.size
override fun onBindViewHolder(holder: DealViewHolder, position: Int) {
holder.bindModel(list[position])
}
class DealsListAdapter : CommonRecyclerAdapter<DealViewHolder,DealPreviewModel>() {
override val vhKlazz = DealViewHolder::class
override fun getVhLayout() = R.layout.deal_card_viewholder
}
class DealViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemView) {
@BindView(R.id.deal_card_header) lateinit var estateTitle: TextView
@BindView(R.id.common_info_block) lateinit var commonInfo:View
......@@ -76,24 +60,24 @@ class DealViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
ButterKnife.bind(this, itemView)
}
fun bindModel(deal: DealPreviewModel) {
val fullObjName = "${typeName(deal.type)}\n№${deal.name}"
override fun onViewBound(model: DealPreviewModel) {
val fullObjName = "${typeName(model.type)}\n№${model.name}"
estateTitle.text = fullObjName
renderCommonInfo(deal)
renderCommonInfo(model)
if (deal.dealTourIds.isNullOrEmpty()) startTour.visibility = View.GONE
if (model.dealTourIds.isNullOrEmpty()) startTour.visibility = View.GONE
else startTour.visibility = View.VISIBLE
dealSum.text = deal.dealSum.toRubly()
dealPayed.text = deal.dealPayout.toRubly()
dealSumToPay.text = deal.dealToPay.toRubly()
dealSum.text = model.dealSum.toRubly()
dealPayed.text = model.dealPayout.toRubly()
dealSumToPay.text = model.dealToPay.toRubly()
statusContainer.deployProgressView(deal.statusList,deal.statusNo,false)
statusContainer.deployProgressView(model.statusList,model.statusNo,false)
val currentStatusText = LayoutInflater.from(itemView.context)
.inflate(R.layout.status_title_textview,statusContainer,false)
as MaterialTextView
currentStatusText.text = deal.statusList[deal.statusNo-1].title
currentStatusText.text = model.statusList[model.statusNo-1].title
statusLayout.addView(currentStatusText,0)
statusLayout.invalidate()
}
......
......@@ -8,7 +8,7 @@ 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.biganto.visual.roompark.presentation.screen.deal.EstateScreenController
import com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
import com.biganto.visual.roompark.presentation.screen.favorites.util.FavoritesListAdapter
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
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