-
-
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.
feat: Added cart sharing, updated cart and item models, and improved …
…database interactions - Implemented cart sharing functionality, allowing users to share their carts via a deep link. - Updated `ShoppingCartTable` to store the `date` as a `Long` instead of `Date`, and added a `toDate()` method for conversion. - Made `ShoppingCartItemsTable` serializable using `@Serializable`. - Refactored `NewCartDao` to return a nullable `ShoppingCartTable?` for `getCartById`. - Added `importSharedCart` function to `MainViewModel` to handle shared cart data. - Implemented `importSharedCartImplementation` in `MainRepositoryImplementation` to handle the decoding and import logic of shared cart data. - Updated `MainScaffoldContent` to add padding for the AdView when ads are enabled. - Updated `HomeScreen` to be able to show AdBanners in the middle of the list of cart items. - Added a new `shareCart` method to `CartViewModel` to allow for sharing the cart. - Refactored `CartRepository` to add new `generateCartShareLink` method to generate the deep link and updated the `loadCartIdImplementation` method to return a `ShoppingCartTable?` - Updated `AddNewCartAlertDialog` to create the `ShoppingCartTable` with the date as a Long. - Fixed the app full name in the `VersionInfoAlertDialog`. - Updated the app `roundIcon` and added a new `intent-filter` for the deep link. - Updated the `onNewIntent` method in the `MainActivity` to handle deep links. - Added `kotlin-serialization` and `jetbrainsKotlinParcelize` plugins. - Updated various dependencies in `libs.versions.toml` and `build.gradle.kts`. - Added `Json` and `Base64` to the app.
- Loading branch information
Mihai-Cristian Condrea
committed
Feb 18, 2025
1 parent
84ab764
commit 0611c31
Showing
22 changed files
with
342 additions
and
97 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
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
62 changes: 62 additions & 0 deletions
62
app/src/main/kotlin/com/d4rk/cartcalculator/ui/components/dialogs/ImportCartAlertDialog.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,62 @@ | ||
package com.d4rk.cartcalculator.ui.components.dialogs | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.ContentPaste | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.ButtonDefaults | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.OutlinedTextField | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.ClipboardManager | ||
import androidx.compose.ui.platform.LocalClipboardManager | ||
import androidx.compose.ui.res.stringResource | ||
|
||
@Composable | ||
fun ImportCartAlertDialog(onDismiss : () -> Unit , onImport : (String) -> Unit) { | ||
var cartLink : String by remember { mutableStateOf(value = "") } | ||
|
||
AlertDialog(onDismissRequest = onDismiss , title = { Text(text = "Import Cart") } , text = { | ||
ImportCartAlertDialogContent(cartLink = cartLink , onCartLinkChange = { cartLink = it }) | ||
} , confirmButton = { | ||
TextButton(onClick = { | ||
if (cartLink.isNotEmpty()) { | ||
onImport(cartLink) | ||
onDismiss() | ||
} | ||
}) { | ||
Text(text = "Import") | ||
} | ||
} , dismissButton = { | ||
TextButton(onClick = onDismiss) { | ||
Text(text = stringResource(id = android.R.string.cancel)) | ||
} | ||
}) | ||
} | ||
|
||
@Composable | ||
fun ImportCartAlertDialogContent(cartLink : String , onCartLinkChange : (String) -> Unit) { | ||
val clipboardManager : ClipboardManager = LocalClipboardManager.current | ||
|
||
Column { | ||
OutlinedTextField(value = cartLink , onValueChange = onCartLinkChange , label = { Text("Paste Cart Link") } , modifier = Modifier.fillMaxWidth() , maxLines = 1 , trailingIcon = { | ||
IconButton(onClick = { | ||
clipboardManager.getText()?.text?.let { text -> | ||
onCartLinkChange(text) | ||
} | ||
}) { | ||
Icon(modifier = Modifier.size(size = ButtonDefaults.IconSize) , imageVector = Icons.Outlined.ContentPaste , contentDescription = stringResource(id = android.R.string.paste)) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.