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

Commit

Permalink
Fix sets not showing values in session exercise card
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitSuda committed Dec 2, 2022
1 parent d0447ba commit d8df565
Showing 1 changed file with 40 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ import com.ankitsuda.base.util.colorFromSupersetId
import com.ankitsuda.base.util.isDark
import com.ankitsuda.base.util.lighterOrDarkerColor
import com.ankitsuda.base.util.toReadableString
import com.ankitsuda.common.compose.kgToUserPrefStr
import com.ankitsuda.common.compose.kmToUserPrefStr
import com.ankitsuda.common.compose.userPrefDistanceUnitStr
import com.ankitsuda.common.compose.userPrefWeightUnitStr
import com.ankitsuda.rebound.domain.*
import com.ankitsuda.rebound.domain.entities.ExerciseLogEntry
import com.ankitsuda.rebound.domain.entities.ExerciseSetGroupNote
Expand Down Expand Up @@ -148,9 +152,6 @@ fun SessionExerciseCardItem(
exerciseCategory = exerciseCategory,
revisedSetText = revisedSetsTexts[sortedEntries.indexOf(entry)],
)
// if (i != sortedEntries.size - 1) {
// RSpacer(8.dp)
// }
}
}
}
Expand Down Expand Up @@ -187,35 +188,10 @@ fun SessionExerciseSetItem(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(20.dp)
) {
when (exerciseCategory) {
// ExerciseCategory.WEIGHTS_AND_REPS -> SetColumnItem(
// value = entry.weight.kgToUserPrefStr(),
// title = userPrefWeightUnitStr()
// )
// TODO fix this
// ExerciseCategory.DISTANCE_AND_TIME -> SetColumnItem(
// value = entry.distance.kmToUserPrefStr(),
// title = userPrefDistanceUnitStr()
// )
else -> {}
}
when (exerciseCategory) {
// TODO fix this
// ExerciseCategory.WEIGHTS_AND_REPS, ExerciseCategory.REPS -> SetColumnItem(
// value = (entry.reps ?: 0).toString(),
// title = stringResource(id = R.string.reps_lowercase)
// )
// TODO fix this
// ExerciseCategory.DISTANCE_AND_TIME, ExerciseCategory.TIME -> SetColumnItem(
// value = (entry.timeRecorded ?: 0).toString(),
// title = stringResource(id = R.string.time)
// )
else -> {}
}
entry.rpe?.let {
for (field in exerciseCategory?.fields ?: emptyList()) {
SetColumnItem(
value = it.toReadableString() ?: "",
title = stringResource(id = R.string.rpe)
entry = entry,
fieldType = field
)
}
}
Expand All @@ -231,6 +207,39 @@ fun SessionExerciseSetItem(
}
}

@Composable
fun SetColumnItem(
entry: ExerciseLogEntry,
fieldType: SetFieldValueType,
) {
when (fieldType) {
SetFieldValueType.WEIGHT,
SetFieldValueType.ADDITIONAL_WEIGHT,
SetFieldValueType.ASSISTED_WEIGHT -> SetColumnItem(
value = entry.weight.kgToUserPrefStr(),
title = userPrefWeightUnitStr()
)
SetFieldValueType.REPS -> SetColumnItem(
value = (entry.reps ?: 0).toString(),
title = stringResource(id = R.string.reps_lowercase)
)
SetFieldValueType.DISTANCE -> SetColumnItem(
value = (entry.distance ?: 0.0).kmToUserPrefStr(),
title = userPrefDistanceUnitStr()
)
SetFieldValueType.DURATION -> SetColumnItem(
value = (entry.timeRecorded ?: 0).toString(),
title = stringResource(id = R.string.duration)
)
SetFieldValueType.RPE -> if ((entry.rpe ?: 0f) > 0f) {
SetColumnItem(
value = entry.rpe?.toReadableString() ?: "",
title = stringResource(id = R.string.rpe)
)
}
}
}

@Composable
fun SetColumnItem(value: String, title: String) {
Text(text = buildAnnotatedString {
Expand Down Expand Up @@ -263,8 +272,6 @@ fun PersonalRecordsRowComponent(
)
}


@OptIn(ExperimentalMaterialApi::class)
@Composable
fun PersonalRecordComponent(
pr: PersonalRecord
Expand Down

0 comments on commit d8df565

Please sign in to comment.