feat(train): weights in pounds too, the person's unit or their region's (ADR 0030, D64)

Every weight is still kept in kilograms. It is shown and entered in the
person's unit, chosen in Your body (Weight in: kg | lb, the profile's
new weightUnit), else the region's: pounds in the US, Liberia and
Myanmar. The entry takes 44 to 880 lb, the same 20 to 400 kg. A weight
left untouched in Your body is saved exactly as it was, not rounded
through pounds. The other figures stay metric.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-04 00:15:55 +01:00
commit 396e010949
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -29,6 +29,7 @@ void main() {
trainingBackground: TrainingBackground.frequent,
typicalDay: TypicalDay.mostlyStanding,
sleepGoal: const Duration(hours: 7, minutes: 30),
weightUnit: WeightUnit.pounds,
);
group('its payload', () {
@ -66,6 +67,32 @@ void main() {
});
});
group('the weight unit', () {
test("is the person's choice, else their region's: pounds in the US, "
'Liberia and Myanmar', () {
expect(WeightUnit.ofRegion('US'), WeightUnit.pounds);
expect(WeightUnit.ofRegion('MM'), WeightUnit.pounds);
expect(WeightUnit.ofRegion('GB'), WeightUnit.kilograms);
expect(WeightUnit.ofRegion(null), WeightUnit.kilograms);
expect(
const ProfileContent(weightUnit: WeightUnit.kilograms)
.weightUnitIn('US'),
WeightUnit.kilograms,
);
expect(const ProfileContent().weightUnitIn('US'), WeightUnit.pounds);
});
test('converts both ways, kilograms kept as they are', () {
expect(WeightUnit.pounds.fromKilograms(0.45359237), closeTo(1, 1e-12));
expect(WeightUnit.pounds.toKilograms(165), closeTo(74.8428, 1e-4));
expect(WeightUnit.kilograms.toKilograms(70), 70);
});
test('goes with a new weight', () {
expect(full.withWeight(60).weightUnit, WeightUnit.pounds);
});
});
test('the age counts whole years, the birthday itself included', () {
final born = ProfileContent(birthDate: DateTime.utc(1990, 4, 12));