Skip to content
Open
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,9 +26,9 @@ 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,
Expand Down Expand Up @@ -68,22 +66,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 74 to 78
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 +92,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 +127,7 @@ private fun HistoryItemRow(
}

@Composable
private fun EmptyHistorySection(){
fun EmptyHistorySection(){
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
Expand Down Expand Up @@ -178,4 +181,4 @@ private fun HistorySectionPreview() {
)
}

}
}
Loading
Loading