From 5e393b2d5d7d063fc7910d54ef7d666559aaacc3 Mon Sep 17 00:00:00 2001 From: Ankit Suda Date: Fri, 18 Nov 2022 19:16:04 +0530 Subject: [PATCH] Fix rpe --- .../workouteditor/WorkoutExerciseItem.kt | 1 + .../keyboard/ReboundSetKeyboardComponent.kt | 21 ++++++++++--------- .../ui/keyboard/field/ReboundSetTextField.kt | 3 ++- .../ui/keyboard/rpe/RpePickerComponent.kt | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/modules/common-ui-components-workout-editor/src/main/java/com/ankitsuda/rebound/ui/components/workouteditor/WorkoutExerciseItem.kt b/modules/common-ui-components-workout-editor/src/main/java/com/ankitsuda/rebound/ui/components/workouteditor/WorkoutExerciseItem.kt index aa153cf2..25e5cecf 100644 --- a/modules/common-ui-components-workout-editor/src/main/java/com/ankitsuda/rebound/ui/components/workouteditor/WorkoutExerciseItem.kt +++ b/modules/common-ui-components-workout-editor/src/main/java/com/ankitsuda/rebound/ui/components/workouteditor/WorkoutExerciseItem.kt @@ -644,6 +644,7 @@ private fun SetItemLayout( || exercise.category == ExerciseCategory.REPS ) { ReboundSetTextField( + layoutWeight = 0.75f, value = exerciseLogEntry.rpe?.toReadableString() ?: "", onValueChange = { onRpeChange(exerciseLogEntry, it.toFloatOrNull()) diff --git a/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/ReboundSetKeyboardComponent.kt b/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/ReboundSetKeyboardComponent.kt index d08c0531..2e87b4cf 100644 --- a/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/ReboundSetKeyboardComponent.kt +++ b/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/ReboundSetKeyboardComponent.kt @@ -139,16 +139,17 @@ fun ReboundSetKeyboardComponent( ) } KeyboardModeType.RPE_PICKER -> { - RpePickerComponent( - modifier = Modifier - .fillMaxWidth() - .height( - height = 250.dp, - ), - onSetText = ::setText, - text = inputConnection?.getText(), - refreshKey = inputConnection - ) + key(inputConnection) { + RpePickerComponent( + modifier = Modifier + .fillMaxWidth() + .height( + height = 250.dp, + ), + onSetText = ::setText, + text = inputConnection?.getText(), + ) + } } } } diff --git a/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/field/ReboundSetTextField.kt b/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/field/ReboundSetTextField.kt index 66297832..6c307db3 100644 --- a/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/field/ReboundSetTextField.kt +++ b/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/field/ReboundSetTextField.kt @@ -38,6 +38,7 @@ import com.ankitsuda.rebound.ui.keyboard.enums.ReboundKeyboardType @Composable fun RowScope.ReboundSetTextField( + layoutWeight: Float = 1.25f, value: String, contentColor: Color, bgColor: Color, @@ -51,7 +52,7 @@ fun RowScope.ReboundSetTextField( modifier = Modifier .height(32.dp) .padding(start = 8.dp, end = 8.dp) - .weight(1.25f) + .weight(layoutWeight) .clip(RoundedCornerShape(12.dp)) .background(bgColor.lighterOrDarkerColor(0.10f)), ) { diff --git a/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/rpe/RpePickerComponent.kt b/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/rpe/RpePickerComponent.kt index 71e7f518..677e8204 100644 --- a/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/rpe/RpePickerComponent.kt +++ b/modules/ui-keyboard/src/main/java/com/ankitsuda/rebound/ui/keyboard/rpe/RpePickerComponent.kt @@ -26,7 +26,7 @@ internal fun RpePickerComponent( modifier: Modifier, onSetText: (String) -> Unit, text: String?, - refreshKey: Any?, + refreshKey: Any? = null, ) { var rpe: Float? by remember(text) { mutableStateOf(text?.toFloatOrNull().takeIf { allRPEs.any { r -> r == it } })