@@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
1919import androidx.compose.foundation.layout.padding
2020import androidx.compose.material3.AlertDialogCustomContent
2121import androidx.compose.material3.Checkbox
22+ import androidx.compose.material3.MaterialTheme
2223import androidx.compose.material3.Surface
2324import androidx.compose.material3.Text
2425import 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}
0 commit comments