Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import com.cornellappdev.uplift.ui.screens.onboarding.ProfileCreationScreen
import com.cornellappdev.uplift.ui.screens.onboarding.SignInPromptScreen
import com.cornellappdev.uplift.ui.screens.profile.ProfileScreen
import com.cornellappdev.uplift.ui.screens.profile.SettingsScreen
import com.cornellappdev.uplift.ui.screens.profile.WorkoutHistoryScreen
import com.cornellappdev.uplift.ui.screens.reminders.CapacityReminderScreen
import com.cornellappdev.uplift.ui.screens.reminders.MainReminderScreen
import com.cornellappdev.uplift.ui.screens.onboarding.WorkoutReminderOnboardingScreen
Expand Down Expand Up @@ -265,6 +266,11 @@ fun MainNavigationWrapper(
composable<UpliftRootRoute.Settings> {
SettingsScreen()
}
composable<UpliftRootRoute.WorkoutHistory> {
WorkoutHistoryScreen(
onBack = { navController.popBackStack() }
)
}
composable<UpliftRootRoute.Sports> {}
composable<UpliftRootRoute.Favorites> {}
}
Expand Down Expand Up @@ -363,4 +369,7 @@ sealed class UpliftRootRoute {

@Serializable
data object Settings : UpliftRootRoute()

@Serializable
data object WorkoutHistory : UpliftRootRoute()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.cornellappdev.uplift.ui.components.general

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material.TabRowDefaults.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.TabRowDefaults.SecondaryIndicator
Expand All @@ -11,8 +17,10 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -24,7 +32,12 @@ import com.cornellappdev.uplift.util.PRIMARY_YELLOW
import com.cornellappdev.uplift.util.montserratFamily

@Composable
fun UpliftTabRow(tabIndex: Int, tabs: List<String>, onTabChange: (Int) -> Unit = {}) {
fun UpliftTabRow(
tabIndex: Int,
tabs: List<String>,
icons: List<Int>? = null,
onTabChange: (Int) -> Unit = {}
) {
TabRow(
selectedTabIndex = tabIndex,
containerColor = Color.White,
Expand All @@ -43,19 +56,35 @@ fun UpliftTabRow(tabIndex: Int, tabs: List<String>, onTabChange: (Int) -> Unit =
}
) {
tabs.forEachIndexed { index, title ->
val isSelected = tabIndex == index
val color = if (isSelected) PRIMARY_BLACK else GRAY04
Tab(
text = {
Text(
text = title,
color = if (tabIndex == index) PRIMARY_BLACK else GRAY04,
fontFamily = montserratFamily,
fontSize = 12.sp,
fontWeight = FontWeight.Bold
)
},
selected = tabIndex == index,
selected = isSelected,
onClick = { onTabChange(index) },
selectedContentColor = GRAY01,
text = {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
if (icons != null && index < icons.size) {
Icon(
painter = painterResource(id = icons[index]),
contentDescription = null,
tint = color,
modifier = Modifier.size(16.dp)
)
Spacer(modifier = Modifier.width(16.dp))
}
Text(
text = title,
color = color,
fontFamily = montserratFamily,
fontSize = 12.sp,
fontWeight = FontWeight.Bold
)
}
}
)
}
}
Expand All @@ -72,4 +101,4 @@ private fun UpliftTabRowPreview() {
tabIndex = it
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.cornellappdev.uplift.ui.components.profile.workouts

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -18,7 +17,6 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.focusModifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -28,16 +26,17 @@ import androidx.compose.ui.unit.sp
import com.cornellappdev.uplift.R
import com.cornellappdev.uplift.ui.components.profile.SectionTitleText
import com.cornellappdev.uplift.util.GRAY01
import com.cornellappdev.uplift.util.GRAY04
import com.cornellappdev.uplift.util.PRIMARY_BLACK
import com.cornellappdev.uplift.util.montserratFamily
import com.cornellappdev.uplift.util.timeAgoString
import java.util.Calendar

data class HistoryItem(
val gymName: String,
val time: String,
val date: String,
val timestamp: Long,
val ago: String
val ago: String,
val shortDate: String
)

@Composable
Expand Down Expand Up @@ -68,22 +67,22 @@ fun HistorySection(
}

@Composable
private fun HistoryList(
fun HistoryList(
historyItems: List<HistoryItem>,
modifier: Modifier = Modifier
) {
Column(modifier = modifier) {
historyItems.take(5).forEachIndexed { index, historyItem ->
HistoryItemRow(historyItem = historyItem)
if (index != historyItems.size - 1) {
HorizontalDivider(color = GRAY01)
HorizontalDivider(color = GRAY01, thickness = 1.dp)
}
Comment on lines 75 to 79
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Divider condition uses the wrong collection length.

Line 76 compares against historyItems.size - 1, but rendering is over historyItems.take(5). When there are more than 5 items, this adds a trailing divider after the last visible row.

Proposed fix
 fun HistoryList(
     historyItems: List<HistoryItem>,
     modifier: Modifier = Modifier
 ) {
     Column(modifier = modifier) {
-        historyItems.take(5).forEachIndexed { index, historyItem ->
+        val visibleItems = historyItems.take(5)
+        visibleItems.forEachIndexed { index, historyItem ->
             HistoryItemRow(historyItem = historyItem)
-            if (index != historyItems.size - 1) {
+            if (index != visibleItems.lastIndex) {
                 HorizontalDivider(color = GRAY01, thickness = 1.dp)
             }
         }
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/cornellappdev/uplift/ui/components/profile/workouts/HistorySection.kt`
around lines 74 - 78, The divider condition is comparing against the full
historyItems list instead of the visible subset; fix by materializing the
displayed list (e.g., val visibleItems = historyItems.take(5)) and iterate over
visibleItems.forEachIndexed { index, historyItem -> ... } then use index !=
visibleItems.size - 1 (or index != visibleItems.lastIndex) when deciding to
render HorizontalDivider in HistorySection (affecting the
HistoryItemRow/HorizontalDivider rendering logic).

}
}
}

@Composable
private fun HistoryItemRow(
fun HistoryItemRow(
historyItem: HistoryItem
) {
val gymName = historyItem.gymName
Expand All @@ -94,23 +93,28 @@ private fun HistoryItemRow(
Row(
modifier = Modifier
.fillMaxWidth()
.height(60.dp)
.padding(vertical = 12.dp),
horizontalArrangement = Arrangement.SpaceBetween
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.Bottom
) {
Column(){
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(4.dp)
){
Text(
text = gymName,
fontFamily = montserratFamily,
fontSize = 14.sp,
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
color = Color.Black
color = PRIMARY_BLACK
)
Text(
text = "$date · $time",
fontFamily = montserratFamily,
fontSize = 12.sp,
fontWeight = FontWeight.Light,
color = Color.Gray
fontWeight = FontWeight.Medium,
color = GRAY04
)
}
Text(
Expand All @@ -124,7 +128,7 @@ private fun HistoryItemRow(
}

@Composable
private fun EmptyHistorySection(){
fun EmptyHistorySection(){
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
Expand Down Expand Up @@ -161,11 +165,11 @@ private fun EmptyHistorySection(){
private fun HistorySectionPreview() {
val now = System.currentTimeMillis()
val historyItems = listOf(
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now - (1 * 24 * 60 * 60 * 1000), "1 day ago"),
HistoryItem("Noyes", "1:00 PM", "March 29, 2024", now - (3 * 24 * 60 * 60 * 1000), "2 days ago"),
HistoryItem("Teagle Up", "2:00 PM", "March 29, 2024", now - (7 * 24 * 60 * 60 * 1000), "1 day ago"),
HistoryItem("Teagle Down", "12:00 PM", "March 29, 2024", now - (15 * 24 * 60 * 60 * 1000), "1 day ago"),
HistoryItem("Helen Newman", "10:00 AM", "March 29, 2024", now, "Today"),
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now - (1 * 24 * 60 * 60 * 1000), "1 day ago", "Mar 28"),
HistoryItem("Noyes", "1:00 PM", "March 29, 2024", now - (3 * 24 * 60 * 60 * 1000), "2 days ago", "Mar 26"),
HistoryItem("Teagle Up", "2:00 PM", "March 29, 2024", now - (7 * 24 * 60 * 60 * 1000), "1 week ago", "Mar 22"),
HistoryItem("Teagle Down", "12:00 PM", "March 29, 2024", now - (15 * 24 * 60 * 60 * 1000), "2 weeks ago", "Mar 14"),
HistoryItem("Helen Newman", "10:00 AM", "March 29, 2024", now, "Today", "Mar 29"),
)
Column(
modifier = Modifier
Expand All @@ -178,4 +182,4 @@ private fun HistorySectionPreview() {
)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ private fun ProfileScreenTopBar(
private fun ProfileScreenContentPreview() {
val now = System.currentTimeMillis()
val historyItems = listOf(
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now - (1 * 24 * 60 * 60 * 1000), "1 day ago"),
HistoryItem("Noyes", "1:00 PM", "March 29, 2024", now - (3 * 24 * 60 * 60 * 1000), "2 days ago"),
HistoryItem("Teagle Up", "2:00 PM", "March 29, 2024", now - (7 * 24 * 60 * 60 * 1000), "1 day ago"),
HistoryItem("Teagle Down", "12:00 PM", "March 29, 2024", now - (15 * 24 * 60 * 60 * 1000), "1 day ago"),
HistoryItem("Helen Newman", "10:00 AM", "March 29, 2024", now, "Today"),
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now, "Today", "Mar 29"),
HistoryItem("Noyes", "1:00 PM", "March 28, 2024", now - 86400000L, "Yesterday", "Mar 28"),
HistoryItem("Teagle Up", "2:00 PM", "February 15, 2024", now - 4000000000L, "1 month ago", "Feb 15"),
HistoryItem("Helen Newman", "9:30 AM", "February 10, 2024", now - 4430000000L, "1 month ago", "Feb 10"),
HistoryItem("Morrison", "6:45 PM", "February 3, 2024", now - 5030000000L, "1 month ago", "Feb 3")
)
Comment on lines 172 to 178
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Preview shortDate strings diverge from the runtime formatter.

The preview uses "Mar 29", "Feb 15", etc. (pattern MMM d), but ProfileViewModel.shortDateFormatter is defined with pattern "MMM, d", so the actual UI will render "Mar, 29". Root cause and fix are discussed on ProfileViewModel.kt lines 202-205.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/main/java/com/cornellappdev/uplift/ui/screens/profile/ProfileScreen.kt`
around lines 172 - 178, Preview shortDate values in the HistoryItem list don't
match the runtime formatter; either change ProfileViewModel.shortDateFormatter
or update the preview entries in ProfileScreen's historyItems to match the same
pattern. Locate ProfileViewModel.shortDateFormatter and the HistoryItem(...)
initializers in ProfileScreen.kt and make the formats consistent (e.g., if the
formatter is "MMM, d" update preview strings from "Mar 29" to "Mar, 29", or
change the formatter to "MMM d" to match the existing preview).

ProfileScreenContent(
uiState = ProfileUiState(
Expand Down
Loading
Loading