Skip to content

Commit 67c3409

Browse files
Modified UI files and added VM tags
1 parent d934494 commit 67c3409

4 files changed

Lines changed: 160 additions & 92 deletions

File tree

app/src/main/java/com/cornellappdev/uplift/ui/components/general/CheckInPopUp.kt

Lines changed: 13 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,22 @@ import androidx.compose.animation.core.tween
66
import androidx.compose.animation.fadeIn
77
import androidx.compose.animation.fadeOut
88
import androidx.compose.animation.togetherWith
9-
import androidx.compose.foundation.Image
109
import androidx.compose.foundation.background
11-
import androidx.compose.foundation.clickable
1210
import androidx.compose.foundation.layout.Arrangement
13-
import androidx.compose.foundation.layout.Column
14-
import androidx.compose.foundation.layout.PaddingValues
1511
import androidx.compose.foundation.layout.Row
16-
import androidx.compose.foundation.layout.Spacer
1712
import androidx.compose.foundation.layout.fillMaxWidth
1813
import androidx.compose.foundation.layout.height
1914
import androidx.compose.foundation.layout.padding
20-
import androidx.compose.foundation.layout.width
2115
import androidx.compose.foundation.shape.RoundedCornerShape
22-
import androidx.compose.material.Button
23-
import androidx.compose.material.ButtonDefaults
24-
import androidx.compose.material.Text
2516
import androidx.compose.runtime.Composable
2617
import androidx.compose.ui.Alignment
2718
import androidx.compose.ui.Modifier
2819
import androidx.compose.ui.draw.shadow
29-
import androidx.compose.ui.layout.ContentScale
30-
import androidx.compose.ui.res.painterResource
3120
import androidx.compose.ui.tooling.preview.Preview
3221
import androidx.compose.ui.unit.dp
33-
import com.cornellappdev.uplift.R
22+
import com.cornellappdev.uplift.ui.components.profile.checkin.CheckInComplete
23+
import com.cornellappdev.uplift.ui.components.profile.checkin.CheckInPrompt
3424
import com.cornellappdev.uplift.ui.theme.AppColors
35-
import com.cornellappdev.uplift.ui.theme.AppTextStyles
3625
import com.cornellappdev.uplift.ui.viewmodels.profile.CheckInMode
3726

3827

@@ -67,81 +56,18 @@ fun CheckInPopUp(
6756
},
6857
label = "check-in"
6958
) { target ->
70-
if (target == CheckInMode.Prompt) {
71-
Row(
72-
modifier = Modifier.fillMaxWidth(),
73-
horizontalArrangement = Arrangement.SpaceBetween,
74-
verticalAlignment = Alignment.CenterVertically
75-
) {
76-
Column(
77-
) {
78-
Text(
79-
text = "We see you're near a gym...",
80-
style = AppTextStyles.BodySemibold,
81-
color = AppColors.Black
82-
)
83-
Spacer(Modifier.height(4.dp))
84-
Text(
85-
text = "$gymName at $currentTimeText",
86-
style = AppTextStyles.LabelNormal,
87-
color = AppColors.Black
88-
)
89-
}
90-
Row(
91-
modifier = Modifier
92-
.height(34.dp),
93-
horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start),
94-
verticalAlignment = Alignment.CenterVertically
95-
) {
96-
Button(
97-
modifier = Modifier
98-
.width(93.dp)
99-
.height(34.dp),
100-
shape = RoundedCornerShape(size = 11.05263.dp),
101-
colors = ButtonDefaults.buttonColors(
102-
backgroundColor = AppColors.LightYellow,
103-
contentColor = AppColors.Black
104-
),
105-
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 10.dp),
106-
onClick = onCheckIn
107-
) {
108-
Text(
109-
text = "Check In?",
110-
style = AppTextStyles.LabelBig,
111-
color = AppColors.Black
112-
)
113-
}
114-
115-
Image(
116-
painter = painterResource(id = R.drawable.ic_close),
117-
contentDescription = "close pop up",
118-
contentScale = ContentScale.None,
119-
modifier = Modifier.clickable { onDismiss() }
120-
)
121-
}
122-
123-
124-
}
125-
126-
} else {
127-
Row(
128-
modifier = Modifier.fillMaxWidth(),
129-
horizontalArrangement = Arrangement.SpaceBetween,
130-
verticalAlignment = Alignment.CenterVertically
131-
) {
132-
Text(
133-
text = "You’re all set. Enjoy your workout!",
134-
style = AppTextStyles.BodySemibold,
135-
color = AppColors.Black
136-
)
137-
Image(
138-
painter = painterResource(id = R.drawable.ic_close),
139-
contentDescription = "close pop up",
140-
contentScale = ContentScale.None,
141-
modifier = Modifier.clickable { onClosePopUp() }
142-
)
143-
}
59+
when (target) {
60+
CheckInMode.Prompt -> CheckInPrompt(
61+
gymName = gymName,
62+
currentTimeText = currentTimeText,
63+
onCheckIn = onCheckIn,
64+
onDismiss = onDismiss
65+
)
66+
CheckInMode.Complete -> CheckInComplete(
67+
onClosePopUp = onClosePopUp
68+
)
14469
}
70+
14571
}
14672
}
14773
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.cornellappdev.uplift.ui.components.profile.checkin
2+
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.clickable
5+
import androidx.compose.foundation.layout.Arrangement
6+
import androidx.compose.foundation.layout.Row
7+
import androidx.compose.foundation.layout.fillMaxWidth
8+
import androidx.compose.material.Text
9+
import androidx.compose.runtime.Composable
10+
import androidx.compose.ui.Alignment
11+
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.layout.ContentScale
13+
import androidx.compose.ui.res.painterResource
14+
import androidx.compose.ui.tooling.preview.Preview
15+
import com.cornellappdev.uplift.R
16+
import com.cornellappdev.uplift.ui.theme.AppColors
17+
import com.cornellappdev.uplift.ui.theme.AppTextStyles
18+
19+
@Composable
20+
fun CheckInComplete(
21+
onClosePopUp: () -> Unit
22+
){
23+
Row(
24+
modifier = Modifier.fillMaxWidth(),
25+
horizontalArrangement = Arrangement.SpaceBetween,
26+
verticalAlignment = Alignment.CenterVertically
27+
) {
28+
Text(
29+
text = "You’re all set. Enjoy your workout!",
30+
style = AppTextStyles.BodySemibold,
31+
color = AppColors.Black
32+
)
33+
Image(
34+
painter = painterResource(id = R.drawable.ic_close),
35+
contentDescription = "close pop up",
36+
contentScale = ContentScale.None,
37+
modifier = Modifier.clickable { onClosePopUp() }
38+
)
39+
}
40+
}
41+
42+
@Preview(showBackground = true)
43+
@Composable
44+
private fun CheckInCompletePreview(){
45+
CheckInComplete({})
46+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package com.cornellappdev.uplift.ui.components.profile.checkin
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.ui.tooling.preview.Preview
5+
import androidx.compose.foundation.Image
6+
import androidx.compose.foundation.clickable
7+
import androidx.compose.foundation.layout.Arrangement
8+
import androidx.compose.foundation.layout.Column
9+
import androidx.compose.foundation.layout.PaddingValues
10+
import androidx.compose.foundation.layout.Row
11+
import androidx.compose.foundation.layout.Spacer
12+
import androidx.compose.foundation.layout.fillMaxWidth
13+
import androidx.compose.foundation.layout.height
14+
import androidx.compose.foundation.layout.width
15+
import androidx.compose.foundation.shape.RoundedCornerShape
16+
import androidx.compose.material.Button
17+
import androidx.compose.material.ButtonDefaults
18+
import androidx.compose.material.Text
19+
import androidx.compose.ui.Alignment
20+
import androidx.compose.ui.Modifier
21+
import androidx.compose.ui.layout.ContentScale
22+
import androidx.compose.ui.res.painterResource
23+
import androidx.compose.ui.unit.dp
24+
import com.cornellappdev.uplift.R
25+
import com.cornellappdev.uplift.ui.theme.AppColors
26+
import com.cornellappdev.uplift.ui.theme.AppTextStyles
27+
28+
@Composable
29+
fun CheckInPrompt(
30+
gymName: String,
31+
currentTimeText: String,
32+
onDismiss: () -> Unit,
33+
onCheckIn: () -> Unit
34+
){
35+
Row(
36+
modifier = Modifier.fillMaxWidth(),
37+
horizontalArrangement = Arrangement.SpaceBetween,
38+
verticalAlignment = Alignment.CenterVertically
39+
) {
40+
Column(
41+
) {
42+
Text(
43+
text = "We see you're near a gym...",
44+
style = AppTextStyles.BodySemibold,
45+
color = AppColors.Black
46+
)
47+
Spacer(Modifier.height(4.dp))
48+
Text(
49+
text = "$gymName at $currentTimeText",
50+
style = AppTextStyles.LabelNormal,
51+
color = AppColors.Black
52+
)
53+
}
54+
Row(
55+
modifier = Modifier
56+
.height(34.dp),
57+
horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start),
58+
verticalAlignment = Alignment.CenterVertically
59+
) {
60+
Button(
61+
modifier = Modifier
62+
.width(93.dp)
63+
.height(34.dp),
64+
shape = RoundedCornerShape(size = 11.05263.dp),
65+
colors = ButtonDefaults.buttonColors(
66+
backgroundColor = AppColors.LightYellow,
67+
contentColor = AppColors.Black
68+
),
69+
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 10.dp),
70+
onClick = onCheckIn
71+
) {
72+
Text(
73+
text = "Check In?",
74+
style = AppTextStyles.LabelBig,
75+
color = AppColors.Black
76+
)
77+
}
78+
79+
Image(
80+
painter = painterResource(id = R.drawable.ic_close),
81+
contentDescription = "close pop up",
82+
contentScale = ContentScale.None,
83+
modifier = Modifier.clickable { onDismiss() }
84+
)
85+
}
86+
87+
88+
}
89+
}
90+
91+
@Preview(showBackground = true)
92+
@Composable
93+
private fun CheckInPromptPreview() {
94+
CheckInPrompt("Helen Newman", "1:00 PM", {}, {})
95+
}

app/src/main/java/com/cornellappdev/uplift/ui/viewmodels/profile/CheckInViewModel.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.combine
1414
import kotlinx.coroutines.launch
1515
import javax.inject.Inject
1616

17+
private const val tag = "CheckInVM"
1718
/**
1819
* UI mode for the Check-In pop up.
1920
* - [Prompt]: user is near an open gym and can choose to check in.
@@ -91,11 +92,11 @@ class CheckInViewModel @Inject constructor(
9192
checkInRepository.evaluateProximity(location)
9293
}
9394
} catch (e: Exception) {
94-
Log.e("CheckInViewModel", "Error evaluating proximity from location update", e)
95+
Log.e(tag, "Error evaluating proximity from location update", e)
9596
}
9697
}
9798
} catch (e: Exception) {
98-
Log.e("CheckInViewModel", "Error collecting location flow", e)
99+
Log.e(tag, "Error collecting location flow", e)
99100
}
100101
}
101102
}
@@ -118,7 +119,7 @@ class CheckInViewModel @Inject constructor(
118119
try {
119120
checkInRepository.markCheckInDismissedFor()
120121
} catch (e: Exception) {
121-
Log.e("CheckInViewModel", "Error dismissing check-in", e)
122+
Log.e(tag, "Error dismissing check-in", e)
122123
}
123124
onClose()
124125
}
@@ -136,7 +137,7 @@ class CheckInViewModel @Inject constructor(
136137
val gymIdInt = currentGymId?.toIntOrNull()
137138

138139
if (gymIdInt == null) {
139-
Log.w("CheckInVM", "Invalid or missing gym ID: $currentGymId")
140+
Log.w(tag, "Invalid or missing gym ID: $currentGymId")
140141
return@launch
141142
}
142143
try {
@@ -149,7 +150,7 @@ class CheckInViewModel @Inject constructor(
149150
}
150151
checkInRepository.logWorkoutFromCheckIn(gymIdInt)
151152
} catch (e: Exception) {
152-
Log.e("CheckInViewModel", "Error checking in", e)
153+
Log.e(tag, "Error checking in", e)
153154
}
154155
}
155156

0 commit comments

Comments
 (0)