diff --git a/modules/common-ui-components/src/main/java/com/ankitsuda/rebound/ui/components/SessionExerciseCardItem.kt b/modules/common-ui-components/src/main/java/com/ankitsuda/rebound/ui/components/SessionExerciseCardItem.kt index 889bdc5d..5cad2cd4 100644 --- a/modules/common-ui-components/src/main/java/com/ankitsuda/rebound/ui/components/SessionExerciseCardItem.kt +++ b/modules/common-ui-components/src/main/java/com/ankitsuda/rebound/ui/components/SessionExerciseCardItem.kt @@ -172,24 +172,22 @@ fun SessionExerciseSetItem( } RSpacer(16.dp) - // TODO: Move to strings.xml - Text(text = buildAnnotatedString { - withStyle(style = SpanStyle(ReboundTheme.colors.onBackground)) { - append(entry.weight.kgToUserPrefStr()) - } - withStyle(style = SpanStyle(ReboundTheme.colors.onBackground.copy(alpha = 0.65f))) { - append(" ${userPrefWeightUnitStr()}") - } - }) + SetColumnItem( + value = entry.weight.kgToUserPrefStr(), + title = userPrefWeightUnitStr() + ) RSpacer(20.dp) - Text(text = buildAnnotatedString { - withStyle(style = SpanStyle(ReboundTheme.colors.onBackground)) { - append((entry.reps ?: 0).toString()) - } - withStyle(style = SpanStyle(ReboundTheme.colors.onBackground.copy(alpha = 0.65f))) { - append(" reps") - } - }) + SetColumnItem( + value = (entry.reps ?: 0).toString(), + title = stringResource(id = R.string.reps_lowercase) + ) + entry.rpe?.let { + RSpacer(20.dp) + SetColumnItem( + value = it.toReadableString() ?: "", + title = stringResource(id = R.string.rpe) + ) + } } if (!entry.personalRecords.isNullOrEmpty()) { @@ -202,6 +200,18 @@ fun SessionExerciseSetItem( } } +@Composable +fun SetColumnItem(value: String, title: String) { + Text(text = buildAnnotatedString { + withStyle(style = SpanStyle(ReboundTheme.colors.onBackground)) { + append(value) + } + withStyle(style = SpanStyle(ReboundTheme.colors.onBackground.copy(alpha = 0.65f))) { + append(" $title") + } + }) +} + @Composable fun PersonalRecordsRowComponent( modifier: Modifier, diff --git a/modules/common-ui-resources/src/main/res/values/strings.xml b/modules/common-ui-resources/src/main/res/values/strings.xml index 595c93e6..fd30d1ad 100644 --- a/modules/common-ui-resources/src/main/res/values/strings.xml +++ b/modules/common-ui-resources/src/main/res/values/strings.xml @@ -181,6 +181,7 @@ Add Exercise Cancel Workout Reps + reps Time Volume Sets diff --git a/modules/ui-workout-details/src/main/java/com/ankitsuda/rebound/ui/workout_details/SessionScreen.kt b/modules/ui-workout-details/src/main/java/com/ankitsuda/rebound/ui/workout_details/SessionScreen.kt index 89d7ee94..4407525b 100644 --- a/modules/ui-workout-details/src/main/java/com/ankitsuda/rebound/ui/workout_details/SessionScreen.kt +++ b/modules/ui-workout-details/src/main/java/com/ankitsuda/rebound/ui/workout_details/SessionScreen.kt @@ -17,6 +17,7 @@ package com.ankitsuda.rebound.ui.workout_details import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Edit @@ -142,7 +143,7 @@ fun SessionScreen( contentPadding = PaddingValues(24.dp) ) { if (!workout?.personalRecords.isNullOrEmpty()) { - item { + item(key = "prs") { PersonalRecordsRowComponent( modifier = Modifier .padding(bottom = 10.dp), @@ -151,7 +152,7 @@ fun SessionScreen( } } - item { + item("quick_info") { Row( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, @@ -194,17 +195,15 @@ fun SessionScreen( } } - for (log in logs) { - item() { - SessionExerciseCardItem( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 20.dp), - supersetId = log.junction.supersetId, - title = log.exercise.name ?: "", - entries = log.logEntries - ) - } + items(logs, key = { it.junction.id }) { log -> + SessionExerciseCardItem( + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 20.dp), + supersetId = log.junction.supersetId, + title = log.exercise.name ?: "", + entries = log.logEntries + ) } }