Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Improve session ui
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitSuda committed Nov 18, 2022
1 parent 4eb7f41 commit fcb019d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<string name="add_exercise">Add Exercise</string>
<string name="cancel_workout">Cancel Workout</string>
<string name="reps">Reps</string>
<string name="reps_lowercase">reps</string>
<string name="time">Time</string>
<string name="volume">Volume</string>
<string name="sets">Sets</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -151,7 +152,7 @@ fun SessionScreen(
}
}

item {
item("quick_info") {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
Expand Down Expand Up @@ -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
)
}
}

Expand Down

0 comments on commit fcb019d

Please sign in to comment.