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

fix qunatity formatted string res

parent 8b13b35c
......@@ -22,6 +22,7 @@ import com.google.android.material.switchmaterial.SwitchMaterial
import com.google.android.material.tabs.TabLayout
import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.material.selections
import com.jakewharton.rxbinding3.view.clicks
import com.jakewharton.rxbinding3.widget.checkedChanges
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
......@@ -43,6 +44,25 @@ class EstateScreenController :
, EstateScreenPresenter>
, EstateScreen {
override fun showCommonInfo(): Observable<Int> =
commonInfoTab.clicks()
.doOnNext {
commonInfoTab.background = resources?.getDrawable(R.drawable.bottom_line_text_view)
explicationTab.background = null
}
.map { 1 }
.observeOn(AndroidSchedulers.mainThread())
override fun showExplication(): Observable<Int> =
explicationTab.clicks()
.doOnNext {
explicationTab.background = resources?.getDrawable(R.drawable.bottom_line_text_view)
commonInfoTab.background = null
}
.map { planTypesTabLayout.selectedTabPosition }
.observeOn(AndroidSchedulers.mainThread())
private fun ViewGroup.switchMatch() =
this.findViewById<SwitchMaterial>(R.id.switch1)
.checkedChanges()
......@@ -122,6 +142,13 @@ class EstateScreenController :
lateinit var wallsSwitcher: ViewGroup
@BindView(R.id.common_info_tab)
lateinit var commonInfoTab: MaterialTextView
@BindView(R.id.explication_tab)
lateinit var explicationTab: MaterialTextView
private fun setToolbar(){
toolBar.showAll()
toolBar.appBar.setExpanded(false,false)
......@@ -157,6 +184,7 @@ class EstateScreenController :
is EstateScreenViewState.LoadPlan -> render(viewState)
is EstateScreenViewState.PlanTypeSelected -> render(viewState)
is EstateScreenViewState.SomeError -> render(viewState)
is EstateScreenViewState.ShowEstateInfo -> render(viewState)
}
}
......@@ -173,6 +201,12 @@ class EstateScreenController :
}
private fun render(viewState: EstateScreenViewState.ShowEstateInfo) {
(flatInfoRecyclerView.adapter as FlatInfoAdapter).setItems(viewState.info)
}
private fun render(viewState: EstateScreenViewState.LoadPlanTypes) {
planTypesTabLayout.removeAllTabs()
......
package com.biganto.visual.roompark.presentation.screen.estate
import android.app.Activity
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.EstateInteractor
import com.biganto.visual.roompark.domain.model.CommonInfoModel
import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.domain.model.FeatureModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.domain.model.*
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
......@@ -99,11 +96,15 @@ class EstateScreenPresenter @Inject constructor(
val showInfo = intent(EstateScreen::showCommonInfo)
.doOnNext { showType = InfoShowType.COMMON_INFO }
.map { pair ->
val plan = planList?.first { it.planId == pair.first }
plan?.switchFeature<FeatureModel.Electric>(pair.second)
plan
}.flatMap(::getPlan)
.map { estate?.commonInfo}
.map (::mapCommonInfo)
.map { EstateScreenViewState.ShowEstateInfo(showType,it) }
val showExplication = intent(EstateScreen::showExplication)
.doOnNext { showType = InfoShowType.EXPLICATIONS }
.map { planList?.get(it)?.explication}
.map (::mapCommonInfo)
.map { EstateScreenViewState.ShowEstateInfo(showType,it) }
val state = restoreStateObservable
.mergeWith(prefetchCards)
......@@ -113,6 +114,8 @@ class EstateScreenPresenter @Inject constructor(
.mergeWith(switchFurn)
.mergeWith(switchSizes)
.mergeWith(switchWalls)
.mergeWith(showInfo)
.mergeWith(showExplication)
.doOnError { Timber.e(it) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......@@ -123,10 +126,17 @@ class EstateScreenPresenter @Inject constructor(
private fun langString(@StringRes id:Int) = context.resources.getString(id)
private fun langString(@StringRes id:Int,vararg args:Any) =
context.resources.getString(id,args)
context.resources.getString(id,*args)
private fun mapCommonInfo(list: List<ExplicationModel>): ArrayList<DisplayInfoModel> =
ArrayList(
List(list.size){Timber.d("area value: ${list[it].area}");DisplayInfoModel(list[it].title
,langString(R.string.area_value,list[it].area))
}
)
private fun mapCommonInfo(info: CommonInfoModel) {
private fun mapCommonInfo(info: CommonInfoModel): ArrayList<DisplayInfoModel> {
val r = arrayListOf<DisplayInfoModel>()
info.building.let {
r.add(DisplayInfoModel(langString(R.string.building),"$it"))
......@@ -151,12 +161,19 @@ class EstateScreenPresenter @Inject constructor(
}
info.windows_face?.let {r.add(DisplayInfoModel(langString(R.string.window_face), it))}
info.direction?.let {r.add(DisplayInfoModel(langString(R.string.direction), it))}
info.price_meter?.let {r.add(DisplayInfoModel(langString(R.string.price_meter), it
.toRubly()))}
info.price?.let {r.add(DisplayInfoModel(langString(R.string.price), it.toRubly()))}
info.discount?.let {r.add(DisplayInfoModel(langString(R.string.max_discount)
, langString(R.string.discount_value,it)))}
info.discount_amount?.let {r.add(DisplayInfoModel(langString(R.string.discounted_price)
, it.toRubly()))}
return r
}
}
private enum class InfoShowType{
enum class InfoShowType{
COMMON_INFO,
EXPLICATIONS
}
......@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.estate
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.EstateModel
import com.biganto.visual.roompark.domain.model.PlanPresetModel
import com.biganto.visual.roompark.presentation.screen.estate.util.DisplayInfoModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/**
......@@ -17,4 +18,5 @@ sealed class EstateScreenViewState : BigantoBaseViewState() {
class PlanTypeSelected(val item:PlanPresetModel) : EstateScreenViewState()
class LoadPlan(val planBody:String) : EstateScreenViewState()
class SomeError(val exception: ExceptionString) : EstateScreenViewState()
class ShowEstateInfo(val showType:InfoShowType,val info:List<DisplayInfoModel>) : EstateScreenViewState()
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
android:weightSum="2">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tab_variant_1"
android:id="@+id/common_info_tab"
style="@style/Default_TextView.Accent_Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -23,7 +23,7 @@
android:text="/" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tab_variant_2"
android:id="@+id/explication_tab"
style="@style/Default_TextView.Accent_Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -55,15 +55,20 @@
<string name="section_begin">Секция</string>
<string name="floor">Этаж</string>
<string name="area">Общая площадь</string>
<string name="area_value">%.1f м\u00B2</string>
<string name="area_value">%,.1f м\u00B2</string>
<string name="area_living">Жилая площадь</string>
<string name="rooms">Кол-во комнат</string>
<string name="flat_kind">Тип квартиры</string>
<string name="flat_decoration">Наличие отделки</string>
<string name="ceiling">Высота потолков</string>
<string name="meters_value">%.1f м</string>
<string name="meters_value">%,.1f м</string>
<string name="window_face">Вид из окон</string>
<string name="direction">Сторона света</string>
<string name="price_meter">Цена за м\u00B2</string>
<string name="price">Стоимость</string>
<string name="max_discount">Максимальная скидка с учетом всех акций</string>
<string name="discount_value">%,.1f \%</string>
<string name="discounted_price">Стоимость со скидкой</string>
<!--endregion-->
</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