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 ...@@ -10,8 +10,6 @@ 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.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.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
......
...@@ -4,10 +4,6 @@ import android.content.Context ...@@ -4,10 +4,6 @@ import android.content.Context
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.di.dagger.AppComponent import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.PerScreen 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.Binds
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
......
...@@ -8,8 +8,12 @@ import com.biganto.visual.roompark.R ...@@ -8,8 +8,12 @@ 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.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.util.view_utils.grid.CeilsDecoration 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 timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
...@@ -28,17 +32,17 @@ class DealsScreenController : ...@@ -28,17 +32,17 @@ class DealsScreenController :
} }
@BindView(R.id.favorites_cards_recycler_view) @BindView(R.id.favorites_cards_recycler_view)
lateinit var favoritesRecyclerView: RecyclerView lateinit var dealsRecyclerView: RecyclerView
private fun bindRecycler() { private fun bindRecycler() {
favoritesRecyclerView.isNestedScrollingEnabled = true dealsRecyclerView.isNestedScrollingEnabled = true
favoritesRecyclerView.layoutManager = dealsRecyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false) LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
favoritesRecyclerView.adapter = DealsListAdapter() dealsRecyclerView.adapter = DealsListAdapter()
favoritesRecyclerView.itemAnimator = null dealsRecyclerView.itemAnimator = null
if (favoritesRecyclerView.itemDecorationCount == 0) if (dealsRecyclerView.itemDecorationCount == 0)
favoritesRecyclerView.addItemDecoration( dealsRecyclerView.addItemDecoration(
CeilsDecoration(1 CeilsDecoration(1
, resources?.getDimensionPixelSize(R.dimen.ceil_grid_padding)) , resources?.getDimensionPixelSize(R.dimen.ceil_grid_padding))
) )
...@@ -51,7 +55,7 @@ class DealsScreenController : ...@@ -51,7 +55,7 @@ class DealsScreenController :
toolBar.appBar.liftOnScrollTargetViewId = R.id.favorites_cards_recycler_view toolBar.appBar.liftOnScrollTargetViewId = R.id.favorites_cards_recycler_view
toolBar.appBar.setLiftable(true) toolBar.appBar.setLiftable(true)
toolBar.appBarScrollable(false) toolBar.appBarScrollable(false)
favoritesRecyclerView.isNestedScrollingEnabled = false dealsRecyclerView.isNestedScrollingEnabled = false
} }
@Inject @Inject
...@@ -61,6 +65,19 @@ class DealsScreenController : ...@@ -61,6 +65,19 @@ class DealsScreenController :
override fun onViewBound(v: View) { override fun onViewBound(v: View) {
setToolbar() setToolbar()
bindRecycler() 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) { override fun render(viewState: DealsScreenViewState) {
...@@ -78,7 +95,7 @@ class DealsScreenController : ...@@ -78,7 +95,7 @@ class DealsScreenController :
} }
private fun render(viewState: DealsScreenViewState.DealsLoaded){ 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) = private fun render(viewState: DealsScreenViewState.SomeError) =
......
...@@ -6,12 +6,13 @@ import android.view.View ...@@ -6,12 +6,13 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView import butterknife.BindView
import butterknife.ButterKnife import butterknife.ButterKnife
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.StatusModel import com.biganto.visual.roompark.domain.model.StatusModel
import com.biganto.visual.roompark.presentation.screen.deals.DealPreviewModel 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.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
...@@ -21,31 +22,14 @@ import com.google.android.material.textview.MaterialTextView ...@@ -21,31 +22,14 @@ import com.google.android.material.textview.MaterialTextView
* Created by Vladislav Bogdashkin on 16.10.2019. * Created by Vladislav Bogdashkin on 16.10.2019.
*/ */
class DealsListAdapter : RecyclerView.Adapter<DealViewHolder>() { class DealsListAdapter : CommonRecyclerAdapter<DealViewHolder,DealPreviewModel>() {
override val vhKlazz = DealViewHolder::class
private var list: MutableList<DealPreviewModel> = mutableListOf() override fun getVhLayout() = R.layout.deal_card_viewholder
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 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.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
...@@ -76,24 +60,24 @@ class DealViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { ...@@ -76,24 +60,24 @@ class DealViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
ButterKnife.bind(this, itemView) ButterKnife.bind(this, itemView)
} }
fun bindModel(deal: DealPreviewModel) { override fun onViewBound(model: DealPreviewModel) {
val fullObjName = "${typeName(deal.type)}\n№${deal.name}" val fullObjName = "${typeName(model.type)}\n№${model.name}"
estateTitle.text = fullObjName 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 else startTour.visibility = View.VISIBLE
dealSum.text = deal.dealSum.toRubly() dealSum.text = model.dealSum.toRubly()
dealPayed.text = deal.dealPayout.toRubly() dealPayed.text = model.dealPayout.toRubly()
dealSumToPay.text = deal.dealToPay.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) val currentStatusText = LayoutInflater.from(itemView.context)
.inflate(R.layout.status_title_textview,statusContainer,false) .inflate(R.layout.status_title_textview,statusContainer,false)
as MaterialTextView as MaterialTextView
currentStatusText.text = deal.statusList[deal.statusNo-1].title currentStatusText.text = model.statusList[model.statusNo-1].title
statusLayout.addView(currentStatusText,0) statusLayout.addView(currentStatusText,0)
statusLayout.invalidate() statusLayout.invalidate()
} }
......
...@@ -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.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.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