Skip to content

Commit

Permalink
QuantityDropDownItem as a separated composable
Browse files Browse the repository at this point in the history
  • Loading branch information
magda-woj committed Aug 9, 2024
1 parent c4efd94 commit 352bddb
Showing 1 changed file with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,37 @@ fun QuantityDropdown(
onDismissRequest = onDismissRequest
) {
for (i in 1..10) {
DropdownMenuItem(
text = {
Row(
verticalAlignment = Alignment.CenterVertically
) {
if (i == selectedQuantity) {
Icon(
imageVector = Icons.Filled.Check,
contentDescription = "Selected",
tint = Color.Black,
modifier = Modifier.size(18.dp)
)
Spacer(modifier = Modifier.width(8.dp))
}
Text(
text = i.toString(),
)
}
},
onClick = { onQuantitySelected(i) }
)
QuantityDropDownItem(i, i == selectedQuantity, onClick = {onQuantitySelected(i)})
}
}
}

@Composable
fun QuantityDropDownItem(
quantity: Int,
isSelected: Boolean,
onClick: () -> Unit
){
DropdownMenuItem(
text = {
Row(
verticalAlignment = Alignment.CenterVertically
) {
if (isSelected) {
Icon(
imageVector = Icons.Filled.Check,
contentDescription = "Selected",
tint = Color.Black,
modifier = Modifier.size(18.dp)
)
Spacer(modifier = Modifier.width(8.dp))
}
Text(
text = quantity.toString(),
)
}
},
onClick = onClick
)

}

0 comments on commit 352bddb

Please sign in to comment.