Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Add exercise preview, archive, video step marks and new filters, and fix three exercises
InlitX2cf73c9113f7
diff --git a/lib/catalog/exercise_catalog.dart b/lib/catalog/exercise_catalog.dartindex 5bc56d4..d1e6b2c 100644--- a/lib/catalog/exercise_catalog.dart+++ b/lib/catalog/exercise_catalog.dart@@ -4449,16 +4449,16 @@ const List<Exercise> kExercises = [),Exercise(id: 'c8f5cSY',- name: 'Side Lying Hip Adduction',- primary: 'quads',- secondary: ['glutes', 'hamstrings'],+ name: 'Side Lying Hip Abduction',+ primary: 'glutes',+ secondary: ['obliques'],equipment: 'Bodyweight',difficulty: 'Intermediate',art: 'side-lying-hip-abduction',steps: ['Lie on your side with your legs straight and stacked on top of each other.','Place your bottom arm under your head for support.',- 'Engage your adductors and lift your top leg as high as possible without rotating your hips or leaning backward.',+ 'Squeeze the side of your glutes and lift your top leg as high as you can without rotating your hips or leaning backward.','Pause for a moment at the top, then slowly lower your leg back down to the starting position.','Repeat for the desired number of repetitions, then switch sides.',],@@ -4483,16 +4483,16 @@ const List<Exercise> kExercises = [id: 'VO2qeJg',name: 'Side Plank Hip Adduction',primary: 'obliques',- secondary: ['glutes', 'quads'],+ secondary: ['quads'],equipment: 'Bodyweight',difficulty: 'Intermediate',art: 'copenhagen-plank',steps: [- 'Start by lying on your side with your legs extended and stacked on top of each other.',- 'Prop yourself up on your forearm, keeping your elbow directly below your shoulder.',- 'Engage your core and lift your hips off the ground, creating a straight line from your head to your feet.',- 'While maintaining the side plank position, lift your top leg towards the ceiling, keeping it straight.',- 'Slowly lower your leg back down to the starting position.',+ 'Lie on your side next to a bench, propped on your forearm with your elbow directly under your shoulder.',+ 'Rest the inside of your top leg on the bench, at the knee to make it easier or at the ankle to make it harder, with your bottom leg on the floor under it.',+ 'Brace your core and lift your hips until your body forms a straight line from head to feet.',+ 'Press your top leg down into the bench and raise your bottom leg until it touches the underside of the bench.',+ 'Lower the bottom leg towards the floor with control, keeping your hips up, and switch sides after the set.',],),Exercise(@@ -8009,14 +8009,14 @@ const List<Exercise> kExercises = [primary: 'hamstrings',secondary: ['glutes', 'calves'],equipment: 'Bodyweight',- difficulty: 'Beginner',+ difficulty: 'Intermediate',art: 'nordic-hamstring-curl',steps: [- 'Lie flat on your back on a mat or bench with your legs extended.',- 'Place your hands by your sides or under your glutes for support.',- 'Bend your knees and lift your feet off the ground, bringing your thighs towards your chest.',- 'Pause for a moment at the top, then slowly lower your legs back to the starting position.',- 'Repeat for the desired number of repetitions.',+ 'Kneel on a pad with your ankles anchored under a bench, a sturdy bar or a partner’s hands.',+ 'Keep your body straight from knees to head, squeeze your glutes and hold your hands in front of your chest.',+ 'Lean forward slowly from the knees, resisting with your hamstrings for as long as you can.',+ 'When you can no longer control the descent, catch yourself with your hands in a push-up position.',+ 'Give a light push off the floor and pull yourself back up to kneeling with your hamstrings.',],),Exercise(@@ -8821,6 +8821,31 @@ const List<String> kFilterEquipment = ['Bodyweight', 'Dumbbell', 'Barbell', 'Machine', 'Cable', 'Band', 'Kettlebell', 'Rings', 'Weighted'];+const Set<String> kNeedsKit = {+ '9WTm7dq', 'lBDjFxJ', 'T2mxWqc', 'X6C6i5Y', '72BC5Za', 'GaSzzuh', 'mExgrF9', 'neutral-grip-pull-up',+ 'active-hang', 'negative-pull-up', 'commando-pull-up', 'l-sit-pull-up', 'towel-pull-up', 'XgWyAiA',+ 'LQFOrMn', 'uWpxD4v', 'PXTIwgu', 'l-sit-hold', '50BETrz', 'guT8YnS', '7xeukSt', 'uTBt1HV', 'dead-hang-hold',+ 'TFqbd8t', 'XVDdcoj', '3xK09Sk', 'v2DfH14', 'tig3PXb', 'xbkPfaw', 'prone-t-raise', 'reverse-snow-angel',+ 'decline-push-up', 'seal-jack', 'feet-elevated-pike-push-up', 'handstand-push-up', '2gPfomN', 'Hy9D21L',+ 'NAkmgdx', 'dragon-flag', 'mweqJin', 'VO2qeJg', 'xdYPUtE', '9E25EOx', 'assisted-pistol-squat', 'shrimp-squat',+ 'single-leg-box-squat', 'sJFIDIp', 'gscGLOU', 'RrLske5', '9RT8oQW', 'u27Kcdz', '6sYyrRX', 'clamshell',+ 'hip-airplane', 'bJYHBIN', 'iPm26QU', 'u5ESqzH', '0jp9Rlz', 'LNE3wfo', 'GwYwElT', 'C5jncD2',+ 'lying-hamstring-walkout', 'hamstring-stretch', 'outdoor-run', 'outdoor-walk', 'outdoor-hike',+};++const List<String> kWarmupIds = [+ 'jumping-jack', 'high-knees', 'cat-cow-stretch', 'worlds-greatest-stretch', 'leg-swings-stretch', 'inchworm',+ 'QChZi3x', 'scapular-push-up', 'hip-airplane', 'glute-bridge', 'bird-dog', 'dead-bug', 'fire-hydrant',+ 'clamshell', 'kneeling-hip-flexor-stretch', 'RtyAsy1', '5BZHW9s', '6YUfHPL', 'jump-rope', 'band-pull-apart',+];++const Set<String> kCardioExtras = {+ 'jump-rope', 'battle-ropes', 'burpee', 'half-burpee', 'mountain-climber', 'high-knees', 'jumping-jack',+ 'skater-hop', 'squat-thrust', 'sprawl', 'lateral-shuffle', 'plank-jack',+};++bool isNoKit(Exercise ex) => ex.equipment == 'Bodyweight' && !kNeedsKit.contains(ex.id);+const Map<String, String> kExerciseModes = {'running': 'cardio','walking': 'cardio',@@ -8830,6 +8855,7 @@ const Map<String, String> kExerciseModes = {'elliptical': 'cardio','rowing': 'cardio','stair-climber': 'cardio',+ 'skierg': 'cardio','jump-rope': 'time','battle-ropes': 'time','VBAWRPG': 'time',diff --git a/lib/screens/exercise_detail_screen.dart b/lib/screens/exercise_detail_screen.dartindex 8fb3e15..129828a 100644--- a/lib/screens/exercise_detail_screen.dart+++ b/lib/screens/exercise_detail_screen.dart@@ -11,8 +11,10 @@ import '../theme/app_theme.dart';import '../widgets/charts.dart';import '../widgets/entrance.dart';import '../widgets/exercise_media.dart';+import '../widgets/exercise_preview.dart';import '../widgets/ruler_picker.dart';import '../widgets/glass.dart';+import '../widgets/liquid_notch.dart';import '../widgets/stopwatch_card.dart';import '../widgets/svg_icon.dart';import '../widgets/timer_panel.dart';@@ -47,13 +49,14 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {final secondary =ex.secondary.map(muscleLabel).join(', ').isEmpty ? t.none : ex.secondary.map(muscleLabel).join(', ');final steps = fit.activeExerciseSteps(ex);- final pr = fit.exercisePr(ex.id);+ final pr = fit.exerciseRecord(ex.id);final oneRm = fit.oneRmSeries(ex.id);final history = fit.exerciseHistory(ex.id);final hasMedia = fit.hasCustomMedia(ex.id);final repsOnly = fit.isRepsOnly(ex.id);final mode = fit.modeOf(ex.id);final custom = fit.isCustom(ex.id);+ final archived = fit.isArchived(ex.id);return RiseScope(id: 'exercise',@@ -92,6 +95,13 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {),const SizedBox(width: 10),],+ RoundAction(+ label: archived ? t.restoreExercise : t.archiveExercise,+ onTap: () => _toggleArchived(context, ex),+ child: Icon(archived ? PhosphorIconsFill.archive : PhosphorIconsRegular.archive,+ size: 16, color: archived ? gc.accent : gc.textSecondary),+ ),+ const SizedBox(width: 10),RoundAction(onTap: () => fit.toggleFavorite(ex.id),child: _star(gc, fav),@@ -104,10 +114,13 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {padding: const EdgeInsets.symmetric(horizontal: 20),child: Stack(children: [- SizedBox(- width: double.infinity,- child: ExerciseMedia(- ex: ex, height: 220, radius: 22, live: true, bordered: false),+ GestureDetector(+ onTap: () => showExercisePreview(context, ex),+ child: SizedBox(+ width: double.infinity,+ child: ExerciseMedia(+ ex: ex, height: 220, radius: 22, live: true, bordered: false),+ ),),Positioned(bottom: 10,@@ -136,6 +149,14 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [+ AnimatedSize(+ duration: const Duration(milliseconds: 260),+ curve: Curves.easeOutCubic,+ alignment: Alignment.topCenter,+ child: archived+ ? Padding(padding: const EdgeInsets.only(bottom: 16), child: _archivedBanner(gc, ex))+ : const SizedBox(width: double.infinity),+ ),Text(exerciseName(ex),style: AppTheme.f(26, weight: FontWeight.w800, color: gc.text, height: 1.1)),const SizedBox(height: 18),@@ -177,7 +198,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {const SizedBox(height: 20),const StopwatchCard(),const SizedBox(height: 20),- if (pr != null && mode.isEmpty) ...[+ if (pr != null) ...[Container(padding: const EdgeInsets.all(18),decoration: BoxDecoration(@@ -196,18 +217,18 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {children: [_cardLabel(gc, t.personalRecord),const SizedBox(height: 8),- Text(fit.weightLabel(pr.topWeight),+ Text(fit.recordLabel(pr),style: AppTheme.f(30,weight: FontWeight.w800, color: gc.text, height: 1)),],),),- Text(t.oneRmEst(fit.weightLabel(pr.oneRm)),+ Text(fit.recordDetail(pr),style: AppTheme.f(12,weight: FontWeight.w500, color: gc.textSecondary)),],),- if (oneRm.length > 2) ...[+ if (pr.kind == PrKind.weight && oneRm.length > 2) ...[const SizedBox(height: 16),TrendChart(values: [for (final v in oneRm) fit.toDisplayWeight(v)], height: 84, scale: fmt),],@@ -501,6 +522,43 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {);}+ void _toggleArchived(BuildContext context, Exercise ex) {+ fit.toggleArchived(ex.id);+ if (!fit.isArchived(ex.id)) return;+ showNotchToast(+ context,+ t.archivedToast,+ subtitle: t.archivedToastHint,+ icon: PhosphorIconsFill.archive,+ accent: context.gc.accent,+ action: t.undo,+ onTap: () => fit.toggleArchived(ex.id),+ duration: const Duration(milliseconds: 3600),+ );+ }++ Widget _archivedBanner(GymColors gc, Exercise ex) => Container(+ padding: const EdgeInsets.fromLTRB(16, 12, 8, 12),+ decoration: BoxDecoration(color: gc.accentSoft, borderRadius: BorderRadius.circular(16)),+ child: Row(children: [+ Icon(PhosphorIconsFill.archive, size: 17, color: gc.accent),+ const SizedBox(width: 12),+ Expanded(+ child: Text(t.archivedBanner,+ style: AppTheme.f(12.5, weight: FontWeight.w600, color: gc.text, height: 1.35)),+ ),+ GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => fit.toggleArchived(ex.id),+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),+ child: Text(t.restoreExercise,+ style: AppTheme.f(13, weight: FontWeight.w700, color: gc.accent)),+ ),+ ),+ ]),+ );+Widget _cardLabel(GymColors gc, String label) => Text(label.toUpperCase(),style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3));diff --git a/lib/screens/exercises_screen.dart b/lib/screens/exercises_screen.dartindex 2aed5f2..ea7c619 100644--- a/lib/screens/exercises_screen.dart+++ b/lib/screens/exercises_screen.dart@@ -24,10 +24,25 @@ class ExercisesScreen extends StatefulWidget {class _ExercisesScreenState extends State<ExercisesScreen> {late final TextEditingController _c = TextEditingController(text: fit.exSearch);+ final ScrollController _scroll = ScrollController();+ final ValueNotifier<bool> _deep = ValueNotifier(false);++ @override+ void initState() {+ super.initState();+ _scroll.addListener(_track);+ WidgetsBinding.instance.addPostFrameCallback((_) => _track());+ }++ void _track() {+ if (_scroll.hasClients) _deep.value = _scroll.offset > 900;+ }@overridevoid dispose() {_c.dispose();+ _scroll.dispose();+ _deep.dispose();super.dispose();}@@ -46,7 +61,11 @@ class _ExercisesScreenState extends State<ExercisesScreen> {child: _header(context, gc, list.length),),Expanded(- child: ListView.builder(+ child: Stack(children: [+ Positioned.fill(+ child: ListView.builder(+ key: const PageStorageKey('exercises'),+ controller: _scroll,padding: const EdgeInsets.fromLTRB(20, 0, 20, 110),itemCount: list.isEmpty ? 1 : list.length,itemBuilder: (context, i) {@@ -72,7 +91,36 @@ class _ExercisesScreenState extends State<ExercisesScreen> {],);},- ),+ ),+ ),+ Positioned(+ right: 20,+ bottom: 112,+ child: ValueListenableBuilder<bool>(+ valueListenable: _deep,+ builder: (context, deep, _) => IgnorePointer(+ ignoring: !deep,+ child: AnimatedScale(+ scale: deep ? 1 : 0.6,+ duration: const Duration(milliseconds: 220),+ curve: Curves.easeOutCubic,+ child: AnimatedOpacity(+ opacity: deep ? 1 : 0,+ duration: const Duration(milliseconds: 220),+ child: RoundAction(+ size: 44,+ filled: true,+ label: t.backToTop,+ onTap: () => _scroll.animateTo(0,+ duration: const Duration(milliseconds: 520), curve: Curves.easeOutCubic),+ child: Icon(PhosphorIconsBold.arrowUp, size: 18, color: gc.onEmber),+ ),+ ),+ ),+ ),+ ),+ ),+ ]),),],),@@ -110,7 +158,7 @@ class _ExercisesScreenState extends State<ExercisesScreen> {RoundAction(size: 40,label: t.newExercise,- onTap: () => showCreateExerciseSheet(context),+ onTap: () => showCreateExerciseSheet(context, initialName: _c.text),child: Icon(PhosphorIconsRegular.plus, size: 17, color: gc.text),),],@@ -125,9 +173,10 @@ class _ExercisesScreenState extends State<ExercisesScreen> {Widget _quickChips(BuildContext context, GymColors gc) {final active = _activeFilters;- final anyOn = active > 0 || fit.exNoGearOnly || fit.exFavouritesOnly;+ final anyOn = active > 0 || fit.exNoGearOnly || fit.exFavouritesOnly || fit.exMineOnly || fit.exArchivedOnly;return SingleChildScrollView(scrollDirection: Axis.horizontal,+ clipBehavior: Clip.none,child: Row(children: [Pill(label: active > 0 ? '${t.filters} · $active' : t.filters,@@ -160,6 +209,30 @@ class _ExercisesScreenState extends State<ExercisesScreen> {vPad: 7,fontSize: 12.5,),+ if (fit.customExercises.isNotEmpty || fit.exMineOnly) ...[+ const SizedBox(width: 8),+ Pill(+ label: t.mineOnly,+ bg: fit.exMineOnly ? gc.ember : gc.bgRaised2,+ fg: fit.exMineOnly ? gc.onEmber : gc.textSecondary,+ onTap: fit.toggleMineFilter,+ hPad: 14,+ vPad: 7,+ fontSize: 12.5,+ ),+ ],+ if (fit.archived.isNotEmpty) ...[+ const SizedBox(width: 8),+ Pill(+ label: '${t.archivedFilter} · ${fit.archived.length}',+ bg: fit.exArchivedOnly ? gc.ember : gc.bgRaised2,+ fg: fit.exArchivedOnly ? gc.onEmber : gc.textSecondary,+ onTap: fit.toggleArchivedFilter,+ hPad: 14,+ vPad: 7,+ fontSize: 12.5,+ ),+ ],if (anyOn) ...[const SizedBox(width: 8),Pill(@@ -292,9 +365,9 @@ class _FilterChipData {}void showCreateExerciseSheet(BuildContext context,- {void Function(String id)? onCreated, Exercise? editing}) {+ {void Function(String id)? onCreated, Exercise? editing, String initialName = ''}) {final gc = context.gc;- final nameCtrl = TextEditingController(text: editing?.name ?? '');+ final nameCtrl = TextEditingController(text: editing?.name ?? initialName.trim());final stepsCtrl = TextEditingController(text: editing?.steps.join('\n') ?? '');String muscle = editing?.primary ?? kMuscles.first.id;String equipment = editing?.equipment ?? kEquipment.first;diff --git a/lib/state/library_state.dart b/lib/state/library_state.dartindex 2c05849..a0fba9b 100644--- a/lib/state/library_state.dart+++ b/lib/state/library_state.dart@@ -9,6 +9,24 @@ mixin LibraryState on FitCore {int _customSeq = 0;List<Exercise> get allExercises => [...kExercises, ...customExercises];+ bool fitsHere(Exercise ex) => true;++ bool exArchivedOnly = false;++ bool isArchived(String id) => archived.contains(id);++ void toggleArchived(String id) {+ if (!archived.remove(id)) archived.add(id);+ if (archived.isEmpty) exArchivedOnly = false;+ _persist();+ notifyListeners();+ }++ void toggleArchivedFilter() {+ exArchivedOnly = !exArchivedOnly;+ notifyListeners();+ }+Exercise? exerciseById(String id) {for (final e in allExercises) {if (e.id == id) return e;@@ -40,6 +58,7 @@ mixin LibraryState on FitCore {exDifficultyFilter = null;exEquipmentFilter = null;exFavouritesOnly = false;+ exArchivedOnly = false;notifyListeners();}@@ -72,6 +91,7 @@ mixin LibraryState on FitCore {List<Exercise> exercisesMatching(String query) {final matchesSearch = exerciseSearch(query);final list = allExercises.where((ex) {+ if (isArchived(ex.id) != exArchivedOnly) return false;if (exFavouritesOnly && favorites[ex.id] != true) return false;if (!matchesSearch(ex)) return false;if (exMuscleFilter != null &&@@ -209,17 +229,33 @@ mixin LibraryState on FitCore {bool hasCustomMedia(String id) => mediaFor(id).isNotEmpty;+ int? videoMark(String id, int step) => videoMarks[id]?[step];++ void setVideoMark(String id, int step, int? ms) {+ final marks = videoMarks.putIfAbsent(id, () => {});+ if (ms == null) {+ marks.remove(step);+ } else {+ marks[step] = ms;+ }+ if (marks.isEmpty) videoMarks.remove(id);+ _persist();+ notifyListeners();+ }+Future<void> attachExerciseMedia(String id, String srcPath) async {final base = await MediaStore.importFor(id, srcPath);if (base == null) return;final old = mediaFor(id);if (old.isNotEmpty && old != base) await MediaStore.delete(old);exerciseMedia[id] = base;+ videoMarks.remove(id);_persist();notifyListeners();}void clearExerciseMedia(String id) {+ videoMarks.remove(id);final old = exerciseMedia.remove(id);if (old != null && old.isNotEmpty) MediaStore.delete(old);_persist();diff --git a/lib/state/places_state.dart b/lib/state/places_state.dartindex 0e398b5..2e2aa05 100644--- a/lib/state/places_state.dart+++ b/lib/state/places_state.dart@@ -24,6 +24,7 @@ mixin PlacesState on FitCore, LibraryState {return place == null ? kEquipment.toSet() : {...place.equipment, 'Bodyweight'};}+ @overridebool fitsHere(Exercise ex) =>activePlace == null || gearHere.contains(ex.equipment) || isCustom(ex.id);@@ -151,21 +152,36 @@ mixin PlacesState on FitCore, LibraryState {}bool exNoGearOnly = false;+ bool exMineOnly = false;void toggleNoGearFilter() {exNoGearOnly = !exNoGearOnly;+ if (exNoGearOnly) exEquipmentFilter = null;+ notifyListeners();+ }++ void toggleMineFilter() {+ exMineOnly = !exMineOnly;notifyListeners();}+ @override+ void setEquipmentFilter(String e) {+ exNoGearOnly = false;+ super.setEquipmentFilter(e);+ }+@overrideList<Exercise> exercisesMatching(String query) => super.exercisesMatching(query)- .where((ex) => (!exNoGearOnly || ex.equipment == 'Bodyweight') && fitsHere(ex))+ .where((ex) =>+ (!exNoGearOnly || isNoKit(ex)) && (!exMineOnly || isCustom(ex.id)) && fitsHere(ex)).toList();@overridevoid clearExFilters() {exNoGearOnly = false;+ exMineOnly = false;super.clearExFilters();}diff --git a/lib/widgets/exercise_media.dart b/lib/widgets/exercise_media.dartindex 6d911d4..29befe1 100644--- a/lib/widgets/exercise_media.dart+++ b/lib/widgets/exercise_media.dart@@ -157,7 +157,7 @@ class _VideoTileState extends State<_VideoTile> {Widget child;if (_ok && _c != null) {child = FittedBox(- fit: BoxFit.cover,+ fit: BoxFit.contain,clipBehavior: Clip.hardEdge,child: SizedBox(width: _c!.value.size.width,diff --git a/lib/widgets/exercise_preview.dart b/lib/widgets/exercise_preview.dartnew file mode 100644index 0000000..e485c40--- /dev/null+++ b/lib/widgets/exercise_preview.dart@@ -0,0 +1,341 @@+import 'dart:io';++import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import 'package:video_player/video_player.dart';++import '../l10n/l10n.dart';+import '../models/exercise.dart';+import '../services/media_store.dart';+import '../state/fit_state.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import 'exercise_media.dart';+import 'glass.dart';+import 'shimmer.dart';+import 'ui_kit.dart';++Future<void> showExercisePreview(BuildContext context, Exercise ex, {bool suggestions = false}) {+ HapticFeedback.selectionClick();+ return showAppDialog<void>(+ context: context,+ builder: (_) => _ExercisePreview(ex: ex, suggestions: suggestions),+ );+}++class _ExercisePreview extends StatefulWidget {+ const _ExercisePreview({required this.ex, required this.suggestions});++ final Exercise ex;+ final bool suggestions;++ @override+ State<_ExercisePreview> createState() => _ExercisePreviewState();+}++class _ExercisePreviewState extends State<_ExercisePreview> {+ VideoPlayerController? _video;++ Exercise get ex => widget.ex;++ @override+ void initState() {+ super.initState();+ final media = fit.mediaFor(ex.id);+ final path = media.isEmpty ? null : MediaStore.pathFor(media);+ if (path != null && MediaStore.isVideo(media)) _load(path);+ }++ Future<void> _load(String path) async {+ final c = VideoPlayerController.file(File(path));+ setState(() => _video = c);+ try {+ await c.initialize();+ await c.setLooping(true);+ await c.setVolume(0);+ await c.play();+ } catch (_) {+ if (mounted) setState(() => _video = null);+ c.dispose();+ return;+ }+ if (mounted) setState(() {});+ }++ @override+ void dispose() {+ _video?.dispose();+ super.dispose();+ }++ void _seek(int ms) {+ final c = _video;+ if (c == null) return;+ HapticFeedback.selectionClick();+ c.seekTo(Duration(milliseconds: ms));+ c.play();+ }++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final pad = MediaQuery.viewPaddingOf(context);+ final steps = fit.activeExerciseSteps(ex);+ final video = _video;+ return Padding(+ padding: EdgeInsets.fromLTRB(16, pad.top + 24, 16, pad.bottom + 24),+ child: Material(+ color: gc.bgRaised,+ clipBehavior: Clip.antiAlias,+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(28),+ side: BorderSide(color: gc.border),+ ),+ child: AnimatedBuilder(+ animation: fit,+ builder: (context, _) => Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Expanded(+ child: SingleChildScrollView(+ padding: const EdgeInsets.fromLTRB(12, 12, 12, 24),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Stack(children: [+ video == null+ ? ExerciseMedia(ex: ex, height: 250, radius: 20, live: true, bordered: false)+ : _VideoStage(controller: video),+ Positioned(+ top: 10,+ right: 10,+ child: RoundAction(+ label: MaterialLocalizations.of(context).closeButtonLabel,+ onTap: () => Navigator.of(context).pop(),+ child: Icon(PhosphorIconsBold.x, size: 15, color: gc.text),+ ),+ ),+ ]),+ Padding(+ padding: const EdgeInsets.fromLTRB(8, 20, 8, 0),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(exerciseName(ex),+ style: AppTheme.f(24, weight: FontWeight.w800, color: gc.text, height: 1.1)),+ const SizedBox(height: 16),+ Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ _meta(gc, t.primaryLabel, muscleLabel(ex.primary)),+ const SizedBox(width: 18),+ _meta(gc, t.secondaryLabel,+ ex.secondary.isEmpty ? t.none : ex.secondary.map(muscleLabel).join(', ')),+ const SizedBox(width: 18),+ _meta(gc, t.equipmentLabel, t.equipment(ex.equipment)),+ ],+ ),+ if (steps.isNotEmpty) ...[+ const SizedBox(height: 24),+ Text(titleCase(t.howTo),+ style: AppTheme.f(17, weight: FontWeight.w700, color: gc.text)),+ if (video != null) ...[+ const SizedBox(height: 4),+ Text(t.videoMarksHint,+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary, height: 1.4)),+ ],+ const SizedBox(height: 14),+ for (var i = 0; i < steps.length; i++) ...[+ _step(gc, i, steps[i], video),+ if (i < steps.length - 1) const SizedBox(height: 12),+ ],+ ],+ ],+ ),+ ),+ ],+ ),+ ),+ ),+ if (widget.suggestions) _suggestRow(gc),+ ],+ ),+ ),+ ),+ );+ }++ Widget _suggestRow(GymColors gc) => GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => fit.toggleSuggest(ex.id),+ child: Container(+ padding: const EdgeInsets.fromLTRB(20, 16, 20, 18),+ decoration: BoxDecoration(border: Border(top: BorderSide(color: gc.border))),+ child: Row(children: [+ Icon(PhosphorIconsRegular.sparkle, size: 18, color: gc.textSecondary),+ const SizedBox(width: 12),+ Expanded(+ child: Text(t.suggestInWorkouts, style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),+ ),+ TinySwitch(on: fit.suggests(ex.id)),+ ]),+ ),+ );++ Widget _meta(GymColors gc, String label, String value) => Flexible(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(label.toUpperCase(),+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3)),+ const SizedBox(height: 5),+ Text(value,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),+ ],+ ),+ );++ Widget _step(GymColors gc, int i, String text, VideoPlayerController? video) {+ final mark = video == null ? null : fit.videoMark(ex.id, i);+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: mark == null ? null : () => _seek(mark),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Container(+ width: 24,+ height: 24,+ alignment: Alignment.center,+ decoration: BoxDecoration(color: gc.emberSoft, shape: BoxShape.circle),+ child: Text('${i + 1}', style: AppTheme.f(12, weight: FontWeight.w700, color: gc.ember)),+ ),+ const SizedBox(width: 12),+ Expanded(+ child: Text(text, style: AppTheme.f(14, weight: FontWeight.w500, color: gc.textSecondary, height: 1.5)),+ ),+ if (video != null) ...[+ const SizedBox(width: 8),+ mark == null ? _pin(gc, video, i) : _chip(gc, mark, i),+ ],+ ],+ ),+ );+ }++ Widget _pin(GymColors gc, VideoPlayerController video, int i) => Semantics(+ button: true,+ label: t.videoMarkHere,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () {+ HapticFeedback.selectionClick();+ fit.setVideoMark(ex.id, i, video.value.position.inMilliseconds);+ },+ child: Container(+ width: 34,+ height: 26,+ alignment: Alignment.center,+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(100),+ border: Border.all(color: gc.border),+ ),+ child: Icon(PhosphorIconsRegular.pushPin, size: 13, color: gc.textTertiary),+ ),+ ),+ );++ Widget _chip(GymColors gc, int ms, int i) => GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => _seek(ms),+ onLongPress: () {+ HapticFeedback.mediumImpact();+ fit.setVideoMark(ex.id, i, null);+ },+ child: Container(+ height: 26,+ padding: const EdgeInsets.symmetric(horizontal: 10),+ alignment: Alignment.center,+ decoration: BoxDecoration(color: gc.accentSoft, borderRadius: BorderRadius.circular(100)),+ child: Text(_clock(ms), style: AppTheme.f(12, weight: FontWeight.w700, color: gc.accent)),+ ),+ );+}++String _clock(int ms) {+ final s = ms ~/ 1000;+ return '${s ~/ 60}:${(s % 60).toString().padLeft(2, '0')}';+}++class _VideoStage extends StatelessWidget {+ const _VideoStage({required this.controller});++ final VideoPlayerController controller;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final maxHeight = MediaQuery.sizeOf(context).height * 0.5;+ return ClipRRect(+ borderRadius: BorderRadius.circular(20),+ child: ColoredBox(+ color: gc.bgRaised2,+ child: ValueListenableBuilder<VideoPlayerValue>(+ valueListenable: controller,+ builder: (context, v, _) {+ if (!v.isInitialized) return SizedBox(height: 250, child: Shimmer(radius: 20));+ final playing = v.isPlaying;+ return Column(children: [+ GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => playing ? controller.pause() : controller.play(),+ child: ConstrainedBox(+ constraints: BoxConstraints(maxHeight: maxHeight),+ child: Stack(alignment: Alignment.center, children: [+ Center(child: AspectRatio(aspectRatio: v.aspectRatio, child: VideoPlayer(controller))),+ AnimatedOpacity(+ opacity: playing ? 0 : 1,+ duration: const Duration(milliseconds: 200),+ child: Container(+ width: 58,+ height: 58,+ decoration: BoxDecoration(color: gc.bg.withValues(alpha: 0.55), shape: BoxShape.circle),+ child: Icon(PhosphorIconsFill.play, size: 24, color: gc.text),+ ),+ ),+ ]),+ ),+ ),+ Padding(+ padding: const EdgeInsets.fromLTRB(14, 2, 14, 4),+ child: Row(children: [+ Expanded(+ child: SizedBox(+ height: 26,+ child: VideoProgressIndicator(+ controller,+ allowScrubbing: true,+ padding: const EdgeInsets.symmetric(vertical: 10.5),+ colors: VideoProgressColors(+ playedColor: gc.accent,+ bufferedColor: gc.border,+ backgroundColor: gc.bgRaised,+ ),+ ),+ ),+ ),+ const SizedBox(width: 12),+ Text('${_clock(v.position.inMilliseconds)} / ${_clock(v.duration.inMilliseconds)}',+ style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textSecondary)),+ ]),+ ),+ ]);+ },+ ),+ ),+ );+ }+}