Commit 0e5dd9ee authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix switcher && walls-furniture condition

parent ffdb56e4
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173"> <code_scheme name="Project" version="173">
<AndroidXmlCodeStyleSettings>
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
</AndroidXmlCodeStyleSettings>
<JetCodeStyleSettings> <JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings> </JetCodeStyleSettings>
......
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
</profile-state> </profile-state>
</entry> </entry>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
...@@ -91,7 +91,6 @@ class EstateScreenController : ...@@ -91,7 +91,6 @@ class EstateScreenController :
override fun switchElectric(): Observable<Pair<Int, Boolean>> = override fun switchElectric(): Observable<Pair<Int, Boolean>> =
electricSwitcher.switchMatch() electricSwitcher.switchMatch()
override fun planTypesTabSelected(): Observable<Int> = override fun planTypesTabSelected(): Observable<Int> =
planTypesTabLayout.selections() planTypesTabLayout.selections()
.debounce (200L, TimeUnit.MILLISECONDS) .debounce (200L, TimeUnit.MILLISECONDS)
...@@ -238,6 +237,11 @@ class EstateScreenController : ...@@ -238,6 +237,11 @@ class EstateScreenController :
bottomNavigationController.hide() bottomNavigationController.hide()
setToolbar() setToolbar()
bindRecycler() bindRecycler()
detachDisposable.add(
furnSwitcher.clicks()
.filter { !furnSwitcher.isEnabled }
.subscribe { snackbar.showSnackBar("Мебелировка не доступна") }
)
} }
override fun render(viewState: EstateScreenViewState) { override fun render(viewState: EstateScreenViewState) {
...@@ -343,8 +347,16 @@ class EstateScreenController : ...@@ -343,8 +347,16 @@ class EstateScreenController :
is FeatureModel.Furniture -> { is FeatureModel.Furniture -> {
furnContainer.setGone(false) furnContainer.setGone(false)
furnTitle.text = it.featureTitle furnTitle.text = it.featureTitle
furnSwitcher.findViewById<SwitchMaterial>(R.id.switch1).isChecked = val fSwitcher = furnSwitcher.findViewById<SwitchMaterial>(R.id.switch1)
it.switchedOn fSwitcher.isChecked = it.switchedOn
// val fSwitcher = furnSwitcher.findViewById<SwitchMaterial>(R.id.switch1)
val wls = plan
.features
.firstOrNull { feature -> feature is FeatureModel.Walls }
?.switchedOn
fSwitcher.isEnabled = wls ?: true
furnitureDivider.setGone(false) furnitureDivider.setGone(false)
} }
is FeatureModel.Walls ->{ is FeatureModel.Walls ->{
......
...@@ -40,6 +40,11 @@ class EstateScreenPresenter @Inject constructor( ...@@ -40,6 +40,11 @@ class EstateScreenPresenter @Inject constructor(
private fun getPlan(plan: PlanPresetModel): Observable<EstateScreenViewState> = private fun getPlan(plan: PlanPresetModel): Observable<EstateScreenViewState> =
interactor.getPlan(plan) interactor.getPlan(plan)
.map<EstateScreenViewState> { EstateScreenViewState.LoadPlan(it) } .map<EstateScreenViewState> { EstateScreenViewState.LoadPlan(it) }
.startWith(
Observable.just<EstateScreenViewState>(
EstateScreenViewState.PlanTypeSelected(plan)
)
)
override fun bindIntents() { override fun bindIntents() {
...@@ -53,17 +58,18 @@ class EstateScreenPresenter @Inject constructor( ...@@ -53,17 +58,18 @@ class EstateScreenPresenter @Inject constructor(
val fetchPlan = intent(EstateScreen::planTypesTabSelected) val fetchPlan = intent(EstateScreen::planTypesTabSelected)
.map { planList?.get(it) } .map { planList?.get(it) }
.flatMap {planPreset -> .flatMap { planPreset ->
interactor.getPlan(planPreset) interactor.getPlan(planPreset)
.map<EstateScreenViewState> { plan -> EstateScreenViewState.LoadPlan(plan) } .map<EstateScreenViewState> { plan -> EstateScreenViewState.LoadPlan(plan) }
.startWith( .startWith(
Observable.just<EstateScreenViewState>( Observable.just<EstateScreenViewState>(
EstateScreenViewState.PlanTypeSelected(planPreset) EstateScreenViewState.PlanTypeSelected(planPreset)
) )
) )
.startWith( .startWith(
Observable.just<EstateScreenViewState>( Observable.just<EstateScreenViewState>(
EstateScreenViewState.ShowEstateInfo( EstateScreenViewState.ShowEstateInfo(
showType showType
,if (showType== InfoShowType.COMMON_INFO) ,if (showType== InfoShowType.COMMON_INFO)
...@@ -74,6 +80,7 @@ class EstateScreenPresenter @Inject constructor( ...@@ -74,6 +80,7 @@ class EstateScreenPresenter @Inject constructor(
) )
} }
val switchSizes = intent(EstateScreen::switchSizes) val switchSizes = intent(EstateScreen::switchSizes)
.map { pair -> .map { pair ->
val plan = planList?.first { it.planId == pair.first } val plan = planList?.first { it.planId == pair.first }
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:width="http://schemas.android.com/apk/res-auto"> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:width="http://schemas.android.com/apk/res-auto">
<item android:state_enabled="false">
<layer-list>
<item>
<shape android:shape="rectangle"
android:dither="true"
android:useLevel="false">
<size android:width="48dp" android:height="24dp"/>
<corners android:radius="12dp"/>
</shape>
</item>
<item
android:right="8dp">
<bitmap
android:width="14dp"
android:height="15dp"
android:src="@drawable/ic_bell_off"
android:tintMode="multiply"
android:gravity="end"
android:tint="@color/colorPrimaryDark" />
</item>
</layer-list>
</item>
<item android:state_checked="false"> <item android:state_checked="false">
<layer-list> <layer-list>
<item> <item>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" <item android:state_enabled="false"
android:color="@color/colorAccent"> android:color="@color/colorOpacityBackgroundInv">
</item> </item>
<item android:state_checked="true" <item android:state_checked="true"
android:color="@color/colorAccent"> android:color="@color/colorAccent">
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:width="http://schemas.android.com/apk/res-auto">
<item android:state_enabled="false">
<layer-list>
<item>
<shape android:shape="rectangle"
android:dither="true"
android:useLevel="false">
<size android:width="48dp" android:height="24dp"/>
<corners android:radius="12dp"/>
</shape>
</item>
</layer-list>
</item>
<item android:state_checked="false">
<layer-list>
<item>
<shape android:shape="rectangle"
android:dither="true"
android:useLevel="false">
<size android:width="48dp" android:height="24dp"/>
<corners android:radius="12dp"/>
</shape>
</item>
</layer-list>
</item>
<item android:state_checked="true">
<layer-list>
<item>
<shape android:shape="rectangle"
android:dither="true"
android:useLevel="false">
<size android:width="48dp" android:height="24dp"/>
<solid android:color="#FFFFFFFF"/>
<corners android:radius="12dp" />
</shape>
</item>
</layer-list>
</item>
</selector>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<com.google.android.material.switchmaterial.SwitchMaterial <com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch1" android:id="@+id/switch1"
style="@style/BellSwitchStyle"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="24dp" android:layout_height="24dp"
android:height="24dp" android:height="24dp"
......
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<include <include
android:id="@+id/sizes_switcher" android:id="@+id/sizes_switcher"
layout="@layout/bell_switch_view" layout="@layout/switch_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical" android:layout_gravity="end|center_vertical"
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
<include <include
android:id="@+id/furniture_switcher" android:id="@+id/furniture_switcher"
layout="@layout/bell_switch_view" layout="@layout/switch_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical" android:layout_gravity="end|center_vertical"
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
<include <include
android:id="@+id/electricity_switcher" android:id="@+id/electricity_switcher"
layout="@layout/bell_switch_view" layout="@layout/switch_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical" android:layout_gravity="end|center_vertical"
...@@ -227,7 +227,7 @@ ...@@ -227,7 +227,7 @@
<include <include
android:id="@+id/walls_switcher" android:id="@+id/walls_switcher"
layout="@layout/bell_switch_view" layout="@layout/switch_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical" android:layout_gravity="end|center_vertical"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bell_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch1"
android:layout_width="48dp"
android:layout_height="24dp"
android:height="24dp"
android:checked="false"
app:switchMinWidth="48dp" />
</LinearLayout>
\ No newline at end of file
...@@ -10,9 +10,7 @@ ...@@ -10,9 +10,7 @@
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="materialCardViewStyle">@style/Widget.Biganto.MaterialCardView</item> <item name="materialCardViewStyle">@style/Widget.Biganto.MaterialCardView</item>
<item name="switchStyle"> <item name="switchStyle">@style/Widget.MaterialComponents.CompoundButton.Switch.AccentSwitch</item>
@style/Widget.MaterialComponents.CompoundButton.Switch.BellSwitchStyle
</item>
<item name="colorControlActivated">@color/colorAccent</item> <item name="colorControlActivated">@color/colorAccent</item>
<item name="colorControlHighlight">@color/colorAccent</item> <item name="colorControlHighlight">@color/colorAccent</item>
<item name="colorControlNormal">@color/colorAccent</item> <item name="colorControlNormal">@color/colorAccent</item>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="materialCardViewStyle">@style/Widget.Biganto.MaterialCardView</item> <item name="materialCardViewStyle">@style/Widget.Biganto.MaterialCardView</item>
<item name="switchStyle">@style/Widget.MaterialComponents.CompoundButton.Switch.BellSwitchStyle</item> <item name="switchStyle">@style/Widget.MaterialComponents.CompoundButton.Switch.AccentSwitch</item>
<item name="colorControlActivated">@color/colorAccent</item> <item name="colorControlActivated">@color/colorAccent</item>
<item name="colorControlHighlight">@color/colorAccent</item> <item name="colorControlHighlight">@color/colorAccent</item>
<item name="colorControlNormal">@color/colorAccent</item> <item name="colorControlNormal">@color/colorAccent</item>
...@@ -25,13 +25,20 @@ ...@@ -25,13 +25,20 @@
<item name="android:windowBackground">@color/colorAccent</item> <item name="android:windowBackground">@color/colorAccent</item>
</style> </style>
<style name="Widget.MaterialComponents.CompoundButton.Switch.BellSwitchStyle" > <style name="BellSwitchStyle" parent="Widget.MaterialComponents.CompoundButton.Switch">
<item name="track" >@drawable/bell_switch_track</item> <item name="track" >@drawable/bell_switch_track</item>
<item name="android:thumb" >@drawable/bell_switcher</item> <item name="android:thumb" >@drawable/bell_switcher</item>
<item name="thumbTint">@color/colorPrimaryDark</item> <item name="thumbTint">@color/colorPrimaryDark</item>
<item name="trackTint">@drawable/bell_switch_track_tint</item> <item name="trackTint">@drawable/bell_switch_track_tint</item>
</style> </style>
<style name="Widget.MaterialComponents.CompoundButton.Switch.AccentSwitch" >
<item name="track" >@drawable/switch_track</item>
<item name="android:thumb" >@drawable/bell_switcher</item>
<item name="thumbTint">@color/colorPrimaryDark</item>
<item name="trackTint">@drawable/bell_switch_track_tint</item>
</style>
<style name="Widget.Biganto.MaterialCardView" parent="Widget.MaterialComponents.CardView"> <style name="Widget.Biganto.MaterialCardView" parent="Widget.MaterialComponents.CardView">
<item name="cardUseCompatPadding">false</item> <item name="cardUseCompatPadding">false</item>
<item name="strokeWidth">0dp</item> <item name="strokeWidth">0dp</item>
......
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