feat(train): a weight vest among the equipment (ADR 0034, D7)
All checks were successful
CI / check (push) Successful in 45m21s
CI / deploy (push) Successful in 1m1s

A vest keeps its weight and, if adjustable, how far it goes. At a place
that has one, a set of bodyweight work offers it beside the weight, a
tap writing its weight in.

Whats-New: Add a weight vest to your equipment, and put its weight on a bodyweight set with a tap.
Whats-New-De: Trage eine Gewichtsweste bei deiner Ausrüstung ein und übernimm ihr Gewicht mit einem Tipp in einen Satz mit Körpergewicht.

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-05 16:47:23 +01:00
commit 011b144ba1
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
3 changed files with 332 additions and 15 deletions

View file

@ -97,4 +97,33 @@ void main() {
expect(decodePlace(_bytes([1, 2])), isNull);
expect(decodePlace(ByteData(0)), isNull);
});
test('a weight vest keeps its weight, and how far an adjustable one goes '
'(ADR 0034, D7)', () {
const place = PlaceContent(
name: 'Home',
items: [
EquipmentItem(
kind: EquipmentKind.weightVest,
grams: 6000,
gramsUpTo: 10000,
),
EquipmentItem(kind: EquipmentKind.weightVest, grams: 8000),
],
);
expect(decodePlace(encodePlace(place)), place);
});
test("an upper weight that isn't above the vest's weight is left out", () {
final place = decodePlace(
_bytes({
'schemaVersion': 1,
'name': 'Home',
'items': [
{'kind': 'weightVest', 'count': 1, 'grams': 8000, 'gramsUpTo': 8000},
],
}),
);
expect(place!.items.single.gramsUpTo, isNull);
});
}

View file

@ -0,0 +1,52 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_train_flutter/l10n/app_localizations.dart';
import 'package:halkyon_train_flutter/src/feature/equipment/model/equipment.dart';
import 'package:halkyon_train_flutter/src/feature/strength/widget/vest_chip.dart';
import 'package:material_ui/material_ui.dart';
/// The vest offered at a set of the body (ADR 0034, D7).
void main() {
Future<void> pump(
WidgetTester tester,
EquipmentItem vest,
void Function(int) onWear,
) => tester.pumpWidget(
MaterialApp(
locale: const Locale('en'),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: VestChip(vest: vest, onWear: onWear),
),
),
);
testWidgets('an adjustable vest shows its range and gives its lightest', (
tester,
) async {
int? worn;
await pump(
tester,
const EquipmentItem(
kind: EquipmentKind.weightVest,
grams: 6000,
gramsUpTo: 10000,
),
(grams) => worn = grams,
);
expect(find.text('Weight vest, 6–10 kg'), findsOneWidget);
await tester.tap(find.byType(ActionChip));
expect(worn, 6000);
});
testWidgets('a vest of one weight shows that weight', (tester) async {
await pump(
tester,
const EquipmentItem(kind: EquipmentKind.weightVest, grams: 8000),
(_) {},
);
expect(find.text('Weight vest, 8 kg'), findsOneWidget);
});
}

View file

@ -74,4 +74,18 @@ void main() {
expect(series.last.change, const PlateChange(off: [], on: [10000]));
expect(plateSeries(ExerciseLoad.dumbbellPair, [7000], home), isNull);
});
test(
'a place offers its weight vest to what the body lifts (ADR 0034, D7)',
() {
const vest = EquipmentItem(
kind: EquipmentKind.weightVest,
grams: 6000,
gramsUpTo: 10000,
);
expect(vestAt(const PlaceContent(name: 'Home', items: [vest])), vest);
expect(vestAt(home), isNull);
expect(vestAt(null), isNull);
},
);
}