Skip to content

Commit 6ec2e24

Browse files
Merge pull request #108 from cuappdev/melissa/history-page
Implemented workout history page
2 parents 338cee3 + 697dd2c commit 6ec2e24

10 files changed

Lines changed: 799 additions & 45 deletions

File tree

app/src/main/java/com/cornellappdev/uplift/ui/MainNavigationWrapper.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import com.cornellappdev.uplift.ui.screens.onboarding.ProfileCreationScreen
4747
import com.cornellappdev.uplift.ui.screens.onboarding.SignInPromptScreen
4848
import com.cornellappdev.uplift.ui.screens.profile.ProfileScreen
4949
import com.cornellappdev.uplift.ui.screens.profile.SettingsScreen
50+
import com.cornellappdev.uplift.ui.screens.profile.WorkoutHistoryScreen
5051
import com.cornellappdev.uplift.ui.screens.reminders.CapacityReminderScreen
5152
import com.cornellappdev.uplift.ui.screens.reminders.MainReminderScreen
5253
import com.cornellappdev.uplift.ui.screens.onboarding.WorkoutReminderOnboardingScreen
@@ -265,6 +266,11 @@ fun MainNavigationWrapper(
265266
composable<UpliftRootRoute.Settings> {
266267
SettingsScreen()
267268
}
269+
composable<UpliftRootRoute.WorkoutHistory> {
270+
WorkoutHistoryScreen(
271+
onBack = { navController.popBackStack() }
272+
)
273+
}
268274
composable<UpliftRootRoute.Sports> {}
269275
composable<UpliftRootRoute.Favorites> {}
270276
}
@@ -363,4 +369,7 @@ sealed class UpliftRootRoute {
363369

364370
@Serializable
365371
data object Settings : UpliftRootRoute()
372+
373+
@Serializable
374+
data object WorkoutHistory : UpliftRootRoute()
366375
}

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

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package com.cornellappdev.uplift.ui.components.general
22

3+
import androidx.compose.foundation.layout.Arrangement
4+
import androidx.compose.foundation.layout.Row
5+
import androidx.compose.foundation.layout.Spacer
6+
import androidx.compose.foundation.layout.size
7+
import androidx.compose.foundation.layout.width
38
import androidx.compose.material.TabRowDefaults.Divider
9+
import androidx.compose.material3.Icon
410
import androidx.compose.material3.Tab
511
import androidx.compose.material3.TabRow
612
import androidx.compose.material3.TabRowDefaults.SecondaryIndicator
@@ -11,8 +17,10 @@ import androidx.compose.runtime.getValue
1117
import androidx.compose.runtime.mutableStateOf
1218
import androidx.compose.runtime.remember
1319
import androidx.compose.runtime.setValue
20+
import androidx.compose.ui.Alignment
1421
import androidx.compose.ui.Modifier
1522
import androidx.compose.ui.graphics.Color
23+
import androidx.compose.ui.res.painterResource
1624
import androidx.compose.ui.text.font.FontWeight
1725
import androidx.compose.ui.tooling.preview.Preview
1826
import androidx.compose.ui.unit.dp
@@ -24,7 +32,12 @@ import com.cornellappdev.uplift.util.PRIMARY_YELLOW
2432
import com.cornellappdev.uplift.util.montserratFamily
2533

2634
@Composable
27-
fun UpliftTabRow(tabIndex: Int, tabs: List<String>, onTabChange: (Int) -> Unit = {}) {
35+
fun UpliftTabRow(
36+
tabIndex: Int,
37+
tabs: List<String>,
38+
icons: List<Int>? = null,
39+
onTabChange: (Int) -> Unit = {}
40+
) {
2841
TabRow(
2942
selectedTabIndex = tabIndex,
3043
containerColor = Color.White,
@@ -43,19 +56,35 @@ fun UpliftTabRow(tabIndex: Int, tabs: List<String>, onTabChange: (Int) -> Unit =
4356
}
4457
) {
4558
tabs.forEachIndexed { index, title ->
59+
val isSelected = tabIndex == index
60+
val color = if (isSelected) PRIMARY_BLACK else GRAY04
4661
Tab(
47-
text = {
48-
Text(
49-
text = title,
50-
color = if (tabIndex == index) PRIMARY_BLACK else GRAY04,
51-
fontFamily = montserratFamily,
52-
fontSize = 12.sp,
53-
fontWeight = FontWeight.Bold
54-
)
55-
},
56-
selected = tabIndex == index,
62+
selected = isSelected,
5763
onClick = { onTabChange(index) },
5864
selectedContentColor = GRAY01,
65+
text = {
66+
Row(
67+
verticalAlignment = Alignment.CenterVertically,
68+
horizontalArrangement = Arrangement.Center
69+
) {
70+
if (icons != null && index < icons.size) {
71+
Icon(
72+
painter = painterResource(id = icons[index]),
73+
contentDescription = null,
74+
tint = color,
75+
modifier = Modifier.size(16.dp)
76+
)
77+
Spacer(modifier = Modifier.width(16.dp))
78+
}
79+
Text(
80+
text = title,
81+
color = color,
82+
fontFamily = montserratFamily,
83+
fontSize = 12.sp,
84+
fontWeight = FontWeight.Bold
85+
)
86+
}
87+
}
5988
)
6089
}
6190
}
@@ -72,4 +101,4 @@ private fun UpliftTabRowPreview() {
72101
tabIndex = it
73102
}
74103
)
75-
}
104+
}

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

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.cornellappdev.uplift.ui.components.profile.workouts
22

33
import androidx.compose.foundation.Image
44
import androidx.compose.foundation.layout.Arrangement
5-
import androidx.compose.foundation.layout.Box
65
import androidx.compose.foundation.layout.Column
76
import androidx.compose.foundation.layout.Row
87
import androidx.compose.foundation.layout.Spacer
@@ -18,7 +17,6 @@ import androidx.compose.material3.Text
1817
import androidx.compose.runtime.Composable
1918
import androidx.compose.ui.Alignment
2019
import androidx.compose.ui.Modifier
21-
import androidx.compose.ui.focus.focusModifier
2220
import androidx.compose.ui.graphics.Color
2321
import androidx.compose.ui.res.painterResource
2422
import androidx.compose.ui.text.font.FontWeight
@@ -28,16 +26,17 @@ import androidx.compose.ui.unit.sp
2826
import com.cornellappdev.uplift.R
2927
import com.cornellappdev.uplift.ui.components.profile.SectionTitleText
3028
import com.cornellappdev.uplift.util.GRAY01
29+
import com.cornellappdev.uplift.util.GRAY04
30+
import com.cornellappdev.uplift.util.PRIMARY_BLACK
3131
import com.cornellappdev.uplift.util.montserratFamily
32-
import com.cornellappdev.uplift.util.timeAgoString
33-
import java.util.Calendar
3432

3533
data class HistoryItem(
3634
val gymName: String,
3735
val time: String,
3836
val date: String,
3937
val timestamp: Long,
40-
val ago: String
38+
val ago: String,
39+
val shortDate: String
4140
)
4241

4342
@Composable
@@ -68,22 +67,22 @@ fun HistorySection(
6867
}
6968

7069
@Composable
71-
private fun HistoryList(
70+
fun HistoryList(
7271
historyItems: List<HistoryItem>,
7372
modifier: Modifier = Modifier
7473
) {
7574
Column(modifier = modifier) {
7675
historyItems.take(5).forEachIndexed { index, historyItem ->
7776
HistoryItemRow(historyItem = historyItem)
7877
if (index != historyItems.size - 1) {
79-
HorizontalDivider(color = GRAY01)
78+
HorizontalDivider(color = GRAY01, thickness = 1.dp)
8079
}
8180
}
8281
}
8382
}
8483

8584
@Composable
86-
private fun HistoryItemRow(
85+
fun HistoryItemRow(
8786
historyItem: HistoryItem
8887
) {
8988
val gymName = historyItem.gymName
@@ -94,23 +93,28 @@ private fun HistoryItemRow(
9493
Row(
9594
modifier = Modifier
9695
.fillMaxWidth()
96+
.height(60.dp)
9797
.padding(vertical = 12.dp),
98-
horizontalArrangement = Arrangement.SpaceBetween
98+
horizontalArrangement = Arrangement.SpaceBetween,
99+
verticalAlignment = Alignment.Bottom
99100
) {
100-
Column(){
101+
Column(
102+
modifier = Modifier.weight(1f),
103+
verticalArrangement = Arrangement.spacedBy(4.dp)
104+
){
101105
Text(
102106
text = gymName,
103107
fontFamily = montserratFamily,
104-
fontSize = 14.sp,
108+
fontSize = 12.sp,
105109
fontWeight = FontWeight.Medium,
106-
color = Color.Black
110+
color = PRIMARY_BLACK
107111
)
108112
Text(
109113
text = "$date · $time",
110114
fontFamily = montserratFamily,
111115
fontSize = 12.sp,
112-
fontWeight = FontWeight.Light,
113-
color = Color.Gray
116+
fontWeight = FontWeight.Medium,
117+
color = GRAY04
114118
)
115119
}
116120
Text(
@@ -124,7 +128,7 @@ private fun HistoryItemRow(
124128
}
125129

126130
@Composable
127-
private fun EmptyHistorySection(){
131+
fun EmptyHistorySection(){
128132
Column(
129133
modifier = Modifier.fillMaxSize(),
130134
verticalArrangement = Arrangement.Center,
@@ -161,11 +165,11 @@ private fun EmptyHistorySection(){
161165
private fun HistorySectionPreview() {
162166
val now = System.currentTimeMillis()
163167
val historyItems = listOf(
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"),
168+
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now - (1 * 24 * 60 * 60 * 1000), "1 day ago", "Mar 28"),
169+
HistoryItem("Noyes", "1:00 PM", "March 29, 2024", now - (3 * 24 * 60 * 60 * 1000), "2 days ago", "Mar 26"),
170+
HistoryItem("Teagle Up", "2:00 PM", "March 29, 2024", now - (7 * 24 * 60 * 60 * 1000), "1 week ago", "Mar 22"),
171+
HistoryItem("Teagle Down", "12:00 PM", "March 29, 2024", now - (15 * 24 * 60 * 60 * 1000), "2 weeks ago", "Mar 14"),
172+
HistoryItem("Helen Newman", "10:00 AM", "March 29, 2024", now, "Today", "Mar 29"),
169173
)
170174
Column(
171175
modifier = Modifier
@@ -178,4 +182,4 @@ private fun HistorySectionPreview() {
178182
)
179183
}
180184

181-
}
185+
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ private fun ProfileScreenTopBar(
170170
private fun ProfileScreenContentPreview() {
171171
val now = System.currentTimeMillis()
172172
val historyItems = listOf(
173-
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now - (1 * 24 * 60 * 60 * 1000), "1 day ago"),
174-
HistoryItem("Noyes", "1:00 PM", "March 29, 2024", now - (3 * 24 * 60 * 60 * 1000), "2 days ago"),
175-
HistoryItem("Teagle Up", "2:00 PM", "March 29, 2024", now - (7 * 24 * 60 * 60 * 1000), "1 day ago"),
176-
HistoryItem("Teagle Down", "12:00 PM", "March 29, 2024", now - (15 * 24 * 60 * 60 * 1000), "1 day ago"),
177-
HistoryItem("Helen Newman", "10:00 AM", "March 29, 2024", now, "Today"),
173+
HistoryItem("Morrison", "11:00 PM", "March 29, 2024", now, "Today", "Mar 29"),
174+
HistoryItem("Noyes", "1:00 PM", "March 28, 2024", now - 86400000L, "Yesterday", "Mar 28"),
175+
HistoryItem("Teagle Up", "2:00 PM", "February 15, 2024", now - 4000000000L, "1 month ago", "Feb 15"),
176+
HistoryItem("Helen Newman", "9:30 AM", "February 10, 2024", now - 4430000000L, "1 month ago", "Feb 10"),
177+
HistoryItem("Morrison", "6:45 PM", "February 3, 2024", now - 5030000000L, "1 month ago", "Feb 3")
178178
)
179179
ProfileScreenContent(
180180
uiState = ProfileUiState(

0 commit comments

Comments
 (0)