Stage 1: project setup, Exercise Library, both Mode designs and the Mode switch
- Flutter Android app on CookIT's stack (provider, shared_preferences, gen-l10n) - tools/exercise-import turns free-exercise-db into 876 bundled Exercises with 1,746 WebP images (20 MB); stretching -> Stretching, rest -> Workout - ZenStyle tokens per Mode: calm rounded sage/teal with breath ripples vs. dark ember-to-red with floor-tape slashes; the theme morphs at each Mode's own pace - Remembered global Mode switch, Plans / Library / History tabs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5dfa995d55
commit
1289fadb98
1822 files changed
+2819
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:zenxercise/src/exercises/exercise_library.dart';
|
||||
import 'package:zenxercise/src/modes/mode.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
const json = '''[
|
||||
{"id":"Calf_Stretch","name":"Calf Stretch","mode":"stretching","category":"stretching","level":"beginner",
|
||||
"equipment":null,"force":"static","mechanic":null,"primaryMuscles":["calves"],"secondaryMuscles":[],
|
||||
"instructions":["Lean forward."],"imageCount":2},
|
||||
{"id":"Barbell_Squat","name":"Barbell Squat","mode":"workout","category":"strength","level":"intermediate",
|
||||
"equipment":"barbell","force":"push","mechanic":"compound","primaryMuscles":["quadriceps"],
|
||||
"secondaryMuscles":["glutes","hamstrings"],"instructions":["Squat."],"imageCount":0}
|
||||
]''';
|
||||
|
||||
test('splits Exercises by Mode and finds them by id', () {
|
||||
final library = ExerciseLibrary.fromJson(json);
|
||||
|
||||
expect(library.forMode(Mode.stretching).map((e) => e.id), ['Calf_Stretch']);
|
||||
expect(library.forMode(Mode.workout).map((e) => e.id), ['Barbell_Squat']);
|
||||
expect(library.byId('Barbell_Squat')!.secondaryMuscles, ['glutes', 'hamstrings']);
|
||||
expect(library.byId('Missing'), isNull);
|
||||
});
|
||||
|
||||
test('an Exercise points at its flattened WebP images', () {
|
||||
final calf = ExerciseLibrary.fromJson(json).byId('Calf_Stretch')!;
|
||||
|
||||
expect(calf.images, ['assets/exercises/images/Calf_Stretch_0.webp', 'assets/exercises/images/Calf_Stretch_1.webp']);
|
||||
});
|
||||
|
||||
test('the bundled library holds 123 stretches and 753 workout Exercises whose images exist', () async {
|
||||
final library = await ExerciseLibrary.load(rootBundle);
|
||||
|
||||
expect(library.forMode(Mode.stretching), hasLength(123));
|
||||
expect(library.forMode(Mode.workout), hasLength(753));
|
||||
final anyImage = library.forMode(Mode.stretching).firstWhere((e) => e.imageCount == 2).images.last;
|
||||
expect((await rootBundle.load(anyImage)).lengthInBytes, greaterThan(0));
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user