Skip to content

Commit 10ce923

Browse files
authored
Add: Imperial unit support for depth and distance/rate in the UI (#181)
Required for: #49
1 parent 854b5ec commit 10ce923

26 files changed

Lines changed: 247 additions & 115 deletions

File tree

Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Loading

composeApp/src/commonMain/composeResources/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
<item quantity="other">%1$d meters</item>
1717
</plurals>
1818

19+
<plurals name="unit_foot">
20+
<item quantity="one">%1$d foot</item>
21+
<item quantity="other">%1$d feet</item>
22+
</plurals>
23+
1924
<plurals name="unit_minute">
2025
<item quantity="one">%1$d minute</item>
2126
<item quantity="other">%1$d minutes</item>

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import org.neotech.app.abysner.domain.core.physics.Pressure
3131
import org.neotech.app.abysner.domain.utilities.floorTolerant
3232
import org.neotech.app.abysner.domain.utilities.format
3333
import org.neotech.app.abysner.presentation.theme.AbysnerTheme
34+
import org.neotech.app.abysner.presentation.utilities.depthUnitLabel
3435
import org.neotech.app.abysner.presentation.utilities.formatDisplayDepth
3536
import kotlin.math.round
3637

@@ -42,6 +43,7 @@ fun GasPropertiesComponent(
4243
maxPPO2Secondary: Double?,
4344
maxDensity: Double,
4445
environment: Environment,
46+
unitSystem: UnitSystem,
4547
showTopRow: Boolean = true,
4648
onClickMix: (() -> Unit)? = null
4749
) {
@@ -91,8 +93,9 @@ fun GasPropertiesComponent(
9193
Row(modifier = Modifier.wrapContentHeight(),
9294
horizontalArrangement = Arrangement.spacedBy(12.dp)) {
9395

94-
val mod = gas?.oxygenModAmbientPressureWithTolerance(maxPPO2)
95-
?.formatModDepth(UnitSystem.METRIC, environment)
96+
val mod = gas
97+
?.oxygenModAmbientPressureWithTolerance(maxPPO2)
98+
?.formatModDepth(unitSystem, environment)
9699
?: EMPTY_PLACEHOLDER
97100

98101
FlipCardComponent(
@@ -121,7 +124,7 @@ fun GasPropertiesComponent(
121124

122125
val modSecondary = gas
123126
?.oxygenModAmbientPressureWithTolerance(maxPPO2Secondary)
124-
?.formatModDepth(UnitSystem.METRIC, environment)
127+
?.formatModDepth(unitSystem, environment)
125128
?: EMPTY_PLACEHOLDER
126129

127130
FlipCardComponent(
@@ -149,7 +152,7 @@ fun GasPropertiesComponent(
149152

150153
val densityMod = gas
151154
?.densityModAmbientPressure(maxDensity)
152-
?.formatModDepthRounded(UnitSystem.METRIC, environment)
155+
?.formatModDepthRounded(unitSystem, environment)
153156
?: EMPTY_PLACEHOLDER
154157

155158
FlipCardComponent(
@@ -220,6 +223,7 @@ private fun GasPropertiesComponentPreview() {
220223
maxPPO2Secondary = 1.6,
221224
maxDensity = 6.8,
222225
environment = Environment(Salinity.WATER_FRESH, ATMOSPHERIC_PRESSURE_AT_SEA_LEVEL),
226+
unitSystem = UnitSystem.METRIC,
223227
showTopRow = true
224228
)
225229
}

0 commit comments

Comments
 (0)