Skip to content

Commit 22114fe

Browse files
addressed pr comments
1 parent 40e3d9a commit 22114fe

6 files changed

Lines changed: 74 additions & 72 deletions

File tree

app/src/main/java/com/cornellappdev/uplift/data/repositories/UserInfoRepository.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,15 @@ class UserInfoRepository @Inject constructor(
243243
// Want to log out no matter if the firebase deletes or not
244244
try {
245245
firebaseAuth.currentUser?.delete()?.await()
246+
Log.d("UserInfoRepository", "Firebase account deleted successfully")
246247
} catch (e: Exception) {
247248
Log.e("UserInfoRepository", "Firebase delete failed (User may need to re-login): $e")
248249
}
249250

250251
sessionManager.logout()
251252
dataStore.edit { it.clear() }
252253

253-
Log.d("UserInfoRepository", "Account deleted successfully")
254+
Log.d("UserInfoRepository", "Successfully signed out")
254255
true
255256
} catch (e: Exception) {
256257
Log.e("UserInfoRepository", "Error deleting account: $e")

app/src/main/java/com/cornellappdev/uplift/ui/components/goalsetting/DeleteDialog.kt

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import androidx.compose.ui.graphics.Color
3131
import androidx.compose.ui.res.painterResource
3232
import androidx.compose.ui.text.font.FontWeight
3333
import androidx.compose.ui.text.style.TextAlign
34+
import androidx.compose.ui.tooling.preview.Preview
3435
import androidx.compose.ui.unit.dp
3536
import androidx.compose.ui.unit.sp
3637
import androidx.compose.ui.window.Dialog
@@ -69,7 +70,15 @@ fun DeleteDialog(
6970
Box(
7071
modifier = Modifier.fillMaxSize(),
7172
) {
72-
CloseButton(onDismiss)
73+
CloseButton(modifier = Modifier
74+
.size(32.dp).
75+
clickable(
76+
interactionSource = remember { MutableInteractionSource() },
77+
indication = null
78+
) {
79+
onDismiss()
80+
}
81+
.offset(x = 206.dp, y = 12.dp))
7382
MainDialogColumn(onConfirm, onDismiss)
7483
}
7584
}
@@ -115,20 +124,13 @@ private fun MainDialogColumn(onConfirm: () -> Unit, onDismiss: () -> Unit) {
115124
}
116125

117126
@Composable
118-
private fun CloseButton(onDismiss: () -> Unit) {
127+
fun CloseButton(modifier: Modifier = Modifier,
128+
tint: Color = PRIMARY_BLACK) {
119129
Icon(
120130
imageVector = Icons.Default.Close,
121131
contentDescription = "Close",
122-
tint = PRIMARY_BLACK,
123-
modifier = Modifier
124-
.size(32.dp)
125-
.offset(x = 206.dp, y = 12.dp)
126-
.clickable(
127-
interactionSource = remember { MutableInteractionSource() },
128-
indication = null
129-
) {
130-
onDismiss()
131-
}
132+
tint = tint,
133+
modifier = modifier
132134
)
133135
}
134136

@@ -154,4 +156,13 @@ private fun ConfirmButton(onConfirm: () -> Unit) {
154156
textAlign = TextAlign.Center
155157
)
156158
}
159+
}
160+
161+
@Preview
162+
@Composable
163+
private fun DeleteDialogPreview() {
164+
DeleteDialog(
165+
deleteDialogOpen = true ,
166+
onConfirm = {}
167+
) { }
157168
}

app/src/main/java/com/cornellappdev/uplift/ui/components/profile/DeleteDialog.kt

Lines changed: 35 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
package com.cornellappdev.uplift.ui.components.profile
22

33
import androidx.compose.foundation.clickable
4+
import androidx.compose.foundation.interaction.MutableInteractionSource
45
import androidx.compose.foundation.layout.Arrangement
56
import androidx.compose.foundation.layout.Box
67
import androidx.compose.foundation.layout.Column
7-
import androidx.compose.foundation.layout.Spacer
88
import androidx.compose.foundation.layout.fillMaxWidth
9-
import androidx.compose.foundation.layout.height
109
import androidx.compose.foundation.layout.padding
1110
import androidx.compose.foundation.layout.size
1211
import androidx.compose.foundation.layout.width
1312
import androidx.compose.foundation.shape.RoundedCornerShape
14-
import androidx.compose.material.icons.Icons
15-
import androidx.compose.material.icons.filled.Close
16-
import androidx.compose.material3.Button
17-
import androidx.compose.material3.ButtonDefaults
1813
import androidx.compose.material3.Icon
1914
import androidx.compose.material3.Surface
2015
import androidx.compose.material3.Text
2116
import androidx.compose.runtime.Composable
17+
import androidx.compose.runtime.remember
2218
import androidx.compose.ui.Alignment
2319
import androidx.compose.ui.Modifier
2420
import androidx.compose.ui.graphics.Color
2521
import androidx.compose.ui.res.painterResource
2622
import androidx.compose.ui.text.TextStyle
27-
import androidx.compose.ui.text.font.FontStyle
2823
import androidx.compose.ui.text.font.FontWeight
2924
import androidx.compose.ui.text.style.TextAlign
3025
import androidx.compose.ui.tooling.preview.Preview
3126
import androidx.compose.ui.unit.dp
3227
import androidx.compose.ui.unit.sp
3328
import androidx.compose.ui.window.Dialog
3429
import com.cornellappdev.uplift.R
30+
import com.cornellappdev.uplift.ui.components.general.UpliftButton
31+
import com.cornellappdev.uplift.ui.components.goalsetting.CloseButton
3532
import com.cornellappdev.uplift.ui.theme.AppColors
3633
import com.cornellappdev.uplift.util.montserratFamily
3734

@@ -47,25 +44,29 @@ fun DeleteAccountConfirmationDialog(
4744
modifier = Modifier.width(250.dp)
4845
) {
4946
Box(
50-
modifier = Modifier.padding(20.dp)
47+
modifier = Modifier.fillMaxWidth()
5148
) {
52-
// Top-right Close Button
53-
Icon(
54-
imageVector = Icons.Default.Close,
55-
contentDescription = "Close",
49+
CloseButton(
50+
tint = AppColors.Black.copy(alpha = 0.4f),
5651
modifier = Modifier
5752
.align(Alignment.TopEnd)
58-
.clickable { onDismiss() }
59-
.size(24.dp),
60-
tint = AppColors.Black.copy(alpha = 0.4f)
53+
.padding(top = 12.dp, end = 12.dp)
54+
.size(24.dp)
55+
.clickable(
56+
interactionSource = remember { MutableInteractionSource() },
57+
indication = null
58+
) {
59+
onDismiss()
60+
},
6161
)
6262

6363
Column(
64-
modifier = Modifier.fillMaxWidth(),
64+
modifier = Modifier
65+
.fillMaxWidth()
66+
.padding(20.dp),
6567
horizontalAlignment = Alignment.CenterHorizontally,
6668
verticalArrangement = Arrangement.spacedBy(20.dp)
6769
) {
68-
// Top Center Trash Icon
6970
Icon(
7071
painter = painterResource(id = R.drawable.ic_trash_2),
7172
contentDescription = "Delete account",
@@ -107,41 +108,26 @@ fun DeleteAccountConfirmationDialog(
107108
horizontalAlignment = Alignment.CenterHorizontally,
108109
verticalArrangement = Arrangement.spacedBy(12.dp)
109110
) {
110-
// Delete Button (Black Pill)
111-
Button(
111+
UpliftButton(
112112
onClick = onConfirm,
113+
text = "Delete",
113114
modifier = Modifier
114-
.fillMaxWidth()
115-
.height(41.dp),
116-
shape = RoundedCornerShape(38.dp),
117-
colors = ButtonDefaults.buttonColors(
118-
containerColor = AppColors.Black,
119-
contentColor = AppColors.White
120-
),
121-
elevation = ButtonDefaults.buttonElevation(defaultElevation = 0.dp)
122-
) {
123-
Text(
124-
text = "Delete",
125-
style = TextStyle(
126-
fontFamily = montserratFamily,
127-
fontSize = 16.sp,
128-
fontWeight = FontWeight.Bold
129-
)
130-
)
131-
}
115+
.fillMaxWidth(),
116+
height = 41.dp,
117+
containerColor = AppColors.Black,
118+
contentColor = AppColors.White,
119+
fontSize = 16f,
120+
elevation = 0.dp
121+
)
132122

133-
// Back Button
134-
Text(
123+
UpliftButton(
124+
onClick = onDismiss,
135125
text = "Back",
136-
modifier = Modifier
137-
.clickable { onDismiss() }
138-
.padding(vertical = 4.dp),
139-
style = TextStyle(
140-
fontFamily = montserratFamily,
141-
fontSize = 14.sp,
142-
fontWeight = FontWeight.Bold,
143-
color = AppColors.Black
144-
)
126+
modifier = Modifier.align(Alignment.CenterHorizontally),
127+
containerColor = Color.Transparent,
128+
contentColor = AppColors.Black,
129+
fontSize = 14f,
130+
elevation = 0.dp
145131
)
146132
}
147133
}
@@ -157,4 +143,4 @@ fun DeleteAccountConfirmationDialogPreview() {
157143
onDismiss = {},
158144
onConfirm = {}
159145
)
160-
}
146+
}

app/src/main/java/com/cornellappdev/uplift/ui/screens/profile/SettingsScreen.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
3030
import com.cornellappdev.uplift.R
3131
import com.cornellappdev.uplift.ui.components.general.UpliftTopBarWithBack
3232
import com.cornellappdev.uplift.ui.components.profile.DeleteAccountConfirmationDialog
33+
import com.cornellappdev.uplift.ui.theme.AppColors
3334
import com.cornellappdev.uplift.ui.viewmodels.profile.SettingsViewModel
3435
import com.cornellappdev.uplift.util.GRAY01
3536
import com.cornellappdev.uplift.util.GRAY03
@@ -48,7 +49,7 @@ fun SettingsScreen(
4849
onAboutPressed = settingsViewModel::onAboutPressed,
4950
onReportPressed = settingsViewModel::onReportPressed,
5051
onLogOut = settingsViewModel::onLogOut,
51-
onDeletePress = { showDeleteDialog = true },
52+
onDeleteClick = { showDeleteDialog = true },
5253
)
5354
if (showDeleteDialog) {
5455
DeleteAccountConfirmationDialog(
@@ -70,7 +71,7 @@ private fun SettingsScreenContent(
7071
onAboutPressed: () -> Unit,
7172
onReportPressed: () -> Unit,
7273
onLogOut: () -> Unit,
73-
onDeletePress: () -> Unit,
74+
onDeleteClick: () -> Unit,
7475
) {
7576
Scaffold(topBar = {
7677
UpliftTopBarWithBack(title = "Settings", onBackClick = onBackClick)
@@ -101,7 +102,7 @@ private fun SettingsScreenContent(
101102
if (isLoggedIn) {
102103
LogOutButton(onLogOut)
103104
Divider(color = GRAY01)
104-
DeleteAccountButton(onDeletePress)
105+
DeleteAccountButton(onDeleteClick)
105106
}
106107
}
107108
}
@@ -128,33 +129,33 @@ private fun LogOutButton(
128129
fontSize = 16.sp,
129130
fontFamily = montserratFamily,
130131
fontWeight = FontWeight.Medium,
131-
color = Color(0xFFFE1313)
132+
color = AppColors.Red
132133
)
133134
}
134135
}
135136

136137
@Composable
137138
private fun DeleteAccountButton(
138-
onDeletePress: () -> Unit,
139+
onDeleteClick: () -> Unit,
139140
){
140141
Row(
141142
modifier = Modifier.clickable(
142-
onClick = onDeletePress
143+
onClick = onDeleteClick
143144
),
144145
horizontalArrangement = Arrangement.spacedBy(8.dp),
145146
verticalAlignment = Alignment.CenterVertically,
146147
){
147148
Icon(
148149
painterResource(id = R.drawable.ic_trash),
149150
contentDescription = "Delete account",
150-
tint = Color(0xFFFE1313)
151+
tint = AppColors.Red
151152
)
152153
Text(
153154
text = "Delete account",
154155
fontSize = 16.sp,
155156
fontFamily = montserratFamily,
156157
fontWeight = FontWeight.Medium,
157-
color = Color(0xFFFE1313)
158+
color = AppColors.Red
158159
)
159160
}
160161
}
@@ -205,6 +206,6 @@ private fun SettingsScreenPreview() {
205206
onAboutPressed = {},
206207
onReportPressed = {},
207208
onLogOut = {},
208-
onDeletePress = {},
209+
onDeleteClick = {},
209210
)
210211
}

app/src/main/java/com/cornellappdev/uplift/ui/theme/Color.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ object AppColors {
1414
val LightYellow = Color(0xFFFCF5A4)
1515
val TextPrimary = Color(0xFF1B1F23)
1616
val Gray01 = Color(0xFFE5ECED)
17+
val Red = Color(0xFFFE1313)
1718
}
1819

1920
object ConfettiColors{

app/src/main/java/com/cornellappdev/uplift/ui/viewmodels/nav/RootNavigationViewModel.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ class RootNavigationViewModel @Inject constructor(
6666

6767
val hasSkipped = userInfoRepository.getSkipFromDataStore()
6868
val shouldShowHome = loggedIn || hasSkipped || !ONBOARDING_FLAG
69+
val newRoute = if (shouldShowHome) UpliftRootRoute.Home else UpliftRootRoute.Onboarding
6970
applyMutation {
7071
copy(
71-
startDestination = if (shouldShowHome) UpliftRootRoute.Home else UpliftRootRoute.Onboarding
72+
startDestination = newRoute,
73+
navEvent = UIEvent(newRoute)
7274
)
7375
}
7476
}

0 commit comments

Comments
 (0)