Skip to content

Commit

Permalink
fix addButton enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
yasemin.aksoy committed Feb 1, 2022
1 parent cf73c79 commit 540a0e8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/ComponentVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object ComponentVersions {
const val phoneNumberVersion = "1.0.2"
const val dialogsVersion = "1.2.8"
const val cardInputViewVersion = "1.1.3"
const val quantityPickerViewVersion = "1.2.6"
const val quantityPickerViewVersion = "1.2.7"
const val timelineViewVersion = "1.0.0"
const val touchDelegatorVersion = "1.0.0"
const val fitOptionMessageView = "1.0.0"
Expand Down
1 change: 1 addition & 0 deletions libraries/quantity-picker-view/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ To set programmatically, you can call `QuantityPickerView.setQuantityPickerViewS
| setMinQuantity | minQuantity: Int | To set minQuantity immediately. |
| setAddIconDrawable | icon: Drawable | To set addIconDrawable immediately. |
| setBackgroundImageDrawable | background: Drawable | To set backgroundImageDrawable immediately. |
| setAddButtonEnabled | enable: Boolean | To set enable to addButton immediately |
| stopLoading | | To stop current loading.|
| reset | | To stop loading and set currentQuantity to 0. |
| incrementQuantityBy | quantity | increments current total quantity by quantity parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ class QuantityPickerView : ConstraintLayout {
setQuantityPickerViewState(binding.viewState?.getBackgroundDrawable(background))
}

fun setAddButtonEnabled(enable: Boolean) {
setQuantityPickerViewState(binding.viewState?.getAddButtonEnabled(enable))
}

fun stopLoading() = setQuantityPickerViewState(binding.viewState?.stopLoading())

fun reset() = setQuantityPickerViewState(binding.viewState?.reset())
Expand Down Expand Up @@ -250,7 +254,6 @@ class QuantityPickerView : ConstraintLayout {
)
val quantityTextStyle =
it.getInt(R.styleable.QuantityPickerView_qpv_quantityTextStyle, 0)
val addButtonEnabled = it.getBoolean(R.styleable.QuantityPickerView_qpv_addButtonEnabled, true)
val currentQuantity = it.getInt(R.styleable.QuantityPickerView_qpv_currentQuantity, 0)
val maxQuantity = it.getInt(R.styleable.QuantityPickerView_qpv_maxQuantity, -1)
val minQuantity = it.getInt(R.styleable.QuantityPickerView_qpv_minQuantity, -1)
Expand Down Expand Up @@ -317,7 +320,6 @@ class QuantityPickerView : ConstraintLayout {
quantityTextColor = quantityTextColor,
quantityTextSize = quantityTextSize,
quantityTextStyle = quantityTextStyle,
addButtonEnabled = addButtonEnabled,
currentQuantity = currentQuantity,
backgroundDrawable = background,
progressTintColor = progressTintColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ data class QuantityPickerViewState(
return copy(backgroundDrawable = background)
}

internal fun getAddButtonEnabled(enable: Boolean): QuantityPickerViewState {
return copy(addButtonEnabled = enable)
}

internal fun stopLoading(): QuantityPickerViewState =
copy(showLoading = false, expansionState = expansionState.expand())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<enum name="bold" value="1" />
<enum name="italic" value="2" />
</attr>
<attr name="qpv_addButtonEnabled" format="boolean" />
<attr name="qpv_currentQuantity" format="integer" />
<attr name="qpv_maxQuantity" format="integer" />
<attr name="qpv_minQuantity" format="integer" />
Expand Down

0 comments on commit 540a0e8

Please sign in to comment.