-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new dialog to remove items from the cart and code improvements
- Loading branch information
1 parent
4114807
commit 5199a98
Showing
27 changed files
with
377 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/src/main/kotlin/com/d4rk/cartcalculator/dialogs/DeleteCartItemDialogComposable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.d4rk.cartcalculator.dialogs | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.Info | ||
import androidx.compose.material.icons.outlined.RemoveShoppingCart | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import com.d4rk.cartcalculator.R | ||
import com.d4rk.cartcalculator.data.db.table.ShoppingCartItemsTable | ||
|
||
@Composable | ||
fun DeleteCartItemDialog( | ||
cartItem: ShoppingCartItemsTable, | ||
onDismiss: () -> Unit, | ||
onDeleteConfirmed: (ShoppingCartItemsTable) -> Unit | ||
) { | ||
AlertDialog( | ||
onDismissRequest = onDismiss, | ||
title = { | ||
Text( | ||
text = stringResource(R.string.delete_cart_item_title), | ||
) | ||
}, | ||
text = { DeleteCartItemDialogContent(cartItem) }, | ||
confirmButton = { | ||
TextButton(onClick = { | ||
onDeleteConfirmed(cartItem) | ||
onDismiss() | ||
}) { | ||
Text(stringResource(android.R.string.ok)) | ||
} | ||
}, | ||
dismissButton = { | ||
TextButton(onClick = onDismiss) { | ||
Text(stringResource(android.R.string.cancel)) | ||
} | ||
} | ||
) | ||
} | ||
|
||
@Composable | ||
fun DeleteCartItemDialogContent(cartItem: ShoppingCartItemsTable) { | ||
Column { | ||
Icon( | ||
imageVector = Icons.Outlined.RemoveShoppingCart, | ||
contentDescription = null, | ||
modifier = Modifier.align(Alignment.CenterHorizontally), | ||
tint = MaterialTheme.colorScheme.error | ||
) | ||
Spacer(modifier = Modifier.height(24.dp)) | ||
Text( | ||
text = stringResource(R.string.delete_cart_item_message), | ||
style = MaterialTheme.typography.bodyLarge, | ||
) | ||
Spacer(modifier = Modifier.height(24.dp)) | ||
Icon(imageVector = Icons.Outlined.Info, contentDescription = null) | ||
Spacer(modifier = Modifier.height(12.dp)) | ||
Text( | ||
text = stringResource(R.string.delete_cart_item_warning, cartItem.name), | ||
style = MaterialTheme.typography.bodyLarge | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.