Skip to content

Implemented UI for workout history page#108

Open
melissavelasquezz wants to merge 1 commit intomainfrom
melissa/history-page-ui
Open

Implemented UI for workout history page#108
melissavelasquezz wants to merge 1 commit intomainfrom
melissa/history-page-ui

Conversation

@melissavelasquezz
Copy link
Copy Markdown
Contributor

@melissavelasquezz melissavelasquezz commented Apr 10, 2026

Overview

Implemented the Workout History Page UI according to figma designs.

Changes Made

Implemented Calendar and List tab views of workout history.
Added nav from profile page to workout history page.

Next Steps

Build the workout history viewmodel and implement the drop down info functionality on days where a workout is logged according to designs.
Finish nav and networking.
Test once real workouts are logged.

Screenshots

Workout History UI Preview
WorkoutHistoryUiPreview.mp4

Summary by CodeRabbit

  • New Features
    • Added Workout History screen with Calendar and List view modes for viewing past workouts
    • Navigate between months in Calendar view with visual indicators for workout days
    • View past workouts organized by month/year in List view
    • Tab-based switching between Calendar and List presentation modes

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

Introduces a new Workout History screen featuring calendar and list view modes to display user workout history. Updates navigation routing, enhances UI components with icon support, and adds supporting drawable resources for tabs and month navigation controls.

Changes

Cohort / File(s) Summary
Navigation & ViewModel
app/src/main/java/com/cornellappdev/uplift/ui/MainNavigationWrapper.kt, app/src/main/java/com/cornellappdev/uplift/ui/viewmodels/profile/ProfileViewModel.kt
Added WorkoutHistory route to navigation sealed class; implemented navigation call in toHistory() method to trigger route navigation.
Workout History Screen
app/src/main/java/com/cornellappdev/uplift/ui/screens/profile/WorkoutHistoryScreen.kt
New composable screen with tab-based switching between calendar and list views for displaying workout history, includes header with back action and empty state handling.
UI Components
app/src/main/java/com/cornellappdev/uplift/ui/components/general/UpliftTabRow.kt, app/src/main/java/com/cornellappdev/uplift/ui/components/profile/workouts/HistorySection.kt
Enhanced UpliftTabRow to support optional icon parameters; refactored HistorySection composables to public visibility, updated styling (colors, spacing, dividers) and layout alignment.
Drawable Resources
app/src/main/res/drawable/ic_advance_month.xml, app/src/main/res/drawable/ic_back_month.xml, app/src/main/res/drawable/ic_calendar_tab.xml, app/src/main/res/drawable/ic_list_tab.xml
Added four new vector drawable icons for calendar month navigation controls and tab indicators.

Sequence Diagram

sequenceDiagram
    participant User
    participant ProfileViewModel as ProfileViewModel
    participant NavigationRepository as NavigationRepository
    participant WorkoutHistoryScreen as WorkoutHistoryScreen
    participant UpliftTabRow as UpliftTabRow
    participant Views as Calendar/<br/>List Views

    User->>ProfileViewModel: Triggers toHistory()
    ProfileViewModel->>NavigationRepository: navigate(WorkoutHistory)
    NavigationRepository->>WorkoutHistoryScreen: Render Screen
    WorkoutHistoryScreen->>WorkoutHistoryScreen: Collect ProfileUiState
    WorkoutHistoryScreen->>UpliftTabRow: Initialize with Calendar/List tabs
    User->>UpliftTabRow: Select view mode
    UpliftTabRow->>Views: Render selected view (Calendar or List)
    Views->>Views: Display workout history
    User->>WorkoutHistoryScreen: Click back header
    WorkoutHistoryScreen->>User: Navigate back via onBack()
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A calendar blooms with workouts tracked,
Two views now dance—the list intact!
Month by month, the history gleams,
Tab-switched tabs fulfill fitness dreams.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change—implementing the UI for a workout history page—which aligns with the primary objective of the changeset.
Description check ✅ Passed The description includes Overview, Changes Made, and Next Steps sections as required by the template; it provides sufficient detail about the feature implementation and planned follow-up work.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch melissa/history-page-ui

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
app/src/main/java/com/cornellappdev/uplift/ui/screens/profile/WorkoutHistoryScreen.kt (2)

135-141: Sort history before grouping to keep month sections and rows deterministic.

groupBy preserves encounter order, so unsorted input can produce unstable month ordering and item ordering in the list.

Proposed refactor
-    val groupedItems = remember(historyItems) {
-        historyItems.groupBy {
+    val groupedItems = remember(historyItems) {
+        historyItems
+            .sortedByDescending { it.timestamp }
+            .groupBy {
             val date = Instant.ofEpochMilli(it.timestamp)
                 .atZone(ZoneId.systemDefault())
                 .toLocalDate()
             date.format(DateTimeFormatter.ofPattern("MMMM yyyy", Locale.US))
         }
     }

Also applies to: 151-169

🤖 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/WorkoutHistoryScreen.kt`
around lines 135 - 141, The month grouping logic in WorkoutHistoryScreen uses
historyItems.groupBy which preserves input order, causing non-deterministic
month and row ordering; sort historyItems by timestamp before grouping (e.g.,
replace uses of historyItems.groupBy in the groupedItems calculation and the
other grouping at the later block with historyItems.sortedBy { it.timestamp
}.groupBy { /* same date logic */ }) so both groupedItems and the other grouping
produce stable, deterministic month sections and item order.

85-86: Localize UI strings and date formatting instead of hardcoding English/US values.

This screen currently hardcodes user-facing labels and forces U.S. month formatting, which will render incorrectly for non-English locales.

Also applies to: 122-122, 140-140, 207-207, 235-235

🤖 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/WorkoutHistoryScreen.kt`
around lines 85 - 86, Replace hardcoded UI labels and US-only date formatting
with localized resources and locale-aware formatters: swap the inline strings in
the tabs list (currently "Calendar", "List") for string resources (e.g.,
R.string.calendar, R.string.list) and use those resource IDs wherever
user-facing text is hardcoded (also at the other affected spots). Replace any
DateTimeFormatter or SimpleDateFormat instances forced to Locale.US with a
locale-aware formatter (e.g., DateTimeFormatter.ofLocalizedDate(...) or
android.text.format.DateFormat.getDateFormat(context) /
DateFormat.getMediumDateInstance(Locale.getDefault())) so month and date order
follow the device locale; ensure the code paths that build labels (the same
places referenced by tabs/icons and the other mentioned lines) read context
resources and Locale.getDefault() rather than hardcoded English/US values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@app/src/main/java/com/cornellappdev/uplift/ui/components/profile/workouts/HistorySection.kt`:
- Around line 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).

In
`@app/src/main/java/com/cornellappdev/uplift/ui/screens/profile/WorkoutHistoryScreen.kt`:
- Around line 116-118: The tap targets for the navigation icons in
WorkoutHistoryScreen are too small (currently using Modifier.size(24.dp) or 16dp
for previous/next month controls); update each icon container (the modifiers
that call .clickable { ... } — e.g., the back action using onBack() and the
previous/next month actions) to use a 48.dp touch target (e.g.,
Modifier.size(48.dp).clickable { ... }) while keeping the visual Icon content at
24.dp so the visual size stays the same but accessibility/tap area is increased.

---

Nitpick comments:
In
`@app/src/main/java/com/cornellappdev/uplift/ui/screens/profile/WorkoutHistoryScreen.kt`:
- Around line 135-141: The month grouping logic in WorkoutHistoryScreen uses
historyItems.groupBy which preserves input order, causing non-deterministic
month and row ordering; sort historyItems by timestamp before grouping (e.g.,
replace uses of historyItems.groupBy in the groupedItems calculation and the
other grouping at the later block with historyItems.sortedBy { it.timestamp
}.groupBy { /* same date logic */ }) so both groupedItems and the other grouping
produce stable, deterministic month sections and item order.
- Around line 85-86: Replace hardcoded UI labels and US-only date formatting
with localized resources and locale-aware formatters: swap the inline strings in
the tabs list (currently "Calendar", "List") for string resources (e.g.,
R.string.calendar, R.string.list) and use those resource IDs wherever
user-facing text is hardcoded (also at the other affected spots). Replace any
DateTimeFormatter or SimpleDateFormat instances forced to Locale.US with a
locale-aware formatter (e.g., DateTimeFormatter.ofLocalizedDate(...) or
android.text.format.DateFormat.getDateFormat(context) /
DateFormat.getMediumDateInstance(Locale.getDefault())) so month and date order
follow the device locale; ensure the code paths that build labels (the same
places referenced by tabs/icons and the other mentioned lines) read context
resources and Locale.getDefault() rather than hardcoded English/US values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3da717f9-8788-4c45-ab99-7d970f2a0692

📥 Commits

Reviewing files that changed from the base of the PR and between 4e81463 and 7310469.

📒 Files selected for processing (9)
  • app/src/main/java/com/cornellappdev/uplift/ui/MainNavigationWrapper.kt
  • app/src/main/java/com/cornellappdev/uplift/ui/components/general/UpliftTabRow.kt
  • app/src/main/java/com/cornellappdev/uplift/ui/components/profile/workouts/HistorySection.kt
  • app/src/main/java/com/cornellappdev/uplift/ui/screens/profile/WorkoutHistoryScreen.kt
  • app/src/main/java/com/cornellappdev/uplift/ui/viewmodels/profile/ProfileViewModel.kt
  • app/src/main/res/drawable/ic_advance_month.xml
  • app/src/main/res/drawable/ic_back_month.xml
  • app/src/main/res/drawable/ic_calendar_tab.xml
  • app/src/main/res/drawable/ic_list_tab.xml

Comment on lines 74 to 78
historyItems.take(5).forEachIndexed { index, historyItem ->
HistoryItemRow(historyItem = historyItem)
if (index != historyItems.size - 1) {
HorizontalDivider(color = GRAY01)
HorizontalDivider(color = GRAY01, thickness = 1.dp)
}
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).

Comment on lines +116 to +118
modifier = Modifier
.size(24.dp)
.clickable { onBack() },
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 | 🟠 Major

Increase tap targets for icon actions to improve accessibility.

Back/month navigation actions are attached to 24dp/16dp icons, which are hard to tap reliably.

Proposed fix
-        Icon(
-            painter = painterResource(id = R.drawable.ic_back_arrow),
-            contentDescription = "Back",
-            modifier = Modifier
-                .size(24.dp)
-                .clickable { onBack() },
-            tint = PRIMARY_BLACK
-        )
+        Box(
+            modifier = Modifier
+                .size(48.dp)
+                .clickable { onBack() },
+            contentAlignment = Alignment.Center
+        ) {
+            Icon(
+                painter = painterResource(id = R.drawable.ic_back_arrow),
+                contentDescription = "Back",
+                modifier = Modifier.size(24.dp),
+                tint = PRIMARY_BLACK
+            )
+        }

Apply the same 48dp touch-target pattern to previous/next month controls.

Also applies to: 200-203, 219-222

🤖 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/WorkoutHistoryScreen.kt`
around lines 116 - 118, The tap targets for the navigation icons in
WorkoutHistoryScreen are too small (currently using Modifier.size(24.dp) or 16dp
for previous/next month controls); update each icon container (the modifiers
that call .clickable { ... } — e.g., the back action using onBack() and the
previous/next month actions) to use a 48.dp touch target (e.g.,
Modifier.size(48.dp).clickable { ... }) while keeping the visual Icon content at
24.dp so the visual size stays the same but accessibility/tap area is increased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant