Skip to content

Commit

Permalink
last quantityCount control added
Browse files Browse the repository at this point in the history
  • Loading branch information
burak.ozturk1 committed Dec 30, 2024
1 parent 1cff66b commit 09f4233
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ internal fun QuantityAddIcon(
}
var iconTintColor by remember { mutableStateOf(Color.White) }
val animatedBackgroundColor = remember { Animatable(targetBackgroundColor) }
var lastQuantityCount by remember { mutableStateOf(-1) }

LaunchedEffect(key1 = quantityData.currentQuantity) {
iconTintColor = quantityData.getAddIconColor(icons, quantityData.currentQuantity)
}

val setTargetBackgroundColor: (color: Color) -> Unit = remember {
{ color ->
Expand All @@ -54,7 +52,11 @@ internal fun QuantityAddIcon(
}

LaunchedEffect(key1 = quantityData.currentQuantity) {
setTargetBackgroundColor.invoke(quantityData.getBackgroundColor(icons))
if (lastQuantityCount != quantityData.currentQuantity) {
lastQuantityCount = quantityData.currentQuantity
iconTintColor = quantityData.getAddIconColor(icons, quantityData.currentQuantity)
setTargetBackgroundColor.invoke(quantityData.getBackgroundColor(icons))
}
}

Icon(
Expand All @@ -70,8 +72,8 @@ internal fun QuantityAddIcon(
interactionSource = MutableInteractionSource(),
enabled = quantityData.isAddButtonEnabled(),
onClick = {
//setTargetBackgroundColor.invoke(Color.White)
//iconTintColor = icons.iconColor
setTargetBackgroundColor.invoke(Color.White)
iconTintColor = icons.iconColor
onAddClick?.invoke()
}
)
Expand Down

0 comments on commit 09f4233

Please sign in to comment.