@@ -2,10 +2,14 @@ package com.cornellappdev.uplift.ui.screens.profile
22
33import androidx.compose.animation.AnimatedContent
44import androidx.compose.animation.AnimatedVisibility
5+ import androidx.compose.animation.animateContentSize
6+ import androidx.compose.animation.core.FastOutSlowInEasing
7+ import androidx.compose.animation.core.tween
58import androidx.compose.animation.expandVertically
69import androidx.compose.animation.fadeIn
710import androidx.compose.animation.fadeOut
811import androidx.compose.animation.shrinkVertically
12+ import androidx.compose.animation.togetherWith
913import androidx.compose.foundation.background
1014import androidx.compose.foundation.border
1115import androidx.compose.foundation.clickable
@@ -332,7 +336,6 @@ private fun WorkoutHistoryCalendarView(workoutDates: Map<LocalDate,List<HistoryI
332336 if (date != null ) {
333337 val hasWorkout = workoutDates.containsKey(date)
334338 val isToday = date == LocalDate .now()
335- val isSelected = selectedDate == date
336339
337340 CalendarDayCell (
338341 day = date.dayOfMonth.toString(),
@@ -352,26 +355,40 @@ private fun WorkoutHistoryCalendarView(workoutDates: Map<LocalDate,List<HistoryI
352355 // Dropdown
353356 val selectedInThisWeek = week.find { it == selectedDate }
354357
355- AnimatedVisibility (
356- visible = selectedInThisWeek != null ,
357- enter = fadeIn() + expandVertically(),
358- exit = fadeOut() + shrinkVertically( )
358+ Column (
359+ modifier = Modifier .animateContentSize(
360+ animationSpec = tween( 450 )
361+ )
359362 ) {
360- selectedInThisWeek?.let { selected ->
361- val workouts = workoutDates[selected] ? : emptyList()
362- val dayOfWeekIndex = week.indexOf(selected)
363-
364- Column {
365- Spacer (modifier = Modifier .height(12 .dp))
366- workouts.forEach { workout ->
367- WorkoutCalendarDropdown (
368- historyItem = workout,
369- dayOfWeekIndex = dayOfWeekIndex
370- )
363+ AnimatedVisibility (
364+ visible = selectedInThisWeek != null ,
365+ enter = fadeIn(tween(300 )) + expandVertically(
366+ expandFrom = Alignment .Top ,
367+ animationSpec = tween(350 )
368+ ),
369+ exit = fadeOut(tween(800 )) + shrinkVertically(
370+ shrinkTowards = Alignment .Top ,
371+ animationSpec = tween(700 )
372+ )
373+ ) {
374+ selectedInThisWeek?.let { selected ->
375+ val workouts = workoutDates[selected] ? : emptyList()
376+ val dayOfWeekIndex = week.indexOf(selected)
377+
378+ Column {
379+ Spacer (modifier = Modifier .height(12 .dp))
380+
381+ workouts.forEach { workout ->
382+ WorkoutCalendarDropdown (
383+ historyItem = workout,
384+ dayOfWeekIndex = dayOfWeekIndex
385+ )
386+ }
371387 }
372388 }
373389 }
374390 }
391+
375392 }
376393 }
377394 }
@@ -380,7 +397,7 @@ private fun WorkoutHistoryCalendarView(workoutDates: Map<LocalDate,List<HistoryI
380397}
381398
382399
383- @Composable
400+ @Composable
384401private fun WorkoutCalendarDropdown (
385402 historyItem : HistoryItem ,
386403 dayOfWeekIndex : Int
@@ -476,14 +493,9 @@ private fun WorkoutCalendarDropdown(
476493 .background(GRAY04 , CircleShape )
477494 )
478495 Spacer (modifier = Modifier .width(4 .dp))
479- val shortDate = remember(historyItem.timestamp) {
480- Instant .ofEpochMilli(historyItem.timestamp)
481- .atZone(ZoneId .systemDefault())
482- .toLocalDate()
483- .format(DateTimeFormatter .ofPattern(" MMM d" , Locale .US ))
484- }
496+
485497 Text (
486- text = shortDate,
498+ text = historyItem. shortDate,
487499 fontFamily = montserratFamily,
488500 fontSize = 12 .sp,
489501 fontWeight = FontWeight .Medium ,
@@ -553,11 +565,11 @@ private fun CalendarDayCell(
553565private fun WorkoutHistoryScreenPreview () {
554566 val now = System .currentTimeMillis()
555567 val historyItems = listOf (
556- HistoryItem (" Morrison" , " 11:00 PM" , " March 29, 2024" , now, " Today" ),
557- HistoryItem (" Noyes" , " 1:00 PM" , " March 28, 2024" , now - 86400000L , " Yesterday" ),
558- HistoryItem (" Teagle Up" , " 2:00 PM" , " February 15, 2024" , now - 4000000000L , " 1 month ago" ),
559- HistoryItem (" Helen Newman" , " 9:30 AM" , " February 10, 2024" , now - 4430000000L , " 1 month ago" ),
560- HistoryItem (" Morrison" , " 6:45 PM" , " February 3, 2024" , now - 5030000000L , " 1 month ago" )
568+ HistoryItem (" Morrison" , " 11:00 PM" , " March 29, 2024" , now, " Today" , " Mar 29 " ),
569+ HistoryItem (" Noyes" , " 1:00 PM" , " March 28, 2024" , now - 86400000L , " Yesterday" , " Mar 28 " ),
570+ HistoryItem (" Teagle Up" , " 2:00 PM" , " February 15, 2024" , now - 4000000000L , " 1 month ago" , " Feb 15 " ),
571+ HistoryItem (" Helen Newman" , " 9:30 AM" , " February 10, 2024" , now - 4430000000L , " 1 month ago" , " Feb 10 " ),
572+ HistoryItem (" Morrison" , " 6:45 PM" , " February 3, 2024" , now - 5030000000L , " 1 month ago" , " Feb 3 " )
561573 )
562574
563575 val listItems = buildList {
0 commit comments