Skip to content

Commit fc6c9ee

Browse files
committed
Add: Explanation text for auto-switch depth in setpoint dialogs
1 parent 88d68d5 commit fc6c9ee

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

Loading

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/preferences/CcrSetpointPreference.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
1919
import androidx.compose.foundation.layout.padding
2020
import androidx.compose.material3.AlertDialogCustomContent
2121
import androidx.compose.material3.Checkbox
22+
import androidx.compose.material3.MaterialTheme
2223
import androidx.compose.material3.Surface
2324
import androidx.compose.material3.Text
2425
import androidx.compose.material3.TextButton
@@ -43,6 +44,7 @@ fun CcrSetpointPreference(
4344
modifier: Modifier = Modifier,
4445
label: String,
4546
description: String,
47+
switchDepthDescription: String,
4648
setpoint: Double,
4749
switchDepth: Int?,
4850
onValueChanged: (setpoint: Double, switchDepth: Int?) -> Unit,
@@ -54,6 +56,7 @@ fun CcrSetpointPreference(
5456
title = label,
5557
setpoint = setpoint,
5658
switchDepth = switchDepth,
59+
switchDepthDescription = switchDepthDescription,
5760
onConfirmButtonClicked = { newSetpoint, newSwitchDepth ->
5861
if (newSetpoint != setpoint || newSwitchDepth != switchDepth) {
5962
onValueChanged(newSetpoint, newSwitchDepth)
@@ -91,6 +94,7 @@ private fun CcrSetpointPreferenceDialog(
9194
onDismissRequest: () -> Unit = {},
9295
setpoint: Double,
9396
switchDepth: Int?,
97+
switchDepthDescription: String = "",
9498
) {
9599
val setpointValue: MutableState<Double> = remember(setpoint) { mutableStateOf(setpoint) }
96100
val switchDepthValue: MutableState<Int?> = remember(switchDepth) { mutableStateOf(switchDepth) }
@@ -133,6 +137,7 @@ private fun CcrSetpointPreferenceDialog(
133137
initialValue = setpoint,
134138
isValid = isSetpointValid,
135139
visualTransformation = SuffixVisualTransformation(" bar"),
140+
supportingText = null
136141
) {
137142
if (it != null) {
138143
setpointValue.value = it
@@ -171,6 +176,14 @@ private fun CcrSetpointPreferenceDialog(
171176
}
172177
}
173178
}
179+
180+
if (switchDepthDescription.isNotEmpty()) {
181+
Text(
182+
text = switchDepthDescription,
183+
style = MaterialTheme.typography.bodySmall,
184+
color = MaterialTheme.colorScheme.onSurfaceVariant,
185+
)
186+
}
174187
}
175188
}
176189
)
@@ -184,13 +197,15 @@ private fun CcrSetpointPreferencePreview() {
184197
CcrSetpointPreference(
185198
label = "Low setpoint",
186199
description = "The CCR setpoint used during descent, with optional auto-switch depth to the high setpoint.",
200+
switchDepthDescription = "Auto-switch depth: during descent, switch to the high setpoint at this depth.",
187201
setpoint = 0.7,
188202
switchDepth = 6,
189203
onValueChanged = { _, _ -> },
190204
)
191205
CcrSetpointPreference(
192206
label = "High setpoint",
193207
description = "The CCR setpoint used during bottom time and ascent, with optional auto-switch depth to the low setpoint.",
208+
switchDepthDescription = "Auto-switch depth: during ascent, switch to the low setpoint at this depth.",
194209
setpoint = 1.2,
195210
switchDepth = null,
196211
onValueChanged = { _, _ -> },
@@ -206,7 +221,8 @@ fun CcrSetpointPreferenceDialogPreview() {
206221
CcrSetpointPreferenceDialog(
207222
title = "Low setpoint",
208223
setpoint = 1.2,
209-
switchDepth = 6
224+
switchDepth = 6,
225+
switchDepthDescription = "Auto-switch depth: during descent, switch to the high setpoint at this depth.",
210226
)
211227
}
212228
}

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/screens/DiveConfigurationScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ fun DiveConfigurationScreen(
399399
CcrSetpointPreference(
400400
label = "Low setpoint",
401401
description = "The CCR setpoint used during descent, with optional auto-switch depth to the high setpoint.",
402+
switchDepthDescription = "Auto-switch depth: during descent, switch to the high setpoint at this depth.",
402403
setpoint = configuration.ccrLowSetpoint,
403404
switchDepth = configuration.ccrToHighSetpointSwitchDepth?.roundToInt(),
404405
) { setpoint, switchDepth ->
@@ -408,6 +409,7 @@ fun DiveConfigurationScreen(
408409
CcrSetpointPreference(
409410
label = "High setpoint",
410411
description = "The CCR setpoint used during bottom time and ascent, with optional auto-switch depth to the low setpoint.",
412+
switchDepthDescription = "Auto-switch depth: during ascent, switch to the low setpoint at this depth.",
411413
setpoint = configuration.ccrHighSetpoint,
412414
switchDepth = configuration.ccrToLowSetpointSwitchDepth?.roundToInt(),
413415
) { setpoint, switchDepth ->

0 commit comments

Comments
 (0)