From 573b508223a4c90d9103ec32aecadbfc22241a3b Mon Sep 17 00:00:00 2001 From: nayy Date: Tue, 29 Oct 2024 05:37:11 -0700 Subject: [PATCH] Updated button onClick to save 'hasAccount' status, enabling direct account access on startup --- .../FinalizeAccountCreationScreen.kt | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/wallet_app/app/src/main/java/com/example/walletapp/ui/onboarding/FinalizeAccountCreationScreen.kt b/wallet_app/app/src/main/java/com/example/walletapp/ui/onboarding/FinalizeAccountCreationScreen.kt index e073ecc..ebd1c88 100644 --- a/wallet_app/app/src/main/java/com/example/walletapp/ui/onboarding/FinalizeAccountCreationScreen.kt +++ b/wallet_app/app/src/main/java/com/example/walletapp/ui/onboarding/FinalizeAccountCreationScreen.kt @@ -269,15 +269,23 @@ fun AccountInfoView(onContinue: () -> Unit) { } Spacer(modifier = Modifier.weight(1f)) - - Button( - onClick = onContinue, - contentPadding = ButtonDefaults.ContentPadding, - shape = RoundedCornerShape(8.dp), - colors = ButtonDefaults.buttonColors(backgroundColor = Color("#EC796B".toColorInt()), contentColor = Color.White), - modifier = Modifier - .fillMaxWidth() - .height(49.dp) + onClick = { + // Save the account information to DataStore when the button is clicked + scope.launch { + context.dataStore.edit { preferences -> + // Set hasAccount to true when the account creation is finalized + preferences[hasAccountKey] = true + } + } + // Navigate to the next screen + onContinue() + }, + contentPadding = ButtonDefaults.ContentPadding, + shape = RoundedCornerShape(8.dp), + colors = ButtonDefaults.buttonColors(backgroundColor = Color("#EC796B".toColorInt()), contentColor = Color.White), + modifier = Modifier + .fillMaxWidth() + .height(49.dp ) { Row(verticalAlignment = Alignment.CenterVertically) { Text("Continue")