Skip to content

Commit 80817e7

Browse files
Rebased and Addressed comments
1 parent 2af071e commit 80817e7

6 files changed

Lines changed: 63 additions & 155 deletions

File tree

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ android {
4848
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
4949
buildConfigField("String", "GOOGLE_AUTH_CLIENT_ID", secretsProperties["GOOGLE_AUTH_CLIENT_ID"])
5050
buildConfigField("String", "BACKEND_URL", secretsProperties['PROD_ENDPOINT'])
51-
buildConfigField("boolean", "ONBOARDING_FLAG", "false")
52-
buildConfigField("boolean", "CHECK_IN_FLAG", "false")
51+
buildConfigField("boolean", "ONBOARDING_FLAG", "true")
52+
buildConfigField("boolean", "CHECK_IN_FLAG", "true")
5353
}
5454
debug {
5555
buildConfigField("String", "BACKEND_URL", secretsProperties['DEV_ENDPOINT'])
@@ -58,8 +58,8 @@ android {
5858
"GOOGLE_AUTH_CLIENT_ID", secretsProperties["GOOGLE_AUTH_CLIENT_ID"]
5959
)
6060
signingConfig signingConfigs.debug
61-
buildConfigField("boolean", "ONBOARDING_FLAG", "false")
62-
buildConfigField("boolean", "CHECK_IN_FLAG", "false")
61+
buildConfigField("boolean", "ONBOARDING_FLAG", "true")
62+
buildConfigField("boolean", "CHECK_IN_FLAG", "true")
6363
}
6464
}
6565
compileOptions {

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

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ class UserInfoRepository @Inject constructor(
6464
else {
6565
Log.d("UserInfoRepository", "Skipping goal upload")
6666
}
67-
storeUserFields(id, name, netId, email, skip, goal)
67+
storeUserFields(
68+
id = userFields.id,
69+
username = userFields.name,
70+
netId = userFields.netId,
71+
email = userFields.email ?: email,
72+
skip = skip,
73+
goal = goal
74+
)
6875
Log.d("UserInfoRepositoryImpl", "User created successfully")
6976
return true
7077
} catch (e: Exception) {
@@ -111,11 +118,14 @@ class UserInfoRepository @Inject constructor(
111118
return try {
112119
val user = getUserByNetId(netId) ?: return false
113120

114-
storeId(user.id)
115-
storeNetId(user.netId)
116-
storeUsername(user.name)
117-
storeEmail(user.email)
118-
storeSkip(false)
121+
storeUserFields(
122+
id = user.id,
123+
username = user.name,
124+
netId = user.netId,
125+
email = user.email,
126+
skip = false,
127+
goal = user.workoutGoal ?: 0
128+
)
119129

120130
Log.d("UserInfoRepositoryImpl", "Synced existing user to DataStore: ${user.id}")
121131
true
@@ -172,36 +182,6 @@ class UserInfoRepository @Inject constructor(
172182
firebaseAuth.signOut()
173183
}
174184

175-
private suspend fun storeId(id: String) {
176-
dataStore.edit { preferences ->
177-
preferences[PreferencesKeys.ID] = id
178-
}
179-
}
180-
181-
private suspend fun storeUsername(username: String) {
182-
dataStore.edit { preferences ->
183-
preferences[PreferencesKeys.USERNAME] = username
184-
}
185-
}
186-
187-
private suspend fun storeNetId(netId: String) {
188-
dataStore.edit { preferences ->
189-
preferences[PreferencesKeys.NETID] = netId
190-
}
191-
}
192-
193-
private suspend fun storeEmail(email: String) {
194-
dataStore.edit { preferences ->
195-
preferences[PreferencesKeys.EMAIL] = email
196-
}
197-
}
198-
199-
private suspend fun storeGoal(goal: Int) {
200-
dataStore.edit { preferences ->
201-
preferences[PreferencesKeys.GOAL] = goal
202-
}
203-
}
204-
205185
suspend fun storeSkip(skip: Boolean) {
206186
dataStore.edit { preferences ->
207187
preferences[PreferencesKeys.SKIP] = skip

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

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import androidx.compose.material3.Text
1818
import androidx.compose.runtime.Composable
1919
import androidx.compose.ui.Alignment
2020
import androidx.compose.ui.Modifier
21+
import androidx.compose.ui.focus.focusModifier
2122
import androidx.compose.ui.graphics.Color
2223
import androidx.compose.ui.res.painterResource
2324
import androidx.compose.ui.text.font.FontWeight
@@ -35,7 +36,8 @@ data class HistoryItem(
3536
val gymName: String,
3637
val time: String,
3738
val date: String,
38-
val timestamp: Long
39+
val timestamp: Long,
40+
val ago: String
3941
)
4042

4143
@Composable
@@ -51,29 +53,26 @@ fun HistorySection(
5153
SectionTitleText("My Workout History", onClick)
5254
Spacer(modifier = Modifier.height(12.dp))
5355
if (historyItems.isNotEmpty()) {
54-
Column(
56+
HistoryList(
57+
historyItems = historyItems,
5558
modifier = Modifier
5659
.fillMaxSize()
5760
.verticalScroll(rememberScrollState())
58-
) {
59-
HistoryList(historyItems)
60-
}
61+
)
6162
} else {
62-
Box(
63-
modifier = Modifier.fillMaxSize(),
64-
contentAlignment = Alignment.Center
65-
) {
66-
EmptyHistorySection()
67-
}
63+
EmptyHistorySection()
6864
}
6965
}
7066

7167

7268
}
7369

7470
@Composable
75-
private fun HistoryList(historyItems: List<HistoryItem>) {
76-
Column {
71+
private fun HistoryList(
72+
historyItems: List<HistoryItem>,
73+
modifier: Modifier = Modifier
74+
) {
75+
Column(modifier = modifier) {
7776
historyItems.take(5).forEachIndexed { index, historyItem ->
7877
HistoryItemRow(historyItem = historyItem)
7978
if (index != historyItems.size - 1) {
@@ -90,10 +89,7 @@ private fun HistoryItemRow(
9089
val gymName = historyItem.gymName
9190
val time = historyItem.time
9291
val date = historyItem.date
93-
val calendar = Calendar.getInstance().apply {
94-
timeInMillis = historyItem.timestamp
95-
}
96-
val ago = calendar.timeAgoString()
92+
val ago = historyItem.ago
9793

9894
Row(
9995
modifier = Modifier
@@ -138,8 +134,8 @@ private fun EmptyHistorySection(){
138134
painter = painterResource(id = R.drawable.ic_dufflebag),
139135
contentDescription = null,
140136
modifier = Modifier
141-
.width(64.99967.dp)
142-
.height(50.8181.dp)
137+
.width(65.dp)
138+
.height(51.dp)
143139

144140
)
145141
Spacer(modifier = Modifier.height(12.dp))
@@ -165,11 +161,11 @@ private fun EmptyHistorySection(){
165161
private fun HistorySectionPreview() {
166162
val now = System.currentTimeMillis()
167163
val historyItems = listOf(
168-
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now - (1 * 24 * 60 * 60 * 1000) ),
169-
HistoryItem("Noyes", "1:00 PM", "March 29, 2024", now - (3 * 24 * 60 * 60 * 1000)),
170-
HistoryItem("Teagle Up", "2:00 PM", "March 29, 2024", now - (7 * 24 * 60 * 60 * 1000)),
171-
HistoryItem("Teagle Down", "12:00 PM", "March 29, 2024", now - (15 * 24 * 60 * 60 * 1000)),
172-
HistoryItem("Helen Newman", "10:00 AM", "March 29, 2024", now),
164+
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now - (1 * 24 * 60 * 60 * 1000), "1 day ago"),
165+
HistoryItem("Noyes", "1:00 PM", "March 29, 2024", now - (3 * 24 * 60 * 60 * 1000), "2 days ago"),
166+
HistoryItem("Teagle Up", "2:00 PM", "March 29, 2024", now - (7 * 24 * 60 * 60 * 1000), "1 day ago"),
167+
HistoryItem("Teagle Down", "12:00 PM", "March 29, 2024", now - (15 * 24 * 60 * 60 * 1000), "1 day ago"),
168+
HistoryItem("Helen Newman", "10:00 AM", "March 29, 2024", now, "Today"),
173169
)
174170
Column(
175171
modifier = Modifier

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

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import androidx.compose.ui.geometry.Size
2424
import androidx.compose.ui.graphics.Brush
2525
import androidx.compose.ui.graphics.Color
2626
import androidx.compose.ui.graphics.StrokeCap
27-
import androidx.compose.ui.graphics.drawscope.DrawScope
2827
import androidx.compose.ui.graphics.drawscope.Stroke
2928
import androidx.compose.ui.text.TextStyle
3029
import androidx.compose.ui.text.font.FontWeight
@@ -53,7 +52,7 @@ fun WorkoutProgressArc(
5352
workoutGoal: Int,
5453
) {
5554
val isZero = workoutsCompleted <= 0 || workoutGoal <= 0
56-
val isComplete = workoutGoal > 0 && workoutsCompleted >= workoutGoal
55+
val isComplete = workoutGoal in 1..workoutsCompleted
5756

5857
// Calculate progress percentage
5958
val progress = when {
@@ -187,75 +186,6 @@ private fun ProgressArc(
187186
}
188187
}
189188

190-
private fun DrawScope.drawProgressArc(
191-
workoutsCompleted: Int,
192-
workoutGoal: Int,
193-
gradientBrush: Brush,
194-
startAngle: Float,
195-
progressAngle: Float,
196-
topLeft: Offset,
197-
arcSize: Size,
198-
strokeWidth: Float
199-
) {
200-
if (workoutsCompleted == workoutGoal) {
201-
drawArc(
202-
brush = gradientBrush,
203-
startAngle = startAngle,
204-
sweepAngle = progressAngle,
205-
useCenter = false,
206-
topLeft = topLeft,
207-
size = arcSize,
208-
style = Stroke(width = strokeWidth, cap = StrokeCap.Round)
209-
)
210-
} else {
211-
drawArc(
212-
color = PRIMARY_YELLOW,
213-
startAngle = startAngle,
214-
sweepAngle = progressAngle,
215-
useCenter = false,
216-
topLeft = topLeft,
217-
size = arcSize,
218-
style = Stroke(width = strokeWidth, cap = StrokeCap.Round)
219-
)
220-
}
221-
}
222-
223-
224-
private fun DrawScope.drawArcSliderOuterCircle(
225-
workoutsCompleted: Int,
226-
workoutGoal: Int,
227-
gradientBrush: Brush,
228-
dotRadius: Float,
229-
x: Float,
230-
y: Float
231-
) {
232-
when (workoutsCompleted) {
233-
workoutGoal -> {
234-
drawCircle(
235-
brush = gradientBrush,
236-
radius = dotRadius,
237-
center = Offset(x, y)
238-
)
239-
}
240-
241-
0 -> {
242-
drawCircle(
243-
color = GRAY03,
244-
radius = dotRadius,
245-
center = Offset(x, y)
246-
)
247-
}
248-
249-
else -> {
250-
drawCircle(
251-
color = PRIMARY_YELLOW,
252-
radius = dotRadius,
253-
center = Offset(x, y)
254-
)
255-
}
256-
}
257-
}
258-
259189
@Composable
260190
private fun WorkoutFractionTextSection(workoutsCompleted: Int, workoutGoal: Int, isComplete: Boolean) {
261191
Column(

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,13 @@ private fun ProfileScreenContentPreview() {
176176
uiState = ProfileUiState(
177177
name = "Melissa Velasquez",
178178
netId = "mv477",
179-
totalGymDays = 42,
180-
activeStreak = 5,
179+
totalGymDays = 0,
180+
activeStreak = 0,
181181
workoutGoal = 4,
182-
historyItems = listOf(
183-
HistoryItem(
184-
gymName = "Teagle",
185-
time = "10:00 AM",
186-
date = "March 29, 2024",
187-
timestamp = 0L
188-
)
189-
),
182+
historyItems = emptyList(),
190183
daysOfMonth = listOf(10, 11, 12, 13, 14, 15, 16),
191-
completedDays = listOf(true, false, true, false, true, false, false),
192-
workoutsCompleted = 3
184+
completedDays = listOf(false, false, false, false, false, false, false),
185+
workoutsCompleted = 0
193186
),
194187
{},
195188
{},

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.cornellappdev.uplift.ui.UpliftRootRoute
1010
import com.cornellappdev.uplift.ui.components.profile.workouts.HistoryItem
1111
import com.cornellappdev.uplift.ui.nav.RootNavigationRepository
1212
import com.cornellappdev.uplift.ui.viewmodels.UpliftViewModel
13+
import com.cornellappdev.uplift.util.timeAgoString
1314
import dagger.hilt.android.lifecycle.HiltViewModel
1415
import kotlinx.coroutines.Job
1516
import kotlinx.coroutines.launch
@@ -69,15 +70,17 @@ class ProfileViewModel @Inject constructor(
6970
return@launch
7071
}
7172
val historyItems = profile.workouts.map {
73+
val workoutInstant = Instant.ofEpochMilli(it.timestamp)
74+
val calendar = java.util.Calendar.getInstance().apply {
75+
timeInMillis = it.timestamp
76+
}
7277
HistoryItem(
7378
gymName = it.gymName,
74-
time = formatTime.format(
75-
Instant.ofEpochMilli(it.timestamp)
76-
),
77-
date = formatDate.format(
78-
Instant.ofEpochMilli(it.timestamp)
79-
),
80-
timestamp = it.timestamp
79+
time = formatTime.format(workoutInstant),
80+
date = formatDate.format(workoutInstant),
81+
timestamp = it.timestamp,
82+
dayOfWeek = formatDayOfWeek.format(workoutInstant),
83+
ago = calendar.timeAgoString()
8184
)
8285
}
8386

@@ -149,4 +152,10 @@ class ProfileViewModel @Inject constructor(
149152
.ofPattern("MMMM d, yyyy")
150153
.withLocale(Locale.US)
151154
.withZone(ZoneId.systemDefault())
152-
}
155+
156+
private val formatDayOfWeek = DateTimeFormatter
157+
.ofPattern("EEE")
158+
.withLocale(Locale.US)
159+
.withZone(ZoneId.systemDefault())
160+
}
161+

0 commit comments

Comments
 (0)