Skip to content

Commit

Permalink
now you always choose good position of edited product.
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilMaciuszek committed Jan 18, 2022
1 parent 82950b9 commit 703ac5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,16 @@ fun ShopFormSection(
modifier = modifier
.fillMaxWidth()
) {
var productToChange by remember {
mutableStateOf(Product())
}
menu.value.forEach { item ->
if (editAlertDialog.value) {
productName = item.name!!
price = item.price.toString()
tag1 = item.tags[0].name!!
tag2 = item.tags[1].name!!
tag3 = item.tags[2].name!!
productName = productToChange.name!!
price = productToChange.price.toString()
tag1 = productToChange.tags[0].name!!
tag2 = productToChange.tags[1].name!!
tag3 = productToChange.tags[2].name!!
AlertDialog(onDismissRequest = { editAlertDialog.value = false },
title = { Text(text = "Now you can edit product") },
text = {
Expand Down Expand Up @@ -333,7 +336,7 @@ fun ShopFormSection(
confirmButton = {
enabled.value = productName.isNotEmpty() && price.isNotEmpty()
Button(onClick = {
menu.value.remove(item)
menu.value.remove(productToChange)
menu.value.add(
Product(
productName,
Expand Down Expand Up @@ -394,7 +397,10 @@ fun ShopFormSection(
Icon(
Icons.Default.Edit, "Edit",
Modifier
.clickable { editAlertDialog.value = true }
.clickable {
editAlertDialog.value = true
productToChange = item
}
.padding(top = 30.dp)
)
Icon(
Expand Down

0 comments on commit 703ac5c

Please sign in to comment.