-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for setting weight type when recording exercises; fixed…
… bug with wrong tab showing by default (#200) * Removed old comment in imports * Updated weight utils script * Implemented kg/lbs conversion handling in inputs * Fix icons showing in toggle * Round to two decimals when saving * Fix bug where wrong tab was showing by default * Add new kg/lbs icons to settings modal * Linted code * Removed old comment
- Loading branch information
Showing
5 changed files
with
106 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class WeightUtils { | ||
// Conversion constants | ||
static const double kgToLbRatio = 2.20462; | ||
|
||
// Converts kg to lbs | ||
static double kgToLbs(double kg) { | ||
return kg * 2.20462; | ||
return kg * kgToLbRatio; | ||
} | ||
|
||
// Converts lbs to kg | ||
static double lbsToKg(double lbs) { | ||
return lbs / 2.20462; | ||
return lbs / kgToLbRatio; | ||
} | ||
|
||
static String formatWeight(double weight, bool isKg) { | ||
// Formats the weight according to the selected unit system (kg or lbs) | ||
static String formatWeight(double weightInKg, bool isKg) { | ||
if (isKg) { | ||
return '${weight.toStringAsFixed(2)} kg'; | ||
return weightInKg.toStringAsFixed(1); // 1 decimal place for kg | ||
} else { | ||
return '${kgToLbs(weight).toStringAsFixed(2)} lbs'; | ||
return kgToLbs(weightInKg) | ||
.toStringAsFixed(1); // Convert to lbs with 1 decimal place | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters