Skip to content

Commit

Permalink
Add better dry weight calculator, live imperial conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Nov 10, 2023
1 parent af2025e commit deaa5b8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126

PODFILE CHECKSUM: 0dbd5a87e0ace00c9610d2037ac22083a01f861d

COCOAPODS: 1.12.1
COCOAPODS: 1.14.2
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion lib/divecalculation/divecalculation_cylinder_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DiveCalculationCylinderView extends StatelessWidget {
),
if (metric)
Text(
(cvm.cylinder!.twinset ? "2×" : "") + "${shortNumber(cvm.cylinder!.nominalVolume.cuft)} cuft",
(cvm.cylinder!.twinset ? "2×" : "") + "${shortNumber(cvm.cylinder!.compressedVolume(pressure).cuft)} cuft",
style: h1,
textAlign: TextAlign.right,
),
Expand Down
6 changes: 6 additions & 0 deletions lib/models/cylinder_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'units.dart';

const valveBuyoancyKg = -0.7;
const twinBuyoancyKg = -0.5;
const valveWeightKg = 0.8; // a single valve
const twinWeightKg = 0.6 + 0.8; // manifold and bands

class CylinderModel {
UuidValue id;
Expand Down Expand Up @@ -88,5 +90,9 @@ class CylinderModel {
compressedVolume(pressure(p)).l * airKgPerL,
);

Weight dryWeight(Pressure? p) => WeightKg(
twinFactor * weight.kg + twinFactor * valveWeightKg + twinWeightKg * (twinFactor - 1) + compressedVolume(pressure(p)).l * airKgPerL,
);

Volume get _externalVolume => VolumeL(weight.kg / materialDensity + waterVolume.l);
}
13 changes: 2 additions & 11 deletions lib/models/cylinder_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,9 @@ class CylinderViewModel {
final bool? metric;
const CylinderViewModel({this.cylinder, this.pressure, this.rockBottom, this.metric});

String get description => metric!
? sprintf("%s (%.01f kg)", [cylinder!.name, cylinder!.twinFactor * cylinder!.weight.kg])
: sprintf("%s (%.01f lb)", [
cylinder!.name,
cylinder!.twinFactor * cylinder!.weight.lb,
]);
String get description => sprintf("%s (%s)", [cylinder!.name, weight]);

String get weight => metric!
? sprintf("%.01f kg", [cylinder!.twinFactor * cylinder!.weight.kg])
: sprintf("%.01f lb", [
cylinder!.twinFactor * cylinder!.weight.lb,
]);
String get weight => metric! ? sprintf("%.01f kg", [cylinder!.dryWeight(pressure).kg]) : sprintf("%.01f lb", [cylinder!.dryWeight(pressure).lb]);

String get gas => metric!
? sprintf("%d", [
Expand Down

0 comments on commit deaa5b8

Please sign in to comment.