From fc6c9eec34d143a76e9869f626b2afdb595e2d9d Mon Sep 17 00:00:00 2001 From: Rolf Smit Date: Wed, 6 May 2026 00:39:17 +0200 Subject: [PATCH] Add: Explanation text for auto-switch depth in setpoint dialogs --- ...eferenceDialogScreenshotTest_7a9301c3_0.png | 4 ++-- .../preferences/CcrSetpointPreference.kt | 18 +++++++++++++++++- .../screens/DiveConfigurationScreen.kt | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/androidApp/src/screenshotTestDebug/reference/org/neotech/app/abysner/presentation/component/preferences/PreferenceDialogsScreenshotTestKt/CcrSetpointPreferenceDialogScreenshotTest_7a9301c3_0.png b/androidApp/src/screenshotTestDebug/reference/org/neotech/app/abysner/presentation/component/preferences/PreferenceDialogsScreenshotTestKt/CcrSetpointPreferenceDialogScreenshotTest_7a9301c3_0.png index 925e01b..79a6ea0 100644 --- a/androidApp/src/screenshotTestDebug/reference/org/neotech/app/abysner/presentation/component/preferences/PreferenceDialogsScreenshotTestKt/CcrSetpointPreferenceDialogScreenshotTest_7a9301c3_0.png +++ b/androidApp/src/screenshotTestDebug/reference/org/neotech/app/abysner/presentation/component/preferences/PreferenceDialogsScreenshotTestKt/CcrSetpointPreferenceDialogScreenshotTest_7a9301c3_0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c6e6a3733cdfe604ff9159fabeffc3eb3420d5c6046963a22051750fe11a137 -size 17287 +oid sha256:2da4fb0a769615da5b88752b5e30fb8efac20e9acdf7b4c1fb5d7bba79c45c27 +size 23030 diff --git a/composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/preferences/CcrSetpointPreference.kt b/composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/preferences/CcrSetpointPreference.kt index 3add441..bd1ef1f 100644 --- a/composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/preferences/CcrSetpointPreference.kt +++ b/composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/preferences/CcrSetpointPreference.kt @@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.AlertDialogCustomContent import androidx.compose.material3.Checkbox +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TextButton @@ -43,6 +44,7 @@ fun CcrSetpointPreference( modifier: Modifier = Modifier, label: String, description: String, + switchDepthDescription: String, setpoint: Double, switchDepth: Int?, onValueChanged: (setpoint: Double, switchDepth: Int?) -> Unit, @@ -54,6 +56,7 @@ fun CcrSetpointPreference( title = label, setpoint = setpoint, switchDepth = switchDepth, + switchDepthDescription = switchDepthDescription, onConfirmButtonClicked = { newSetpoint, newSwitchDepth -> if (newSetpoint != setpoint || newSwitchDepth != switchDepth) { onValueChanged(newSetpoint, newSwitchDepth) @@ -91,6 +94,7 @@ private fun CcrSetpointPreferenceDialog( onDismissRequest: () -> Unit = {}, setpoint: Double, switchDepth: Int?, + switchDepthDescription: String = "", ) { val setpointValue: MutableState = remember(setpoint) { mutableStateOf(setpoint) } val switchDepthValue: MutableState = remember(switchDepth) { mutableStateOf(switchDepth) } @@ -133,6 +137,7 @@ private fun CcrSetpointPreferenceDialog( initialValue = setpoint, isValid = isSetpointValid, visualTransformation = SuffixVisualTransformation(" bar"), + supportingText = null ) { if (it != null) { setpointValue.value = it @@ -171,6 +176,14 @@ private fun CcrSetpointPreferenceDialog( } } } + + if (switchDepthDescription.isNotEmpty()) { + Text( + text = switchDepthDescription, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } } } ) @@ -184,6 +197,7 @@ private fun CcrSetpointPreferencePreview() { CcrSetpointPreference( label = "Low setpoint", description = "The CCR setpoint used during descent, with optional auto-switch depth to the high setpoint.", + switchDepthDescription = "Auto-switch depth: during descent, switch to the high setpoint at this depth.", setpoint = 0.7, switchDepth = 6, onValueChanged = { _, _ -> }, @@ -191,6 +205,7 @@ private fun CcrSetpointPreferencePreview() { CcrSetpointPreference( label = "High setpoint", description = "The CCR setpoint used during bottom time and ascent, with optional auto-switch depth to the low setpoint.", + switchDepthDescription = "Auto-switch depth: during ascent, switch to the low setpoint at this depth.", setpoint = 1.2, switchDepth = null, onValueChanged = { _, _ -> }, @@ -206,7 +221,8 @@ fun CcrSetpointPreferenceDialogPreview() { CcrSetpointPreferenceDialog( title = "Low setpoint", setpoint = 1.2, - switchDepth = 6 + switchDepth = 6, + switchDepthDescription = "Auto-switch depth: during descent, switch to the high setpoint at this depth.", ) } } diff --git a/composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/screens/DiveConfigurationScreen.kt b/composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/screens/DiveConfigurationScreen.kt index 7c10235..737bfcf 100644 --- a/composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/screens/DiveConfigurationScreen.kt +++ b/composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/screens/DiveConfigurationScreen.kt @@ -399,6 +399,7 @@ fun DiveConfigurationScreen( CcrSetpointPreference( label = "Low setpoint", description = "The CCR setpoint used during descent, with optional auto-switch depth to the high setpoint.", + switchDepthDescription = "Auto-switch depth: during descent, switch to the high setpoint at this depth.", setpoint = configuration.ccrLowSetpoint, switchDepth = configuration.ccrToHighSetpointSwitchDepth?.roundToInt(), ) { setpoint, switchDepth -> @@ -408,6 +409,7 @@ fun DiveConfigurationScreen( CcrSetpointPreference( label = "High setpoint", description = "The CCR setpoint used during bottom time and ascent, with optional auto-switch depth to the low setpoint.", + switchDepthDescription = "Auto-switch depth: during ascent, switch to the low setpoint at this depth.", setpoint = configuration.ccrHighSetpoint, switchDepth = configuration.ccrToLowSetpointSwitchDepth?.roundToInt(), ) { setpoint, switchDepth ->