Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Screen fixes for web and desktop
InlitXddbf5701b0ad
diff --git a/lib/screens/about_screen.dart b/lib/screens/about_screen.dartindex a76fc5f..5639bc5 100644--- a/lib/screens/about_screen.dart+++ b/lib/screens/about_screen.dart@@ -1,3 +1,4 @@+import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';import 'package:url_launcher/url_launcher.dart';@@ -17,11 +18,16 @@ const _kRepoUrl = 'https://github.com/InlitX/GymMane';const _kKofiUrl = 'https://ko-fi.com/inlitx';class AboutScreen extends StatelessWidget {- const AboutScreen({super.key});+ const AboutScreen({super.key, this.embedded = false});++ final bool embedded;@overrideWidget build(BuildContext context) {final gc = context.gc;+ if (embedded) {+ return Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: riseAll(_content(gc)));+ }return RiseScope(id: 'about',once: false,@@ -40,11 +46,22 @@ class AboutScreen extends StatelessWidget {titleSpacing: 1,),const SizedBox(height: 18),+ ..._content(gc),+ ]),+ ),+ ),+ ),+ );+ }++ List<Widget> _content(GymColors gc) => [_hero(gc),const SizedBox(height: 20),_group(gc, [(PhosphorIconsRegular.gift, t.freeForever, t.freeForeverWhy),- (PhosphorIconsRegular.wifiSlash, t.fullyOffline, t.fullyOfflineWhy),+ kIsWeb+ ? (PhosphorIconsRegular.hardDrives, t.webOwnServer, t.webOwnServerWhy)+ : (PhosphorIconsRegular.wifiSlash, t.fullyOffline, t.fullyOfflineWhy),(PhosphorIconsRegular.export, t.yoursToTake, t.yoursToTakeWhy),]),const SizedBox(height: 18),@@ -62,12 +79,7 @@ class AboutScreen extends StatelessWidget {style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textTertiary, height: 1.6)),const SizedBox(height: 20),_credits(gc),- ]),- ),- ),- ),- );- }+ ];Widget _sectionLabel(GymColors gc, String label) => Text(label.toUpperCase(),style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4));diff --git a/lib/screens/ai_plan_screen.dart b/lib/screens/ai_plan_screen.dartindex 8ad9b85..b89d459 100644--- a/lib/screens/ai_plan_screen.dart+++ b/lib/screens/ai_plan_screen.dart@@ -1,10 +1,7 @@-import 'dart:io';import 'package:flutter/material.dart';import 'package:flutter/services.dart';-import 'package:path_provider/path_provider.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';-import 'package:share_plus/share_plus.dart';import '../l10n/l10n.dart';import '../services/plan_share.dart';@@ -14,6 +11,7 @@ import '../theme/app_theme.dart';import '../widgets/liquid_notch.dart';import '../widgets/ui_kit.dart';import 'plan_import_sheet.dart';+import '../services/file_share.dart';class AiPlanScreen extends StatefulWidget {const AiPlanScreen({super.key});@@ -223,13 +221,8 @@ class _AiPlanScreenState extends State<AiPlanScreen> {Future<void> _export() async {try {- final dir = await getTemporaryDirectory();- final file = File('${dir.path}/gymmane-exercises.txt');- await file.writeAsString(fit.planRequestText());- if (!mounted) return;- await SharePlus.instance.share(- ShareParams(files: [XFile(file.path)], subject: 'GymMane exercises'),- );+ await shareFile('gymmane-exercises.txt', utf8Bytes(fit.planRequestText()),+ mime: 'text/plain', subject: 'GymMane exercises');} catch (_) {}}diff --git a/lib/screens/awards_screen.dart b/lib/screens/awards_screen.dartindex ca4c8aa..b698c90 100644--- a/lib/screens/awards_screen.dart+++ b/lib/screens/awards_screen.dart@@ -152,8 +152,8 @@ class _AwardsScreenState extends State<AwardsScreen> {Widget _grid(BuildContext context, List<AwardId> ids, int rise) {return SliverGrid.builder(itemCount: ids.length,- gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(- crossAxisCount: 2,+ gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(+ maxCrossAxisExtent: 200,mainAxisSpacing: 10,crossAxisSpacing: 10,childAspectRatio: 1.02,diff --git a/lib/screens/compare_screen.dart b/lib/screens/compare_screen.dartindex a785536..ea68c9b 100644--- a/lib/screens/compare_screen.dart+++ b/lib/screens/compare_screen.dart@@ -124,6 +124,7 @@ class _CompareScreenState extends State<CompareScreen> {SizedBox(height: 44,child: ListView(+ key: const PageStorageKey('h-compare_screen-127'),scrollDirection: Axis.horizontal,padding: const EdgeInsets.fromLTRB(20, 4, 20, 4),children: [diff --git a/lib/screens/exercise_detail_screen.dart b/lib/screens/exercise_detail_screen.dartindex 7e69816..82e1f98 100644--- a/lib/screens/exercise_detail_screen.dart+++ b/lib/screens/exercise_detail_screen.dart@@ -4,6 +4,7 @@ import 'package:file_picker/file_picker.dart';import 'package:flutter/material.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import '../app/desktop.dart';import '../l10n/l10n.dart';import '../models/exercise.dart';import '../models/workout.dart';@@ -64,6 +65,338 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {final mode = fit.modeOf(ex.id);final custom = fit.isCustom(ex.id);final archived = fit.isArchived(ex.id);+ final bar = Padding(+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 16),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ RoundBtn(icon: Ic.chevronLeft, onTap: fit.closeExerciseDetail),+ Row(children: [+ if (custom) ...[+ RoundAction(+ label: t.delete,+ onTap: () => _confirmDelete(context, ex),+ child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.textSecondary),+ ),+ const SizedBox(width: 10),+ Semantics(+ button: true,+ label: t.editExercise,+ child: RoundAction(+ onTap: () => showCreateExerciseSheet(context, editing: ex),+ child: Icon(PhosphorIconsRegular.pencilSimple, size: 16, color: gc.textSecondary),+ ),+ ),+ const SizedBox(width: 10),+ if (history.isNotEmpty) ...[+ RoundAction(+ label: t.mergeExercise,+ onTap: () => _merge(context, ex),+ child: Icon(PhosphorIconsRegular.gitMerge, size: 16, color: gc.textSecondary),+ ),+ 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),+ ),+ ]),+ ],+ ),+ );+ final media = Padding(+ padding: const EdgeInsets.symmetric(horizontal: 20),+ child: Stack(+ children: [+ 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,+ right: 10,+ child: Row(+ children: [+ if (hasMedia) ...[+ _mediaBtn(gc, PhosphorIconsRegular.arrowCounterClockwise, t.useDefaultArt,+ () => fit.clearExerciseMedia(ex.id)),+ const SizedBox(width: 8),+ ],+ _mediaBtn(+ gc,+ hasMedia ? PhosphorIconsRegular.pencilSimple : PhosphorIconsRegular.uploadSimple,+ hasMedia ? t.changeMedia : t.addMedia,+ _pickMedia,+ ),+ ],+ ),+ ),+ ],+ ),+ );+ final partA = <Widget>[+ 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)),+ if (ex.aliases.isNotEmpty) ...[+ const SizedBox(height: 6),+ Text(t.alsoCalled(ex.aliases.join(', ')),+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary, height: 1.35)),+ ],+ const SizedBox(height: 18),+ Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ _meta(gc, t.primaryLabel, muscleLabel(ex.primary)),+ const SizedBox(width: 20),+ _meta(gc, t.secondaryLabel, secondary, onTap: () => _editSecondary(context, ex.id)),+ const SizedBox(width: 20),+ _meta(gc, t.equipmentLabel, t.equipment(ex.equipment)),+ ],+ ),+ const SizedBox(height: 18),+ _addToRoutineRow(context, gc, ex),+ const SizedBox(height: 20),+ if (pr != null) ...[+ Container(+ padding: const EdgeInsets.all(18),+ decoration: BoxDecoration(+ color: gc.bgRaised,+ borderRadius: BorderRadius.circular(20),+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Row(+ crossAxisAlignment: CrossAxisAlignment.end,+ children: [+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ _cardLabel(gc, t.personalRecord),+ const SizedBox(height: 8),+ FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerStart,+ child: Text(fit.recordLabel(pr),+ maxLines: 1,+ style: AppTheme.f(30,+ weight: FontWeight.w800, color: gc.text, height: 1)),+ ),+ ],+ ),+ ),+ const SizedBox(width: 10),+ Flexible(+ child: FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerEnd,+ child: Text(fit.recordDetail(pr),+ maxLines: 1,+ style: AppTheme.f(12,+ weight: FontWeight.w500, color: gc.textSecondary)),+ ),+ ),+ ],+ ),+ if (history.length > 1) _bests(gc, ex.id, pr.kind),+ 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),+ ],+ if (pr.kind == PrKind.reps && bestReps.length > 2) ...[+ const SizedBox(height: 16),+ TrendChart(values: bestReps, height: 84, scale: (v) => '${v.round()}'),+ ],+ ],+ ),+ ),+ const SizedBox(height: 20),+ ],+ if (fit.goalFits(ex.id)) ...[+ _goalCard(context, gc, ex.id),+ const SizedBox(height: 20),+ ],+ if (fit.nextTargetLabel(ex.id) != null) ...[+ _nextCard(gc, ex.id),+ const SizedBox(height: 20),+ ],+ _section(gc, t.history),+ const SizedBox(height: 6),+ if (history.isEmpty)+ Text(t.noHistory,+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary))+ else+ for (int i = 0; i < history.length && i < 8; i++)+ _historyRow(gc, history[i], i < history.length - 1 && i < 7, mode),+ const SizedBox(height: 24),+ _notesRow(gc, ex.id),+ const SizedBox(height: 24),+ ];+ final partB = <Widget>[+ if (steps.isNotEmpty || custom) ...[+ Row(children: [+ Expanded(child: _section(gc, t.howTo)),+ if (custom && steps.isNotEmpty)+ Semantics(+ button: true,+ label: t.editExercise,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => showCreateExerciseSheet(context, editing: ex),+ child: Padding(+ padding: const EdgeInsets.all(6),+ child: Icon(PhosphorIconsRegular.pencilSimple, size: 17, color: gc.textTertiary),+ ),+ ),+ ),+ ]),+ const SizedBox(height: 14),+ if (steps.isEmpty) ...[+ Text(t.noStepsYet,+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary, height: 1.45)),+ const SizedBox(height: 12),+ Align(+ alignment: Alignment.centerLeft,+ child: Pill(+ label: t.addSteps,+ bg: gc.bgRaised2,+ fg: gc.accent,+ onTap: () => showCreateExerciseSheet(context, editing: ex),+ ),+ ),+ ],+ for (int i = 0; i < steps.length; i++) ...[+ _step(gc, i + 1, steps[i]),+ if (i < steps.length - 1) const SizedBox(height: 14),+ ],+ ],+ const SizedBox(height: 28),+ _section(gc, t.exerciseSettings),+ const SizedBox(height: 12),+ _group(gc, [+ _modeRow(context, gc, ex.id, mode),+ if (mode != 'cardio') _repsOnlyRow(gc, ex.id, repsOnly),+ if (mode == 'time') ...[+ _switchRow(+ gc,+ PhosphorIconsRegular.arrowsLeftRight,+ t.eachSide,+ t.eachSideHint,+ fit.isEachSide(ex.id),+ () => fit.toggleEachSide(ex.id),+ ),+ _holdProgressRow(gc, ex.id),+ ] else if (mode.isEmpty)+ _switchRow(+ gc,+ PhosphorIconsRegular.arrowsLeftRight,+ t.eachSide,+ t.eachSideRepsHint,+ fit.isSidedReps(ex.id),+ () => fit.toggleSidedReps(ex.id),+ ),+ _restRow(gc, ex.id),+ if (ex.equipment == 'Barbell' || ex.equipment == 'Machine') _barRow(gc, ex),+ if ((ex.equipment == 'Machine' || ex.equipment == 'Cable') && mode.isEmpty && !repsOnly)+ _stackRow(context, gc, ex.id),+ _switchRow(+ gc,+ PhosphorIconsRegular.sparkle,+ t.suggestInWorkouts,+ t.suggestInWorkoutsHint,+ fit.suggests(ex.id),+ () => fit.toggleSuggest(ex.id),+ ),+ if (!repsOnly && mode.isEmpty) ...[+ _switchRow(+ gc,+ PhosphorIconsRegular.arrowFatLinesDown,+ t.assistedSetting,+ t.assistedSettingHint,+ fit.isAssisted(ex.id),+ () => fit.toggleAssisted(ex.id),+ ),+ _progressRow(context, gc, ex.id),+ _switchRow(+ gc,+ PhosphorIconsRegular.fire,+ t.autoWarmup,+ t.autoWarmupHint,+ fit.warmsUp(ex.id),+ () => fit.toggleAutoWarmup(ex.id),+ ),+ ],+ ]),+ if (fit.runsClock(ex.id)) ...[+ const SizedBox(height: 24),+ _section(gc, t.stopwatch),+ const SizedBox(height: 10),+ const StopwatchCard(),+ ],+ if (fit.alternativesHere(ex, 3).isNotEmpty) ...[+ const SizedBox(height: 24),+ _notHere(gc, ex),+ ],+ if (fit.similarExercises(ex, 4).isNotEmpty) ...[+ const SizedBox(height: 24),+ _section(gc, t.similar),+ const SizedBox(height: 10),+ for (final s in fit.similarExercises(ex, 4)) _similarRow(gc, s),+ ],+ ];+ if (DesktopScope.of(context)) {+ return RiseScope(+ key: ValueKey(ex.id),+ id: 'exercise',+ once: false,+ child: SingleChildScrollView(+ clipBehavior: Clip.none,+ padding: const EdgeInsets.fromLTRB(12, 30, 12, 48),+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ Rise(index: 0, child: bar),+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ Rise(index: 1, child: media),+ Padding(+ padding: const EdgeInsets.all(20),+ child: Rise(index: 2, child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: partA)),+ ),+ ]),+ ),+ SizedBox(+ width: 460,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(8, 0, 20, 20),+ child: Rise(index: 3, child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: partB)),+ ),+ ),+ ]),+ ]),+ ),+ );+ }return RiseScope(key: ValueKey(ex.id),@@ -77,308 +410,13 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {child: Column(crossAxisAlignment: CrossAxisAlignment.stretch,children: riseAll([- Padding(- padding: const EdgeInsets.fromLTRB(20, 0, 20, 16),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- RoundBtn(icon: Ic.chevronLeft, onTap: fit.closeExerciseDetail),- Row(children: [- if (custom) ...[- RoundAction(- label: t.delete,- onTap: () => _confirmDelete(context, ex),- child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.textSecondary),- ),- const SizedBox(width: 10),- Semantics(- button: true,- label: t.editExercise,- child: RoundAction(- onTap: () => showCreateExerciseSheet(context, editing: ex),- child: Icon(PhosphorIconsRegular.pencilSimple, size: 16, color: gc.textSecondary),- ),- ),- const SizedBox(width: 10),- if (history.isNotEmpty) ...[- RoundAction(- label: t.mergeExercise,- onTap: () => _merge(context, ex),- child: Icon(PhosphorIconsRegular.gitMerge, size: 16, color: gc.textSecondary),- ),- 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),- ),- ]),- ],- ),- ),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 20),- child: Stack(- children: [- 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,- right: 10,- child: Row(- children: [- if (hasMedia) ...[- _mediaBtn(gc, PhosphorIconsRegular.arrowCounterClockwise, t.useDefaultArt,- () => fit.clearExerciseMedia(ex.id)),- const SizedBox(width: 8),- ],- _mediaBtn(- gc,- hasMedia ? PhosphorIconsRegular.pencilSimple : PhosphorIconsRegular.uploadSimple,- hasMedia ? t.changeMedia : t.addMedia,- _pickMedia,- ),- ],- ),- ),- ],- ),- ),+ bar,+ media,Padding(padding: const EdgeInsets.all(20),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)),- if (ex.aliases.isNotEmpty) ...[- const SizedBox(height: 6),- Text(t.alsoCalled(ex.aliases.join(', ')),- style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary, height: 1.35)),- ],- const SizedBox(height: 18),- Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- _meta(gc, t.primaryLabel, muscleLabel(ex.primary)),- const SizedBox(width: 20),- _meta(gc, t.secondaryLabel, secondary, onTap: () => _editSecondary(context, ex.id)),- const SizedBox(width: 20),- _meta(gc, t.equipmentLabel, t.equipment(ex.equipment)),- ],- ),- const SizedBox(height: 18),- _addToRoutineRow(context, gc, ex),- const SizedBox(height: 20),- if (pr != null) ...[- Container(- padding: const EdgeInsets.all(18),- decoration: BoxDecoration(- color: gc.bgRaised,- borderRadius: BorderRadius.circular(20),- ),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Row(- crossAxisAlignment: CrossAxisAlignment.end,- children: [- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- _cardLabel(gc, t.personalRecord),- const SizedBox(height: 8),- FittedBox(- fit: BoxFit.scaleDown,- alignment: AlignmentDirectional.centerStart,- child: Text(fit.recordLabel(pr),- maxLines: 1,- style: AppTheme.f(30,- weight: FontWeight.w800, color: gc.text, height: 1)),- ),- ],- ),- ),- const SizedBox(width: 10),- Flexible(- child: FittedBox(- fit: BoxFit.scaleDown,- alignment: AlignmentDirectional.centerEnd,- child: Text(fit.recordDetail(pr),- maxLines: 1,- style: AppTheme.f(12,- weight: FontWeight.w500, color: gc.textSecondary)),- ),- ),- ],- ),- if (history.length > 1) _bests(gc, ex.id, pr.kind),- 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),- ],- if (pr.kind == PrKind.reps && bestReps.length > 2) ...[- const SizedBox(height: 16),- TrendChart(values: bestReps, height: 84, scale: (v) => '${v.round()}'),- ],- ],- ),- ),- const SizedBox(height: 20),- ],- if (fit.goalFits(ex.id)) ...[- _goalCard(context, gc, ex.id),- const SizedBox(height: 20),- ],- if (fit.nextTargetLabel(ex.id) != null) ...[- _nextCard(gc, ex.id),- const SizedBox(height: 20),- ],- _section(gc, t.history),- const SizedBox(height: 6),- if (history.isEmpty)- Text(t.noHistory,- style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary))- else- for (int i = 0; i < history.length && i < 8; i++)- _historyRow(gc, history[i], i < history.length - 1 && i < 7, mode),- const SizedBox(height: 24),- _notesRow(gc, ex.id),- const SizedBox(height: 24),- if (steps.isNotEmpty || custom) ...[- Row(children: [- Expanded(child: _section(gc, t.howTo)),- if (custom && steps.isNotEmpty)- Semantics(- button: true,- label: t.editExercise,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () => showCreateExerciseSheet(context, editing: ex),- child: Padding(- padding: const EdgeInsets.all(6),- child: Icon(PhosphorIconsRegular.pencilSimple, size: 17, color: gc.textTertiary),- ),- ),- ),- ]),- const SizedBox(height: 14),- if (steps.isEmpty) ...[- Text(t.noStepsYet,- style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary, height: 1.45)),- const SizedBox(height: 12),- Align(- alignment: Alignment.centerLeft,- child: Pill(- label: t.addSteps,- bg: gc.bgRaised2,- fg: gc.accent,- onTap: () => showCreateExerciseSheet(context, editing: ex),- ),- ),- ],- for (int i = 0; i < steps.length; i++) ...[- _step(gc, i + 1, steps[i]),- if (i < steps.length - 1) const SizedBox(height: 14),- ],- ],- const SizedBox(height: 28),- _section(gc, t.exerciseSettings),- const SizedBox(height: 12),- _group(gc, [- _modeRow(context, gc, ex.id, mode),- if (mode != 'cardio') _repsOnlyRow(gc, ex.id, repsOnly),- if (mode == 'time') ...[- _switchRow(- gc,- PhosphorIconsRegular.arrowsLeftRight,- t.eachSide,- t.eachSideHint,- fit.isEachSide(ex.id),- () => fit.toggleEachSide(ex.id),- ),- _holdProgressRow(gc, ex.id),- ] else if (mode.isEmpty)- _switchRow(- gc,- PhosphorIconsRegular.arrowsLeftRight,- t.eachSide,- t.eachSideRepsHint,- fit.isSidedReps(ex.id),- () => fit.toggleSidedReps(ex.id),- ),- _restRow(gc, ex.id),- if (ex.equipment == 'Barbell' || ex.equipment == 'Machine') _barRow(gc, ex),- if ((ex.equipment == 'Machine' || ex.equipment == 'Cable') && mode.isEmpty && !repsOnly)- _stackRow(context, gc, ex.id),- _switchRow(- gc,- PhosphorIconsRegular.sparkle,- t.suggestInWorkouts,- t.suggestInWorkoutsHint,- fit.suggests(ex.id),- () => fit.toggleSuggest(ex.id),- ),- if (!repsOnly && mode.isEmpty) ...[- _switchRow(- gc,- PhosphorIconsRegular.arrowFatLinesDown,- t.assistedSetting,- t.assistedSettingHint,- fit.isAssisted(ex.id),- () => fit.toggleAssisted(ex.id),- ),- _progressRow(context, gc, ex.id),- _switchRow(- gc,- PhosphorIconsRegular.fire,- t.autoWarmup,- t.autoWarmupHint,- fit.warmsUp(ex.id),- () => fit.toggleAutoWarmup(ex.id),- ),- ],- ]),- if (fit.runsClock(ex.id)) ...[- const SizedBox(height: 24),- _section(gc, t.stopwatch),- const SizedBox(height: 10),- const StopwatchCard(),- ],- if (fit.alternativesHere(ex, 3).isNotEmpty) ...[- const SizedBox(height: 24),- _notHere(gc, ex),- ],- if (fit.similarExercises(ex, 4).isNotEmpty) ...[- const SizedBox(height: 24),- _section(gc, t.similar),- const SizedBox(height: 10),- for (final s in fit.similarExercises(ex, 4)) _similarRow(gc, s),- ],- ],+ children: [...partA, ...partB],),),]),@@ -439,7 +477,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {if (mode == 'cardio') {final km = working.fold<double>(0, (s, x) => s + (x.km ?? 0));return km > 0- ? fit.distanceLabel(km)+ ? fit.distanceLabelFor(e.id, km): durationLabel(working.fold<int>(0, (s, x) => s + (x.sec ?? 0)));}return durationLabel(working.fold<int>(0, (s, x) => (x.sec ?? 0) > s ? x.sec! : s));diff --git a/lib/screens/exercises_screen.dart b/lib/screens/exercises_screen.dartindex c10c68f..fb16b2b 100644--- a/lib/screens/exercises_screen.dart+++ b/lib/screens/exercises_screen.dart@@ -1,11 +1,12 @@-import 'dart:io';import 'dart:math' as math;import 'package:file_picker/file_picker.dart';+import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import '../app/desktop.dart';import '../catalog/exercise_catalog.dart';import '../l10n/l10n.dart';import '../models/exercise.dart';@@ -19,6 +20,7 @@ import '../widgets/exercise_media.dart';import '../widgets/glass.dart';import '../widgets/svg_icon.dart';import '../widgets/ui_kit.dart';+import '../widgets/local_image.dart';class ExercisesScreen extends StatefulWidget {const ExercisesScreen({super.key});@@ -66,6 +68,9 @@ class _ExercisesScreenState extends State<ExercisesScreen> {final contentTop = chipsTop + 34 + 12;return Stack(children: [+ if (DesktopScope.of(context) && list.isNotEmpty)+ Positioned.fill(child: _grid(gc, list, contentTop))+ elsePositioned.fill(child: ListView.builder(key: const PageStorageKey('exercises'),@@ -334,6 +339,7 @@ class _ExercisesScreenState extends State<ExercisesScreen> {if (place.id == fit.activePlaceId) (place.name, () => fit.setActivePlace('')),];return SingleChildScrollView(+ key: const PageStorageKey('h-exercises_screen-342'),scrollDirection: Axis.horizontal,clipBehavior: Clip.none,child: Row(children: [@@ -412,6 +418,57 @@ class _ExercisesScreenState extends State<ExercisesScreen> {return n;}+ Widget _grid(GymColors gc, List<Exercise> list, double top) {+ return LayoutBuilder(builder: (context, box) {+ final n = ((box.maxWidth - 40 + 12) / (340 + 12)).floor().clamp(1, 4);+ final items = <Object>[];+ var i = 0;+ while (i < list.length) {+ final m = list[i].primary;+ var j = i;+ while (j < list.length && list[j].primary == m) {+ j++;+ }+ items.add((m, j - i));+ for (var k = i; k < j; k += n) {+ items.add(list.sublist(k, (k + n).clamp(0, j)));+ }+ i = j;+ }+ return ListView.builder(+ key: const PageStorageKey('exercises'),+ controller: _scroll,+ padding: EdgeInsets.fromLTRB(20, top, 20, 60),+ itemCount: items.length,+ itemBuilder: (context, k) {+ final it = items[k];+ if (it is (String, int)) {+ return Padding(+ padding: EdgeInsets.fromLTRB(4, k == 0 ? 2 : 22, 0, 8),+ child: Row(children: [+ Text(muscleLabel(it.$1).toUpperCase(),+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3)),+ const SizedBox(width: 7),+ Text('${it.$2}',+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textSecondary, letterSpacing: 1.3)),+ ]),+ );+ }+ final row = it as List<Exercise>;+ return Padding(+ padding: const EdgeInsets.only(bottom: 12),+ child: Row(children: [+ for (var c = 0; c < n; c++) ...[+ if (c > 0) const SizedBox(width: 12),+ Expanded(child: c < row.length ? _row(gc, row[c], first: true, last: true) : const SizedBox.shrink()),+ ],+ ]),+ );+ },+ );+ });+ }+Widget _row(GymColors gc, Exercise ex, {required bool first, required bool last}) {final fav = fit.favorites[ex.id] ?? false;return Container(@@ -558,8 +615,19 @@ void showCreateExerciseSheet(BuildContext context,final mediaIsVideo = mediaPath != null && MediaStore.isVideo(mediaPath!);Future<void> pickMedia() async {try {- final res = await FilePicker.platform.pickFiles(type: FileType.media);- final path = res?.files.single.path;+ final res = await FilePicker.platform.pickFiles(type: FileType.media, withData: kIsWeb);+ final picked = res?.files.single;+ if (picked == null) return;+ if (kIsWeb) {+ final bytes = picked.bytes;+ final name = bytes == null+ ? null+ : await MediaStore.saveBytes('custom', MediaStore.extOf(picked.name), bytes);+ final url = name == null ? null : MediaStore.pathFor(name);+ if (url != null) setSheet(() => mediaPath = url);+ return;+ }+ final path = picked.path;if (path != null) setSheet(() => mediaPath = path);} catch (_) {}}@@ -955,7 +1023,7 @@ void showCreateExerciseSheet(BuildContext context,style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),]),)- : Center(child: Image.file(File(mediaPath!), fit: BoxFit.contain, alignment: Alignment.center)),+ : Center(child: Image(image: localImage(mediaPath!), fit: BoxFit.contain, alignment: Alignment.center)),),Positioned(top: 8,diff --git a/lib/screens/history_screen.dart b/lib/screens/history_screen.dartindex e211191..874839d 100644--- a/lib/screens/history_screen.dart+++ b/lib/screens/history_screen.dart@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import '../app/desktop.dart';import '../l10n/l10n.dart';import '../models/workout.dart';import '../state/fit_state.dart';@@ -40,7 +41,27 @@ class HistoryScreen extends StatelessWidget {title: sentenceCase(t.historyTitle),eyebrow: t.profile,onBack: fit.popRoute,- children: [+ children: DesktopScope.of(context)+ ? [+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ SizedBox(width: 420, child: Rise(index: 0, child: _MonthCard(key: ValueKey(month), month: month))),+ const SizedBox(width: 24),+ Expanded(+ child: list.isEmpty+ ? _empty(gc)+ : Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ Text(t.historyWorkouts(list.length),+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4)),+ const SizedBox(height: 10),+ CardFlow(minColumn: 300, maxColumns: 2, gap: 12, children: [+ for (var i = 0; i < list.length; i++)+ Rise(index: i + 1, child: WorkoutHistoryCard(session: list[i], records: records[list[i]] ?? 0)),+ ]),+ ]),+ ),+ ]),+ ]+ : [Rise(index: 0, child: _MonthCard(key: ValueKey(month), month: month)),const SizedBox(height: 22),if (list.isEmpty)diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dartindex 239d19d..c6eae29 100644--- a/lib/screens/home_screen.dart+++ b/lib/screens/home_screen.dart@@ -1,7 +1,11 @@+import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';+import 'history_screen.dart';import '../widgets/body_map.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import '../app/desktop.dart';+import '../widgets/medal.dart' show Medal;import '../l10n/l10n.dart';import '../models/exercise.dart';import '../models/workout.dart';@@ -31,6 +35,7 @@ class HomeScreen extends StatelessWidget {final gc = context.gc;final recommended = fit.recommendedExercises(8);final routines = fit.routinesByLastDone;+ if (DesktopScope.of(context)) return _desktop(context, gc, routines, recommended);return RiseScope(id: 'home',@@ -61,8 +66,115 @@ class HomeScreen extends StatelessWidget {);}+ Widget _desktop(BuildContext context, GymColors gc, List<Routine> routines, List<Exercise> recommended) {+ Medal.warm(context);+ final blocks = _blockMap(context, gc, routines, recommended);+ Widget one(List<Widget> b) =>+ b.length == 1 ? b.single : Column(crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: b);+ final year = fit.heatmapYear;+ const slots = {'weekdays': 1, 'routines': 1, 'folders': 0, 'week': 2, 'nutrition': 2, 'steps': 2, 'activity': 2};+ final hero = fit.showFocus || fit.todayRoutine?.exerciseIds.isNotEmpty == true;+ bool shown(String id) => blocks[id]?.isNotEmpty ?? false;+ final fixed = hero &&+ listEquals(fit.homeOrderShown, kHomeBlocks) &&+ const ['weekdays', 'week', 'routines', 'folders', 'nutrition', 'activity'].every(shown);+ final tiles = <Widget>[];+ final wraps = <Widget Function(Widget)>[];+ void add(Widget w, Widget Function(Widget) wrap) {+ tiles.add(w);+ wraps.add(wrap);+ }+ if (hero) add(_hero(context, gc), (c) => FlowSlot(column: fixed ? 0 : null, child: c));+ if (fit.photoDue) add(_photoNudge(gc), (c) => FlowSlot(column: fixed ? 0 : null, child: c));+ final ids = fixed+ ? [+ for (final id in fit.homeOrderShown)+ if (id != 'recommended' && id != 'activity') id,+ if (!year) 'activity',+ 'recommended',+ if (year) 'activity',+ ]+ : fit.homeOrderShown;+ for (final id in ids) {+ if (blocks[id] case final b? when b.isNotEmpty) {+ add(one(b), switch (id) {+ 'recommended' => year ? (c) => FlowWide(child: c) : (c) => FlowSlot(span: 2, child: c),+ 'activity' when year => (c) => FlowWide(child: c),+ _ => fixed+ ? (c) => FlowSlot(column: slots[id], lift: id == 'week' ? 44 : 0, child: c)+ : (c) => FlowSlot(child: c),+ });+ }+ }+ final risen = riseAll(tiles, from: 1);+ return RiseScope(+ id: 'home',+ child: SingleChildScrollView(+ key: const PageStorageKey('home'),+ clipBehavior: Clip.none,+ padding: const EdgeInsets.fromLTRB(32, 30, 32, 48),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Rise(index: 0, child: _topBar(gc)),+ const SizedBox(height: 26),+ CardFlow(minColumn: 340, gap: 22, children: [+ for (var i = 0; i < risen.length; i++) wraps[i](risen[i]),+ ]),+ if (fit.sessions.isNotEmpty) ...[+ const SizedBox(height: 30),+ Rise(index: risen.length + 1, child: _lastWorkouts(gc)),+ ],+ ],+ ),+ ),+ );+ }++ Widget _lastWorkouts(GymColors gc) {+ final last = [...fit.sessions]..sort((a, b) => b.day.compareTo(a.day));+ final shown = last.take(3).toList();+ return Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ _heading(gc, t.historyTitle, onMore: fit.goHistory),+ const SizedBox(height: 14),+ LayoutBuilder(builder: (context, box) {+ final n = CardFlow.columnsFor(box.maxWidth, minColumn: 340, gap: 22);+ final items = shown.take(n).toList();+ return Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ for (var i = 0; i < n; i++) ...[+ if (i > 0) const SizedBox(width: 22),+ Expanded(child: i < items.length ? WorkoutHistoryCard(session: items[i]) : const SizedBox.shrink()),+ ],+ ]);+ }),+ ]);+ }+List<Widget> _homeBlocks(BuildContext context, GymColors gc, List<Routine> routines, List<Exercise> recommended) {- final blocks = <String, List<Widget>>{+ final blocks = _blockMap(context, gc, routines, recommended);+ final out = <Widget>[];+ String? last;+ for (final id in fit.homeOrderShown) {+ final b = blocks[id];+ if (b == null || b.isEmpty) continue;+ final card = id == 'weekdays' || id == 'steps';+ final gap = last == null+ ? (fit.photoDue ? (card ? 14.0 : 30.0) : (card ? 0.0 : 16.0))+ : (card && (last == 'weekdays' || last == 'steps'))+ ? 14.0+ : id == 'nutrition' && last == 'folders'+ ? 12.0+ : 30.0;+ out.add(SizedBox(height: gap));+ out.addAll(b);+ last = id;+ }+ return out;+ }++ Map<String, List<Widget>> _blockMap(+ BuildContext context, GymColors gc, List<Routine> routines, List<Exercise> recommended) {+ return <String, List<Widget>>{'weekdays': [_away(_weekCard(context, gc))],'steps': [if (fit.stepsOn && fit.stepsAvailable) _away(StepsCard()),@@ -78,6 +190,7 @@ class HomeScreen extends StatelessWidget {builder: (context, box) => SizedBox(height: routineFolderHeight(context),child: ListView.separated(+ key: const PageStorageKey('home-routines'),scrollDirection: Axis.horizontal,clipBehavior: Clip.none,itemCount: routines.length,@@ -120,6 +233,7 @@ class HomeScreen extends StatelessWidget {_section(gc, t.recommended, fit.goExercises, SizedBox(height: 158,child: ListView.separated(+ key: const PageStorageKey('home-recommended'),scrollDirection: Axis.horizontal,itemCount: recommended.length,separatorBuilder: (_, _) => const SizedBox(width: 12),@@ -173,24 +287,6 @@ class HomeScreen extends StatelessWidget {],],};- final out = <Widget>[];- String? last;- for (final id in fit.homeOrderShown) {- final b = blocks[id];- if (b == null || b.isEmpty) continue;- final card = id == 'weekdays' || id == 'steps';- final gap = last == null- ? (fit.photoDue ? (card ? 14.0 : 30.0) : (card ? 0.0 : 16.0))- : (card && (last == 'weekdays' || last == 'steps'))- ? 14.0- : id == 'nutrition' && last == 'folders'- ? 12.0- : 30.0;- out.add(SizedBox(height: gap));- out.addAll(b);- last = id;- }- return out;}Widget _away(Widget child, {double dim = 0.45}) => ScrollAway(radius: 22, dim: dim, child: child);diff --git a/lib/screens/moments_screen.dart b/lib/screens/moments_screen.dartindex 406fc1b..0f29178 100644--- a/lib/screens/moments_screen.dart+++ b/lib/screens/moments_screen.dart@@ -1,401 +1,401 @@-import 'dart:io';-import 'dart:ui' as ui;--import 'package:flutter/material.dart';-import 'package:flutter/services.dart';-import 'package:image_picker/image_picker.dart';-import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';--import '../l10n/l10n.dart';-import '../services/media_store.dart';-import '../state/fit_state.dart';-import '../theme/app_colors.dart';-import '../theme/app_theme.dart';-import '../widgets/entrance.dart';-import '../widgets/sheet_page.dart';-import '../widgets/dialogs.dart';-import '../widgets/file_thumb.dart';-import '../widgets/photo_source_sheet.dart';-import '../widgets/ui_kit.dart';--class MomentsScreen extends StatefulWidget {- const MomentsScreen({super.key});-- @override- State<MomentsScreen> createState() => _MomentsScreenState();-}--class _MomentsScreenState extends State<MomentsScreen> {- bool _busy = false;- bool _grouped = false;-- Future<void> _add() async {- if (_busy) return;- final source = await pickPhotoSource(context);- if (source == null) return;- setState(() => _busy = true);- await addMomentsFrom(source);- if (mounted) setState(() => _busy = false);- }-- void _open(Moment moment) => openMoment(context, moment);-- void _press(Moment moment) {- if (fit.momentPicks.isEmpty) return _open(moment);- fit.toggleMomentPick(moment.file);- }-- void _hold(Moment moment) {- HapticFeedback.selectionClick();- fit.toggleMomentPick(moment.file);- }-- Future<void> _removePicked() async {- final n = fit.momentPicks.length;- final ok = await askConfirm(- context,- title: n == 1 ? t.deletePhotoTitle : t.deletePhotosTitle(n),- body: t.deletePhotoBody,- confirmLabel: t.delete,- danger: true,- );- if (ok) fit.deleteMoments([...fit.momentPicks]);- }-- Widget _picked(GymColors gc, Moment moment, Widget child) {- final on = fit.momentPicks.contains(moment.file);- if (fit.momentPicks.isEmpty) return child;- return Stack(- fit: StackFit.expand,- children: [- AnimatedScale(- scale: on ? 0.9 : 1,- duration: const Duration(milliseconds: 160),- curve: Curves.easeOut,- child: child,- ),- Positioned(- top: 8,- right: 8,- child: AnimatedContainer(- duration: const Duration(milliseconds: 160),- width: 22,- height: 22,- decoration: BoxDecoration(- shape: BoxShape.circle,- color: on ? gc.accent : Colors.black.withValues(alpha: 0.3),- border: Border.all(color: Colors.white, width: 1.6),- ),- child: on ? const Icon(PhosphorIconsBold.check, size: 12, color: Colors.black) : null,- ),- ),- ],- );- }-- @override- Widget build(BuildContext context) {- final gc = context.gc;- final shots = fit.momentsNewest;- final picks = fit.momentPicks.length;-- return RiseScope(- id: 'moments',- once: false,- child: SheetPage(- title: t.photosCard,- eyebrow: picks > 0 ? t.photosSelected(picks) : t.profile,- onBack: fit.backFromMoments,- actions: picks > 0- ? [- RoundAction(- onTap: _removePicked,- label: t.delete,- child: Icon(PhosphorIconsRegular.trash, size: 17, color: gc.danger),- ),- RoundAction(- onTap: fit.clearMomentPicks,- label: t.cancel,- child: Icon(PhosphorIconsRegular.x, size: 17, color: gc.text),- ),- ]- : [- RoundAction(- onTap: () => setState(() => _grouped = !_grouped),- label: t.photosCard,- child: Icon(_grouped ? PhosphorIconsRegular.squaresFour : PhosphorIconsRegular.rows,- size: 17, color: gc.text),- ),- RoundAction(- onTap: _add,- label: t.snapNow,- child: Icon(PhosphorIconsRegular.camera, size: 17, color: gc.text),- ),- ],- slivers: shots.isEmpty- ? [SliverToBoxAdapter(child: Rise(index: 0, child: _empty(gc)))]- : [- SliverToBoxAdapter(child: Rise(index: 0, child: _stats(gc, shots))),- const SliverToBoxAdapter(child: SizedBox(height: 22)),- if (_grouped) ..._byDate(gc, shots) else _plainGrid(gc, shots),- ],- ),- );- }-- Widget _stats(GymColors gc, List<Moment> shots) {- final now = DateTime.now();- final month = shots.where((m) => m.date.year == now.year && m.date.month == now.month).length;- final days = {for (final m in shots) DateTime(m.date.year, m.date.month, m.date.day)}.length;- Widget cell(String value, String label) => Expanded(- child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- RollIn(value, style: AppTheme.f(26, weight: FontWeight.w800, color: gc.text, height: 1.05)),- const SizedBox(height: 5),- Text(label.toUpperCase(),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(9.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.1)),- ]),- );- return Container(- padding: const EdgeInsets.fromLTRB(18, 18, 18, 16),- decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(24)),- child: Row(children: [- cell('${shots.length}', t.photosCard),- cell('$month', t.momentsThisMonth),- cell('$days', t.momentsDays),- ]),- );- }-- Widget _plainGrid(GymColors gc, List<Moment> shots) {- return SliverGrid.builder(- itemCount: shots.length,- gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(- crossAxisCount: 3,- mainAxisSpacing: 8,- crossAxisSpacing: 8,- childAspectRatio: 0.74,- ),- itemBuilder: (_, i) => _tile(gc, shots[i]),- );- }-- String _bucket(DateTime d) {- final now = DateTime.now();- final day = DateTime(d.year, d.month, d.day);- final today = DateTime(now.year, now.month, now.day);- final days = today.difference(day).inDays;- if (days <= 0) return titleCase(t.today);- if (days < 7) return titleCase(t.thisWeek);- if (d.year == now.year) return t.monthName(d.month);- return '${t.monthName(d.month)} ${d.year}';- }-- List<Widget> _byDate(GymColors gc, List<Moment> shots) {- final groups = <String, List<Moment>>{};- for (final m in shots) {- groups.putIfAbsent(_bucket(m.date), () => []).add(m);- }- return [- for (final entry in groups.entries) ...[- SliverToBoxAdapter(- child: Padding(- padding: const EdgeInsets.fromLTRB(2, 6, 0, 12),- child: Text(entry.key, style: AppTheme.f(16, color: gc.text)),- ),- ),- SliverGrid.builder(- itemCount: entry.value.length,- gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(- crossAxisCount: 3,- mainAxisSpacing: 10,- crossAxisSpacing: 10,- ),- itemBuilder: (_, i) => _square(gc, entry.value[i]),- ),- const SliverToBoxAdapter(child: SizedBox(height: 24)),- ],- ];- }-- Widget _square(GymColors gc, Moment moment) {- final path = MediaStore.pathFor(moment.file) ?? '';- return GestureDetector(- onTap: () => _press(moment),- onLongPress: () => _hold(moment),- child: _picked(- gc,- moment,- ClipRRect(- borderRadius: BorderRadius.circular(20),- child: Hero(- tag: moment.file,- flightShuttleBuilder: _photoFlight(path),- child: FileThumb(path, errorBuilder: (_, _, _) => ColoredBox(color: gc.bgRaised2)),- ),- ),- ),- );- }-- Widget _empty(GymColors gc) {- return Padding(- padding: const EdgeInsets.only(top: 60),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Icon(PhosphorIconsRegular.camera, size: 34, color: gc.textTertiary),- const SizedBox(height: 14),- Text(t.momentsEmptyTitle, style: AppTheme.f(16, color: gc.text)),- const SizedBox(height: 6),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 40),- child: Text(t.momentsEmptyHint,- textAlign: TextAlign.center,- style: AppTheme.f(12.5,- weight: FontWeight.w500, color: gc.textTertiary, height: 1.45)),- ),- const SizedBox(height: 18),- GhostButton(label: t.snapNow, icon: PhosphorIconsRegular.camera, onTap: _add),- ],- ),- );- }-- Widget _tile(GymColors gc, Moment moment) {- final path = MediaStore.pathFor(moment.file) ?? '';- return GestureDetector(- onTap: () => _press(moment),- onLongPress: () => _hold(moment),- child: _picked(gc, moment, ClipRRect(- borderRadius: BorderRadius.circular(14),- child: Stack(- fit: StackFit.expand,- children: [- Hero(- tag: moment.file,- flightShuttleBuilder: _photoFlight(path),- child: FileThumb(path, errorBuilder: (_, _, _) => ColoredBox(color: gc.bgRaised2)),- ),- Positioned(- left: 0,- right: 0,- bottom: 0,- child: Container(- padding: const EdgeInsets.symmetric(vertical: 5),- color: Colors.black.withValues(alpha: 0.45),- child: Text(t.shortDate(moment.date),- textAlign: TextAlign.center,- style: AppTheme.f(10.5, weight: FontWeight.w600, color: Colors.white)),- ),- ),- ],- ),- )),- );- }-}--Future<void> addMomentsFrom(ImageSource source, {DateTime? date}) async {- try {- if (source == ImageSource.gallery) {- final shots = await ImagePicker().pickMultiImage(maxWidth: 1440, maxHeight: 1920, imageQuality: 88);- for (final shot in shots) {- await fit.addMoment(shot.path, date: date);- }- return;- }- final shot = await ImagePicker().pickImage(source: source, maxWidth: 1440, maxHeight: 1920, imageQuality: 88);- if (shot == null) return;- await fit.addMoment(shot.path, date: date);- } catch (_) {}-}--HeroFlightShuttleBuilder _photoFlight(String path) => (_, animation, _, _, _) => AnimatedBuilder(- animation: animation,- builder: (_, _) => ClipRRect(- borderRadius: BorderRadius.circular(ui.lerpDouble(18, 22, animation.value)!),- child: SizedBox.expand(- child: Image.file(File(path), fit: BoxFit.cover, gaplessPlayback: true),- ),- ),- );--Future<void> openMoment(BuildContext context, Moment moment) async {- final path = MediaStore.pathFor(moment.file) ?? '';- if (path.isEmpty) return;- try {- await precacheImage(FileImage(File(path)), context);- } catch (_) {}- if (!context.mounted) return;- await Navigator.of(context).push(PageRouteBuilder<void>(- opaque: false,- barrierColor: Colors.transparent,- transitionDuration: const Duration(milliseconds: 280),- reverseTransitionDuration: const Duration(milliseconds: 220),- pageBuilder: (_, animation, _) => _PhotoView(moment: moment, path: path, animation: animation),- ));-}--class _PhotoView extends StatelessWidget {- const _PhotoView({required this.moment, required this.path, required this.animation});-- final Moment moment;- final String path;- final Animation<double> animation;-- @override- Widget build(BuildContext context) {- final gc = context.gc;- return AnimatedBuilder(- animation: animation,- builder: (context, _) {- final v = Curves.easeOutCubic.transform(animation.value);- return Material(- type: MaterialType.transparency,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () => Navigator.of(context).pop(),- child: Stack(- children: [- Positioned.fill(- child: BackdropFilter(- filter: ui.ImageFilter.blur(sigmaX: 20 * v, sigmaY: 20 * v),- child: ColoredBox(color: gc.pageBg.withValues(alpha: 0.62 * v)),- ),- ),- Center(- child: Padding(- padding: const EdgeInsets.fromLTRB(24, 86, 24, 36),- child: Hero(- tag: moment.file,- flightShuttleBuilder: _photoFlight(path),- child: ClipRRect(- borderRadius: BorderRadius.circular(22),- child: Image.file(File(path), fit: BoxFit.contain),- ),- ),- ),- ),- Positioned(- left: 0,- right: 0,- bottom: 54,- child: Opacity(- opacity: v,- child: Text(- t.fullDate(moment.date),- textAlign: TextAlign.center,- style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),- ),- ),- ),- ],- ),- ),- );- },- );- }-}+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:image_picker/image_picker.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';++import '../l10n/l10n.dart';+import '../services/media_store.dart';+import '../state/fit_state.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import '../widgets/entrance.dart';+import '../widgets/sheet_page.dart';+import '../widgets/dialogs.dart';+import '../widgets/file_thumb.dart';+import '../widgets/photo_source_sheet.dart';+import '../widgets/ui_kit.dart';+import '../widgets/local_image.dart';++class MomentsScreen extends StatefulWidget {+ const MomentsScreen({super.key});++ @override+ State<MomentsScreen> createState() => _MomentsScreenState();+}++class _MomentsScreenState extends State<MomentsScreen> {+ bool _busy = false;+ bool _grouped = false;++ Future<void> _add() async {+ if (_busy) return;+ final source = await pickPhotoSource(context);+ if (source == null) return;+ setState(() => _busy = true);+ await addMomentsFrom(source);+ if (mounted) setState(() => _busy = false);+ }++ void _open(Moment moment) => openMoment(context, moment);++ void _press(Moment moment) {+ if (fit.momentPicks.isEmpty) return _open(moment);+ fit.toggleMomentPick(moment.file);+ }++ void _hold(Moment moment) {+ HapticFeedback.selectionClick();+ fit.toggleMomentPick(moment.file);+ }++ Future<void> _removePicked() async {+ final n = fit.momentPicks.length;+ final ok = await askConfirm(+ context,+ title: n == 1 ? t.deletePhotoTitle : t.deletePhotosTitle(n),+ body: t.deletePhotoBody,+ confirmLabel: t.delete,+ danger: true,+ );+ if (ok) fit.deleteMoments([...fit.momentPicks]);+ }++ Widget _picked(GymColors gc, Moment moment, Widget child) {+ final on = fit.momentPicks.contains(moment.file);+ if (fit.momentPicks.isEmpty) return child;+ return Stack(+ fit: StackFit.expand,+ children: [+ AnimatedScale(+ scale: on ? 0.9 : 1,+ duration: const Duration(milliseconds: 160),+ curve: Curves.easeOut,+ child: child,+ ),+ Positioned(+ top: 8,+ right: 8,+ child: AnimatedContainer(+ duration: const Duration(milliseconds: 160),+ width: 22,+ height: 22,+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ color: on ? gc.accent : Colors.black.withValues(alpha: 0.3),+ border: Border.all(color: Colors.white, width: 1.6),+ ),+ child: on ? const Icon(PhosphorIconsBold.check, size: 12, color: Colors.black) : null,+ ),+ ),+ ],+ );+ }++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final shots = fit.momentsNewest;+ final picks = fit.momentPicks.length;++ return RiseScope(+ id: 'moments',+ once: false,+ child: SheetPage(+ title: t.photosCard,+ eyebrow: picks > 0 ? t.photosSelected(picks) : t.profile,+ onBack: fit.backFromMoments,+ actions: picks > 0+ ? [+ RoundAction(+ onTap: _removePicked,+ label: t.delete,+ child: Icon(PhosphorIconsRegular.trash, size: 17, color: gc.danger),+ ),+ RoundAction(+ onTap: fit.clearMomentPicks,+ label: t.cancel,+ child: Icon(PhosphorIconsRegular.x, size: 17, color: gc.text),+ ),+ ]+ : [+ RoundAction(+ onTap: () => setState(() => _grouped = !_grouped),+ label: t.photosCard,+ child: Icon(_grouped ? PhosphorIconsRegular.squaresFour : PhosphorIconsRegular.rows,+ size: 17, color: gc.text),+ ),+ RoundAction(+ onTap: _add,+ label: t.snapNow,+ child: Icon(PhosphorIconsRegular.camera, size: 17, color: gc.text),+ ),+ ],+ slivers: shots.isEmpty+ ? [SliverToBoxAdapter(child: Rise(index: 0, child: _empty(gc)))]+ : [+ SliverToBoxAdapter(child: Rise(index: 0, child: _stats(gc, shots))),+ const SliverToBoxAdapter(child: SizedBox(height: 22)),+ if (_grouped) ..._byDate(gc, shots) else _plainGrid(gc, shots),+ ],+ ),+ );+ }++ Widget _stats(GymColors gc, List<Moment> shots) {+ final now = DateTime.now();+ final month = shots.where((m) => m.date.year == now.year && m.date.month == now.month).length;+ final days = {for (final m in shots) DateTime(m.date.year, m.date.month, m.date.day)}.length;+ Widget cell(String value, String label) => Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ RollIn(value, style: AppTheme.f(26, weight: FontWeight.w800, color: gc.text, height: 1.05)),+ const SizedBox(height: 5),+ Text(label.toUpperCase(),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(9.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.1)),+ ]),+ );+ return Container(+ padding: const EdgeInsets.fromLTRB(18, 18, 18, 16),+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(24)),+ child: Row(children: [+ cell('${shots.length}', t.photosCard),+ cell('$month', t.momentsThisMonth),+ cell('$days', t.momentsDays),+ ]),+ );+ }++ Widget _plainGrid(GymColors gc, List<Moment> shots) {+ return SliverGrid.builder(+ itemCount: shots.length,+ gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(+ crossAxisCount: 3,+ mainAxisSpacing: 8,+ crossAxisSpacing: 8,+ childAspectRatio: 0.74,+ ),+ itemBuilder: (_, i) => _tile(gc, shots[i]),+ );+ }++ String _bucket(DateTime d) {+ final now = DateTime.now();+ final day = DateTime(d.year, d.month, d.day);+ final today = DateTime(now.year, now.month, now.day);+ final days = today.difference(day).inDays;+ if (days <= 0) return titleCase(t.today);+ if (days < 7) return titleCase(t.thisWeek);+ if (d.year == now.year) return t.monthName(d.month);+ return '${t.monthName(d.month)} ${d.year}';+ }++ List<Widget> _byDate(GymColors gc, List<Moment> shots) {+ final groups = <String, List<Moment>>{};+ for (final m in shots) {+ groups.putIfAbsent(_bucket(m.date), () => []).add(m);+ }+ return [+ for (final entry in groups.entries) ...[+ SliverToBoxAdapter(+ child: Padding(+ padding: const EdgeInsets.fromLTRB(2, 6, 0, 12),+ child: Text(entry.key, style: AppTheme.f(16, color: gc.text)),+ ),+ ),+ SliverGrid.builder(+ itemCount: entry.value.length,+ gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(+ crossAxisCount: 3,+ mainAxisSpacing: 10,+ crossAxisSpacing: 10,+ ),+ itemBuilder: (_, i) => _square(gc, entry.value[i]),+ ),+ const SliverToBoxAdapter(child: SizedBox(height: 24)),+ ],+ ];+ }++ Widget _square(GymColors gc, Moment moment) {+ final path = MediaStore.pathFor(moment.file) ?? '';+ return GestureDetector(+ onTap: () => _press(moment),+ onLongPress: () => _hold(moment),+ child: _picked(+ gc,+ moment,+ ClipRRect(+ borderRadius: BorderRadius.circular(20),+ child: Hero(+ tag: moment.file,+ flightShuttleBuilder: _photoFlight(path),+ child: FileThumb(path, errorBuilder: (_, _, _) => ColoredBox(color: gc.bgRaised2)),+ ),+ ),+ ),+ );+ }++ Widget _empty(GymColors gc) {+ return Padding(+ padding: const EdgeInsets.only(top: 60),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Icon(PhosphorIconsRegular.camera, size: 34, color: gc.textTertiary),+ const SizedBox(height: 14),+ Text(t.momentsEmptyTitle, style: AppTheme.f(16, color: gc.text)),+ const SizedBox(height: 6),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 40),+ child: Text(t.momentsEmptyHint,+ textAlign: TextAlign.center,+ style: AppTheme.f(12.5,+ weight: FontWeight.w500, color: gc.textTertiary, height: 1.45)),+ ),+ const SizedBox(height: 18),+ GhostButton(label: t.snapNow, icon: PhosphorIconsRegular.camera, onTap: _add),+ ],+ ),+ );+ }++ Widget _tile(GymColors gc, Moment moment) {+ final path = MediaStore.pathFor(moment.file) ?? '';+ return GestureDetector(+ onTap: () => _press(moment),+ onLongPress: () => _hold(moment),+ child: _picked(gc, moment, ClipRRect(+ borderRadius: BorderRadius.circular(14),+ child: Stack(+ fit: StackFit.expand,+ children: [+ Hero(+ tag: moment.file,+ flightShuttleBuilder: _photoFlight(path),+ child: FileThumb(path, errorBuilder: (_, _, _) => ColoredBox(color: gc.bgRaised2)),+ ),+ Positioned(+ left: 0,+ right: 0,+ bottom: 0,+ child: Container(+ padding: const EdgeInsets.symmetric(vertical: 5),+ color: Colors.black.withValues(alpha: 0.45),+ child: Text(t.shortDate(moment.date),+ textAlign: TextAlign.center,+ style: AppTheme.f(10.5, weight: FontWeight.w600, color: Colors.white)),+ ),+ ),+ ],+ ),+ )),+ );+ }+}++Future<void> addMomentsFrom(ImageSource source, {DateTime? date}) async {+ try {+ if (source == ImageSource.gallery) {+ final shots = await ImagePicker().pickMultiImage(maxWidth: 1440, maxHeight: 1920, imageQuality: 88);+ for (final shot in shots) {+ await fit.addMoment(shot.path, date: date);+ }+ return;+ }+ final shot = await ImagePicker().pickImage(source: source, maxWidth: 1440, maxHeight: 1920, imageQuality: 88);+ if (shot == null) return;+ await fit.addMoment(shot.path, date: date);+ } catch (_) {}+}++HeroFlightShuttleBuilder _photoFlight(String path) => (_, animation, _, _, _) => AnimatedBuilder(+ animation: animation,+ builder: (_, _) => ClipRRect(+ borderRadius: BorderRadius.circular(ui.lerpDouble(18, 22, animation.value)!),+ child: SizedBox.expand(+ child: Image(image: localImage(path), fit: BoxFit.cover, gaplessPlayback: true),+ ),+ ),+ );++Future<void> openMoment(BuildContext context, Moment moment) async {+ final path = MediaStore.pathFor(moment.file) ?? '';+ if (path.isEmpty) return;+ try {+ await precacheImage(localImage(path), context);+ } catch (_) {}+ if (!context.mounted) return;+ await Navigator.of(context).push(PageRouteBuilder<void>(+ opaque: false,+ barrierColor: Colors.transparent,+ transitionDuration: const Duration(milliseconds: 280),+ reverseTransitionDuration: const Duration(milliseconds: 220),+ pageBuilder: (_, animation, _) => _PhotoView(moment: moment, path: path, animation: animation),+ ));+}++class _PhotoView extends StatelessWidget {+ const _PhotoView({required this.moment, required this.path, required this.animation});++ final Moment moment;+ final String path;+ final Animation<double> animation;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ return AnimatedBuilder(+ animation: animation,+ builder: (context, _) {+ final v = Curves.easeOutCubic.transform(animation.value);+ return Material(+ type: MaterialType.transparency,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => Navigator.of(context).pop(),+ child: Stack(+ children: [+ Positioned.fill(+ child: BackdropFilter(+ filter: ui.ImageFilter.blur(sigmaX: 20 * v, sigmaY: 20 * v),+ child: ColoredBox(color: gc.pageBg.withValues(alpha: 0.62 * v)),+ ),+ ),+ Center(+ child: Padding(+ padding: const EdgeInsets.fromLTRB(24, 86, 24, 36),+ child: Hero(+ tag: moment.file,+ flightShuttleBuilder: _photoFlight(path),+ child: ClipRRect(+ borderRadius: BorderRadius.circular(22),+ child: Image(image: localImage(path), fit: BoxFit.contain),+ ),+ ),+ ),+ ),+ Positioned(+ left: 0,+ right: 0,+ bottom: 54,+ child: Opacity(+ opacity: v,+ child: Text(+ t.fullDate(moment.date),+ textAlign: TextAlign.center,+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),+ ),+ ),+ ),+ ],+ ),+ ),+ );+ },+ );+ }+}diff --git a/lib/screens/notes_screen.dart b/lib/screens/notes_screen.dartindex 9cab8d3..ff7e28a 100644--- a/lib/screens/notes_screen.dart+++ b/lib/screens/notes_screen.dart@@ -1,6 +1,7 @@import 'package:flutter/material.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import '../app/desktop.dart';import '../l10n/l10n.dart';import '../models/exercise.dart';import '../models/note.dart';@@ -20,18 +21,19 @@ class NotesScreen extends StatelessWidget {final scoped = fit.noteScope.isEmpty ? null : fit.exerciseById(fit.noteScope);final all = fit.notesAllView;final folder = fit.openFolder;+ final wide = DesktopScope.of(context);return SafeArea(bottom: false,child: Column(children: [Padding(- padding: const EdgeInsets.fromLTRB(20, 12, 20, 0),+ padding: wide ? const EdgeInsets.fromLTRB(32, 30, 32, 0) : const EdgeInsets.fromLTRB(20, 12, 20, 0),child: ScreenHeader(title: folder != null? folder.name.toUpperCase(): (scoped == null ? t.journal : exerciseName(scoped).toUpperCase()),- subtitle: all ? t.noteCount(fit.notesInScope.length) : t.noteMonthCount(fit.notesInMonth),+ subtitle: all || wide ? t.noteCount(fit.notesInScope.length) : t.noteMonthCount(fit.notesInMonth),onBack: fit.backFromNotes,actions: [_action(@@ -52,7 +54,7 @@ class NotesScreen extends StatelessWidget {label: t.moreOptions,onTap: () => showNoteFolderMenu(context, folder),)- else+ else if (!wide)_action(gc,icon: all ? PhosphorIconsRegular.calendarBlank : PhosphorIconsRegular.listBullets,@@ -64,14 +66,87 @@ class NotesScreen extends StatelessWidget {),const SizedBox(height: 16),Expanded(- child: all- ? _allNotes(context, gc, scoped == null, folders: scoped == null && folder == null)- : _calendar(context, gc, scoped == null)),+ child: wide+ ? _desktop(context, gc, scoped == null, folders: scoped == null && folder == null)+ : all+ ? _allNotes(context, gc, scoped == null, folders: scoped == null && folder == null)+ : _calendar(context, gc, scoped == null)),],),);}+ Widget _desktop(BuildContext context, GymColors gc, bool showExercise, {required bool folders}) {+ final visible = fit.notesFiltered;+ return Padding(+ padding: const EdgeInsets.symmetric(horizontal: 12),+ child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ SizedBox(width: 380, child: _calendar(context, gc, showExercise)),+ const SizedBox(width: 8),+ Expanded(+ child: Column(children: [+ if (folders) _folders(context, gc),+ if (fit.notesInScope.isNotEmpty)+ NoteFilterBar(+ selected: fit.noteFilter,+ counts: fit.noteKindCounts,+ onPick: fit.setNoteFilter,+ padding: const EdgeInsets.symmetric(horizontal: 20),+ ),+ Expanded(+ child: visible.isEmpty+ ? _empty(gc)+ : ListView(+ padding: const EdgeInsets.fromLTRB(20, 14, 20, 32),+ children: _groupedGrid(gc, visible, showExercise: showExercise),+ ),+ ),+ ]),+ ),+ ]),+ );+ }++ List<Widget> _groupedGrid(GymColors gc, List<GymNote> notes, {required bool showExercise}) {+ final out = <Widget>[];+ final groups = <(DateTime, List<GymNote>)>[];+ for (final n in notes) {+ final d = DateTime(n.date.year, n.date.month, n.date.day);+ if (groups.isEmpty || groups.last.$1 != d) groups.add((d, []));+ groups.last.$2.add(n);+ }+ for (final (d, list) in groups) {+ out.add(_dayHeading(gc, d, first: out.isEmpty));+ out.add(CardFlow(minColumn: 320, maxColumns: 3, gap: 12, children: [+ for (final n in list) NoteCard(note: n, showExercise: showExercise, showDate: false),+ ]));+ }+ return out;+ }++ Widget _dayHeading(GymColors gc, DateTime d, {required bool first}) => Padding(+ padding: EdgeInsets.only(top: first ? 0 : 18, bottom: 12),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.end,+ children: [+ Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(noteDayLabel(d).toUpperCase(),+ style: AppTheme.f(12.5, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),+ const SizedBox(height: 3),+ Text(t.fullDate(d), style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),+ ],+ ),+ const SizedBox(width: 12),+ Expanded(child: Padding(+ padding: const EdgeInsets.only(bottom: 6),+ child: Container(height: 1, color: gc.border),+ )),+ ],+ ),+ );+Widget _action(GymColors gc, {required IconData icon,@@ -207,6 +282,7 @@ class NotesScreen extends StatelessWidget {SizedBox(height: noteFolderHeight(context),child: ListView.separated(+ key: const PageStorageKey('h-notes_screen-285'),scrollDirection: Axis.horizontal,padding: const EdgeInsets.symmetric(horizontal: 20),itemCount: fit.noteFolders.length + 1,diff --git a/lib/screens/onboarding_screen.dart b/lib/screens/onboarding_screen.dartindex dbd1afb..f6a5e6e 100644--- a/lib/screens/onboarding_screen.dart+++ b/lib/screens/onboarding_screen.dart@@ -1,5 +1,6 @@import 'dart:math' as math;+import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';import 'package:flutter/scheduler.dart';import 'package:flutter/services.dart';@@ -8,6 +9,7 @@ import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';import '../catalog/body_art.dart';import '../catalog/exercise_catalog.dart';+import '../app/desktop.dart';import '../l10n/l10n.dart';import '../services/device_kind.dart';import '../state/fit_state.dart';@@ -42,6 +44,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {bool _probing = false;bool _blur = false;bool _motion = false;+ bool _wide = false;@overridevoid initState() {@@ -178,6 +181,34 @@ class _OnboardingScreenState extends State<OnboardingScreen> {@overrideWidget build(BuildContext context) {final gc = context.gc;+ _wide = DesktopScope.wideFor(MediaQuery.sizeOf(context).width);+ final content = Column(+ children: [+ ValueListenableBuilder<int>(valueListenable: _at, builder: (_, _, _) => _topBar(gc)),+ Expanded(+ child: RepaintBoundary(+ child: PageView(+ controller: _page,+ onPageChanged: _onPage,+ children: [+ for (final page in [+ _welcome(gc),+ _nameStep(gc),+ _photoStep(gc),+ _unitsStep(gc),+ _bodyStep(gc),+ _goalStep(gc),+ _placeStep(gc),+ if (_slow) _speedStep(gc),+ ])+ RepaintBoundary(child: page),+ ],+ ),+ ),+ ),+ ValueListenableBuilder<int>(valueListenable: _at, builder: (_, _, _) => _bottomBar(gc)),+ ],+ );return Scaffold(backgroundColor: gc.bg,resizeToAvoidBottomInset: false,@@ -186,33 +217,22 @@ class _OnboardingScreenState extends State<OnboardingScreen> {Positioned.fill(child: RepaintBoundary(child: _Glow(gc))),const Positioned.fill(child: RepaintBoundary(child: AppBackground(pattern: 'dots'))),SafeArea(- child: Column(- children: [- ValueListenableBuilder<int>(valueListenable: _at, builder: (_, _, _) => _topBar(gc)),- Expanded(- child: RepaintBoundary(- child: PageView(- controller: _page,- onPageChanged: _onPage,- children: [- for (final page in [- _welcome(gc),- _nameStep(gc),- _photoStep(gc),- _unitsStep(gc),- _bodyStep(gc),- _goalStep(gc),- _placeStep(gc),- if (_slow) _speedStep(gc),- ])- RepaintBoundary(child: page),- ],- ),- ),- ),- ValueListenableBuilder<int>(valueListenable: _at, builder: (_, _, _) => _bottomBar(gc)),- ],- ),+ child: _wide+ ? LayoutBuilder(+ builder: (context, box) => Center(+ child: Container(+ width: math.min(1080, box.maxWidth - 64),+ height: math.min(660, box.maxHeight - 48),+ clipBehavior: Clip.antiAlias,+ decoration: BoxDecoration(+ color: gc.bg.withValues(alpha: 0.72),+ borderRadius: BorderRadius.circular(28),+ ),+ child: content,+ ),+ ),+ )+ : content,),],),@@ -221,7 +241,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {Widget _topBar(GymColors gc) {return Padding(- padding: const EdgeInsets.fromLTRB(24, 16, 16, 0),+ padding: _wide ? const EdgeInsets.fromLTRB(44, 30, 36, 0) : const EdgeInsets.fromLTRB(24, 16, 16, 0),child: Row(children: [Expanded(@@ -259,8 +279,16 @@ class _OnboardingScreenState extends State<OnboardingScreen> {}Widget _bottomBar(GymColors gc) {+ final next = PrimaryButton(+ label: _index == _last+ ? t.welcomeStart+ : _index == 2 && fit.profile.photo.isEmpty+ ? t.onbPhotoLater+ : t.next,+ onTap: () => _index == _last ? _finish() : _go(_index + 1),+ );return Padding(- padding: const EdgeInsets.fromLTRB(24, 8, 24, 22),+ padding: _wide ? const EdgeInsets.fromLTRB(44, 8, 44, 32) : const EdgeInsets.fromLTRB(24, 8, 24, 22),child: Row(children: [if (_index > 0)@@ -275,16 +303,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {child: Icon(PhosphorIconsBold.arrowLeft, size: 18, color: gc.textSecondary),),),- Expanded(- child: PrimaryButton(- label: _index == _last- ? t.welcomeStart- : _index == 2 && fit.profile.photo.isEmpty- ? t.onbPhotoLater- : t.next,- onTap: () => _index == _last ? _finish() : _go(_index + 1),- ),- ),+ if (_wide) ...[const Spacer(), SizedBox(width: 240, child: next)] else Expanded(child: next),],),);@@ -298,6 +317,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {required Widget child,Widget Function(double height)? hero,}) {+ if (_wide) return _split(gc, step: step, title: title, why: why, child: child, hero: hero);return LayoutBuilder(builder: (context, box) => SingleChildScrollView(padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),@@ -342,6 +362,74 @@ class _OnboardingScreenState extends State<OnboardingScreen> {);}+ Widget _split(+ GymColors gc, {+ required int step,+ required String title,+ required String why,+ required Widget child,+ Widget Function(double height)? hero,+ }) {+ return LayoutBuilder(+ builder: (context, box) {+ final h = (box.maxHeight * 0.34).clamp(150.0, 210.0);+ final heroBox = hero == null ? null : SizedBox(height: h, child: Center(child: hero(h)));+ return Padding(+ padding: const EdgeInsetsDirectional.fromSTEB(0, 8, 28, 4),+ child: Row(+ children: [+ Expanded(+ flex: 5,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(44, 0, 36, 0),+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ _in(0, _label(gc, t.onbStep(step, _last))),+ const SizedBox(height: 14),+ _in(1, Text(title, style: AppTheme.f(40, weight: FontWeight.w800, color: gc.text, height: 1.08))),+ const SizedBox(height: 16),+ _in(2, Text(why, style: AppTheme.f(15.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.55))),+ ],+ ),+ ),+ ),+ Expanded(+ flex: 6,+ child: Container(+ decoration: BoxDecoration(+ color: gc.bgRaised.withValues(alpha: 0.5),+ borderRadius: BorderRadius.circular(24),+ ),+ child: SingleChildScrollView(+ padding: const EdgeInsets.all(28),+ child: ConstrainedBox(+ constraints: BoxConstraints(minHeight: box.maxHeight - 40 - 56),+ child: Center(+ child: ConstrainedBox(+ constraints: const BoxConstraints(maxWidth: 440),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ if (heroBox != null) ...[_in(0, heroBox), const SizedBox(height: 26)],+ _in(3, child),+ ],+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ ],+ ),+ );+ },+ );+ }+Widget _label(GymColors gc, String text) => Text(text.toUpperCase(),style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4));@@ -350,6 +438,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {clipBehavior: Clip.antiAlias,decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(20)),child: Column(+ mainAxisSize: MainAxisSize.min,children: [for (var i = 0; i < rows.length; i++) ...[if (i > 0)@@ -367,6 +456,58 @@ class _OnboardingScreenState extends State<OnboardingScreen> {);Widget _welcome(GymColors gc) {+ if (_wide) {+ return Row(+ children: [+ Expanded(+ flex: 5,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(44, 12, 24, 12),+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ _in(0, Image.asset('assets/img/runner.png', height: 170, opacity: const AlwaysStoppedAnimation(0.9))),+ const SizedBox(height: 22),+ _in(1, _label(gc, t.welcomeKicker)),+ const SizedBox(height: 8),+ _in(2, Text('GymMane', style: AppTheme.f(52, weight: FontWeight.w800, color: gc.text, height: 1))),+ const SizedBox(height: 12),+ _in(3, Text(kIsWeb ? t.webWelcomeBlurb : t.welcomeBlurb,+ style: AppTheme.f(15, weight: FontWeight.w500, color: gc.textSecondary, height: 1.5))),+ ],+ ),+ ),+ ),+ Expanded(+ flex: 6,+ child: Container(+ margin: const EdgeInsetsDirectional.fromSTEB(0, 8, 28, 4),+ padding: const EdgeInsets.all(28),+ decoration: BoxDecoration(+ color: gc.bgRaised.withValues(alpha: 0.5),+ borderRadius: BorderRadius.circular(24),+ ),+ child: Center(+ child: ConstrainedBox(+ constraints: const BoxConstraints(maxWidth: 460),+ child: _in(+ 4,+ _group(gc, [+ _promise(gc, PhosphorIconsRegular.gift, t.freeForever, t.freeForeverWhy),+ kIsWeb+ ? _promise(gc, PhosphorIconsRegular.hardDrives, t.webOwnServer, t.webOwnServerWhy)+ : _promise(gc, PhosphorIconsRegular.wifiSlash, t.fullyOffline, t.fullyOfflineWhy),+ _promise(gc, PhosphorIconsRegular.export, t.yoursToTake, t.yoursToTakeWhy),+ ]),+ ),+ ),+ ),+ ),+ ),+ ],+ );+ }return LayoutBuilder(builder: (context, box) => SingleChildScrollView(padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),@@ -406,7 +547,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {3,Padding(padding: const EdgeInsets.symmetric(horizontal: 4),- child: Text(t.welcomeBlurb,+ child: Text(kIsWeb ? t.webWelcomeBlurb : t.welcomeBlurb,style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.5)),),),@@ -415,7 +556,9 @@ class _OnboardingScreenState extends State<OnboardingScreen> {4,_group(gc, [_promise(gc, PhosphorIconsRegular.gift, t.freeForever, t.freeForeverWhy),- _promise(gc, PhosphorIconsRegular.wifiSlash, t.fullyOffline, t.fullyOfflineWhy),+ kIsWeb+ ? _promise(gc, PhosphorIconsRegular.hardDrives, t.webOwnServer, t.webOwnServerWhy)+ : _promise(gc, PhosphorIconsRegular.wifiSlash, t.fullyOffline, t.fullyOfflineWhy),_promise(gc, PhosphorIconsRegular.export, t.yoursToTake, t.yoursToTakeWhy),]),),@@ -644,9 +787,15 @@ class _OnboardingScreenState extends State<OnboardingScreen> {child: RollingText('$goal',style: AppTheme.d(h * 0.3, weight: FontWeight.w800, color: gc.text, height: 1.4)),),- Text(t.perWeek(goal).replaceFirst('$goal', '').trim().toUpperCase(),- textAlign: TextAlign.center,- style: AppTheme.f(10, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.2)),+ SizedBox(+ width: h * 0.58,+ child: FittedBox(+ fit: BoxFit.scaleDown,+ child: Text(t.perWeek(goal).replaceFirst('$goal', '').trim().toUpperCase(),+ textAlign: TextAlign.center,+ style: AppTheme.f(10, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.2)),+ ),+ ),]),),),diff --git a/lib/screens/plan_import_sheet.dart b/lib/screens/plan_import_sheet.dartindex d7c610c..c5eaf29 100644--- a/lib/screens/plan_import_sheet.dart+++ b/lib/screens/plan_import_sheet.dart@@ -4,9 +4,7 @@ import 'dart:io';import 'package:file_picker/file_picker.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';-import 'package:path_provider/path_provider.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';-import 'package:share_plus/share_plus.dart';import '../l10n/l10n.dart';import '../models/workout.dart';@@ -17,6 +15,7 @@ import '../theme/app_theme.dart';import '../widgets/glass.dart';import '../widgets/liquid_notch.dart';import '../widgets/ui_kit.dart';+import '../services/file_share.dart';const _sample = '{ "name": "Push", "exercises": [ ... ] }';@@ -24,18 +23,12 @@ Future<void> sharePlan(List<Routine> routines, {String? title}) async {if (routines.isEmpty) return;final name = title ?? fit.routineTitle(routines.first);try {- final dir = await getTemporaryDirectory();final slug = name.toLowerCase().replaceAll(RegExp(r'[^a-z0-9]+'), '-').replaceAll(RegExp(r'^-+|-+$'), '');- final file = File('${dir.path}/gymmane-${slug.isEmpty ? 'plan' : slug}.json');- await file.writeAsString(fit.exportPlanJson(routines));- await SharePlus.instance.share(ShareParams(- files: [XFile(file.path, mimeType: 'application/json')],- text: '${fit.planSummaryText(routines)}\n\n${t.shareMessage(name)}',- subject: name,- ));+ await shareFile('gymmane-${slug.isEmpty ? 'plan' : slug}.json', utf8Bytes(fit.exportPlanJson(routines)),+ mime: 'application/json', text: '${fit.planSummaryText(routines)}\n\n${t.shareMessage(name)}', subject: name);} catch (_) {}}diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dartindex 812665d..3bb3a14 100644--- a/lib/screens/profile_screen.dart+++ b/lib/screens/profile_screen.dart@@ -1,4 +1,3 @@-import 'dart:io';import 'dart:math' as math;import 'dart:ui' as ui;@@ -7,6 +6,7 @@ import 'package:flutter/services.dart';import 'package:image_picker/image_picker.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import '../app/desktop.dart';import '../l10n/l10n.dart';import '../models/profile.dart';import '../services/food_library.dart';@@ -111,7 +111,7 @@ class _ProfileScreenState extends State<ProfileScreen> with SingleTickerProviderfinal shot = await ImagePicker().pickImage(source: source, maxWidth: 1600, maxHeight: 900, imageQuality: 82);if (shot == null) return;- fit.setProfileBanner(await File(shot.path).readAsBytes());+ fit.setProfileBanner(await shot.readAsBytes());} catch (_) {} finally {if (mounted) setState(() => _busy = false);@@ -170,9 +170,11 @@ class _ProfileScreenState extends State<ProfileScreen> with SingleTickerProviderconst SizedBox(height: 6),Rise(index: 0, child: _pills(gc)),Padding(- padding: const EdgeInsets.fromLTRB(20, 26, 20, 110),- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,+ padding: DesktopScope.of(context)+ ? const EdgeInsets.fromLTRB(32, 26, 32, 48)+ : const EdgeInsets.fromLTRB(20, 26, 20, 110),+ child: _boxes(+ context,children: [if (fit.gamification) ...[Rise(@@ -185,15 +187,18 @@ class _ProfileScreenState extends State<ProfileScreen> with SingleTickerProvider),const SizedBox(height: 30),],- Rise(- index: 2,- child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [- _heading(gc, t.snapshots,- count: fit.momentCount > 0 ? '${fit.momentCount}' : null,- onMore: fit.momentCount > 0 ? fit.goMoments : null),- const SizedBox(height: 16),- _photoCards(gc),- ]),+ _photosTile(+ context,+ Rise(+ index: 2,+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ _heading(gc, t.snapshots,+ count: fit.momentCount > 0 ? '${fit.momentCount}' : null,+ onMore: fit.momentCount > 0 ? fit.goMoments : null),+ const SizedBox(height: 16),+ _photoCards(context, gc),+ ]),+ ),),const SizedBox(height: 30),if (fit.passOn) ...[@@ -271,6 +276,23 @@ class _ProfileScreenState extends State<ProfileScreen> with SingleTickerProvider);}+ Widget _photosTile(BuildContext context, Widget tile) =>+ DesktopScope.of(context) && fit.gamification && MediaQuery.sizeOf(context).width >= 1350+ ? FlowSlot(lift: 44, child: tile)+ : tile;++ Widget _boxes(BuildContext context, {required List<Widget> children}) {+ if (!DesktopScope.of(context)) {+ return Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: children);+ }+ return CardFlow(+ minColumn: 370,+ maxColumns: 2,+ gap: 30,+ children: [for (final c in children) if (c is! SizedBox) c],+ );+ }+Widget _traveller(GymColors gc, Size size, double top, double pull, double p) {final big = 86 + (kRecapAvatar - 86) * Curves.easeInOutSine.transform(p);final center = Offset(size.width / 2, recapAvatarY(size));@@ -536,6 +558,7 @@ class _ProfileScreenState extends State<ProfileScreen> with SingleTickerProviderreturn SizedBox(height: 36,child: ListView.separated(+ key: const PageStorageKey('h-profile_screen-561'),scrollDirection: Axis.horizontal,padding: const EdgeInsets.symmetric(horizontal: 20),itemCount: cells.length,@@ -564,9 +587,13 @@ class _ProfileScreenState extends State<ProfileScreen> with SingleTickerProviderstatic const _turns = [-0.06, 0.045, -0.03, 0.055];- Widget _photoCards(GymColors gc) {+ Widget _photoCards(BuildContext context, GymColors gc) {+ return LayoutBuilder(builder: (context, outer) => _photoFan(gc, DesktopScope.of(context) && outer.maxWidth < 640));+ }++ Widget _photoFan(GymColors gc, bool big) {final shots = fit.momentsNewest.take(4).map((m) => m.file).toList();- const w = 104.0, h = 136.0;+ final w = big ? 168.0 : 104.0, h = big ? 222.0 : 136.0;return Semantics(button: true,label: shots.isEmpty ? t.addPhoto : t.photosCard,@@ -578,12 +605,13 @@ class _ProfileScreenState extends State<ProfileScreen> with SingleTickerProviderchild: LayoutBuilder(builder: (context, box) {const n = 4;final step = math.min(w * 0.8, (box.maxWidth - w) / (n - 1));+ final pad = math.max(0.0, (box.maxWidth - w - step * (n - 1)) / 2);return Stack(clipBehavior: Clip.none,children: [for (var i = 0; i < n; i++)Positioned(- left: i * step,+ left: pad + i * step,top: i.isOdd ? 12 : 6,width: w,height: h,diff --git a/lib/screens/progress_screen.dart b/lib/screens/progress_screen.dartindex c997e5c..aecba25 100644--- a/lib/screens/progress_screen.dart+++ b/lib/screens/progress_screen.dart@@ -5,9 +5,11 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import '../app/desktop.dart';import '../l10n/l10n.dart';import '../models/progress_shot.dart';import '../models/workout.dart';+import '../services/food_library.dart' show foldText;import '../services/media_store.dart';import '../state/fit_state.dart';import '../theme/app_colors.dart';@@ -17,6 +19,7 @@ import '../widgets/check_in.dart';import '../widgets/charts.dart';import '../widgets/dialogs.dart';import '../widgets/entrance.dart';+import '../widgets/exercise_history_sheet.dart';import '../widgets/exercise_media.dart';import '../widgets/file_thumb.dart';import '../widgets/glass.dart';@@ -43,6 +46,42 @@ class ProgressScreen extends StatelessWidget {final split = fit.muscleSplit;final prs = fit.personalRecords;final bw = fit.bodyweightSeries;+ final header = Row(+ children: [+ Expanded(+ child: Text(t.progressTitle,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(30, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.8, height: 1.1)),+ ),+ const SizedBox(width: 12),+ _headerActions(context, gc),+ ],+ );+ final cards = <Widget>[+ if (fit.sessions.isEmpty) _setupCard(context, gc),+ _heroRow(context, gc, change, bw),+ _consistency(context, gc),+ _totals(gc),+ const _MuscleMapCard(),+ if (fit.sessions.isNotEmpty) const MuscleRadarCard(),+ ..._blocks(context, gc, bw, split, prs),+ if (fit.sessions.isNotEmpty && _missing.isNotEmpty) _setupCard(context, gc),+ ];+ if (DesktopScope.of(context)) {+ return RiseScope(+ id: 'progress',+ child: SingleChildScrollView(+ clipBehavior: Clip.none,+ padding: const EdgeInsets.fromLTRB(32, 30, 32, 48),+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ Rise(index: 0, child: header),+ const SizedBox(height: 24),+ CardFlow(minColumn: 360, gap: 18, children: riseAll(cards, from: 1)),+ ]),+ ),+ );+ }return RiseScope(id: 'progress',@@ -1970,13 +2009,25 @@ class _PrCard extends StatefulWidget {class _PrCardState extends State<_PrCard> {static const _shown = 5;bool _all = false;+ final _search = TextEditingController();+ String _query = '';++ @override+ void dispose() {+ _search.dispose();+ super.dispose();+ }@overrideWidget build(BuildContext context) {final gc = context.gc;final prs = widget.prs;- final rows = _all ? prs : prs.take(_shown).toList();- final hidden = prs.length - rows.length;+ final q = foldText(_query.trim());+ final found = !_all || q.isEmpty+ ? prs+ : [for (final pr in prs) if (foldText(t.catalogName(pr.id, pr.name)).contains(q)) pr];+ final rows = _all ? found : prs.take(_shown).toList();+ final hidden = prs.length - (_all ? prs.length : rows.length);return SoftCard(radius: 22,borderColor: Colors.transparent,@@ -2000,7 +2051,17 @@ class _PrCardState extends State<_PrCard> {alignment: Alignment.topCenter,child: Column(children: [- for (var i = 0; i < rows.length; i++) _row(gc, rows[i], i, i < rows.length - 1 || hidden > 0),+ if (_all && prs.length > _shown) ...[+ const SizedBox(height: 4),+ SearchField(+ controller: _search,+ hint: t.searchExercises,+ onChanged: (v) => setState(() => _query = v),+ ),+ const SizedBox(height: 6),+ ],+ for (var i = 0; i < rows.length; i++)+ _row(gc, rows[i], prs.indexOf(rows[i]), i < rows.length - 1 || prs.length > _shown),],),),@@ -2009,7 +2070,13 @@ class _PrCardState extends State<_PrCard> {button: true,child: GestureDetector(behavior: HitTestBehavior.opaque,- onTap: () => setState(() => _all = !_all),+ onTap: () => setState(() {+ _all = !_all;+ if (!_all) {+ _search.clear();+ _query = '';+ }+ }),child: SizedBox(height: 44,child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [@@ -2033,7 +2100,10 @@ class _PrCardState extends State<_PrCard> {Widget _row(GymColors gc, PersonalRecord pr, int rank, bool border) {final medal = rank < 3 ? [gc.brass, gc.textSecondary, gc.accent][rank] : null;- return Container(+ return Pressable(+ onTap: () => showExerciseHistorySheet(context, pr.id),+ scale: 0.98,+ child: Container(padding: const EdgeInsets.symmetric(vertical: 11),decoration: BoxDecoration(border: border ? Border(bottom: BorderSide(color: gc.border.withValues(alpha: 0.6))) : null,@@ -2086,6 +2156,7 @@ class _PrCardState extends State<_PrCard> {Text(fit.recordLabel(pr), style: AppTheme.d(19, weight: FontWeight.w800, color: gc.text)),],),+ ),);}}@@ -2814,12 +2885,12 @@ Widget _editSetRow(GymColors gc, LoggedSession s, LoggedExercise e, int i, boolchild: Text('${i + 1}', style: AppTheme.d(15, weight: FontWeight.w700, color: gc.text)),),if (distance) ...[- cell(t.distanceCol(fit.distanceUnit).replaceAll(RegExp(r'\s*\(.*\)'), ''), fit.distanceValue(set.km ?? 0),+ cell(t.distanceCol(fit.distanceUnitFor(e.id)).replaceAll(RegExp(r'\s*\(.*\)'), ''), fit.distanceValueFor(e.id, set.km ?? 0),() => fit.bumpLoggedKm(e, i, -1), () => fit.bumpLoggedKm(e, i, 1),minWidth: 36, edit: (ctx) async {final v = await askNumber(ctx,- title: t.distanceCol(fit.distanceUnit).replaceAll(RegExp(r'\s*\(.*\)'), ''),- initial: fit.distanceValue(set.km ?? 0),+ title: t.distanceCol(fit.distanceUnitFor(e.id)).replaceAll(RegExp(r'\s*\(.*\)'), ''),+ initial: fit.distanceValueFor(e.id, set.km ?? 0),decimal: true);if (v != null) fit.setLoggedKmShown(e, i, v);}),@@ -2847,7 +2918,8 @@ Widget _editSetRow(GymColors gc, LoggedSession s, LoggedExercise e, int i, boolif (v != null) fit.setLoggedReps(e, i, v.round());}),if (!repsOnly && (!timed || set.weight > 0))- cell(t.weightCol(fit.units.toUpperCase()), fit.weightValue(set.weight), () => fit.bumpLoggedWeight(e, i, -1),+ cell(t.weightCol(fit.units.toUpperCase()), fmt((fit.toDisplayWeight(set.weight) * 100).round() / 100),+ () => fit.bumpLoggedWeight(e, i, -1),() => fit.bumpLoggedWeight(e, i, 1),minWidth: 34, edit: (ctx) async {final shown = (fit.toDisplayWeight(set.weight) * 100).round() / 100;diff --git a/lib/screens/recap_screen.dart b/lib/screens/recap_screen.dartindex 58540b6..3bc98b9 100644--- a/lib/screens/recap_screen.dart+++ b/lib/screens/recap_screen.dart@@ -1,2161 +1,2157 @@-import 'dart:io';-import 'dart:math' as math;-import 'dart:ui' as ui;--import 'package:flutter/material.dart';-import 'package:flutter/rendering.dart';-import 'package:flutter/scheduler.dart';-import 'package:flutter/services.dart';-import 'package:path_provider/path_provider.dart';-import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';-import 'package:share_plus/share_plus.dart';--import '../catalog/awards.dart';-import '../l10n/l10n.dart';-import '../models/exercise.dart';-import '../models/workout.dart';-import '../services/food_library.dart';-import '../services/health_metrics.dart';-import '../state/fit_state.dart';-import '../theme/app_colors.dart';-import '../theme/app_theme.dart';-import '../widgets/body_map.dart';-import '../widgets/exercise_media.dart';-import '../widgets/exercise_preview.dart';-import '../widgets/liquid_notch.dart';-import '../widgets/medal.dart';-import '../widgets/medal_shelf.dart';-import '../widgets/name_ticker.dart';-import '../widgets/nutrition_art.dart';-import '../widgets/profile_avatar.dart';-import '../widgets/ui_kit.dart';--const double kRecapAvatar = 150;--double recapAvatarY(Size size) => size.height * 0.4;--Future<void> openRecap(BuildContext context) async {- if (fit.nutritionBeta && !FoodLibrary.ready) await FoodLibrary.load();- if (!context.mounted) return;- await Navigator.of(context).push(PageRouteBuilder<void>(- transitionDuration: const Duration(milliseconds: 380),- reverseTransitionDuration: const Duration(milliseconds: 300),- pageBuilder: (_, _, _) => const RecapScreen(),- transitionsBuilder: (_, a, _, child) =>- FadeTransition(opacity: CurvedAnimation(parent: a, curve: Curves.easeOut), child: child),- ));-}--enum _Page { hello, workouts, time, volume, peak, lift, fresh, muscle, records, medals, cardio, steps, sleep, food, habit, share }--TextStyle _num(double size, Color color) => AppTheme.f(size,- weight: FontWeight.w900, color: color, letterSpacing: -size * 0.045, height: 1)- .copyWith(fontFeatures: const [ui.FontFeature.tabularFigures()]);--class StoryRings extends StatefulWidget {- const StoryRings({super.key, required this.size, required this.color, this.ring = true});-- final double size;- final Color color;- final bool ring;-- @override- State<StoryRings> createState() => _StoryRingsState();-}--class _StoryRingsState extends State<StoryRings> with SingleTickerProviderStateMixin {- late final AnimationController _c;-- @override- void initState() {- super.initState();- _c = AnimationController(vsync: this, duration: const Duration(milliseconds: 1250))..forward();- }-- @override- void dispose() {- _c.dispose();- super.dispose();- }-- @override- Widget build(BuildContext context) {- final box = widget.size + 200;- return IgnorePointer(- child: SizedBox(- width: box,- height: box,- child: RepaintBoundary(- child: CustomPaint(painter: _RingsPainter(_c, widget.size, widget.color, widget.ring)),- ),- ),- );- }-}--class _RingsPainter extends CustomPainter {- _RingsPainter(this.a, this.size, this.color, this.ring) : super(repaint: a);-- final Animation<double> a;- final double size;- final Color color;- final bool ring;-- @override- void paint(Canvas canvas, Size box) {- final c = box.center(Offset.zero);- final base = size / 2 + 7;- for (var i = 0; i < 2; i++) {- final start = i * 0.24;- final v = ((a.value - start) / (1 - start)).clamp(0.0, 1.0);- if (v <= 0 || v >= 1) continue;- final e = Curves.easeOutCubic.transform(v);- canvas.drawCircle(- c,- base + 58 * e,- Paint()- ..style = PaintingStyle.stroke- ..strokeWidth = 1.4 * (1 - e) + 0.5- ..color = color.withValues(alpha: (1 - v) * (i == 0 ? 0.4 : 0.22)),- );- }- if (ring) {- final show = Curves.easeOut.transform((a.value / 0.35).clamp(0.0, 1.0));- canvas.drawCircle(- c,- base,- Paint()- ..style = PaintingStyle.stroke- ..strokeWidth = 1.6- ..color = color.withValues(alpha: 0.5 * show),- );- }- }-- @override- bool shouldRepaint(_RingsPainter old) => old.size != size || old.color != color || old.ring != ring;-}--class _Count extends StatelessWidget {- const _Count(this.value, {required this.style, this.format, this.delay = 0, this.duration = 1500});-- final double value;- final TextStyle style;- final String Function(double v)? format;- final int delay;- final int duration;-- @override- Widget build(BuildContext context) {- final total = delay + duration;- return TweenAnimationBuilder<double>(- tween: Tween(begin: 0, end: value),- duration: Duration(milliseconds: total),- curve: Interval(delay / total, 1, curve: Curves.easeOutExpo),- builder: (_, v, _) => Text(format?.call(v) ?? '${v.round()}', style: style),- );- }-}--class _Enter extends StatelessWidget {- const _Enter({required this.child, this.delay = 0, this.from = 18});-- final Widget child;- final int delay;- final double from;-- @override- Widget build(BuildContext context) {- final total = delay + 520;- return TweenAnimationBuilder<double>(- tween: Tween(begin: 0, end: 1),- duration: Duration(milliseconds: total),- curve: Interval(delay / total, 1, curve: Curves.easeOutCubic),- builder: (_, v, child) => Opacity(- opacity: v,- child: Transform.translate(offset: Offset(0, from * (1 - v)), child: child),- ),- child: child,- );- }-}--class _Pop extends StatelessWidget {- const _Pop({required this.child, this.delay = 0});-- final Widget child;- final int delay;-- @override- Widget build(BuildContext context) {- final total = delay + 560;- return TweenAnimationBuilder<double>(- tween: Tween(begin: 0, end: 1),- duration: Duration(milliseconds: total),- curve: Interval(delay / total, 1, curve: Curves.easeOutBack),- builder: (_, v, child) => Opacity(- opacity: v.clamp(0.0, 1.0),- child: Transform.scale(scale: 0.4 + 0.6 * v, child: child),- ),- child: child,- );- }-}--class RecapScreen extends StatefulWidget {- const RecapScreen({super.key});-- @override- State<RecapScreen> createState() => _RecapScreenState();-}--class _RecapScreenState extends State<RecapScreen> {- late final MonthRecap _recap = fit.recapFor(fit.recapMonth);- late final MonthRecap _prev = fit.recapFor(DateTime(_recap.month.year, _recap.month.month - 1));- late final Exercise? _lift = _recap.lift == null ? null : fit.exerciseById(_recap.lift!.id);- late final _extras = recapExtras(_recap);- late final List<String> _wall = recapWallIds(_recap);- late final List<_Page> _pages = [- _Page.hello,- if (!_recap.empty) ...[- _Page.workouts,- _Page.time,- if (_recap.volumeKg > 0) _Page.volume,- if (_extras.peak != null) _Page.peak,- if (_lift != null) _Page.lift,- if (_extras.fresh.isNotEmpty) _Page.fresh,- if (_recap.topMuscle != null) _Page.muscle,- _Page.records,- if (_extras.medals.isNotEmpty) _Page.medals,- if (_extras.cardio != null) _Page.cardio,- if (_extras.steps != null) _Page.steps,- if (_extras.sleep != null) _Page.sleep,- if (_extras.food != null) _Page.food,- if (_recap.favDay != null) _Page.habit,- _Page.share,- ],- ];- final _cards = [GlobalKey(), GlobalKey(), GlobalKey()];- final _variants = PageController(viewportFraction: 0.8);- final _pager = PageController();- int _variant = 0;- int _at = 0;- double _pulled = 0;- bool _busy = false;-- String get _month => t.monthInline(_recap.month.month);- String get _prevMonth => t.monthInline(_prev.month.month);-- @override- void dispose() {- _variants.dispose();- _pager.dispose();- super.dispose();- }-- void _go(int to) {- if (to < 0 || to >= _pages.length || !_pager.hasClients) return;- _pager.animateToPage(to, duration: const Duration(milliseconds: 420), curve: Curves.easeOutCubic);- }-- void _tap(TapUpDetails d, double width) {- final page = _pages[_at];- if (page == _Page.share || (page == _Page.hello && _recap.empty)) return;- final at = _pager.hasClients ? (_pager.page ?? _at.toDouble()).round() : _at;- _go(d.localPosition.dx < width * 0.3 ? at - 1 : at + 1);- }-- bool _scrolled(ScrollNotification n) {- if (n.depth != 0 || n.metrics.axis != Axis.vertical) return false;- if (n is ScrollStartNotification) _pulled = 0;- if (n is OverscrollNotification && n.dragDetails != null && n.overscroll < 0 && _at == 0) {- _pulled -= n.overscroll;- if (_pulled > 60) {- _pulled = -double.infinity;- Navigator.of(context).maybePop();- }- }- return false;- }-- void _openExercise(Exercise ex) => showExercisePreview(context, ex);-- String _tickerText(_Page page) => switch (page) {- _Page.hello => fit.displayName,- _Page.workouts => t.recapTickWorkouts,- _Page.time => t.recapTickTime,- _Page.volume => t.recapTickVolume,- _Page.peak => t.recapTickPeak,- _Page.lift => _lift == null ? '' : exerciseName(_lift),- _Page.fresh => t.recapTickFresh,- _Page.muscle => muscleLabel(_recap.topMuscle ?? ''),- _Page.records => t.recapTickRecords,- _Page.medals => t.recapTickMedals,- _Page.cardio => 'Cardio',- _Page.steps => t.recapTickSteps,- _Page.sleep => t.recapTickSleep,- _Page.food => t.recapTickFood,- _Page.habit => t.weekday(_recap.favDay ?? 1),- _Page.share => 'GymMane',- };-- Future<void> _share() async {- if (_busy) return;- setState(() => _busy = true);- try {- final boundary = _cards[_variant].currentContext?.findRenderObject() as RenderRepaintBoundary?;- if (boundary == null) return;- final image = await boundary.toImage(pixelRatio: 1080 / boundary.size.width);- final data = await image.toByteData(format: ui.ImageByteFormat.png);- image.dispose();- if (data == null) return;- final dir = await getTemporaryDirectory();- final file = File('${dir.path}/gymmane-${_recap.month.year}-${_recap.month.month}-$_variant.png');- await file.writeAsBytes(data.buffer.asUint8List(), flush: true);- if (!mounted) return;- await SharePlus.instance.share(ShareParams(files: [XFile(file.path)], subject: 'GymMane'));- } catch (_) {- if (mounted) {- showNotchToast(context, t.shareFailed, icon: PhosphorIconsFill.warningCircle, accent: context.gc.warn);- }- } finally {- if (mounted) setState(() => _busy = false);- }- }-- @override- Widget build(BuildContext context) {- final gc = context.gc;- final pad = MediaQuery.paddingOf(context);- final size = MediaQuery.sizeOf(context);- final page = _pages[_at];- return Scaffold(- backgroundColor: gc.bg,- body: Stack(children: [- Positioned.fill(- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 520),- switchInCurve: Curves.easeOutCubic,- switchOutCurve: Curves.easeInCubic,- child: _backdrop(gc, page),- ),- ),- Positioned.fill(- child: NotificationListener<ScrollNotification>(- onNotification: _scrolled,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTapUp: (d) => _tap(d, size.width),- child: PageView.builder(- controller: _pager,- scrollDirection: Axis.vertical,- physics: const PageScrollPhysics(parent: ClampingScrollPhysics()),- itemCount: _pages.length,- onPageChanged: (i) {- HapticFeedback.selectionClick();- setState(() => _at = i);- },- itemBuilder: (context, i) => AnimatedBuilder(- animation: _pager,- child: _slot(gc, size, pad, _pages[i]),- builder: (context, child) {- final at = _pager.hasClients && _pager.position.haveDimensions- ? _pager.page ?? _at.toDouble()- : _at.toDouble();- final d = (at - i).abs().clamp(0.0, 1.0);- return Opacity(- opacity: 1 - Curves.easeIn.transform(d) * 0.9,- child: Transform.scale(scale: 1 - 0.06 * d, child: child),- );- },- ),- ),- ),- ),- ),- Positioned(- left: 20,- right: 14,- top: pad.top + 8,- child: Row(children: [- Expanded(- child: Text(t.monthYear(_recap.month).toUpperCase(),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(10.5, weight: FontWeight.w800, color: gc.textTertiary, letterSpacing: 1.6)),- ),- _CloseButton(onTap: () => Navigator.of(context).maybePop()),- ]),- ),- if (_pages.length > 1)- Positioned(- right: 10,- top: 0,- bottom: 0,- child: IgnorePointer(child: Center(child: _rail(gc))),- ),- ]),- );- }-- Widget _backdrop(GymColors gc, _Page page) {- if (page == _Page.lift && _wall.isNotEmpty) return _ExerciseWall(key: const ValueKey('wall'), ids: _wall);- final text = _tickerText(page);- return NameTicker(- key: ValueKey('$text$page'),- text: text,- color: gc.text.withValues(alpha: 0.06),- rows: 0,- );- }-- Widget _slot(GymColors gc, Size size, EdgeInsets pad, _Page page) {- if (page == _Page.hello) return Stack(children: _hello(gc, size));- final side = page == _Page.share ? 0.0 : 24.0;- return Padding(- padding: EdgeInsets.fromLTRB(side, pad.top + 60, page == _Page.share ? 0 : 34, pad.bottom + 24),- child: _page(gc, page, gc.accent),- );- }-- Widget _rail(GymColors gc) => Column(mainAxisSize: MainAxisSize.min, children: [- for (var i = 0; i < _pages.length; i++)- AnimatedContainer(- duration: const Duration(milliseconds: 280),- curve: Curves.easeOutCubic,- margin: const EdgeInsets.symmetric(vertical: 3),- width: 4,- height: i == _at ? 22 : 6,- decoration: BoxDecoration(- color: i == _at ? gc.text : (i < _at ? gc.textSecondary : gc.bgRaised2),- borderRadius: BorderRadius.circular(2),- ),- ),- ]);-- Widget _kicker(String text, Color tone) => _Enter(- child: Text(text.toUpperCase(), style: AppTheme.f(11, weight: FontWeight.w800, color: tone, letterSpacing: 1.8)),- );-- Widget _line(GymColors gc, String text, {Color? color, int delay = 900}) => _Enter(- delay: delay,- child: Text(text, style: AppTheme.f(16, weight: FontWeight.w600, color: color ?? gc.textSecondary, height: 1.4)),- );-- Widget _bigRow(List<Widget> parts) => FittedBox(- fit: BoxFit.scaleDown,- alignment: AlignmentDirectional.centerStart,- child: Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: parts)),- );-- Widget _unit(String text, double size, Color tone) => Padding(- padding: const EdgeInsets.only(left: 6, right: 14),- child: Text(text, style: AppTheme.f(size * 0.3, weight: FontWeight.w800, color: tone)),- );-- Widget _bottom(List<Widget> children) => Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisAlignment: MainAxisAlignment.end,- children: children,- );-- Widget _versus(GymColors gc, Color tone, double now, double before, String Function(double) say) {- if (_prev.empty) return const SizedBox.shrink();- final diff = now - before;- final up = diff > 0.0001;- final same = diff.abs() <= 0.0001;- return _Enter(- delay: 1200,- child: Container(- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 7),- decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(100)),- child: Row(mainAxisSize: MainAxisSize.min, children: [- Icon(same ? PhosphorIconsBold.equals : (up ? PhosphorIconsBold.arrowUp : PhosphorIconsBold.arrowDown),- size: 12, color: tone),- const SizedBox(width: 6),- Flexible(- child: Text(- same- ? t.recapSameAs(_prevMonth)- : (up ? t.recapMoreThan(say(diff.abs()), _prevMonth) : t.recapLessThan(say(diff.abs()), _prevMonth)),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(12.5, weight: FontWeight.w800, color: tone),- ),- ),- ]),- ),- );- }-- Widget _page(GymColors gc, _Page page, Color tone) => switch (page) {- _Page.hello => const SizedBox.shrink(),- _Page.workouts => _WorkoutsPage(- recap: _recap,- tone: tone,- kicker: _kicker(t.recapWorkoutsKicker, tone),- versus: _versus(gc, tone, _recap.workouts.toDouble(), _prev.workouts.toDouble(), (v) => '${v.round()}'),- notes: [- if (_extras.streak >= 2) t.recapStreak(_extras.streak),- if (_extras.yearAgo > 0) t.recapYearAgo(_extras.yearAgo),- ],- ),- _Page.time => _time(gc, tone),- _Page.volume => _volume(gc, tone),- _Page.peak => _peakPage(gc, tone),- _Page.lift => _liftPage(gc, tone),- _Page.fresh => _freshPage(gc, tone),- _Page.muscle => _muscle(gc, tone),- _Page.records => _records(gc, tone),- _Page.medals => _medals(gc, tone),- _Page.cardio => _cardio(gc, tone),- _Page.steps => _stepsPage(gc, tone),- _Page.sleep => _sleepPage(gc, tone),- _Page.food => _food(gc, tone),- _Page.habit => _habit(gc, tone),- _Page.share => _sharePage(gc, tone),- };-- List<Widget> _hello(GymColors gc, Size size) {- final first = fit.displayName.split(' ').first;- final y = recapAvatarY(size);- return [- Positioned(- left: (size.width - kRecapAvatar - 200) / 2,- top: y - (kRecapAvatar + 200) / 2,- child: const StoryRings(size: kRecapAvatar, color: Colors.white),- ),- Positioned(- left: (size.width - kRecapAvatar) / 2,- top: y - kRecapAvatar / 2,- child: const ProfileAvatar(size: kRecapAvatar),- ),- Positioned(- left: 28,- right: 28,- top: y + kRecapAvatar / 2 + 34,- child: Column(children: [- _Enter(- delay: 200,- child: Text(t.recapHi(first),- textAlign: TextAlign.center,- style: AppTheme.f(40, weight: FontWeight.w900, color: gc.text, letterSpacing: -1.2)),- ),- const SizedBox(height: 10),- _Enter(- delay: 420,- child: Text(_recap.empty ? t.recapEmpty(_month) : t.recapReady(_month),- textAlign: TextAlign.center,- style: AppTheme.f(16, weight: FontWeight.w600, color: gc.textSecondary, height: 1.4)),- ),- const SizedBox(height: 28),- _Enter(- delay: 650,- child: SizedBox(- width: 200,- child: _recap.empty- ? PrimaryButton(label: t.recapClose, onTap: () => Navigator.of(context).maybePop())- : PrimaryButton(label: t.recapGo, onTap: () => _go(1)),- ),- ),- ]),- ),- ];- }-- Widget _time(GymColors gc, Color tone) {- final h = _recap.seconds ~/ 3600;- final m = (_recap.seconds % 3600) ~/ 60;- final mins = _recap.sessionMinutes;- final top = mins.fold(1, math.max);- final longest = _recap.longest;- return _bottom([- _kicker(t.recapTimeKicker, tone),- const SizedBox(height: 6),- _bigRow([- if (h > 0) ...[- _Count(h.toDouble(), style: _num(112, gc.text)),- _unit('h', 112, tone),- ],- _Count(m.toDouble(), style: _num(112, gc.text), delay: h > 0 ? 350 : 0),- _unit('min', 112, tone),- ]),- const SizedBox(height: 14),- _versus(gc, tone, _recap.seconds / 3600, _prev.seconds / 3600, (v) => '${fmt((v * 10).round() / 10)} h'),- const SizedBox(height: 22),- SizedBox(- height: 96,- child: Row(crossAxisAlignment: CrossAxisAlignment.end, children: [- for (var i = 0; i < mins.length; i++) ...[- if (i > 0) const SizedBox(width: 4),- Expanded(- child: TweenAnimationBuilder<double>(- tween: Tween(begin: 0, end: mins[i] / top),- duration: Duration(milliseconds: 700 + i * 45),- curve: Interval(math.min(0.7, i * 45 / (700 + i * 45)), 1, curve: Curves.easeOutBack),- builder: (_, v, _) => Container(- height: 6 + 88 * v.clamp(0.0, 1.08),- decoration: BoxDecoration(- color: mins[i] == top ? gc.text : gc.text.withValues(alpha: 0.22),- borderRadius: BorderRadius.circular(4),- ),- ),- ),- ),- ],- ]),- ),- const SizedBox(height: 18),- _line(gc, t.recapAvg(_recap.avgMinutes), color: gc.text),- if (longest != null && longest.durationSec > 0) ...[- const SizedBox(height: 4),- _line(gc, t.recapLongest('${longest.durationSec ~/ 60} min', t.shortDate(longest.day)), delay: 1100),- ],- const SizedBox(height: 30),- ]);- }-- Widget _volume(GymColors gc, Color tone) {- final cars = (_recap.volumeKg / 1500).floor();- final shown = math.min(cars, 14);- final top = _recap.topExercise == null ? null : fit.exerciseById(_recap.topExercise!);- return _bottom([- _kicker(t.recapVolumeKicker, tone),- const SizedBox(height: 6),- _bigRow([- _Count(_recap.volumeKg, style: _num(112, gc.text), format: fit.volumeValue, duration: 1800),- _unit(fit.volumeUnit, 112, tone),- ]),- const SizedBox(height: 14),- _versus(gc, tone, _recap.volumeKg, _prev.volumeKg, fit.volumeLabel),- const SizedBox(height: 24),- if (shown > 0) ...[- Wrap(spacing: 8, runSpacing: 8, children: [- for (var i = 0; i < shown; i++)- _Pop(delay: 700 + i * 90, child: Icon(PhosphorIconsFill.car, size: 26, color: gc.text)),- ]),- const SizedBox(height: 12),- _line(gc, t.recapCars(cars, groupedInt(cars)), color: gc.text, delay: 1300),- ],- if (top != null) ...[- const SizedBox(height: 4),- _line(gc, t.recapTop(exerciseName(top), fit.volumeLabel(_recap.topExerciseKg)), delay: 1500),- ],- const SizedBox(height: 30),- ]);- }-- Widget _chip(GymColors gc, Widget value, String label, int delay) => Expanded(- child: _Enter(- delay: delay,- child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- FittedBox(fit: BoxFit.scaleDown, alignment: AlignmentDirectional.centerStart, child: value),- const SizedBox(height: 4),- Text(label.toUpperCase(),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(9.5, weight: FontWeight.w800, color: gc.textTertiary, letterSpacing: 1.2)),- ]),- ),- );-- Widget _peakPage(GymColors gc, Color tone) {- final s = _extras.peak!;- final exs = [for (final e in s.exercises) ?fit.exerciseById(e.id)];- final name = s.name?.trim() ?? '';- return _bottom([- _kicker(t.recapPeakKicker, tone),- const SizedBox(height: 6),- _Enter(- delay: 100,- child: FittedBox(- fit: BoxFit.scaleDown,- alignment: AlignmentDirectional.centerStart,- child: Text(t.shortDate(s.day),- style: AppTheme.f(80, weight: FontWeight.w900, color: gc.text, letterSpacing: -3, height: 1)),- ),- ),- const SizedBox(height: 6),- _Enter(- delay: 250,- child: Text(name.isEmpty ? t.weekday(s.day.weekday) : '${t.weekday(s.day.weekday)} · $name',- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(20, weight: FontWeight.w800, color: gc.textSecondary)),- ),- const SizedBox(height: 26),- Row(children: [- _chip(gc, _Count(s.volume, style: _num(34, gc.text), delay: 350, format: fit.volumeValue),- '${t.statLifted} · ${fit.volumeUnit}', 350),- _chip(gc, _Count((s.durationSec ~/ 60).toDouble(), style: _num(34, gc.text), delay: 500), '${t.duration} · min',- 500),- _chip(gc, _Count(s.setCount.toDouble(), style: _num(34, gc.text), delay: 650), t.setsCaps, 650),- ]),- if (exs.isNotEmpty) ...[- const SizedBox(height: 22),- Wrap(spacing: 8, runSpacing: 8, children: [- for (final (i, ex) in exs.take(6).indexed)- _Pop(- delay: 800 + i * 90,- child: Pressable(- onTap: () => _openExercise(ex),- child: SizedBox(width: 48, child: ExerciseMedia(ex: ex, height: 48, radius: 12, bordered: false)),- ),- ),- ]),- ],- const SizedBox(height: 30),- ]);- }-- Widget _freshPage(GymColors gc, Color tone) {- final exs = [for (final id in _extras.fresh) ?fit.exerciseById(id)];- final shown = exs.take(6).toList();- return _bottom([- _kicker(t.recapFreshKicker, tone),- const SizedBox(height: 6),- Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [- _Count(exs.length.toDouble(), style: _num(112, gc.text), duration: 900),- const SizedBox(width: 10),- Flexible(- child: Text(t.recapFresh(exs.length),- maxLines: 2,- style: AppTheme.f(28, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.6, height: 1.05)),- ),- ])),- const SizedBox(height: 22),- LayoutBuilder(builder: (context, box) {- final tile = (box.maxWidth - 20) / 3;- return Wrap(spacing: 10, runSpacing: 14, children: [- for (final (i, ex) in shown.indexed)- _Pop(- delay: 400 + i * 110,- child: Pressable(- onTap: () => _openExercise(ex),- child: SizedBox(- width: tile,- child: Column(children: [- ExerciseMedia(ex: ex, height: tile, radius: 18, bordered: false),- const SizedBox(height: 6),- Text(exerciseName(ex),- maxLines: 2,- textAlign: TextAlign.center,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(11.5, weight: FontWeight.w700, color: gc.textSecondary, height: 1.2)),- ]),- ),- ),- ),- ]);- }),- if (exs.length > shown.length) ...[- const SizedBox(height: 10),- _line(gc, t.recapMedalsMore(exs.length - shown.length), delay: 1200),- ],- const SizedBox(height: 30),- ]);- }-- Widget _liftPage(GymColors gc, Color tone) {- final ex = _lift!;- final l = _recap.lift!;- final rest = [- for (final r in _recap.topLifts.where((r) => r.id != l.id).take(4))- if (fit.exerciseById(r.id) case final e?) (ex: e, sets: r.sets),- ];- Widget chip(Widget value, String label, int delay) => _chip(gc, value, label, delay);- return _bottom([- _kicker(t.recapLiftKicker, tone),- const SizedBox(height: 12),- Row(crossAxisAlignment: CrossAxisAlignment.end, children: [- _Pop(- child: Pressable(- onTap: () => _openExercise(ex),- child: Container(- padding: const EdgeInsets.all(3),- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(29),- border: Border.all(color: gc.border, width: 1.5),- ),- child: SizedBox(width: 170, child: ExerciseMedia(ex: ex, height: 170, radius: 26, live: true)),- ),- ),- ),- const SizedBox(width: 14),- Expanded(- child: _Enter(- delay: 150,- child: Text(exerciseName(ex),- maxLines: 4,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(24, weight: FontWeight.w900, color: gc.text, letterSpacing: -0.6, height: 1.05)),- ),- ),- ]),- const SizedBox(height: 18),- Row(children: [- chip(_Count(l.sets.toDouble(), style: _num(34, gc.text), delay: 300), t.setsCaps, 300),- if (l.bestKg > 0)- chip(- _Count(l.bestKg,- style: _num(34, gc.text), delay: 450, format: (v) => fit.weightLabel(v).split(' ').first),- '${t.recapBest} · ${fit.units}',- 450),- chip(_Count(l.times.toDouble(), style: _num(34, gc.text), delay: 600), t.recapTimes, 600),- ]),- if (rest.isNotEmpty) ...[- const SizedBox(height: 20),- _Enter(- delay: 750,- child: Text(t.recapLiftRest.toUpperCase(),- style: AppTheme.f(10, weight: FontWeight.w800, color: gc.textTertiary, letterSpacing: 1.6)),- ),- const SizedBox(height: 10),- for (final (i, r) in rest.indexed)- _Enter(- delay: 850 + i * 120,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () => _openExercise(r.ex),- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 4),- child: Row(children: [- SizedBox(width: 20, child: Text('${i + 2}', style: _num(18, tone).copyWith(letterSpacing: 0))),- const SizedBox(width: 8),- SizedBox(width: 38, child: ExerciseMedia(ex: r.ex, height: 38, radius: 10, bordered: false)),- const SizedBox(width: 12),- Expanded(- child: Text(exerciseName(r.ex),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text)),- ),- const SizedBox(width: 10),- Text(t.setCount(r.sets), style: AppTheme.f(13, weight: FontWeight.w700, color: gc.textSecondary)),- ]),- ),- ),- ),- ],- const SizedBox(height: 16),- ]);- }-- Widget _muscle(GymColors gc, Color tone) {- return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- const Spacer(),- Center(- child: _Enter(- from: 30,- child: LayoutBuilder(- builder: (context, box) => BodyHeatArt(gc: gc, intensity: _recap.heat, width: math.min(box.maxWidth, 320)),- ),- ),- ),- const SizedBox(height: 30),- _kicker(t.recapMuscleKicker, tone),- const SizedBox(height: 6),- _Enter(- delay: 200,- child: FittedBox(- fit: BoxFit.scaleDown,- alignment: AlignmentDirectional.centerStart,- child: Text(muscleLabel(_recap.topMuscle ?? ''),- style: AppTheme.f(56, weight: FontWeight.w900, color: gc.text, letterSpacing: -2, height: 1)),- ),- ),- const SizedBox(height: 10),- _Count(_recap.topMuscleSets.toDouble(),- style: AppTheme.f(16, weight: FontWeight.w700, color: tone),- delay: 500,- format: (v) => t.setCount(v.round())),- if (_extras.forgot case final m?) ...[- const SizedBox(height: 6),- _line(gc, t.recapForgot(muscleLabel(m)), delay: 1000),- ],- const SizedBox(height: 30),- ]);- }-- Widget _records(GymColors gc, Color tone) {- final list = _recap.records.take(4).toList();- return _bottom([- _kicker(t.recapRecordsKicker, tone),- const SizedBox(height: 6),- _Count(_recap.records.length.toDouble(), style: _num(112, gc.text), duration: 900),- const SizedBox(height: 18),- if (list.isEmpty)- _line(gc, t.recapNoRecords(_recap.sets))- else- for (final (i, r) in list.indexed)- _Enter(- delay: 500 + i * 180,- child: Pressable(- onTap: fit.exerciseById(r.id) == null ? null : () => _openExercise(fit.exerciseById(r.id)!),- child: Container(- margin: const EdgeInsets.only(bottom: 8),- padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),- decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(16)),- child: Row(children: [- Icon(PhosphorIconsRegular.trophy, size: 18, color: gc.textSecondary),- const SizedBox(width: 12),- Expanded(- child: Text(fit.exerciseById(r.id) == null ? r.id : exerciseName(fit.exerciseById(r.id)!),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(15, weight: FontWeight.w700, color: gc.text)),- ),- const SizedBox(width: 10),- _Count(r.kg,- style: _num(18, gc.text).copyWith(letterSpacing: 0), delay: 600 + i * 180, format: fit.weightLabel),- ]),- ),- ),- ),- const SizedBox(height: 30),- ]);- }-- Widget _medals(GymColors gc, Color tone) {- final won = _extras.medals;- final shown = won.take(9).toList();- return _bottom([- _kicker(t.recapMedalsKicker, tone),- const SizedBox(height: 6),- _Count(won.length.toDouble(), style: _num(112, gc.text), duration: 900),- const SizedBox(height: 22),- Wrap(spacing: 14, runSpacing: 14, children: [- for (final (i, id) in shown.indexed)- _Pop(- delay: 400 + i * 120,- child: Pressable(- onTap: () => showMedalSheet(context, id),- child: Column(mainAxisSize: MainAxisSize.min, children: [- Medal(id: id, size: 74),- const SizedBox(height: 6),- SizedBox(- width: 80,- child: Text(awardName(id),- maxLines: 2,- textAlign: TextAlign.center,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textSecondary, height: 1.2)),- ),- ]),- ),- ),- ]),- if (won.length > shown.length) ...[- const SizedBox(height: 10),- _line(gc, t.recapMedalsMore(won.length - shown.length), delay: 1400),- ],- const SizedBox(height: 30),- ]);- }-- Widget _cardio(GymColors gc, Color tone) {- final c = _extras.cardio!;- final top = c.topId == null ? null : fit.exerciseById(c.topId!);- return _bottom([- _kicker(t.recapCardioKicker, tone),- const SizedBox(height: 6),- if (c.km > 0)- _bigRow([- _Count(c.km, style: _num(112, gc.text), format: fit.distanceValue, duration: 1700),- _unit(fit.distanceUnit, 112, tone),- ])- else- _bigRow([- _Count(c.sec / 60, style: _num(112, gc.text)),- _unit('min', 112, tone),- ]),- const SizedBox(height: 22),- _Route(progress: 1, color: gc.text, track: gc.bgRaised2),- const SizedBox(height: 22),- if (c.km > 0) _line(gc, t.recapCardioTime(c.sec ~/ 60, c.count), color: gc.text),- if (c.km <= 0) _line(gc, t.recapCardioCount(c.count), color: gc.text),- if (top != null) ...[- const SizedBox(height: 4),- _line(gc, t.recapCardioTop(exerciseName(top)), delay: 1100),- ],- const SizedBox(height: 30),- ]);- }-- Widget _stepsPage(GymColors gc, Color tone) {- final s = _extras.steps!;- final group = MaterialLocalizations.of(context);- return _bottom([- _kicker(t.recapStepsKicker, tone),- const SizedBox(height: 6),- _bigRow([- _Count(s.total.toDouble(),- style: _num(96, gc.text), format: (v) => group.formatDecimal(v.round()), duration: 1800),- ]),- Text(t.recapStepsWord, style: AppTheme.f(28, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.6)),- const SizedBox(height: 24),- _MonthChart(values: s.perDay, avg: s.avg, month: _recap.month, tone: gc.text, label: gc.textTertiary),- const SizedBox(height: 18),- _line(gc, t.recapStepsAvg(group.formatDecimal(s.avg)), color: gc.text),- const SizedBox(height: 4),- _line(gc, t.recapStepsBest(group.formatDecimal(s.best), t.shortDate(s.bestDay)), delay: 1100),- const SizedBox(height: 30),- ]);- }-- Widget _sleepPage(GymColors gc, Color tone) {- final s = _extras.sleep!;- return _bottom([- _kicker(t.recapSleepKicker, tone),- const SizedBox(height: 6),- _bigRow([- _Count((s.avg ~/ 60).toDouble(), style: _num(112, gc.text)),- _unit('h', 112, tone),- _Count((s.avg % 60).toDouble(), style: _num(112, gc.text), delay: 300),- _unit('min', 112, tone),- ]),- Text(t.recapSleepAvg, style: AppTheme.f(20, weight: FontWeight.w800, color: gc.textSecondary)),- const SizedBox(height: 24),- _MonthChart(values: s.perNight, avg: s.avg, month: _recap.month, tone: gc.text, label: gc.textTertiary),- const SizedBox(height: 18),- _line(gc, t.recapSleepBest('${s.best ~/ 60} h ${s.best % 60} min', t.shortDate(s.bestDay)), color: gc.text),- const SizedBox(height: 30),- ]);- }-- Widget _food(GymColors gc, Color tone) {- final f = _extras.food!;- final star = f.star;- final rest = f.top.where((e) => e.name != star).take(3).toList();- final group = MaterialLocalizations.of(context);- return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- Expanded(- child: LayoutBuilder(- builder: (context, box) {- final size = math.min(250.0, math.min(box.maxWidth, box.maxHeight) - 16);- if (size < 120 || f.top.isEmpty) return const SizedBox.shrink();- return Center(- child: _Enter(- from: 26,- child: FoodPlate(- size: size,- items: [for (final e in f.top) (e.photo, e.name)],- wrap: (i, child) => _Enter(delay: 260 + i * 140, from: -24, child: child),- ),- ),- );- },- ),- ),- const SizedBox(height: 18),- _kicker(star == null ? t.recapFoodKicker : t.recapFoodStarKicker, tone),- const SizedBox(height: 8),- if (star != null) ...[- _Enter(- delay: 150,- child: Text(star,- maxLines: 2,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(40, weight: FontWeight.w900, color: gc.text, letterSpacing: -1.2, height: 1.02)),- ),- const SizedBox(height: 6),- _Enter(- delay: 260,- child: Text(t.recapFoodStarDays(f.starTimes),- style: AppTheme.f(18, weight: FontWeight.w800, color: gc.textSecondary)),- ),- ] else ...[- _bigRow([- _Count(f.protein.toDouble(), style: _num(96, gc.text)),- _unit('g', 96, tone),- ]),- Text(t.recapFoodProtein(f.goal), style: AppTheme.f(18, weight: FontWeight.w800, color: gc.textSecondary)),- ],- const SizedBox(height: 22),- Row(children: [- if (star != null)- _chip(gc, _Count(f.protein.toDouble(), style: _num(30, gc.text), delay: 400), t.recapFoodProteinLabel, 400),- _chip(gc, Text('${f.hit}/${f.days}', style: _num(30, gc.text)), t.recapFoodGoalDays, 550),- if (f.water > 0)- _chip(gc, Text(fit.waterValue(f.water), style: _num(30, gc.text)), '${t.recapFoodWaterLabel} · ${fit.waterUnit}',- 700)- else- _chip(gc, Text(group.formatDecimal(fit.energyOf(f.kcal)), style: _num(30, gc.text)),- '${fit.energyUnit} · ${t.recapAvgLabel}', 700),- ]),- if (rest.isNotEmpty) ...[- const SizedBox(height: 18),- for (final (i, r) in rest.indexed)- _Enter(- delay: 850 + i * 120,- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 4),- child: Row(children: [- FoodSticker(photo: r.photo, name: r.name, size: 38, tilt: false, shadow: false),- const SizedBox(width: 12),- Expanded(- child: Text(r.name,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text)),- ),- const SizedBox(width: 10),- Text(t.recapFoodTimes(r.days), style: AppTheme.f(13, weight: FontWeight.w700, color: gc.textSecondary)),- ]),- ),- ),- ],- const SizedBox(height: 24),- ]);- }-- Widget _habit(GymColors gc, Color tone) {- final start = _recap.usualStart;- final days = _recap.weekdays;- final top = days.fold(1, math.max);- final order = [for (var i = 0; i < 7; i++) (fit.weekStartDay - 1 + i) % 7 + 1];- return _bottom([- _kicker(t.recapHabitKicker, tone),- const SizedBox(height: 6),- _Enter(- delay: 100,- child: FittedBox(- fit: BoxFit.scaleDown,- alignment: AlignmentDirectional.centerStart,- child: Text(t.weekday(_recap.favDay ?? 1),- style: AppTheme.f(72, weight: FontWeight.w900, color: gc.text, letterSpacing: -3, height: 1)),- ),- ),- const SizedBox(height: 26),- SizedBox(- height: 120,- child: Row(crossAxisAlignment: CrossAxisAlignment.end, children: [- for (final (i, d) in order.indexed) ...[- if (i > 0) const SizedBox(width: 8),- Expanded(- child: Column(mainAxisAlignment: MainAxisAlignment.end, children: [- TweenAnimationBuilder<double>(- tween: Tween(begin: 0, end: days[d - 1] / top),- duration: Duration(milliseconds: 800 + i * 70),- curve: Interval(i * 70 / (800 + i * 70), 1, curve: Curves.easeOutBack),- builder: (_, v, _) => Container(- height: 6 + 84 * v.clamp(0.0, 1.08),- decoration: BoxDecoration(- color: d == _recap.favDay ? gc.text : gc.text.withValues(alpha: 0.22),- borderRadius: BorderRadius.circular(6),- ),- ),- ),- const SizedBox(height: 8),- Text(t.weekdayInitial(d),- style: AppTheme.f(12, weight: FontWeight.w800, color: d == _recap.favDay ? gc.text : gc.textTertiary)),- ]),- ),- ],- ]),- ),- const SizedBox(height: 18),- if (start != null)- _line(- gc,- t.recapHabitStart(MaterialLocalizations.of(context).formatTimeOfDay(- TimeOfDay(hour: start ~/ 60, minute: start % 60),- alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context))),- color: gc.text),- const SizedBox(height: 30),- ]);- }-- Widget _sharePage(GymColors gc, Color tone) {- final names = [t.recapCardSummary, t.recapCardCalendar, t.recapCardLift];- return Column(children: [- _kicker(t.recapShareKicker, tone),- const SizedBox(height: 14),- Expanded(- child: PageView.builder(- controller: _variants,- itemCount: 3,- onPageChanged: (i) {- HapticFeedback.selectionClick();- setState(() => _variant = i);- },- itemBuilder: (context, i) => AnimatedScale(- scale: i == _variant ? 1 : 0.9,- duration: const Duration(milliseconds: 260),- curve: Curves.easeOutCubic,- child: Center(- child: AspectRatio(- aspectRatio: 9 / 16,- child: DecoratedBox(- position: DecorationPosition.foreground,- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(18),- border: Border.all(color: gc.text.withValues(alpha: 0.14)),- ),- child: FittedBox(- child: RepaintBoundary(- key: _cards[i],- child: RecapCard(recap: _recap, variant: i),- ),- ),- ),- ),- ),- ),- ),- ),- const SizedBox(height: 14),- AnimatedSwitcher(- duration: const Duration(milliseconds: 200),- child: Text(names[_variant],- key: ValueKey(_variant), style: AppTheme.f(13, weight: FontWeight.w800, color: gc.textSecondary)),- ),- const SizedBox(height: 8),- Row(mainAxisSize: MainAxisSize.min, children: [- for (var i = 0; i < 3; i++)- AnimatedContainer(- duration: const Duration(milliseconds: 240),- margin: const EdgeInsets.symmetric(horizontal: 3),- width: i == _variant ? 18 : 6,- height: 6,- decoration: BoxDecoration(- color: i == _variant ? gc.text : gc.bgRaised2,- borderRadius: BorderRadius.circular(3),- ),- ),- ]),- const SizedBox(height: 16),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 24),- child: PrimaryButton(label: t.recapShare, onTap: _share),- ),- ]);- }-}--typedef RecapExtras = ({- ({double km, int sec, int count, String? topId})? cardio,- ({int total, int avg, int best, DateTime bestDay, List<int> perDay})? steps,- ({int avg, int best, DateTime bestDay, List<int> perNight})? sleep,- ({- int days,- int kcal,- int protein,- int goal,- int hit,- List<({String name, String photo, int days})> top,- String? star,- int starTimes,- int water,- })? food,- List<AwardId> medals,- LoggedSession? peak,- List<String> fresh,- int streak,- int yearAgo,- String? forgot,-});--List<String> recapWallIds(MonthRecap recap) {- final ids = <String>[...recap.exerciseIds.where((id) => fit.exerciseById(id) != null)];- if (ids.length < 8) {- for (final s in fit.sessions.reversed) {- if (!s.day.isBefore(recap.month)) continue;- for (final e in s.exercises) {- if (!ids.contains(e.id) && fit.exerciseById(e.id) != null) ids.add(e.id);- }- if (ids.length >= 12) break;- }- }- if (ids.isNotEmpty && ids.length < 10) {- final muscles = {for (final id in ids) fit.exerciseById(id)!.primary};- for (final e in fit.allExercises) {- if (ids.length >= 10) break;- if (e.art.isNotEmpty && muscles.contains(e.primary) && !ids.contains(e.id)) ids.add(e.id);- }- }- return ids;-}--RecapExtras recapExtras(MonthRecap recap) {- final from = recap.month;- final to = DateTime(from.year, from.month + 1);- final today = DateTime.now();- final days = [- for (var d = from; d.isBefore(to) && !d.isAfter(today); d = DateTime(d.year, d.month, d.day + 1)) d,- ];-- var km = 0.0;- var sec = 0, count = 0;- final byCardio = <String, int>{};- for (final s in fit.sessions) {- if (s.day.isBefore(from) || !s.day.isBefore(to)) continue;- var any = false;- for (final e in s.exercises) {- if (!fit.isCardio(e.id)) continue;- any = true;- for (final st in e.sets) {- km += st.km ?? 0;- sec += st.sec ?? 0;- }- byCardio[e.id] = (byCardio[e.id] ?? 0) + 1;- }- if (any) count++;- }- String? topCardio;- for (final e in byCardio.entries) {- if (topCardio == null || e.value > byCardio[topCardio]!) topCardio = e.key;- }-- ({int total, int avg, int best, DateTime bestDay, List<int> perDay})? steps;- if (fit.stepsOn) {- final perDay = [for (final d in days) fit.stepsOnDay(d)];- final walked = perDay.where((n) => n > 0).toList();- if (walked.length >= 3) {- var best = 0;- var bestDay = from;- for (final (i, n) in perDay.indexed) {- if (n > best) {- best = n;- bestDay = days[i];- }- }- final total = walked.fold(0, (a, b) => a + b);- steps = (total: total, avg: total ~/ walked.length, best: best, bestDay: bestDay, perDay: perDay);- }- }-- ({int avg, int best, DateTime bestDay, List<int> perNight})? sleep;- if (fit.healthShown.contains(HealthMetric.sleep)) {- final nights = [for (final d in days) (fit.healthOnDay(HealthMetric.sleep, d)?.first ?? 0).round()];- final slept = nights.where((n) => n > 0).toList();- if (slept.length >= 3) {- var best = 0;- var bestDay = from;- for (final (i, n) in nights.indexed) {- if (n > best) {- best = n;- bestDay = days[i];- }- }- sleep = (avg: slept.fold(0, (a, b) => a + b) ~/ slept.length, best: best, bestDay: bestDay, perNight: nights);- }- }-- var logged = 0, hit = 0, waterDays = 0, water = 0;- var kcal = 0.0, protein = 0.0;- final foods = <String, int>{};- final photos = <String, String>{};- if (fit.nutritionBeta) {- for (final d in days) {- final entries = fit.entriesOn(d);- final sips = fit.waterOn(d);- if (sips > 0) {- waterDays++;- water += sips;- }- if (entries.isEmpty) continue;- logged++;- final m = fit.totalOn(d);- kcal += m.kcal;- protein += m.protein;- final reached = m.protein >= fit.goalsFor(d).protein;- if (reached) hit++;- for (final e in entries) {- if ((photos[e.name] ?? '').isEmpty) photos[e.name] = fit.photoForEntry(e);- }- for (final name in {for (final e in entries) e.name}) {- foods[name] = (foods[name] ?? 0) + 1;- }- }- }- final favs = foods.entries.toList()..sort((a, b) => b.value.compareTo(a.value));-- final medals = !fit.gamification- ? <AwardId>[]- : [- for (final id in AwardId.values)- if (fit.awardWonAt(id) case final at? when !at.isBefore(from) && at.isBefore(to)) id,- ];-- final inMonth = [for (final s in fit.sessions) if (!s.day.isBefore(from) && s.day.isBefore(to)) s];- LoggedSession? peak;- if (inMonth.length >= 3) {- for (final s in inMonth) {- if (s.volume > 0 && (peak == null || s.volume > peak.volume)) peak = s;- }- }-- final before = fit.sessions.any((s) => s.day.isBefore(from));- final fresh = !before- ? <String>[]- : [- for (final id in recap.exerciseIds)- if (fit.exerciseById(id) != null && fit.exerciseHistory(id).every((h) => !h.date.isBefore(from))) id,- ];-- final sorted = recap.days.toList()..sort();- var streak = 0, run = 0;- for (final (i, d) in sorted.indexed) {- run = i > 0 && sorted[i - 1] == d - 1 ? run + 1 : 1;- streak = math.max(streak, run);- }-- final last = DateTime(from.year, from.month + 1, 0);- final now = fit.muscleSetsBetween(from, last);- final prevSets = fit.muscleSetsBetween(DateTime(from.year, from.month - 1), DateTime(from.year, from.month, 0));- String? forgot;- var forgotSets = 0.0;- for (final e in prevSets.entries) {- if (e.value >= 4 && (now[e.key] ?? 0) <= 0 && e.value > forgotSets) {- forgotSets = e.value;- forgot = e.key;- }- }-- return (- cardio: count == 0 || (km <= 0 && sec <= 0) ? null : (km: km, sec: sec, count: count, topId: topCardio),- steps: steps,- sleep: sleep,- food: logged < 1- ? null- : (- days: logged,- kcal: (kcal / logged).round(),- protein: (protein / logged).round(),- goal: fit.activeGoals.protein,- hit: hit,- top: [for (final e in favs.take(5)) (name: e.key, photo: photos[e.key] ?? '', days: e.value)],- star: favs.isEmpty || favs.first.value < 2 ? null : favs.first.key,- starTimes: favs.isEmpty ? 0 : favs.first.value,- water: waterDays == 0 ? 0 : water ~/ waterDays,- ),- medals: medals,- peak: peak,- fresh: fresh,- streak: streak,- yearAgo: fit.recapFor(DateTime(from.year - 1, from.month)).workouts,- forgot: forgot,- );-}--class _ExerciseWall extends StatefulWidget {- const _ExerciseWall({super.key, required this.ids});-- final List<String> ids;-- @override- State<_ExerciseWall> createState() => _ExerciseWallState();-}--class _ExerciseWallState extends State<_ExerciseWall> with SingleTickerProviderStateMixin {- late final Ticker _ticker = createTicker((e) => _clock.value = e.inMicroseconds / 1e6);- final _clock = ValueNotifier<double>(0);- late final List<Exercise> _exs = [for (final id in widget.ids) ?fit.exerciseById(id)];-- @override- void didChangeDependencies() {- super.didChangeDependencies();- final calm = MediaQuery.maybeDisableAnimationsOf(context) ?? false;- if (!calm && !_ticker.isActive) _ticker.start();- }-- @override- void dispose() {- _ticker.dispose();- _clock.dispose();- super.dispose();- }-- @override- Widget build(BuildContext context) {- final gc = context.gc;- if (_exs.isEmpty) return const SizedBox.shrink();- return LayoutBuilder(builder: (context, box) {- const columns = 4;- final tile = box.maxWidth / 3.2;- const gap = 10.0;- final span = tile + gap;- final tall = box.maxHeight * 1.6;- final perColumn = (tall / span).ceil() + 2;- return ClipRect(- child: Stack(children: [- Positioned.fill(- child: Transform.rotate(- angle: -0.18,- child: OverflowBox(- maxWidth: box.maxWidth * 1.6,- maxHeight: tall,- child: RepaintBoundary(- child: ValueListenableBuilder<double>(- valueListenable: _clock,- builder: (_, time, _) => Row(mainAxisAlignment: MainAxisAlignment.center, children: [- for (var c = 0; c < columns; c++)- Padding(- padding: const EdgeInsets.symmetric(horizontal: gap / 2),- child: SizedBox(- width: tile,- height: tall,- child: ClipRect(- child: OverflowBox(- alignment: Alignment.topCenter,- maxHeight: double.infinity,- child: Transform.translate(- offset: Offset(0, -((time * (14 + c * 5) * (c.isEven ? 1 : -1)) % span) - span),- child: Column(mainAxisSize: MainAxisSize.min, children: [- for (var i = 0; i < perColumn; i++)- Padding(- padding: const EdgeInsets.only(bottom: gap),- child: SizedBox(- width: tile,- child: ExerciseMedia(- ex: _exs[(i * 3 + c) % _exs.length],- height: tile,- radius: 18,- bordered: false,- ),- ),- ),- ]),- ),- ),- ),- ),- ),- ]),- ),- ),- ),- ),- ),- Positioned.fill(- child: DecoratedBox(- decoration: BoxDecoration(- gradient: LinearGradient(- begin: Alignment.topCenter,- end: Alignment.bottomCenter,- colors: [gc.bg.withValues(alpha: 0.72), gc.bg.withValues(alpha: 0.7), gc.bg],- stops: const [0, 0.38, 0.62],- ),- ),- ),- ),- ]),- );- });- }-}--class _MonthChart extends StatelessWidget {- const _MonthChart({required this.values, required this.avg, required this.month, required this.tone, required this.label});-- final List<int> values;- final int avg;- final DateTime month;- final Color tone;- final Color label;-- @override- Widget build(BuildContext context) => SizedBox(- height: 128,- width: double.infinity,- child: TweenAnimationBuilder<double>(- tween: Tween(begin: 0, end: 1),- duration: const Duration(milliseconds: 1300),- builder: (_, v, _) => CustomPaint(- painter: _MonthChartPainter(- values: values,- avg: avg,- count: DateTime(month.year, month.month + 1, 0).day,- tone: tone,- label: label,- progress: v,- rtl: Directionality.of(context) == TextDirection.rtl,- scale: MediaQuery.textScalerOf(context),- ),- ),- ),- );-}--class _MonthChartPainter extends CustomPainter {- _MonthChartPainter({- required this.values,- required this.avg,- required this.count,- required this.tone,- required this.label,- required this.progress,- required this.rtl,- required this.scale,- });-- final List<int> values;- final int avg;- final int count;- final Color tone;- final Color label;- final double progress;- final bool rtl;- final TextScaler scale;-- @override- void paint(Canvas canvas, Size size) {- const labelH = 22.0;- final h = size.height - labelH;- final slot = size.width / count;- final barW = math.min(10.0, slot * 0.58);- final top = math.max(1, values.fold(0, math.max));- double cx(int i) => rtl ? size.width - slot * (i + 0.5) : slot * (i + 0.5);- final paint = Paint();- for (var i = 0; i < count; i++) {- final v = i < values.length ? values[i] : 0;- final x = cx(i);- if (v <= 0) {- paint.color = tone.withValues(alpha: (i < values.length ? 0.22 : 0.1) * progress);- canvas.drawCircle(Offset(x, h - 1.8), 1.8, paint);- continue;- }- final local = Curves.easeOutCubic.transform(((progress * 1.5) - i / count * 0.5).clamp(0.0, 1.0));- final bh = math.max(barW, h * v / top) * local;- if (bh <= 0) continue;- paint.color = v == top ? tone : tone.withValues(alpha: 0.3);- canvas.drawRRect(- RRect.fromRectAndRadius(Rect.fromLTWH(x - barW / 2, h - bh, barW, bh), Radius.circular(barW / 2)),- paint,- );- }- if (avg > 0) {- final y = h - h * avg / top;- final dash = Paint()- ..color = tone.withValues(alpha: 0.4 * Curves.easeOut.transform(((progress - 0.5) * 2).clamp(0.0, 1.0)))- ..strokeWidth = 1.2- ..strokeCap = StrokeCap.round;- for (var x = 0.0; x < size.width; x += 7) {- canvas.drawLine(Offset(x, y), Offset(math.min(x + 3, size.width), y), dash);- }- }- for (final d in {1, (count + 1) ~/ 2, count}) {- final tp = TextPainter(- text: TextSpan(text: '$d', style: AppTheme.f(10.5, weight: FontWeight.w800, color: label)),- textDirection: TextDirection.ltr,- textScaler: scale.clamp(maxScaleFactor: 1.3),- )..layout();- tp.paint(canvas, Offset((cx(d - 1) - tp.width / 2).clamp(0.0, size.width - tp.width), h + 8));- }- }-- @override- bool shouldRepaint(_MonthChartPainter old) =>- old.progress != progress || old.values != values || old.tone != tone || old.label != label || old.rtl != rtl;-}--class _Route extends StatelessWidget {- const _Route({required this.progress, required this.color, required this.track});-- final double progress;- final Color color;- final Color track;-- @override- Widget build(BuildContext context) => TweenAnimationBuilder<double>(- tween: Tween(begin: 0, end: progress),- duration: const Duration(milliseconds: 1600),- curve: Curves.easeInOutCubic,- builder: (_, v, _) => SizedBox(- height: 70,- width: double.infinity,- child: CustomPaint(painter: _RoutePainter(v, color, track)),- ),- );-}--class _RoutePainter extends CustomPainter {- _RoutePainter(this.v, this.color, this.track);-- final double v;- final Color color;- final Color track;-- @override- void paint(Canvas canvas, Size s) {- final h = s.height;- final path = Path()- ..moveTo(4, h * 0.7)- ..cubicTo(s.width * 0.18, h * 0.05, s.width * 0.32, h * 0.05, s.width * 0.45, h * 0.5)- ..cubicTo(s.width * 0.58, h * 0.95, s.width * 0.74, h * 0.95, s.width * 0.84, h * 0.4)- ..quadraticBezierTo(s.width * 0.92, h * 0.05, s.width - 4, h * 0.3);- final base = Paint()- ..color = track- ..style = PaintingStyle.stroke- ..strokeWidth = 5- ..strokeCap = StrokeCap.round;- canvas.drawPath(path, base);- final metric = path.computeMetrics().first;- canvas.drawPath(metric.extractPath(0, metric.length * v), base..color = color);- final tip = metric.getTangentForOffset(metric.length * v)?.position;- if (tip != null) {- canvas.drawCircle(tip, 9, Paint()..color = color);- canvas.drawCircle(tip, 4, Paint()..color = track);- }- }-- @override- bool shouldRepaint(_RoutePainter old) => old.v != v || old.color != color;-}--class _CloseButton extends StatelessWidget {- const _CloseButton({required this.onTap});-- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- final gc = context.gc;- return Semantics(- button: true,- label: t.recapClose,- child: Pressable(- onTap: onTap,- scale: 0.88,- child: Padding(- padding: const EdgeInsets.all(2),- child: Container(- width: 40,- height: 40,- decoration: BoxDecoration(color: gc.text.withValues(alpha: 0.1), shape: BoxShape.circle),- child: Icon(PhosphorIconsBold.x, size: 17, color: gc.text),- ),- ),- ),- );- }-}--class _WorkoutsPage extends StatefulWidget {- const _WorkoutsPage({- required this.recap,- required this.tone,- required this.kicker,- required this.versus,- this.notes = const [],- });-- final MonthRecap recap;- final Color tone;- final Widget kicker;- final Widget versus;- final List<String> notes;-- @override- State<_WorkoutsPage> createState() => _WorkoutsPageState();-}--class _WorkoutsPageState extends State<_WorkoutsPage> with SingleTickerProviderStateMixin {- late final List<int> _days = widget.recap.days.toList()..sort();- late final AnimationController _run;- int _lit = 0;-- @override- void initState() {- super.initState();- _run = AnimationController(vsync: this, duration: Duration(milliseconds: 500 + 90 * _days.length))- ..addListener(() {- final lit = (Curves.easeInOut.transform(_run.value) * _days.length).round();- if (lit != _lit) {- if (lit > _lit) HapticFeedback.selectionClick();- setState(() => _lit = lit);- }- })- ..addStatusListener((s) {- if (s == AnimationStatus.completed && mounted) setState(() {});- });- Future<void>.delayed(const Duration(milliseconds: 350), () {- if (mounted) _run.forward();- });- }-- @override- void dispose() {- _run.dispose();- super.dispose();- }-- @override- Widget build(BuildContext context) {- final gc = context.gc;- final m = widget.recap.month;- final count = DateTime(m.year, m.month + 1, 0).day;- final lead = (DateTime(m.year, m.month, 1).weekday - fit.weekStartDay + 7) % 7;- final lit = {for (final d in _days.take(_lit)) d};- final shown = (_lit / math.max(1, _days.length) * widget.recap.workouts).round();- final order = [for (var i = 0; i < 7; i++) (fit.weekStartDay - 1 + i) % 7 + 1];- return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.end, children: [- widget.kicker,- const SizedBox(height: 6),- Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [- Text('$shown', style: _num(112, gc.text)),- const SizedBox(width: 10),- Text(t.recapWorkouts(widget.recap.workouts),- style: AppTheme.f(28, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.6)),- ])),- const SizedBox(height: 14),- widget.versus,- const SizedBox(height: 22),- LayoutBuilder(builder: (context, box) {- final cell = math.min(38.0, (box.maxWidth - 6 * 6) / 7);- return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- Wrap(spacing: 6, children: [- for (final d in order)- SizedBox(- width: cell,- child: Text(t.weekdayInitial(d),- textAlign: TextAlign.center,- style: AppTheme.f(10.5, weight: FontWeight.w800, color: gc.textTertiary)),- ),- ]),- const SizedBox(height: 8),- Wrap(spacing: 6, runSpacing: 6, children: [- for (var i = 0; i < lead; i++) SizedBox(width: cell, height: cell),- for (var d = 1; d <= count; d++)- AnimatedScale(- scale: lit.contains(d) ? 1 : 0.88,- duration: const Duration(milliseconds: 260),- curve: Curves.easeOutBack,- child: AnimatedContainer(- duration: const Duration(milliseconds: 220),- width: cell,- height: cell,- alignment: Alignment.center,- decoration: BoxDecoration(- color: lit.contains(d) ? gc.ember : gc.bgRaised2,- shape: BoxShape.circle,- border: lit.contains(d) ? null : Border.all(color: gc.border.withValues(alpha: 0.7)),- ),- child: Text('$d',- style: AppTheme.f(cell * 0.34,- weight: FontWeight.w800, color: lit.contains(d) ? gc.onEmber : gc.textSecondary)),- ),- ),- ]),- ]);- }),- const SizedBox(height: 16),- AnimatedOpacity(- opacity: _run.isCompleted ? 1 : 0,- duration: const Duration(milliseconds: 400),- child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- Text(t.recapDays(_days.length),- style: AppTheme.f(16, weight: FontWeight.w600, color: gc.text, height: 1.4)),- for (final note in widget.notes) ...[- const SizedBox(height: 4),- Text(note, style: AppTheme.f(16, weight: FontWeight.w600, color: gc.textSecondary, height: 1.4)),- ],- ]),- ),- const SizedBox(height: 30),- ]);- }-}---class RecapCard extends StatelessWidget {- const RecapCard({super.key, required this.recap, this.variant = 0});-- final MonthRecap recap;- final int variant;-- @override- Widget build(BuildContext context) {- final gc = context.gc;- final tone = gc.accent;- final lift = recap.lift == null ? null : fit.exerciseById(recap.lift!.id);- final wall = variant == 2 ? recapWallIds(recap) : const <String>[];- return SizedBox(- width: 360,- height: 640,- child: ClipRRect(- borderRadius: BorderRadius.circular(28),- child: ColoredBox(- color: gc.bg,- child: Stack(children: [- if (wall.isNotEmpty)- Positioned(left: 0, right: 0, top: 0, height: 440, child: _staticWall(wall, gc.bg))- else- Positioned(- left: 0,- right: 0,- top: variant == 1 ? 130 : 70,- height: 240,- child: NameTicker(- text: switch (variant) {- 1 => t.monthName(recap.month.month),- 2 when lift != null => exerciseName(lift),- _ => fit.displayName,- },- color: gc.text.withValues(alpha: 0.06),- rows: 3,- size: 74,- running: false,- ),- ),- Padding(- padding: const EdgeInsets.fromLTRB(24, 26, 24, 22),- child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- _header(gc, tone),- const SizedBox(height: 18),- Expanded(- child: switch (variant) {- 1 => _calendar(gc, tone),- 2 when lift != null => _lift(gc, tone, lift),- _ => _summary(gc, tone),- },- ),- const SizedBox(height: 18),- Center(child: _mark(gc)),- ]),- ),- ]),- ),- ),- );- }-- Widget _staticWall(List<String> ids, Color bg) {- final exs = [for (final id in ids) ?fit.exerciseById(id)];- return Stack(fit: StackFit.expand, children: [- Positioned(- left: 0,- right: 0,- top: 0,- bottom: 40,- child: Opacity(- opacity: 0.43,- child: ClipRect(- child: Transform.rotate(- angle: -0.18,- child: OverflowBox(- maxWidth: 760,- maxHeight: 760,- child: Column(mainAxisSize: MainAxisSize.min, children: [- for (var r = 0; r < 7; r++)- Padding(- padding: const EdgeInsets.only(bottom: 8),- child: Row(mainAxisSize: MainAxisSize.min, children: [- for (var c = 0; c < 7; c++)- Padding(- padding: const EdgeInsets.symmetric(horizontal: 4),- child: SizedBox(- width: 96,- child: ExerciseMedia(ex: exs[(r * 3 + c) % exs.length], height: 96, radius: 16, bordered: false),- ),- ),- ]),- ),- ]),- ),- ),- ),- ),- ),- DecoratedBox(- decoration: BoxDecoration(- gradient: LinearGradient(- begin: Alignment.topCenter,- end: Alignment.bottomCenter,- colors: [bg.withValues(alpha: 0), bg.withValues(alpha: 0.3), bg],- stops: const [0, 0.45, 0.88],- ),- ),- ),- ]);- }-- Widget _header(GymColors gc, Color tone) => Row(children: [- const ProfileAvatar(size: 46),- const SizedBox(width: 11),- Expanded(- child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- Text(fit.displayName,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(18, weight: FontWeight.w900, color: gc.text, letterSpacing: -0.4)),- Text('@${fit.profileHandle}',- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(11.5, weight: FontWeight.w700, color: gc.textSecondary)),- ]),- ),- const SizedBox(width: 8),- Text(t.monthYear(recap.month).toUpperCase(),- style: AppTheme.f(9.5, weight: FontWeight.w800, color: tone, letterSpacing: 1.4)),- ]);-- Widget _mark(GymColors gc) => Row(mainAxisSize: MainAxisSize.min, children: [- ClipRRect(- borderRadius: BorderRadius.circular(5),- child: Image.asset('assets/img/app_icon.png', width: 20, height: 20),- ),- const SizedBox(width: 7),- Text('GymMane', style: AppTheme.f(14, weight: FontWeight.w900, color: gc.text, letterSpacing: -0.2, height: 1)),- ]);-- Widget _stat(GymColors gc, String value, String unit, String label, {double size = 28, bool soft = false}) => Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- FittedBox(- fit: BoxFit.scaleDown,- alignment: AlignmentDirectional.centerStart,- child: Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [- Text(value, style: _num(size, soft ? gc.textSecondary : gc.text)),- if (unit.isNotEmpty) ...[- const SizedBox(width: 3),- Text(unit, style: AppTheme.f(size * 0.4, weight: FontWeight.w800, color: gc.textSecondary)),- ],- ])),- ),- const SizedBox(height: 4),- Text(label.toUpperCase(),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(8.5, weight: FontWeight.w800, color: gc.textTertiary, letterSpacing: 1.1)),- ],- );-- (String, String) get _time {- final h = recap.seconds ~/ 3600;- final m = (recap.seconds % 3600) ~/ 60;- return h > 0 ? ('$h', 'h') : ('$m', 'min');- }-- Widget _summary(GymColors gc, Color tone) {- final time = _time;- return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [- Text('${recap.workouts}', style: _num(80, gc.text)),- const SizedBox(width: 8),- Text(t.recapWorkouts(recap.workouts),- style: AppTheme.f(22, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.4)),- ])),- const SizedBox(height: 2),- Text(t.recapDays(recap.days.length), style: AppTheme.f(13.5, weight: FontWeight.w700, color: gc.textSecondary)),- const Spacer(),- Center(child: BodyHeatArt(gc: gc, intensity: recap.heat, width: 220)),- if (recap.topMuscle != null) ...[- const SizedBox(height: 8),- Center(- child: Text('${t.recapMuscleKicker} · ${muscleLabel(recap.topMuscle!)}'.toUpperCase(),- style: AppTheme.f(9.5, weight: FontWeight.w800, color: tone, letterSpacing: 1.3)),- ),- ],- const Spacer(),- Row(children: [- Expanded(child: _stat(gc, time.$1, time.$2, t.duration, size: 34)),- Expanded(child: _stat(gc, fit.volumeValue(recap.volumeKg), fit.volumeUnit, t.statLifted, size: 34)),- Expanded(child: _stat(gc, '${recap.sets}', '', t.setsCaps, size: 34)),- ]),- const SizedBox(height: 14),- Row(children: [- Expanded(child: _stat(gc, '${recap.records.length}', '', t.prs, size: 22, soft: true)),- Expanded(child: _stat(gc, '${recap.avgMinutes}', 'min', t.recapAvgLabel, size: 22, soft: true)),- Expanded(- child: _stat(gc, recap.favDay == null ? '–' : t.weekdayShort(recap.favDay!), '', t.recapFavLabel,- size: 22, soft: true),- ),- ]),- ]);- }-- Widget _calendar(GymColors gc, Color tone) {- final m = recap.month;- final count = DateTime(m.year, m.month + 1, 0).day;- final lead = (DateTime(m.year, m.month, 1).weekday - fit.weekStartDay + 7) % 7;- final time = _time;- final order = [for (var i = 0; i < 7; i++) (fit.weekStartDay - 1 + i) % 7 + 1];- return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- Text(t.monthName(m.month),- style: AppTheme.f(56, weight: FontWeight.w900, color: gc.text, letterSpacing: -2.4, height: 1)),- const SizedBox(height: 6),- Text(t.recapCalendarLine(recap.workouts, recap.days.length),- style: AppTheme.f(13.5, weight: FontWeight.w800, color: tone)),- const SizedBox(height: 18),- Row(children: [- for (final d in order)- Expanded(- child: Center(- child:- Text(t.weekdayInitial(d), style: AppTheme.f(10, weight: FontWeight.w800, color: gc.textTertiary)),- ),- ),- ]),- const SizedBox(height: 6),- GridView.count(- crossAxisCount: 7,- shrinkWrap: true,- physics: const NeverScrollableScrollPhysics(),- mainAxisSpacing: 6,- crossAxisSpacing: 6,- padding: EdgeInsets.zero,- children: [- for (var i = 0; i < lead; i++) const SizedBox.shrink(),- for (var d = 1; d <= count; d++)- Container(- alignment: Alignment.center,- decoration: BoxDecoration(- color: recap.days.contains(d) ? gc.ember : gc.bgRaised2,- shape: BoxShape.circle,- ),- child: Text('$d',- style: AppTheme.f(11.5,- weight: FontWeight.w800, color: recap.days.contains(d) ? gc.onEmber : gc.textSecondary)),- ),- ],- ),- const Spacer(),- Row(children: [- Expanded(child: _stat(gc, time.$1, time.$2, t.duration, size: 34)),- Expanded(child: _stat(gc, fit.volumeValue(recap.volumeKg), fit.volumeUnit, t.statLifted, size: 34)),- Expanded(- child: _stat(gc, recap.favDay == null ? '–' : t.weekdayShort(recap.favDay!), '', t.recapFavLabel, size: 34),- ),- ]),- ]);- }-- Widget _lift(GymColors gc, Color tone, Exercise ex) {- final l = recap.lift!;- final heavy = l.bestKg > 0;- return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- const Spacer(flex: 2),- Center(- child: Container(- padding: const EdgeInsets.all(3),- decoration: BoxDecoration(borderRadius: BorderRadius.circular(27), border: Border.all(color: gc.border, width: 1.5)),- child: SizedBox(width: 196, child: ExerciseMedia(ex: ex, height: 196, radius: 24)),- ),- ),- const Spacer(flex: 3),- Text(t.recapLiftKicker.toUpperCase(),- style: AppTheme.f(10, weight: FontWeight.w800, color: tone, letterSpacing: 1.6)),- const SizedBox(height: 6),- Text(exerciseName(ex),- maxLines: 2,- overflow: TextOverflow.ellipsis,- style: AppTheme.f(28, weight: FontWeight.w900, color: gc.text, letterSpacing: -0.8, height: 1.05)),- const SizedBox(height: 18),- _stat(- gc,- heavy ? fit.weightLabel(l.bestKg).split(' ').first : '${l.sets}',- heavy ? fit.units : '',- heavy ? t.recapBest : t.setsCaps,- size: 72,- ),- const SizedBox(height: 18),- Row(children: [- if (heavy) Expanded(child: _stat(gc, '${l.sets}', '', t.setsCaps, size: 26)),- Expanded(child: _stat(gc, '${l.times}', '', t.recapTimes, size: 26)),- Expanded(child: _stat(gc, fit.volumeValue(l.volumeKg), fit.volumeUnit, t.statLifted, size: 26)),- ]),- ]);- }-}+import 'dart:math' as math;+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';+import 'package:flutter/scheduler.dart';+import 'package:flutter/services.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';++import '../catalog/awards.dart';+import '../l10n/l10n.dart';+import '../models/exercise.dart';+import '../models/workout.dart';+import '../services/food_library.dart';+import '../services/health_metrics.dart';+import '../state/fit_state.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import '../widgets/body_map.dart';+import '../widgets/exercise_media.dart';+import '../widgets/exercise_preview.dart';+import '../widgets/liquid_notch.dart';+import '../widgets/medal.dart';+import '../widgets/medal_shelf.dart';+import '../widgets/name_ticker.dart';+import '../widgets/nutrition_art.dart';+import '../widgets/profile_avatar.dart';+import '../widgets/ui_kit.dart';+import '../services/file_share.dart';++const double kRecapAvatar = 150;++double recapAvatarY(Size size) => size.height * 0.4;++Future<void> openRecap(BuildContext context) async {+ if (fit.nutritionBeta && !FoodLibrary.ready) await FoodLibrary.load();+ if (!context.mounted) return;+ await Navigator.of(context).push(PageRouteBuilder<void>(+ transitionDuration: const Duration(milliseconds: 380),+ reverseTransitionDuration: const Duration(milliseconds: 300),+ pageBuilder: (_, _, _) => const RecapScreen(),+ transitionsBuilder: (_, a, _, child) =>+ FadeTransition(opacity: CurvedAnimation(parent: a, curve: Curves.easeOut), child: child),+ ));+}++enum _Page { hello, workouts, time, volume, peak, lift, fresh, muscle, records, medals, cardio, steps, sleep, food, habit, share }++TextStyle _num(double size, Color color) => AppTheme.f(size,+ weight: FontWeight.w900, color: color, letterSpacing: -size * 0.045, height: 1)+ .copyWith(fontFeatures: const [ui.FontFeature.tabularFigures()]);++class StoryRings extends StatefulWidget {+ const StoryRings({super.key, required this.size, required this.color, this.ring = true});++ final double size;+ final Color color;+ final bool ring;++ @override+ State<StoryRings> createState() => _StoryRingsState();+}++class _StoryRingsState extends State<StoryRings> with SingleTickerProviderStateMixin {+ late final AnimationController _c;++ @override+ void initState() {+ super.initState();+ _c = AnimationController(vsync: this, duration: const Duration(milliseconds: 1250))..forward();+ }++ @override+ void dispose() {+ _c.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final box = widget.size + 200;+ return IgnorePointer(+ child: SizedBox(+ width: box,+ height: box,+ child: RepaintBoundary(+ child: CustomPaint(painter: _RingsPainter(_c, widget.size, widget.color, widget.ring)),+ ),+ ),+ );+ }+}++class _RingsPainter extends CustomPainter {+ _RingsPainter(this.a, this.size, this.color, this.ring) : super(repaint: a);++ final Animation<double> a;+ final double size;+ final Color color;+ final bool ring;++ @override+ void paint(Canvas canvas, Size box) {+ final c = box.center(Offset.zero);+ final base = size / 2 + 7;+ for (var i = 0; i < 2; i++) {+ final start = i * 0.24;+ final v = ((a.value - start) / (1 - start)).clamp(0.0, 1.0);+ if (v <= 0 || v >= 1) continue;+ final e = Curves.easeOutCubic.transform(v);+ canvas.drawCircle(+ c,+ base + 58 * e,+ Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1.4 * (1 - e) + 0.5+ ..color = color.withValues(alpha: (1 - v) * (i == 0 ? 0.4 : 0.22)),+ );+ }+ if (ring) {+ final show = Curves.easeOut.transform((a.value / 0.35).clamp(0.0, 1.0));+ canvas.drawCircle(+ c,+ base,+ Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1.6+ ..color = color.withValues(alpha: 0.5 * show),+ );+ }+ }++ @override+ bool shouldRepaint(_RingsPainter old) => old.size != size || old.color != color || old.ring != ring;+}++class _Count extends StatelessWidget {+ const _Count(this.value, {required this.style, this.format, this.delay = 0, this.duration = 1500});++ final double value;+ final TextStyle style;+ final String Function(double v)? format;+ final int delay;+ final int duration;++ @override+ Widget build(BuildContext context) {+ final total = delay + duration;+ return TweenAnimationBuilder<double>(+ tween: Tween(begin: 0, end: value),+ duration: Duration(milliseconds: total),+ curve: Interval(delay / total, 1, curve: Curves.easeOutExpo),+ builder: (_, v, _) => Text(format?.call(v) ?? '${v.round()}', style: style),+ );+ }+}++class _Enter extends StatelessWidget {+ const _Enter({required this.child, this.delay = 0, this.from = 18});++ final Widget child;+ final int delay;+ final double from;++ @override+ Widget build(BuildContext context) {+ final total = delay + 520;+ return TweenAnimationBuilder<double>(+ tween: Tween(begin: 0, end: 1),+ duration: Duration(milliseconds: total),+ curve: Interval(delay / total, 1, curve: Curves.easeOutCubic),+ builder: (_, v, child) => Opacity(+ opacity: v,+ child: Transform.translate(offset: Offset(0, from * (1 - v)), child: child),+ ),+ child: child,+ );+ }+}++class _Pop extends StatelessWidget {+ const _Pop({required this.child, this.delay = 0});++ final Widget child;+ final int delay;++ @override+ Widget build(BuildContext context) {+ final total = delay + 560;+ return TweenAnimationBuilder<double>(+ tween: Tween(begin: 0, end: 1),+ duration: Duration(milliseconds: total),+ curve: Interval(delay / total, 1, curve: Curves.easeOutBack),+ builder: (_, v, child) => Opacity(+ opacity: v.clamp(0.0, 1.0),+ child: Transform.scale(scale: 0.4 + 0.6 * v, child: child),+ ),+ child: child,+ );+ }+}++class RecapScreen extends StatefulWidget {+ const RecapScreen({super.key});++ @override+ State<RecapScreen> createState() => _RecapScreenState();+}++class _RecapScreenState extends State<RecapScreen> {+ late final MonthRecap _recap = fit.recapFor(fit.recapMonth);+ late final MonthRecap _prev = fit.recapFor(DateTime(_recap.month.year, _recap.month.month - 1));+ late final Exercise? _lift = _recap.lift == null ? null : fit.exerciseById(_recap.lift!.id);+ late final _extras = recapExtras(_recap);+ late final List<String> _wall = recapWallIds(_recap);+ late final List<_Page> _pages = [+ _Page.hello,+ if (!_recap.empty) ...[+ _Page.workouts,+ _Page.time,+ if (_recap.volumeKg > 0) _Page.volume,+ if (_extras.peak != null) _Page.peak,+ if (_lift != null) _Page.lift,+ if (_extras.fresh.isNotEmpty) _Page.fresh,+ if (_recap.topMuscle != null) _Page.muscle,+ _Page.records,+ if (_extras.medals.isNotEmpty) _Page.medals,+ if (_extras.cardio != null) _Page.cardio,+ if (_extras.steps != null) _Page.steps,+ if (_extras.sleep != null) _Page.sleep,+ if (_extras.food != null) _Page.food,+ if (_recap.favDay != null) _Page.habit,+ _Page.share,+ ],+ ];+ final _cards = [GlobalKey(), GlobalKey(), GlobalKey()];+ final _variants = PageController(viewportFraction: 0.8);+ final _pager = PageController();+ int _variant = 0;+ int _at = 0;+ double _pulled = 0;+ bool _busy = false;++ String get _month => t.monthInline(_recap.month.month);+ String get _prevMonth => t.monthInline(_prev.month.month);++ @override+ void dispose() {+ _variants.dispose();+ _pager.dispose();+ super.dispose();+ }++ void _go(int to) {+ if (to < 0 || to >= _pages.length || !_pager.hasClients) return;+ _pager.animateToPage(to, duration: const Duration(milliseconds: 420), curve: Curves.easeOutCubic);+ }++ void _tap(TapUpDetails d, double width) {+ final page = _pages[_at];+ if (page == _Page.share || (page == _Page.hello && _recap.empty)) return;+ final at = _pager.hasClients ? (_pager.page ?? _at.toDouble()).round() : _at;+ _go(d.localPosition.dx < width * 0.3 ? at - 1 : at + 1);+ }++ bool _scrolled(ScrollNotification n) {+ if (n.depth != 0 || n.metrics.axis != Axis.vertical) return false;+ if (n is ScrollStartNotification) _pulled = 0;+ if (n is OverscrollNotification && n.dragDetails != null && n.overscroll < 0 && _at == 0) {+ _pulled -= n.overscroll;+ if (_pulled > 60) {+ _pulled = -double.infinity;+ Navigator.of(context).maybePop();+ }+ }+ return false;+ }++ void _openExercise(Exercise ex) => showExercisePreview(context, ex);++ String _tickerText(_Page page) => switch (page) {+ _Page.hello => fit.displayName,+ _Page.workouts => t.recapTickWorkouts,+ _Page.time => t.recapTickTime,+ _Page.volume => t.recapTickVolume,+ _Page.peak => t.recapTickPeak,+ _Page.lift => _lift == null ? '' : exerciseName(_lift),+ _Page.fresh => t.recapTickFresh,+ _Page.muscle => muscleLabel(_recap.topMuscle ?? ''),+ _Page.records => t.recapTickRecords,+ _Page.medals => t.recapTickMedals,+ _Page.cardio => 'Cardio',+ _Page.steps => t.recapTickSteps,+ _Page.sleep => t.recapTickSleep,+ _Page.food => t.recapTickFood,+ _Page.habit => t.weekday(_recap.favDay ?? 1),+ _Page.share => 'GymMane',+ };++ Future<void> _share() async {+ if (_busy) return;+ setState(() => _busy = true);+ try {+ final boundary = _cards[_variant].currentContext?.findRenderObject() as RenderRepaintBoundary?;+ if (boundary == null) return;+ final image = await boundary.toImage(pixelRatio: 1080 / boundary.size.width);+ final data = await image.toByteData(format: ui.ImageByteFormat.png);+ image.dispose();+ if (data == null) return;+ if (!mounted) return;+ await shareFile('gymmane-${_recap.month.year}-${_recap.month.month}-$_variant.png', data.buffer.asUint8List(),+ mime: 'image/png', subject: 'GymMane');+ } catch (_) {+ if (mounted) {+ showNotchToast(context, t.shareFailed, icon: PhosphorIconsFill.warningCircle, accent: context.gc.warn);+ }+ } finally {+ if (mounted) setState(() => _busy = false);+ }+ }++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final pad = MediaQuery.paddingOf(context);+ final size = MediaQuery.sizeOf(context);+ final page = _pages[_at];+ return Scaffold(+ backgroundColor: gc.bg,+ body: Stack(children: [+ Positioned.fill(+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 520),+ switchInCurve: Curves.easeOutCubic,+ switchOutCurve: Curves.easeInCubic,+ child: _backdrop(gc, page),+ ),+ ),+ Positioned.fill(+ child: NotificationListener<ScrollNotification>(+ onNotification: _scrolled,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTapUp: (d) => _tap(d, size.width),+ child: PageView.builder(+ controller: _pager,+ scrollDirection: Axis.vertical,+ physics: const PageScrollPhysics(parent: ClampingScrollPhysics()),+ itemCount: _pages.length,+ onPageChanged: (i) {+ HapticFeedback.selectionClick();+ setState(() => _at = i);+ },+ itemBuilder: (context, i) => AnimatedBuilder(+ animation: _pager,+ child: _slot(gc, size, pad, _pages[i]),+ builder: (context, child) {+ final at = _pager.hasClients && _pager.position.haveDimensions+ ? _pager.page ?? _at.toDouble()+ : _at.toDouble();+ final d = (at - i).abs().clamp(0.0, 1.0);+ return Opacity(+ opacity: 1 - Curves.easeIn.transform(d) * 0.9,+ child: Transform.scale(scale: 1 - 0.06 * d, child: child),+ );+ },+ ),+ ),+ ),+ ),+ ),+ Positioned(+ left: 20,+ right: 14,+ top: pad.top + 8,+ child: Row(children: [+ Expanded(+ child: Text(t.monthYear(_recap.month).toUpperCase(),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(10.5, weight: FontWeight.w800, color: gc.textTertiary, letterSpacing: 1.6)),+ ),+ _CloseButton(onTap: () => Navigator.of(context).maybePop()),+ ]),+ ),+ if (_pages.length > 1)+ Positioned(+ right: 10,+ top: 0,+ bottom: 0,+ child: IgnorePointer(child: Center(child: _rail(gc))),+ ),+ ]),+ );+ }++ Widget _backdrop(GymColors gc, _Page page) {+ if (page == _Page.lift && _wall.isNotEmpty) return _ExerciseWall(key: const ValueKey('wall'), ids: _wall);+ final text = _tickerText(page);+ return NameTicker(+ key: ValueKey('$text$page'),+ text: text,+ color: gc.text.withValues(alpha: 0.06),+ rows: 0,+ );+ }++ Widget _slot(GymColors gc, Size size, EdgeInsets pad, _Page page) {+ if (page == _Page.hello) return Stack(children: _hello(gc, size));+ final side = page == _Page.share ? 0.0 : 24.0;+ return Padding(+ padding: EdgeInsets.fromLTRB(side, pad.top + 60, page == _Page.share ? 0 : 34, pad.bottom + 24),+ child: _page(gc, page, gc.accent),+ );+ }++ Widget _rail(GymColors gc) => Column(mainAxisSize: MainAxisSize.min, children: [+ for (var i = 0; i < _pages.length; i++)+ AnimatedContainer(+ duration: const Duration(milliseconds: 280),+ curve: Curves.easeOutCubic,+ margin: const EdgeInsets.symmetric(vertical: 3),+ width: 4,+ height: i == _at ? 22 : 6,+ decoration: BoxDecoration(+ color: i == _at ? gc.text : (i < _at ? gc.textSecondary : gc.bgRaised2),+ borderRadius: BorderRadius.circular(2),+ ),+ ),+ ]);++ Widget _kicker(String text, Color tone) => _Enter(+ child: Text(text.toUpperCase(), style: AppTheme.f(11, weight: FontWeight.w800, color: tone, letterSpacing: 1.8)),+ );++ Widget _line(GymColors gc, String text, {Color? color, int delay = 900}) => _Enter(+ delay: delay,+ child: Text(text, style: AppTheme.f(16, weight: FontWeight.w600, color: color ?? gc.textSecondary, height: 1.4)),+ );++ Widget _bigRow(List<Widget> parts) => FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerStart,+ child: Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: parts)),+ );++ Widget _unit(String text, double size, Color tone) => Padding(+ padding: const EdgeInsets.only(left: 6, right: 14),+ child: Text(text, style: AppTheme.f(size * 0.3, weight: FontWeight.w800, color: tone)),+ );++ Widget _bottom(List<Widget> children) => Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisAlignment: MainAxisAlignment.end,+ children: children,+ );++ Widget _versus(GymColors gc, Color tone, double now, double before, String Function(double) say) {+ if (_prev.empty) return const SizedBox.shrink();+ final diff = now - before;+ final up = diff > 0.0001;+ final same = diff.abs() <= 0.0001;+ return _Enter(+ delay: 1200,+ child: Container(+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 7),+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(100)),+ child: Row(mainAxisSize: MainAxisSize.min, children: [+ Icon(same ? PhosphorIconsBold.equals : (up ? PhosphorIconsBold.arrowUp : PhosphorIconsBold.arrowDown),+ size: 12, color: tone),+ const SizedBox(width: 6),+ Flexible(+ child: Text(+ same+ ? t.recapSameAs(_prevMonth)+ : (up ? t.recapMoreThan(say(diff.abs()), _prevMonth) : t.recapLessThan(say(diff.abs()), _prevMonth)),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(12.5, weight: FontWeight.w800, color: tone),+ ),+ ),+ ]),+ ),+ );+ }++ Widget _page(GymColors gc, _Page page, Color tone) => switch (page) {+ _Page.hello => const SizedBox.shrink(),+ _Page.workouts => _WorkoutsPage(+ recap: _recap,+ tone: tone,+ kicker: _kicker(t.recapWorkoutsKicker, tone),+ versus: _versus(gc, tone, _recap.workouts.toDouble(), _prev.workouts.toDouble(), (v) => '${v.round()}'),+ notes: [+ if (_extras.streak >= 2) t.recapStreak(_extras.streak),+ if (_extras.yearAgo > 0) t.recapYearAgo(_extras.yearAgo),+ ],+ ),+ _Page.time => _time(gc, tone),+ _Page.volume => _volume(gc, tone),+ _Page.peak => _peakPage(gc, tone),+ _Page.lift => _liftPage(gc, tone),+ _Page.fresh => _freshPage(gc, tone),+ _Page.muscle => _muscle(gc, tone),+ _Page.records => _records(gc, tone),+ _Page.medals => _medals(gc, tone),+ _Page.cardio => _cardio(gc, tone),+ _Page.steps => _stepsPage(gc, tone),+ _Page.sleep => _sleepPage(gc, tone),+ _Page.food => _food(gc, tone),+ _Page.habit => _habit(gc, tone),+ _Page.share => _sharePage(gc, tone),+ };++ List<Widget> _hello(GymColors gc, Size size) {+ final first = fit.displayName.split(' ').first;+ final y = recapAvatarY(size);+ return [+ Positioned(+ left: (size.width - kRecapAvatar - 200) / 2,+ top: y - (kRecapAvatar + 200) / 2,+ child: const StoryRings(size: kRecapAvatar, color: Colors.white),+ ),+ Positioned(+ left: (size.width - kRecapAvatar) / 2,+ top: y - kRecapAvatar / 2,+ child: const ProfileAvatar(size: kRecapAvatar),+ ),+ Positioned(+ left: 28,+ right: 28,+ top: y + kRecapAvatar / 2 + 34,+ child: Column(children: [+ _Enter(+ delay: 200,+ child: Text(t.recapHi(first),+ textAlign: TextAlign.center,+ style: AppTheme.f(40, weight: FontWeight.w900, color: gc.text, letterSpacing: -1.2)),+ ),+ const SizedBox(height: 10),+ _Enter(+ delay: 420,+ child: Text(_recap.empty ? t.recapEmpty(_month) : t.recapReady(_month),+ textAlign: TextAlign.center,+ style: AppTheme.f(16, weight: FontWeight.w600, color: gc.textSecondary, height: 1.4)),+ ),+ const SizedBox(height: 28),+ _Enter(+ delay: 650,+ child: SizedBox(+ width: 200,+ child: _recap.empty+ ? PrimaryButton(label: t.recapClose, onTap: () => Navigator.of(context).maybePop())+ : PrimaryButton(label: t.recapGo, onTap: () => _go(1)),+ ),+ ),+ ]),+ ),+ ];+ }++ Widget _time(GymColors gc, Color tone) {+ final h = _recap.seconds ~/ 3600;+ final m = (_recap.seconds % 3600) ~/ 60;+ final mins = _recap.sessionMinutes;+ final top = mins.fold(1, math.max);+ final longest = _recap.longest;+ return _bottom([+ _kicker(t.recapTimeKicker, tone),+ const SizedBox(height: 6),+ _bigRow([+ if (h > 0) ...[+ _Count(h.toDouble(), style: _num(112, gc.text)),+ _unit('h', 112, tone),+ ],+ _Count(m.toDouble(), style: _num(112, gc.text), delay: h > 0 ? 350 : 0),+ _unit('min', 112, tone),+ ]),+ const SizedBox(height: 14),+ _versus(gc, tone, _recap.seconds / 3600, _prev.seconds / 3600, (v) => '${fmt((v * 10).round() / 10)} h'),+ const SizedBox(height: 22),+ SizedBox(+ height: 96,+ child: Row(crossAxisAlignment: CrossAxisAlignment.end, children: [+ for (var i = 0; i < mins.length; i++) ...[+ if (i > 0) const SizedBox(width: 4),+ Expanded(+ child: TweenAnimationBuilder<double>(+ tween: Tween(begin: 0, end: mins[i] / top),+ duration: Duration(milliseconds: 700 + i * 45),+ curve: Interval(math.min(0.7, i * 45 / (700 + i * 45)), 1, curve: Curves.easeOutBack),+ builder: (_, v, _) => Container(+ height: 6 + 88 * v.clamp(0.0, 1.08),+ decoration: BoxDecoration(+ color: mins[i] == top ? gc.text : gc.text.withValues(alpha: 0.22),+ borderRadius: BorderRadius.circular(4),+ ),+ ),+ ),+ ),+ ],+ ]),+ ),+ const SizedBox(height: 18),+ _line(gc, t.recapAvg(_recap.avgMinutes), color: gc.text),+ if (longest != null && longest.durationSec > 0) ...[+ const SizedBox(height: 4),+ _line(gc, t.recapLongest('${longest.durationSec ~/ 60} min', t.shortDate(longest.day)), delay: 1100),+ ],+ const SizedBox(height: 30),+ ]);+ }++ Widget _volume(GymColors gc, Color tone) {+ final cars = (_recap.volumeKg / 1500).floor();+ final shown = math.min(cars, 14);+ final top = _recap.topExercise == null ? null : fit.exerciseById(_recap.topExercise!);+ return _bottom([+ _kicker(t.recapVolumeKicker, tone),+ const SizedBox(height: 6),+ _bigRow([+ _Count(_recap.volumeKg, style: _num(112, gc.text), format: fit.volumeValue, duration: 1800),+ _unit(fit.volumeUnit, 112, tone),+ ]),+ const SizedBox(height: 14),+ _versus(gc, tone, _recap.volumeKg, _prev.volumeKg, fit.volumeLabel),+ const SizedBox(height: 24),+ if (shown > 0) ...[+ Wrap(spacing: 8, runSpacing: 8, children: [+ for (var i = 0; i < shown; i++)+ _Pop(delay: 700 + i * 90, child: Icon(PhosphorIconsFill.car, size: 26, color: gc.text)),+ ]),+ const SizedBox(height: 12),+ _line(gc, t.recapCars(cars, groupedInt(cars)), color: gc.text, delay: 1300),+ ],+ if (top != null) ...[+ const SizedBox(height: 4),+ _line(gc, t.recapTop(exerciseName(top), fit.volumeLabel(_recap.topExerciseKg)), delay: 1500),+ ],+ const SizedBox(height: 30),+ ]);+ }++ Widget _chip(GymColors gc, Widget value, String label, int delay) => Expanded(+ child: _Enter(+ delay: delay,+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ FittedBox(fit: BoxFit.scaleDown, alignment: AlignmentDirectional.centerStart, child: value),+ const SizedBox(height: 4),+ Text(label.toUpperCase(),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(9.5, weight: FontWeight.w800, color: gc.textTertiary, letterSpacing: 1.2)),+ ]),+ ),+ );++ Widget _peakPage(GymColors gc, Color tone) {+ final s = _extras.peak!;+ final exs = [for (final e in s.exercises) ?fit.exerciseById(e.id)];+ final name = s.name?.trim() ?? '';+ return _bottom([+ _kicker(t.recapPeakKicker, tone),+ const SizedBox(height: 6),+ _Enter(+ delay: 100,+ child: FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerStart,+ child: Text(t.shortDate(s.day),+ style: AppTheme.f(80, weight: FontWeight.w900, color: gc.text, letterSpacing: -3, height: 1)),+ ),+ ),+ const SizedBox(height: 6),+ _Enter(+ delay: 250,+ child: Text(name.isEmpty ? t.weekday(s.day.weekday) : '${t.weekday(s.day.weekday)} · $name',+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(20, weight: FontWeight.w800, color: gc.textSecondary)),+ ),+ const SizedBox(height: 26),+ Row(children: [+ _chip(gc, _Count(s.volume, style: _num(34, gc.text), delay: 350, format: fit.volumeValue),+ '${t.statLifted} · ${fit.volumeUnit}', 350),+ _chip(gc, _Count((s.durationSec ~/ 60).toDouble(), style: _num(34, gc.text), delay: 500), '${t.duration} · min',+ 500),+ _chip(gc, _Count(s.setCount.toDouble(), style: _num(34, gc.text), delay: 650), t.setsCaps, 650),+ ]),+ if (exs.isNotEmpty) ...[+ const SizedBox(height: 22),+ Wrap(spacing: 8, runSpacing: 8, children: [+ for (final (i, ex) in exs.take(6).indexed)+ _Pop(+ delay: 800 + i * 90,+ child: Pressable(+ onTap: () => _openExercise(ex),+ child: SizedBox(width: 48, child: ExerciseMedia(ex: ex, height: 48, radius: 12, bordered: false)),+ ),+ ),+ ]),+ ],+ const SizedBox(height: 30),+ ]);+ }++ Widget _freshPage(GymColors gc, Color tone) {+ final exs = [for (final id in _extras.fresh) ?fit.exerciseById(id)];+ final shown = exs.take(6).toList();+ return _bottom([+ _kicker(t.recapFreshKicker, tone),+ const SizedBox(height: 6),+ Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [+ _Count(exs.length.toDouble(), style: _num(112, gc.text), duration: 900),+ const SizedBox(width: 10),+ Flexible(+ child: Text(t.recapFresh(exs.length),+ maxLines: 2,+ style: AppTheme.f(28, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.6, height: 1.05)),+ ),+ ])),+ const SizedBox(height: 22),+ LayoutBuilder(builder: (context, box) {+ final tile = (box.maxWidth - 20) / 3;+ return Wrap(spacing: 10, runSpacing: 14, children: [+ for (final (i, ex) in shown.indexed)+ _Pop(+ delay: 400 + i * 110,+ child: Pressable(+ onTap: () => _openExercise(ex),+ child: SizedBox(+ width: tile,+ child: Column(children: [+ ExerciseMedia(ex: ex, height: tile, radius: 18, bordered: false),+ const SizedBox(height: 6),+ Text(exerciseName(ex),+ maxLines: 2,+ textAlign: TextAlign.center,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(11.5, weight: FontWeight.w700, color: gc.textSecondary, height: 1.2)),+ ]),+ ),+ ),+ ),+ ]);+ }),+ if (exs.length > shown.length) ...[+ const SizedBox(height: 10),+ _line(gc, t.recapMedalsMore(exs.length - shown.length), delay: 1200),+ ],+ const SizedBox(height: 30),+ ]);+ }++ Widget _liftPage(GymColors gc, Color tone) {+ final ex = _lift!;+ final l = _recap.lift!;+ final rest = [+ for (final r in _recap.topLifts.where((r) => r.id != l.id).take(4))+ if (fit.exerciseById(r.id) case final e?) (ex: e, sets: r.sets),+ ];+ Widget chip(Widget value, String label, int delay) => _chip(gc, value, label, delay);+ return _bottom([+ _kicker(t.recapLiftKicker, tone),+ const SizedBox(height: 12),+ Row(crossAxisAlignment: CrossAxisAlignment.end, children: [+ _Pop(+ child: Pressable(+ onTap: () => _openExercise(ex),+ child: Container(+ padding: const EdgeInsets.all(3),+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(29),+ border: Border.all(color: gc.border, width: 1.5),+ ),+ child: SizedBox(width: 170, child: ExerciseMedia(ex: ex, height: 170, radius: 26, live: true)),+ ),+ ),+ ),+ const SizedBox(width: 14),+ Expanded(+ child: _Enter(+ delay: 150,+ child: Text(exerciseName(ex),+ maxLines: 4,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(24, weight: FontWeight.w900, color: gc.text, letterSpacing: -0.6, height: 1.05)),+ ),+ ),+ ]),+ const SizedBox(height: 18),+ Row(children: [+ chip(_Count(l.sets.toDouble(), style: _num(34, gc.text), delay: 300), t.setsCaps, 300),+ if (l.bestKg > 0)+ chip(+ _Count(l.bestKg,+ style: _num(34, gc.text), delay: 450, format: (v) => fit.weightLabel(v).split(' ').first),+ '${t.recapBest} · ${fit.units}',+ 450),+ chip(_Count(l.times.toDouble(), style: _num(34, gc.text), delay: 600), t.recapTimes, 600),+ ]),+ if (rest.isNotEmpty) ...[+ const SizedBox(height: 20),+ _Enter(+ delay: 750,+ child: Text(t.recapLiftRest.toUpperCase(),+ style: AppTheme.f(10, weight: FontWeight.w800, color: gc.textTertiary, letterSpacing: 1.6)),+ ),+ const SizedBox(height: 10),+ for (final (i, r) in rest.indexed)+ _Enter(+ delay: 850 + i * 120,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => _openExercise(r.ex),+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 4),+ child: Row(children: [+ SizedBox(width: 20, child: Text('${i + 2}', style: _num(18, tone).copyWith(letterSpacing: 0))),+ const SizedBox(width: 8),+ SizedBox(width: 38, child: ExerciseMedia(ex: r.ex, height: 38, radius: 10, bordered: false)),+ const SizedBox(width: 12),+ Expanded(+ child: Text(exerciseName(r.ex),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text)),+ ),+ const SizedBox(width: 10),+ Text(t.setCount(r.sets), style: AppTheme.f(13, weight: FontWeight.w700, color: gc.textSecondary)),+ ]),+ ),+ ),+ ),+ ],+ const SizedBox(height: 16),+ ]);+ }++ Widget _muscle(GymColors gc, Color tone) {+ return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ const Spacer(),+ Center(+ child: _Enter(+ from: 30,+ child: LayoutBuilder(+ builder: (context, box) => BodyHeatArt(gc: gc, intensity: _recap.heat, width: math.min(box.maxWidth, 320)),+ ),+ ),+ ),+ const SizedBox(height: 30),+ _kicker(t.recapMuscleKicker, tone),+ const SizedBox(height: 6),+ _Enter(+ delay: 200,+ child: FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerStart,+ child: Text(muscleLabel(_recap.topMuscle ?? ''),+ style: AppTheme.f(56, weight: FontWeight.w900, color: gc.text, letterSpacing: -2, height: 1)),+ ),+ ),+ const SizedBox(height: 10),+ _Count(_recap.topMuscleSets.toDouble(),+ style: AppTheme.f(16, weight: FontWeight.w700, color: tone),+ delay: 500,+ format: (v) => t.setCount(v.round())),+ if (_extras.forgot case final m?) ...[+ const SizedBox(height: 6),+ _line(gc, t.recapForgot(muscleLabel(m)), delay: 1000),+ ],+ const SizedBox(height: 30),+ ]);+ }++ Widget _records(GymColors gc, Color tone) {+ final list = _recap.records.take(4).toList();+ return _bottom([+ _kicker(t.recapRecordsKicker, tone),+ const SizedBox(height: 6),+ _Count(_recap.records.length.toDouble(), style: _num(112, gc.text), duration: 900),+ const SizedBox(height: 18),+ if (list.isEmpty)+ _line(gc, t.recapNoRecords(_recap.sets))+ else+ for (final (i, r) in list.indexed)+ _Enter(+ delay: 500 + i * 180,+ child: Pressable(+ onTap: fit.exerciseById(r.id) == null ? null : () => _openExercise(fit.exerciseById(r.id)!),+ child: Container(+ margin: const EdgeInsets.only(bottom: 8),+ padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(16)),+ child: Row(children: [+ Icon(PhosphorIconsRegular.trophy, size: 18, color: gc.textSecondary),+ const SizedBox(width: 12),+ Expanded(+ child: Text(fit.exerciseById(r.id) == null ? r.id : exerciseName(fit.exerciseById(r.id)!),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(15, weight: FontWeight.w700, color: gc.text)),+ ),+ const SizedBox(width: 10),+ _Count(r.kg,+ style: _num(18, gc.text).copyWith(letterSpacing: 0), delay: 600 + i * 180, format: fit.weightLabel),+ ]),+ ),+ ),+ ),+ const SizedBox(height: 30),+ ]);+ }++ Widget _medals(GymColors gc, Color tone) {+ final won = _extras.medals;+ final shown = won.take(9).toList();+ return _bottom([+ _kicker(t.recapMedalsKicker, tone),+ const SizedBox(height: 6),+ _Count(won.length.toDouble(), style: _num(112, gc.text), duration: 900),+ const SizedBox(height: 22),+ Wrap(spacing: 14, runSpacing: 14, children: [+ for (final (i, id) in shown.indexed)+ _Pop(+ delay: 400 + i * 120,+ child: Pressable(+ onTap: () => showMedalSheet(context, id),+ child: Column(mainAxisSize: MainAxisSize.min, children: [+ Medal(id: id, size: 74),+ const SizedBox(height: 6),+ SizedBox(+ width: 80,+ child: Text(awardName(id),+ maxLines: 2,+ textAlign: TextAlign.center,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textSecondary, height: 1.2)),+ ),+ ]),+ ),+ ),+ ]),+ if (won.length > shown.length) ...[+ const SizedBox(height: 10),+ _line(gc, t.recapMedalsMore(won.length - shown.length), delay: 1400),+ ],+ const SizedBox(height: 30),+ ]);+ }++ Widget _cardio(GymColors gc, Color tone) {+ final c = _extras.cardio!;+ final top = c.topId == null ? null : fit.exerciseById(c.topId!);+ return _bottom([+ _kicker(t.recapCardioKicker, tone),+ const SizedBox(height: 6),+ if (c.km > 0)+ _bigRow([+ _Count(c.km, style: _num(112, gc.text), format: fit.distanceValue, duration: 1700),+ _unit(fit.distanceUnit, 112, tone),+ ])+ else+ _bigRow([+ _Count(c.sec / 60, style: _num(112, gc.text)),+ _unit('min', 112, tone),+ ]),+ const SizedBox(height: 22),+ _Route(progress: 1, color: gc.text, track: gc.bgRaised2),+ const SizedBox(height: 22),+ if (c.km > 0) _line(gc, t.recapCardioTime(c.sec ~/ 60, c.count), color: gc.text),+ if (c.km <= 0) _line(gc, t.recapCardioCount(c.count), color: gc.text),+ if (top != null) ...[+ const SizedBox(height: 4),+ _line(gc, t.recapCardioTop(exerciseName(top)), delay: 1100),+ ],+ const SizedBox(height: 30),+ ]);+ }++ Widget _stepsPage(GymColors gc, Color tone) {+ final s = _extras.steps!;+ final group = MaterialLocalizations.of(context);+ return _bottom([+ _kicker(t.recapStepsKicker, tone),+ const SizedBox(height: 6),+ _bigRow([+ _Count(s.total.toDouble(),+ style: _num(96, gc.text), format: (v) => group.formatDecimal(v.round()), duration: 1800),+ ]),+ Text(t.recapStepsWord, style: AppTheme.f(28, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.6)),+ const SizedBox(height: 24),+ _MonthChart(values: s.perDay, avg: s.avg, month: _recap.month, tone: gc.text, label: gc.textTertiary),+ const SizedBox(height: 18),+ _line(gc, t.recapStepsAvg(group.formatDecimal(s.avg)), color: gc.text),+ const SizedBox(height: 4),+ _line(gc, t.recapStepsBest(group.formatDecimal(s.best), t.shortDate(s.bestDay)), delay: 1100),+ const SizedBox(height: 30),+ ]);+ }++ Widget _sleepPage(GymColors gc, Color tone) {+ final s = _extras.sleep!;+ return _bottom([+ _kicker(t.recapSleepKicker, tone),+ const SizedBox(height: 6),+ _bigRow([+ _Count((s.avg ~/ 60).toDouble(), style: _num(112, gc.text)),+ _unit('h', 112, tone),+ _Count((s.avg % 60).toDouble(), style: _num(112, gc.text), delay: 300),+ _unit('min', 112, tone),+ ]),+ Text(t.recapSleepAvg, style: AppTheme.f(20, weight: FontWeight.w800, color: gc.textSecondary)),+ const SizedBox(height: 24),+ _MonthChart(values: s.perNight, avg: s.avg, month: _recap.month, tone: gc.text, label: gc.textTertiary),+ const SizedBox(height: 18),+ _line(gc, t.recapSleepBest('${s.best ~/ 60} h ${s.best % 60} min', t.shortDate(s.bestDay)), color: gc.text),+ const SizedBox(height: 30),+ ]);+ }++ Widget _food(GymColors gc, Color tone) {+ final f = _extras.food!;+ final star = f.star;+ final rest = f.top.where((e) => e.name != star).take(3).toList();+ final group = MaterialLocalizations.of(context);+ return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Expanded(+ child: LayoutBuilder(+ builder: (context, box) {+ final size = math.min(250.0, math.min(box.maxWidth, box.maxHeight) - 16);+ if (size < 120 || f.top.isEmpty) return const SizedBox.shrink();+ return Center(+ child: _Enter(+ from: 26,+ child: FoodPlate(+ size: size,+ items: [for (final e in f.top) (e.photo, e.name)],+ wrap: (i, child) => _Enter(delay: 260 + i * 140, from: -24, child: child),+ ),+ ),+ );+ },+ ),+ ),+ const SizedBox(height: 18),+ _kicker(star == null ? t.recapFoodKicker : t.recapFoodStarKicker, tone),+ const SizedBox(height: 8),+ if (star != null) ...[+ _Enter(+ delay: 150,+ child: Text(star,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(40, weight: FontWeight.w900, color: gc.text, letterSpacing: -1.2, height: 1.02)),+ ),+ const SizedBox(height: 6),+ _Enter(+ delay: 260,+ child: Text(t.recapFoodStarDays(f.starTimes),+ style: AppTheme.f(18, weight: FontWeight.w800, color: gc.textSecondary)),+ ),+ ] else ...[+ _bigRow([+ _Count(f.protein.toDouble(), style: _num(96, gc.text)),+ _unit('g', 96, tone),+ ]),+ Text(t.recapFoodProtein(f.goal), style: AppTheme.f(18, weight: FontWeight.w800, color: gc.textSecondary)),+ ],+ const SizedBox(height: 22),+ Row(children: [+ if (star != null)+ _chip(gc, _Count(f.protein.toDouble(), style: _num(30, gc.text), delay: 400), t.recapFoodProteinLabel, 400),+ _chip(gc, Text('${f.hit}/${f.days}', style: _num(30, gc.text)), t.recapFoodGoalDays, 550),+ if (f.water > 0)+ _chip(gc, Text(fit.waterValue(f.water), style: _num(30, gc.text)), '${t.recapFoodWaterLabel} · ${fit.waterUnit}',+ 700)+ else+ _chip(gc, Text(group.formatDecimal(fit.energyOf(f.kcal)), style: _num(30, gc.text)),+ '${fit.energyUnit} · ${t.recapAvgLabel}', 700),+ ]),+ if (rest.isNotEmpty) ...[+ const SizedBox(height: 18),+ for (final (i, r) in rest.indexed)+ _Enter(+ delay: 850 + i * 120,+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 4),+ child: Row(children: [+ FoodSticker(photo: r.photo, name: r.name, size: 38, tilt: false, shadow: false),+ const SizedBox(width: 12),+ Expanded(+ child: Text(r.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text)),+ ),+ const SizedBox(width: 10),+ Text(t.recapFoodTimes(r.days), style: AppTheme.f(13, weight: FontWeight.w700, color: gc.textSecondary)),+ ]),+ ),+ ),+ ],+ const SizedBox(height: 24),+ ]);+ }++ Widget _habit(GymColors gc, Color tone) {+ final start = _recap.usualStart;+ final days = _recap.weekdays;+ final top = days.fold(1, math.max);+ final order = [for (var i = 0; i < 7; i++) (fit.weekStartDay - 1 + i) % 7 + 1];+ return _bottom([+ _kicker(t.recapHabitKicker, tone),+ const SizedBox(height: 6),+ _Enter(+ delay: 100,+ child: FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerStart,+ child: Text(t.weekday(_recap.favDay ?? 1),+ style: AppTheme.f(72, weight: FontWeight.w900, color: gc.text, letterSpacing: -3, height: 1)),+ ),+ ),+ const SizedBox(height: 26),+ SizedBox(+ height: 120,+ child: Row(crossAxisAlignment: CrossAxisAlignment.end, children: [+ for (final (i, d) in order.indexed) ...[+ if (i > 0) const SizedBox(width: 8),+ Expanded(+ child: Column(mainAxisAlignment: MainAxisAlignment.end, children: [+ TweenAnimationBuilder<double>(+ tween: Tween(begin: 0, end: days[d - 1] / top),+ duration: Duration(milliseconds: 800 + i * 70),+ curve: Interval(i * 70 / (800 + i * 70), 1, curve: Curves.easeOutBack),+ builder: (_, v, _) => Container(+ height: 6 + 84 * v.clamp(0.0, 1.08),+ decoration: BoxDecoration(+ color: d == _recap.favDay ? gc.text : gc.text.withValues(alpha: 0.22),+ borderRadius: BorderRadius.circular(6),+ ),+ ),+ ),+ const SizedBox(height: 8),+ Text(t.weekdayInitial(d),+ style: AppTheme.f(12, weight: FontWeight.w800, color: d == _recap.favDay ? gc.text : gc.textTertiary)),+ ]),+ ),+ ],+ ]),+ ),+ const SizedBox(height: 18),+ if (start != null)+ _line(+ gc,+ t.recapHabitStart(MaterialLocalizations.of(context).formatTimeOfDay(+ TimeOfDay(hour: start ~/ 60, minute: start % 60),+ alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context))),+ color: gc.text),+ const SizedBox(height: 30),+ ]);+ }++ Widget _sharePage(GymColors gc, Color tone) {+ final names = [t.recapCardSummary, t.recapCardCalendar, t.recapCardLift];+ return Column(children: [+ _kicker(t.recapShareKicker, tone),+ const SizedBox(height: 14),+ Expanded(+ child: PageView.builder(+ controller: _variants,+ itemCount: 3,+ onPageChanged: (i) {+ HapticFeedback.selectionClick();+ setState(() => _variant = i);+ },+ itemBuilder: (context, i) => AnimatedScale(+ scale: i == _variant ? 1 : 0.9,+ duration: const Duration(milliseconds: 260),+ curve: Curves.easeOutCubic,+ child: Center(+ child: AspectRatio(+ aspectRatio: 9 / 16,+ child: DecoratedBox(+ position: DecorationPosition.foreground,+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(18),+ border: Border.all(color: gc.text.withValues(alpha: 0.14)),+ ),+ child: FittedBox(+ child: RepaintBoundary(+ key: _cards[i],+ child: RecapCard(recap: _recap, variant: i),+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ const SizedBox(height: 14),+ AnimatedSwitcher(+ duration: const Duration(milliseconds: 200),+ child: Text(names[_variant],+ key: ValueKey(_variant), style: AppTheme.f(13, weight: FontWeight.w800, color: gc.textSecondary)),+ ),+ const SizedBox(height: 8),+ Row(mainAxisSize: MainAxisSize.min, children: [+ for (var i = 0; i < 3; i++)+ AnimatedContainer(+ duration: const Duration(milliseconds: 240),+ margin: const EdgeInsets.symmetric(horizontal: 3),+ width: i == _variant ? 18 : 6,+ height: 6,+ decoration: BoxDecoration(+ color: i == _variant ? gc.text : gc.bgRaised2,+ borderRadius: BorderRadius.circular(3),+ ),+ ),+ ]),+ const SizedBox(height: 16),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 24),+ child: PrimaryButton(label: t.recapShare, onTap: _share),+ ),+ ]);+ }+}++typedef RecapExtras = ({+ ({double km, int sec, int count, String? topId})? cardio,+ ({int total, int avg, int best, DateTime bestDay, List<int> perDay})? steps,+ ({int avg, int best, DateTime bestDay, List<int> perNight})? sleep,+ ({+ int days,+ int kcal,+ int protein,+ int goal,+ int hit,+ List<({String name, String photo, int days})> top,+ String? star,+ int starTimes,+ int water,+ })? food,+ List<AwardId> medals,+ LoggedSession? peak,+ List<String> fresh,+ int streak,+ int yearAgo,+ String? forgot,+});++List<String> recapWallIds(MonthRecap recap) {+ final ids = <String>[...recap.exerciseIds.where((id) => fit.exerciseById(id) != null)];+ if (ids.length < 8) {+ for (final s in fit.sessions.reversed) {+ if (!s.day.isBefore(recap.month)) continue;+ for (final e in s.exercises) {+ if (!ids.contains(e.id) && fit.exerciseById(e.id) != null) ids.add(e.id);+ }+ if (ids.length >= 12) break;+ }+ }+ if (ids.isNotEmpty && ids.length < 10) {+ final muscles = {for (final id in ids) fit.exerciseById(id)!.primary};+ for (final e in fit.allExercises) {+ if (ids.length >= 10) break;+ if (e.art.isNotEmpty && muscles.contains(e.primary) && !ids.contains(e.id)) ids.add(e.id);+ }+ }+ return ids;+}++RecapExtras recapExtras(MonthRecap recap) {+ final from = recap.month;+ final to = DateTime(from.year, from.month + 1);+ final today = DateTime.now();+ final days = [+ for (var d = from; d.isBefore(to) && !d.isAfter(today); d = DateTime(d.year, d.month, d.day + 1)) d,+ ];++ var km = 0.0;+ var sec = 0, count = 0;+ final byCardio = <String, int>{};+ for (final s in fit.sessions) {+ if (s.day.isBefore(from) || !s.day.isBefore(to)) continue;+ var any = false;+ for (final e in s.exercises) {+ if (!fit.isCardio(e.id)) continue;+ any = true;+ for (final st in e.sets) {+ km += st.km ?? 0;+ sec += st.sec ?? 0;+ }+ byCardio[e.id] = (byCardio[e.id] ?? 0) + 1;+ }+ if (any) count++;+ }+ String? topCardio;+ for (final e in byCardio.entries) {+ if (topCardio == null || e.value > byCardio[topCardio]!) topCardio = e.key;+ }++ ({int total, int avg, int best, DateTime bestDay, List<int> perDay})? steps;+ if (fit.stepsOn) {+ final perDay = [for (final d in days) fit.stepsOnDay(d)];+ final walked = perDay.where((n) => n > 0).toList();+ if (walked.length >= 3) {+ var best = 0;+ var bestDay = from;+ for (final (i, n) in perDay.indexed) {+ if (n > best) {+ best = n;+ bestDay = days[i];+ }+ }+ final total = walked.fold(0, (a, b) => a + b);+ steps = (total: total, avg: total ~/ walked.length, best: best, bestDay: bestDay, perDay: perDay);+ }+ }++ ({int avg, int best, DateTime bestDay, List<int> perNight})? sleep;+ if (fit.healthShown.contains(HealthMetric.sleep)) {+ final nights = [for (final d in days) (fit.healthOnDay(HealthMetric.sleep, d)?.first ?? 0).round()];+ final slept = nights.where((n) => n > 0).toList();+ if (slept.length >= 3) {+ var best = 0;+ var bestDay = from;+ for (final (i, n) in nights.indexed) {+ if (n > best) {+ best = n;+ bestDay = days[i];+ }+ }+ sleep = (avg: slept.fold(0, (a, b) => a + b) ~/ slept.length, best: best, bestDay: bestDay, perNight: nights);+ }+ }++ var logged = 0, hit = 0, waterDays = 0, water = 0;+ var kcal = 0.0, protein = 0.0;+ final foods = <String, int>{};+ final photos = <String, String>{};+ if (fit.nutritionBeta) {+ for (final d in days) {+ final entries = fit.entriesOn(d);+ final sips = fit.waterOn(d);+ if (sips > 0) {+ waterDays++;+ water += sips;+ }+ if (entries.isEmpty) continue;+ logged++;+ final m = fit.totalOn(d);+ kcal += m.kcal;+ protein += m.protein;+ final reached = m.protein >= fit.goalsFor(d).protein;+ if (reached) hit++;+ for (final e in entries) {+ if ((photos[e.name] ?? '').isEmpty) photos[e.name] = fit.photoForEntry(e);+ }+ for (final name in {for (final e in entries) e.name}) {+ foods[name] = (foods[name] ?? 0) + 1;+ }+ }+ }+ final favs = foods.entries.toList()..sort((a, b) => b.value.compareTo(a.value));++ final medals = !fit.gamification+ ? <AwardId>[]+ : [+ for (final id in AwardId.values)+ if (fit.awardWonAt(id) case final at? when !at.isBefore(from) && at.isBefore(to)) id,+ ];++ final inMonth = [for (final s in fit.sessions) if (!s.day.isBefore(from) && s.day.isBefore(to)) s];+ LoggedSession? peak;+ if (inMonth.length >= 3) {+ for (final s in inMonth) {+ if (s.volume > 0 && (peak == null || s.volume > peak.volume)) peak = s;+ }+ }++ final before = fit.sessions.any((s) => s.day.isBefore(from));+ final fresh = !before+ ? <String>[]+ : [+ for (final id in recap.exerciseIds)+ if (fit.exerciseById(id) != null && fit.exerciseHistory(id).every((h) => !h.date.isBefore(from))) id,+ ];++ final sorted = recap.days.toList()..sort();+ var streak = 0, run = 0;+ for (final (i, d) in sorted.indexed) {+ run = i > 0 && sorted[i - 1] == d - 1 ? run + 1 : 1;+ streak = math.max(streak, run);+ }++ final last = DateTime(from.year, from.month + 1, 0);+ final now = fit.muscleSetsBetween(from, last);+ final prevSets = fit.muscleSetsBetween(DateTime(from.year, from.month - 1), DateTime(from.year, from.month, 0));+ String? forgot;+ var forgotSets = 0.0;+ for (final e in prevSets.entries) {+ if (e.value >= 4 && (now[e.key] ?? 0) <= 0 && e.value > forgotSets) {+ forgotSets = e.value;+ forgot = e.key;+ }+ }++ return (+ cardio: count == 0 || (km <= 0 && sec <= 0) ? null : (km: km, sec: sec, count: count, topId: topCardio),+ steps: steps,+ sleep: sleep,+ food: logged < 1+ ? null+ : (+ days: logged,+ kcal: (kcal / logged).round(),+ protein: (protein / logged).round(),+ goal: fit.activeGoals.protein,+ hit: hit,+ top: [for (final e in favs.take(5)) (name: e.key, photo: photos[e.key] ?? '', days: e.value)],+ star: favs.isEmpty || favs.first.value < 2 ? null : favs.first.key,+ starTimes: favs.isEmpty ? 0 : favs.first.value,+ water: waterDays == 0 ? 0 : water ~/ waterDays,+ ),+ medals: medals,+ peak: peak,+ fresh: fresh,+ streak: streak,+ yearAgo: fit.recapFor(DateTime(from.year - 1, from.month)).workouts,+ forgot: forgot,+ );+}++class _ExerciseWall extends StatefulWidget {+ const _ExerciseWall({super.key, required this.ids});++ final List<String> ids;++ @override+ State<_ExerciseWall> createState() => _ExerciseWallState();+}++class _ExerciseWallState extends State<_ExerciseWall> with SingleTickerProviderStateMixin {+ late final Ticker _ticker = createTicker((e) => _clock.value = e.inMicroseconds / 1e6);+ final _clock = ValueNotifier<double>(0);+ late final List<Exercise> _exs = [for (final id in widget.ids) ?fit.exerciseById(id)];++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ final calm = MediaQuery.maybeDisableAnimationsOf(context) ?? false;+ if (!calm && !_ticker.isActive) _ticker.start();+ }++ @override+ void dispose() {+ _ticker.dispose();+ _clock.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ if (_exs.isEmpty) return const SizedBox.shrink();+ return LayoutBuilder(builder: (context, box) {+ const columns = 4;+ final tile = box.maxWidth / 3.2;+ const gap = 10.0;+ final span = tile + gap;+ final tall = box.maxHeight * 1.6;+ final perColumn = (tall / span).ceil() + 2;+ return ClipRect(+ child: Stack(children: [+ Positioned.fill(+ child: Transform.rotate(+ angle: -0.18,+ child: OverflowBox(+ maxWidth: box.maxWidth * 1.6,+ maxHeight: tall,+ child: RepaintBoundary(+ child: ValueListenableBuilder<double>(+ valueListenable: _clock,+ builder: (_, time, _) => Row(mainAxisAlignment: MainAxisAlignment.center, children: [+ for (var c = 0; c < columns; c++)+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: gap / 2),+ child: SizedBox(+ width: tile,+ height: tall,+ child: ClipRect(+ child: OverflowBox(+ alignment: Alignment.topCenter,+ maxHeight: double.infinity,+ child: Transform.translate(+ offset: Offset(0, -((time * (14 + c * 5) * (c.isEven ? 1 : -1)) % span) - span),+ child: Column(mainAxisSize: MainAxisSize.min, children: [+ for (var i = 0; i < perColumn; i++)+ Padding(+ padding: const EdgeInsets.only(bottom: gap),+ child: SizedBox(+ width: tile,+ child: ExerciseMedia(+ ex: _exs[(i * 3 + c) % _exs.length],+ height: tile,+ radius: 18,+ bordered: false,+ ),+ ),+ ),+ ]),+ ),+ ),+ ),+ ),+ ),+ ]),+ ),+ ),+ ),+ ),+ ),+ Positioned.fill(+ child: DecoratedBox(+ decoration: BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [gc.bg.withValues(alpha: 0.72), gc.bg.withValues(alpha: 0.7), gc.bg],+ stops: const [0, 0.38, 0.62],+ ),+ ),+ ),+ ),+ ]),+ );+ });+ }+}++class _MonthChart extends StatelessWidget {+ const _MonthChart({required this.values, required this.avg, required this.month, required this.tone, required this.label});++ final List<int> values;+ final int avg;+ final DateTime month;+ final Color tone;+ final Color label;++ @override+ Widget build(BuildContext context) => SizedBox(+ height: 128,+ width: double.infinity,+ child: TweenAnimationBuilder<double>(+ tween: Tween(begin: 0, end: 1),+ duration: const Duration(milliseconds: 1300),+ builder: (_, v, _) => CustomPaint(+ painter: _MonthChartPainter(+ values: values,+ avg: avg,+ count: DateTime(month.year, month.month + 1, 0).day,+ tone: tone,+ label: label,+ progress: v,+ rtl: Directionality.of(context) == TextDirection.rtl,+ scale: MediaQuery.textScalerOf(context),+ ),+ ),+ ),+ );+}++class _MonthChartPainter extends CustomPainter {+ _MonthChartPainter({+ required this.values,+ required this.avg,+ required this.count,+ required this.tone,+ required this.label,+ required this.progress,+ required this.rtl,+ required this.scale,+ });++ final List<int> values;+ final int avg;+ final int count;+ final Color tone;+ final Color label;+ final double progress;+ final bool rtl;+ final TextScaler scale;++ @override+ void paint(Canvas canvas, Size size) {+ const labelH = 22.0;+ final h = size.height - labelH;+ final slot = size.width / count;+ final barW = math.min(10.0, slot * 0.58);+ final top = math.max(1, values.fold(0, math.max));+ double cx(int i) => rtl ? size.width - slot * (i + 0.5) : slot * (i + 0.5);+ final paint = Paint();+ for (var i = 0; i < count; i++) {+ final v = i < values.length ? values[i] : 0;+ final x = cx(i);+ if (v <= 0) {+ paint.color = tone.withValues(alpha: (i < values.length ? 0.22 : 0.1) * progress);+ canvas.drawCircle(Offset(x, h - 1.8), 1.8, paint);+ continue;+ }+ final local = Curves.easeOutCubic.transform(((progress * 1.5) - i / count * 0.5).clamp(0.0, 1.0));+ final bh = math.max(barW, h * v / top) * local;+ if (bh <= 0) continue;+ paint.color = v == top ? tone : tone.withValues(alpha: 0.3);+ canvas.drawRRect(+ RRect.fromRectAndRadius(Rect.fromLTWH(x - barW / 2, h - bh, barW, bh), Radius.circular(barW / 2)),+ paint,+ );+ }+ if (avg > 0) {+ final y = h - h * avg / top;+ final dash = Paint()+ ..color = tone.withValues(alpha: 0.4 * Curves.easeOut.transform(((progress - 0.5) * 2).clamp(0.0, 1.0)))+ ..strokeWidth = 1.2+ ..strokeCap = StrokeCap.round;+ for (var x = 0.0; x < size.width; x += 7) {+ canvas.drawLine(Offset(x, y), Offset(math.min(x + 3, size.width), y), dash);+ }+ }+ for (final d in {1, (count + 1) ~/ 2, count}) {+ final tp = TextPainter(+ text: TextSpan(text: '$d', style: AppTheme.f(10.5, weight: FontWeight.w800, color: label)),+ textDirection: TextDirection.ltr,+ textScaler: scale.clamp(maxScaleFactor: 1.3),+ )..layout();+ tp.paint(canvas, Offset((cx(d - 1) - tp.width / 2).clamp(0.0, size.width - tp.width), h + 8));+ }+ }++ @override+ bool shouldRepaint(_MonthChartPainter old) =>+ old.progress != progress || old.values != values || old.tone != tone || old.label != label || old.rtl != rtl;+}++class _Route extends StatelessWidget {+ const _Route({required this.progress, required this.color, required this.track});++ final double progress;+ final Color color;+ final Color track;++ @override+ Widget build(BuildContext context) => TweenAnimationBuilder<double>(+ tween: Tween(begin: 0, end: progress),+ duration: const Duration(milliseconds: 1600),+ curve: Curves.easeInOutCubic,+ builder: (_, v, _) => SizedBox(+ height: 70,+ width: double.infinity,+ child: CustomPaint(painter: _RoutePainter(v, color, track)),+ ),+ );+}++class _RoutePainter extends CustomPainter {+ _RoutePainter(this.v, this.color, this.track);++ final double v;+ final Color color;+ final Color track;++ @override+ void paint(Canvas canvas, Size s) {+ final h = s.height;+ final path = Path()+ ..moveTo(4, h * 0.7)+ ..cubicTo(s.width * 0.18, h * 0.05, s.width * 0.32, h * 0.05, s.width * 0.45, h * 0.5)+ ..cubicTo(s.width * 0.58, h * 0.95, s.width * 0.74, h * 0.95, s.width * 0.84, h * 0.4)+ ..quadraticBezierTo(s.width * 0.92, h * 0.05, s.width - 4, h * 0.3);+ final base = Paint()+ ..color = track+ ..style = PaintingStyle.stroke+ ..strokeWidth = 5+ ..strokeCap = StrokeCap.round;+ canvas.drawPath(path, base);+ final metric = path.computeMetrics().first;+ canvas.drawPath(metric.extractPath(0, metric.length * v), base..color = color);+ final tip = metric.getTangentForOffset(metric.length * v)?.position;+ if (tip != null) {+ canvas.drawCircle(tip, 9, Paint()..color = color);+ canvas.drawCircle(tip, 4, Paint()..color = track);+ }+ }++ @override+ bool shouldRepaint(_RoutePainter old) => old.v != v || old.color != color;+}++class _CloseButton extends StatelessWidget {+ const _CloseButton({required this.onTap});++ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ return Semantics(+ button: true,+ label: t.recapClose,+ child: Pressable(+ onTap: onTap,+ scale: 0.88,+ child: Padding(+ padding: const EdgeInsets.all(2),+ child: Container(+ width: 40,+ height: 40,+ decoration: BoxDecoration(color: gc.text.withValues(alpha: 0.1), shape: BoxShape.circle),+ child: Icon(PhosphorIconsBold.x, size: 17, color: gc.text),+ ),+ ),+ ),+ );+ }+}++class _WorkoutsPage extends StatefulWidget {+ const _WorkoutsPage({+ required this.recap,+ required this.tone,+ required this.kicker,+ required this.versus,+ this.notes = const [],+ });++ final MonthRecap recap;+ final Color tone;+ final Widget kicker;+ final Widget versus;+ final List<String> notes;++ @override+ State<_WorkoutsPage> createState() => _WorkoutsPageState();+}++class _WorkoutsPageState extends State<_WorkoutsPage> with SingleTickerProviderStateMixin {+ late final List<int> _days = widget.recap.days.toList()..sort();+ late final AnimationController _run;+ int _lit = 0;++ @override+ void initState() {+ super.initState();+ _run = AnimationController(vsync: this, duration: Duration(milliseconds: 500 + 90 * _days.length))+ ..addListener(() {+ final lit = (Curves.easeInOut.transform(_run.value) * _days.length).round();+ if (lit != _lit) {+ if (lit > _lit) HapticFeedback.selectionClick();+ setState(() => _lit = lit);+ }+ })+ ..addStatusListener((s) {+ if (s == AnimationStatus.completed && mounted) setState(() {});+ });+ Future<void>.delayed(const Duration(milliseconds: 350), () {+ if (mounted) _run.forward();+ });+ }++ @override+ void dispose() {+ _run.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final m = widget.recap.month;+ final count = DateTime(m.year, m.month + 1, 0).day;+ final lead = (DateTime(m.year, m.month, 1).weekday - fit.weekStartDay + 7) % 7;+ final lit = {for (final d in _days.take(_lit)) d};+ final shown = (_lit / math.max(1, _days.length) * widget.recap.workouts).round();+ final order = [for (var i = 0; i < 7; i++) (fit.weekStartDay - 1 + i) % 7 + 1];+ return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.end, children: [+ widget.kicker,+ const SizedBox(height: 6),+ Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [+ Text('$shown', style: _num(112, gc.text)),+ const SizedBox(width: 10),+ Text(t.recapWorkouts(widget.recap.workouts),+ style: AppTheme.f(28, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.6)),+ ])),+ const SizedBox(height: 14),+ widget.versus,+ const SizedBox(height: 22),+ LayoutBuilder(builder: (context, box) {+ final cell = math.min(38.0, (box.maxWidth - 6 * 6) / 7);+ return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Wrap(spacing: 6, children: [+ for (final d in order)+ SizedBox(+ width: cell,+ child: Text(t.weekdayInitial(d),+ textAlign: TextAlign.center,+ style: AppTheme.f(10.5, weight: FontWeight.w800, color: gc.textTertiary)),+ ),+ ]),+ const SizedBox(height: 8),+ Wrap(spacing: 6, runSpacing: 6, children: [+ for (var i = 0; i < lead; i++) SizedBox(width: cell, height: cell),+ for (var d = 1; d <= count; d++)+ AnimatedScale(+ scale: lit.contains(d) ? 1 : 0.88,+ duration: const Duration(milliseconds: 260),+ curve: Curves.easeOutBack,+ child: AnimatedContainer(+ duration: const Duration(milliseconds: 220),+ width: cell,+ height: cell,+ alignment: Alignment.center,+ decoration: BoxDecoration(+ color: lit.contains(d) ? gc.ember : gc.bgRaised2,+ shape: BoxShape.circle,+ border: lit.contains(d) ? null : Border.all(color: gc.border.withValues(alpha: 0.7)),+ ),+ child: Text('$d',+ style: AppTheme.f(cell * 0.34,+ weight: FontWeight.w800, color: lit.contains(d) ? gc.onEmber : gc.textSecondary)),+ ),+ ),+ ]),+ ]);+ }),+ const SizedBox(height: 16),+ AnimatedOpacity(+ opacity: _run.isCompleted ? 1 : 0,+ duration: const Duration(milliseconds: 400),+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Text(t.recapDays(_days.length),+ style: AppTheme.f(16, weight: FontWeight.w600, color: gc.text, height: 1.4)),+ for (final note in widget.notes) ...[+ const SizedBox(height: 4),+ Text(note, style: AppTheme.f(16, weight: FontWeight.w600, color: gc.textSecondary, height: 1.4)),+ ],+ ]),+ ),+ const SizedBox(height: 30),+ ]);+ }+}+++class RecapCard extends StatelessWidget {+ const RecapCard({super.key, required this.recap, this.variant = 0});++ final MonthRecap recap;+ final int variant;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final tone = gc.accent;+ final lift = recap.lift == null ? null : fit.exerciseById(recap.lift!.id);+ final wall = variant == 2 ? recapWallIds(recap) : const <String>[];+ return SizedBox(+ width: 360,+ height: 640,+ child: ClipRRect(+ borderRadius: BorderRadius.circular(28),+ child: ColoredBox(+ color: gc.bg,+ child: Stack(children: [+ if (wall.isNotEmpty)+ Positioned(left: 0, right: 0, top: 0, height: 440, child: _staticWall(wall, gc.bg))+ else+ Positioned(+ left: 0,+ right: 0,+ top: variant == 1 ? 130 : 70,+ height: 240,+ child: NameTicker(+ text: switch (variant) {+ 1 => t.monthName(recap.month.month),+ 2 when lift != null => exerciseName(lift),+ _ => fit.displayName,+ },+ color: gc.text.withValues(alpha: 0.06),+ rows: 3,+ size: 74,+ running: false,+ ),+ ),+ Padding(+ padding: const EdgeInsets.fromLTRB(24, 26, 24, 22),+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ _header(gc, tone),+ const SizedBox(height: 18),+ Expanded(+ child: switch (variant) {+ 1 => _calendar(gc, tone),+ 2 when lift != null => _lift(gc, tone, lift),+ _ => _summary(gc, tone),+ },+ ),+ const SizedBox(height: 18),+ Center(child: _mark(gc)),+ ]),+ ),+ ]),+ ),+ ),+ );+ }++ Widget _staticWall(List<String> ids, Color bg) {+ final exs = [for (final id in ids) ?fit.exerciseById(id)];+ return Stack(fit: StackFit.expand, children: [+ Positioned(+ left: 0,+ right: 0,+ top: 0,+ bottom: 40,+ child: Opacity(+ opacity: 0.43,+ child: ClipRect(+ child: Transform.rotate(+ angle: -0.18,+ child: OverflowBox(+ maxWidth: 760,+ maxHeight: 760,+ child: Column(mainAxisSize: MainAxisSize.min, children: [+ for (var r = 0; r < 7; r++)+ Padding(+ padding: const EdgeInsets.only(bottom: 8),+ child: Row(mainAxisSize: MainAxisSize.min, children: [+ for (var c = 0; c < 7; c++)+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 4),+ child: SizedBox(+ width: 96,+ child: ExerciseMedia(ex: exs[(r * 3 + c) % exs.length], height: 96, radius: 16, bordered: false),+ ),+ ),+ ]),+ ),+ ]),+ ),+ ),+ ),+ ),+ ),+ DecoratedBox(+ decoration: BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [bg.withValues(alpha: 0), bg.withValues(alpha: 0.3), bg],+ stops: const [0, 0.45, 0.88],+ ),+ ),+ ),+ ]);+ }++ Widget _header(GymColors gc, Color tone) => Row(children: [+ const ProfileAvatar(size: 46),+ const SizedBox(width: 11),+ Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Text(fit.displayName,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(18, weight: FontWeight.w900, color: gc.text, letterSpacing: -0.4)),+ Text('@${fit.profileHandle}',+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(11.5, weight: FontWeight.w700, color: gc.textSecondary)),+ ]),+ ),+ const SizedBox(width: 8),+ Text(t.monthYear(recap.month).toUpperCase(),+ style: AppTheme.f(9.5, weight: FontWeight.w800, color: tone, letterSpacing: 1.4)),+ ]);++ Widget _mark(GymColors gc) => Row(mainAxisSize: MainAxisSize.min, children: [+ ClipRRect(+ borderRadius: BorderRadius.circular(5),+ child: Image.asset('assets/img/app_icon.png', width: 20, height: 20),+ ),+ const SizedBox(width: 7),+ Text('GymMane', style: AppTheme.f(14, weight: FontWeight.w900, color: gc.text, letterSpacing: -0.2, height: 1)),+ ]);++ Widget _stat(GymColors gc, String value, String unit, String label, {double size = 28, bool soft = false}) => Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerStart,+ child: Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [+ Text(value, style: _num(size, soft ? gc.textSecondary : gc.text)),+ if (unit.isNotEmpty) ...[+ const SizedBox(width: 3),+ Text(unit, style: AppTheme.f(size * 0.4, weight: FontWeight.w800, color: gc.textSecondary)),+ ],+ ])),+ ),+ const SizedBox(height: 4),+ Text(label.toUpperCase(),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(8.5, weight: FontWeight.w800, color: gc.textTertiary, letterSpacing: 1.1)),+ ],+ );++ (String, String) get _time {+ final h = recap.seconds ~/ 3600;+ final m = (recap.seconds % 3600) ~/ 60;+ return h > 0 ? ('$h', 'h') : ('$m', 'min');+ }++ Widget _summary(GymColors gc, Color tone) {+ final time = _time;+ return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Ltr(child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [+ Text('${recap.workouts}', style: _num(80, gc.text)),+ const SizedBox(width: 8),+ Text(t.recapWorkouts(recap.workouts),+ style: AppTheme.f(22, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.4)),+ ])),+ const SizedBox(height: 2),+ Text(t.recapDays(recap.days.length), style: AppTheme.f(13.5, weight: FontWeight.w700, color: gc.textSecondary)),+ const Spacer(),+ Center(child: BodyHeatArt(gc: gc, intensity: recap.heat, width: 220)),+ if (recap.topMuscle != null) ...[+ const SizedBox(height: 8),+ Center(+ child: Text('${t.recapMuscleKicker} · ${muscleLabel(recap.topMuscle!)}'.toUpperCase(),+ style: AppTheme.f(9.5, weight: FontWeight.w800, color: tone, letterSpacing: 1.3)),+ ),+ ],+ const Spacer(),+ Row(children: [+ Expanded(child: _stat(gc, time.$1, time.$2, t.duration, size: 34)),+ Expanded(child: _stat(gc, fit.volumeValue(recap.volumeKg), fit.volumeUnit, t.statLifted, size: 34)),+ Expanded(child: _stat(gc, '${recap.sets}', '', t.setsCaps, size: 34)),+ ]),+ const SizedBox(height: 14),+ Row(children: [+ Expanded(child: _stat(gc, '${recap.records.length}', '', t.prs, size: 22, soft: true)),+ Expanded(child: _stat(gc, '${recap.avgMinutes}', 'min', t.recapAvgLabel, size: 22, soft: true)),+ Expanded(+ child: _stat(gc, recap.favDay == null ? '–' : t.weekdayShort(recap.favDay!), '', t.recapFavLabel,+ size: 22, soft: true),+ ),+ ]),+ ]);+ }++ Widget _calendar(GymColors gc, Color tone) {+ final m = recap.month;+ final count = DateTime(m.year, m.month + 1, 0).day;+ final lead = (DateTime(m.year, m.month, 1).weekday - fit.weekStartDay + 7) % 7;+ final time = _time;+ final order = [for (var i = 0; i < 7; i++) (fit.weekStartDay - 1 + i) % 7 + 1];+ return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Text(t.monthName(m.month),+ style: AppTheme.f(56, weight: FontWeight.w900, color: gc.text, letterSpacing: -2.4, height: 1)),+ const SizedBox(height: 6),+ Text(t.recapCalendarLine(recap.workouts, recap.days.length),+ style: AppTheme.f(13.5, weight: FontWeight.w800, color: tone)),+ const SizedBox(height: 18),+ Row(children: [+ for (final d in order)+ Expanded(+ child: Center(+ child:+ Text(t.weekdayInitial(d), style: AppTheme.f(10, weight: FontWeight.w800, color: gc.textTertiary)),+ ),+ ),+ ]),+ const SizedBox(height: 6),+ GridView.count(+ crossAxisCount: 7,+ shrinkWrap: true,+ physics: const NeverScrollableScrollPhysics(),+ mainAxisSpacing: 6,+ crossAxisSpacing: 6,+ padding: EdgeInsets.zero,+ children: [+ for (var i = 0; i < lead; i++) const SizedBox.shrink(),+ for (var d = 1; d <= count; d++)+ Container(+ alignment: Alignment.center,+ decoration: BoxDecoration(+ color: recap.days.contains(d) ? gc.ember : gc.bgRaised2,+ shape: BoxShape.circle,+ ),+ child: Text('$d',+ style: AppTheme.f(11.5,+ weight: FontWeight.w800, color: recap.days.contains(d) ? gc.onEmber : gc.textSecondary)),+ ),+ ],+ ),+ const Spacer(),+ Row(children: [+ Expanded(child: _stat(gc, time.$1, time.$2, t.duration, size: 34)),+ Expanded(child: _stat(gc, fit.volumeValue(recap.volumeKg), fit.volumeUnit, t.statLifted, size: 34)),+ Expanded(+ child: _stat(gc, recap.favDay == null ? '–' : t.weekdayShort(recap.favDay!), '', t.recapFavLabel, size: 34),+ ),+ ]),+ ]);+ }++ Widget _lift(GymColors gc, Color tone, Exercise ex) {+ final l = recap.lift!;+ final heavy = l.bestKg > 0;+ return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ const Spacer(flex: 2),+ Center(+ child: Container(+ padding: const EdgeInsets.all(3),+ decoration: BoxDecoration(borderRadius: BorderRadius.circular(27), border: Border.all(color: gc.border, width: 1.5)),+ child: SizedBox(width: 196, child: ExerciseMedia(ex: ex, height: 196, radius: 24)),+ ),+ ),+ const Spacer(flex: 3),+ Text(t.recapLiftKicker.toUpperCase(),+ style: AppTheme.f(10, weight: FontWeight.w800, color: tone, letterSpacing: 1.6)),+ const SizedBox(height: 6),+ Text(exerciseName(ex),+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(28, weight: FontWeight.w900, color: gc.text, letterSpacing: -0.8, height: 1.05)),+ const SizedBox(height: 18),+ _stat(+ gc,+ heavy ? fit.weightLabel(l.bestKg).split(' ').first : '${l.sets}',+ heavy ? fit.units : '',+ heavy ? t.recapBest : t.setsCaps,+ size: 72,+ ),+ const SizedBox(height: 18),+ Row(children: [+ if (heavy) Expanded(child: _stat(gc, '${l.sets}', '', t.setsCaps, size: 26)),+ Expanded(child: _stat(gc, '${l.times}', '', t.recapTimes, size: 26)),+ Expanded(child: _stat(gc, fit.volumeValue(l.volumeKg), fit.volumeUnit, t.statLifted, size: 26)),+ ]),+ ]);+ }+}diff --git a/lib/screens/routine_edit_screen.dart b/lib/screens/routine_edit_screen.dartindex 5e4a9c7..5e95b18 100644--- a/lib/screens/routine_edit_screen.dart+++ b/lib/screens/routine_edit_screen.dart@@ -367,6 +367,7 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {(fit.exEquipmentFilter == null ? 0 : 1) +(fit.exDifficultyFilter == null ? 0 : 1);return SingleChildScrollView(+ key: const PageStorageKey('h-routine_edit_screen-370'),scrollDirection: Axis.horizontal,clipBehavior: Clip.none,child: Row(children: [diff --git a/lib/screens/routines_screen.dart b/lib/screens/routines_screen.dartindex f66dd5e..b37ffba 100644--- a/lib/screens/routines_screen.dart+++ b/lib/screens/routines_screen.dart@@ -1,4 +1,5 @@import 'package:flutter/material.dart';+import '../app/desktop.dart';import '../widgets/body_map.dart';import 'package:flutter/services.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';@@ -26,6 +27,198 @@ class RoutinesScreen extends StatelessWidget {@overrideWidget build(BuildContext context) {final gc = context.gc;+ final header = <Widget>[+ ScreenHeader(+ title: t.routines,+ onBack: fit.backFromRoutines,+ titleSize: 22,+ actions: [+ Semantics(+ button: true,+ label: t.importRoutines,+ child: RoundAction(+ onTap: () => showPlanImportSheet(context),+ child: Icon(PhosphorIconsRegular.downloadSimple, size: 17, color: gc.text),+ ),+ ),+ if (fit.activeRoutines.isNotEmpty) ...[+ const SizedBox(width: 8),+ Semantics(+ button: true,+ label: t.shareWeek,+ child: RoundAction(+ onTap: () => _shareMenu(context),+ child: Icon(PhosphorIconsRegular.shareNetwork, size: 17, color: gc.text),+ ),+ ),+ ],+ ],+ ),+ ];+ final plan = <Widget>[+ Row(children: [+ Expanded(+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 300),+ transitionBuilder: (child, a) => FadeTransition(+ opacity: CurvedAnimation(parent: a, curve: const Interval(0.45, 1)),+ child: child,+ ),+ layoutBuilder: (current, previous) =>+ Stack(alignment: Alignment.centerLeft, children: [...previous, ?current]),+ child: Padding(+ key: ValueKey(fit.rotation),+ padding: const EdgeInsetsDirectional.only(start: 4),+ child: Text((fit.rotation ? t.rotationTitle : t.weeklyPlan).toUpperCase(),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: _label(gc)),+ ),+ ),+ ),+ const SizedBox(width: 8),+ SegToggle(+ [+ SegOption(t.planFixedWeek, !fit.rotation, () => fit.setRotation(false)),+ SegOption(t.planRotation, fit.rotation, () => fit.setRotation(true)),+ ],+ hPad: 10,+ vPad: 5,+ fontSize: 11,+ ),+ ]),+ const SizedBox(height: 10),+ AnimatedSize(+ duration: const Duration(milliseconds: 380),+ curve: Curves.easeOutCubic,+ alignment: Alignment.topCenter,+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 320),+ switchInCurve: Curves.easeOutCubic,+ switchOutCurve: Curves.easeInCubic,+ layoutBuilder: (current, previous) =>+ Stack(alignment: Alignment.topCenter, children: [...previous, ?current]),+ transitionBuilder: (child, a) => FadeTransition(+ opacity: CurvedAnimation(parent: a, curve: const Interval(0.45, 1)),+ child: SlideTransition(+ position: Tween(+ begin: Offset(child.key == const ValueKey(true) ? 0.06 : -0.06, 0),+ end: Offset.zero,+ ).animate(a),+ child: child,+ ),+ ),+ child: KeyedSubtree(+ key: ValueKey(fit.rotation),+ child: fit.rotation+ ? _rotationCard(context, gc)+ : Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ SoftCard(+ radius: 22,+ borderColor: Colors.transparent,+ padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),+ child: Column(children: [for (int i = 0; i < 7; i++) _dayRow(context, gc, i)]),+ ),+ if (fit.activeRoutines.isNotEmpty) ...[+ const SizedBox(height: 10),+ _plansRow(context, gc),+ ],+ ],+ ),+ ),+ ),+ ),+ ];+ final mine = <Widget>[+ Padding(+ padding: const EdgeInsetsDirectional.only(start: 4),+ child: Text(t.yourRoutines.toUpperCase(), style: _label(gc)),+ ),+ const SizedBox(height: 12),+ if (fit.activeRoutines.isEmpty)+ Padding(+ padding: const EdgeInsets.symmetric(vertical: 26),+ child: Text(t.noRoutines,+ textAlign: TextAlign.center, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),+ )+ else ...[+ for (final group in fit.routineGroups) ...[+ _groupBlock(context, gc, group),+ const SizedBox(height: 12),+ ],+ if (fit.routineGroups.isNotEmpty && fit.routinesInGroup('').isNotEmpty) const SizedBox(height: 6),+ _folders(context, fit.routinesInGroup('')),+ ],+ if (fit.archivedRoutines.isNotEmpty) ...[+ const SizedBox(height: 6),+ _archivedHeader(gc),+ AnimatedSize(+ duration: const Duration(milliseconds: 340),+ curve: Curves.easeOutCubic,+ alignment: Alignment.topCenter,+ child: AnimatedOpacity(+ duration: const Duration(milliseconds: 260),+ opacity: fit.showArchivedRoutines ? 0.6 : 0,+ child: fit.showArchivedRoutines+ ? _folders(context, fit.archivedRoutines)+ : const SizedBox(width: double.infinity),+ ),+ ),+ ],+ ];+ final acts = <Widget>[+ PrimaryButton(+ label: t.newRoutine,+ onTap: () => fit.openRoutine(fit.createRoutine()),+ ),+ const SizedBox(height: 10),+ GhostButton(+ label: t.templates,+ icon: PhosphorIconsRegular.stack,+ onTap: () => _openTemplates(context),+ ),+ const SizedBox(height: 10),+ GhostButton(+ label: t.importRoutines,+ icon: PhosphorIconsRegular.downloadSimple,+ onTap: () => showPlanImportSheet(context),+ ),+ const SizedBox(height: 10),+ GhostButton(+ label: t.aiRoutine,+ icon: PhosphorIconsRegular.sparkle,+ onTap: fit.goAiPlan,+ ),+ const SizedBox(height: 30),+ const SizedBox(height: 30),+ const CircuitSection(),+ ];+ if (DesktopScope.of(context)) {+ return RiseScope(+ id: 'routines',+ child: SingleChildScrollView(+ key: const PageStorageKey('routines'),+ clipBehavior: Clip.none,+ padding: const EdgeInsets.fromLTRB(32, 30, 32, 48),+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ ...riseAll(header),+ const SizedBox(height: 22),+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ SizedBox(+ width: 400,+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: riseAll([...plan, const SizedBox(height: 16), ...acts], from: 1)),+ ),+ const SizedBox(width: 32),+ Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: riseAll(mine, from: 2)),+ ),+ ]),+ ]),+ ),+ );+ }return RiseScope(id: 'routines',child: SafeArea(@@ -37,168 +230,13 @@ class RoutinesScreen extends StatelessWidget {child: Column(crossAxisAlignment: CrossAxisAlignment.stretch,children: riseAll([- ScreenHeader(- title: t.routines,- onBack: fit.backFromRoutines,- titleSize: 22,- actions: [- Semantics(- button: true,- label: t.importRoutines,- child: RoundAction(- onTap: () => showPlanImportSheet(context),- child: Icon(PhosphorIconsRegular.downloadSimple, size: 17, color: gc.text),- ),- ),- if (fit.activeRoutines.isNotEmpty) ...[- const SizedBox(width: 8),- Semantics(- button: true,- label: t.shareWeek,- child: RoundAction(- onTap: () => _shareMenu(context),- child: Icon(PhosphorIconsRegular.shareNetwork, size: 17, color: gc.text),- ),- ),- ],- ],- ),+ ...header,const SizedBox(height: 22),- Row(children: [- Expanded(- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 300),- transitionBuilder: (child, a) => FadeTransition(- opacity: CurvedAnimation(parent: a, curve: const Interval(0.45, 1)),- child: child,- ),- layoutBuilder: (current, previous) =>- Stack(alignment: Alignment.centerLeft, children: [...previous, ?current]),- child: Padding(- key: ValueKey(fit.rotation),- padding: const EdgeInsetsDirectional.only(start: 4),- child: Text((fit.rotation ? t.rotationTitle : t.weeklyPlan).toUpperCase(),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: _label(gc)),- ),- ),- ),- const SizedBox(width: 8),- SegToggle(- [- SegOption(t.planFixedWeek, !fit.rotation, () => fit.setRotation(false)),- SegOption(t.planRotation, fit.rotation, () => fit.setRotation(true)),- ],- hPad: 10,- vPad: 5,- fontSize: 11,- ),- ]),- const SizedBox(height: 10),- AnimatedSize(- duration: const Duration(milliseconds: 380),- curve: Curves.easeOutCubic,- alignment: Alignment.topCenter,- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 320),- switchInCurve: Curves.easeOutCubic,- switchOutCurve: Curves.easeInCubic,- layoutBuilder: (current, previous) =>- Stack(alignment: Alignment.topCenter, children: [...previous, ?current]),- transitionBuilder: (child, a) => FadeTransition(- opacity: CurvedAnimation(parent: a, curve: const Interval(0.45, 1)),- child: SlideTransition(- position: Tween(- begin: Offset(child.key == const ValueKey(true) ? 0.06 : -0.06, 0),- end: Offset.zero,- ).animate(a),- child: child,- ),- ),- child: KeyedSubtree(- key: ValueKey(fit.rotation),- child: fit.rotation- ? _rotationCard(context, gc)- : Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- SoftCard(- radius: 22,- borderColor: Colors.transparent,- padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),- child: Column(children: [for (int i = 0; i < 7; i++) _dayRow(context, gc, i)]),- ),- if (fit.activeRoutines.isNotEmpty) ...[- const SizedBox(height: 10),- _plansRow(context, gc),- ],- ],- ),- ),- ),- ),+ ...plan,const SizedBox(height: 30),- Padding(- padding: const EdgeInsetsDirectional.only(start: 4),- child: Text(t.yourRoutines.toUpperCase(), style: _label(gc)),- ),- const SizedBox(height: 12),- if (fit.activeRoutines.isEmpty)- Padding(- padding: const EdgeInsets.symmetric(vertical: 26),- child: Text(t.noRoutines,- textAlign: TextAlign.center, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),- )- else ...[- for (final group in fit.routineGroups) ...[- _groupBlock(context, gc, group),- const SizedBox(height: 12),- ],- if (fit.routineGroups.isNotEmpty && fit.routinesInGroup('').isNotEmpty) const SizedBox(height: 6),- _folders(context, fit.routinesInGroup('')),- ],- if (fit.archivedRoutines.isNotEmpty) ...[- const SizedBox(height: 6),- _archivedHeader(gc),- AnimatedSize(- duration: const Duration(milliseconds: 340),- curve: Curves.easeOutCubic,- alignment: Alignment.topCenter,- child: AnimatedOpacity(- duration: const Duration(milliseconds: 260),- opacity: fit.showArchivedRoutines ? 0.6 : 0,- child: fit.showArchivedRoutines- ? _folders(context, fit.archivedRoutines)- : const SizedBox(width: double.infinity),- ),- ),- ],+ ...mine,const SizedBox(height: 16),- PrimaryButton(- label: t.newRoutine,- onTap: () => fit.openRoutine(fit.createRoutine()),- ),- const SizedBox(height: 10),- GhostButton(- label: t.templates,- icon: PhosphorIconsRegular.stack,- onTap: () => _openTemplates(context),- ),- const SizedBox(height: 10),- GhostButton(- label: t.importRoutines,- icon: PhosphorIconsRegular.downloadSimple,- onTap: () => showPlanImportSheet(context),- ),- const SizedBox(height: 10),- GhostButton(- label: t.aiRoutine,- icon: PhosphorIconsRegular.sparkle,- onTap: fit.goAiPlan,- ),- const SizedBox(height: 30),- const CircuitSection(),+ ...acts,]),),),@@ -290,6 +328,7 @@ class RoutinesScreen extends StatelessWidget {);return SingleChildScrollView(+ key: const PageStorageKey('h-routines_screen-331'),scrollDirection: Axis.horizontal,child: Row(children: [for (final p in fit.savedPlans) ...[@@ -1110,21 +1149,25 @@ class RoutinesScreen extends StatelessWidget {}Widget _folders(BuildContext context, List<Routine> list) {- return Column(children: [- for (var i = 0; i < list.length; i += 2)- Padding(- padding: const EdgeInsets.only(bottom: 12),- child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [- Expanded(child: RoutineFolder(routine: list[i], onMenu: () => showRoutineMenu(context, list[i]))),- const SizedBox(width: 12),- Expanded(- child: i + 1 < list.length- ? RoutineFolder(routine: list[i + 1], onMenu: () => showRoutineMenu(context, list[i + 1]))- : const SizedBox.shrink(),- ),- ]),- ),- ]);+ return LayoutBuilder(builder: (context, box) {+ final n = (box.maxWidth / 250).floor().clamp(2, 4);+ return Column(children: [+ for (var i = 0; i < list.length; i += n)+ Padding(+ padding: const EdgeInsets.only(bottom: 12),+ child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ for (var k = 0; k < n; k++) ...[+ if (k > 0) const SizedBox(width: 12),+ Expanded(+ child: i + k < list.length+ ? RoutineFolder(routine: list[i + k], onMenu: () => showRoutineMenu(context, list[i + k]))+ : const SizedBox.shrink(),+ ),+ ],+ ]),+ ),+ ]);+ });}void _pickRoutine(BuildContext context, int weekday, DateTime day) {diff --git a/lib/screens/session_photos.dart b/lib/screens/session_photos.dartindex 8e79b91..a8d1544 100644--- a/lib/screens/session_photos.dart+++ b/lib/screens/session_photos.dart@@ -107,6 +107,7 @@ class _SessionPhotosState extends State<SessionPhotos> {Widget _strip(GymColors gc, List<Moment> photos) => SizedBox(height: 72,child: ListView.separated(+ key: const PageStorageKey('h-session_photos-110'),scrollDirection: Axis.horizontal,clipBehavior: Clip.none,itemCount: photos.length + 1,diff --git a/lib/screens/session_screen.dart b/lib/screens/session_screen.dartindex 3bb8f2a..eb4fb11 100644--- a/lib/screens/session_screen.dart+++ b/lib/screens/session_screen.dart@@ -536,6 +536,12 @@ class SessionScreen extends StatelessWidget {Navigator.pop(sheet);fit.setExerciseUnits(ex.id, fit.isLbFor(ex.id) ? 'kg' : 'lb');}),+ if (mode == 'cardio')+ OptionItem(t.exerciseUnitSwitch(fit.isMiFor(ex.id) ? 'km' : 'mi'),+ icon: PhosphorIconsRegular.ruler, onTap: () {+ Navigator.pop(sheet);+ fit.setExerciseDistance(ex.id, fit.isMiFor(ex.id) ? 'km' : 'mi');+ }),OptionItem(t.addNote, icon: PhosphorIconsRegular.notePencil, onTap: () {Navigator.pop(sheet);showWorkoutNoteEditor(context, ex.id);@@ -767,7 +773,7 @@ class SessionScreen extends StatelessWidget {behavior: HitTestBehavior.opaque,onTap: () => _editRest(context, s),child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [- FitText(t.liveResting.toUpperCase(),+ FitText((s.restSwitch ? t.switchSides : t.liveResting).toUpperCase(),style: AppTheme.f(9.5, weight: FontWeight.w800, color: gc.accent, letterSpacing: 1.2)),RollingText(clockLabel(left),style: AppTheme.f(24, weight: FontWeight.w800, color: gc.text, height: 1.1)),@@ -1162,7 +1168,8 @@ class SessionScreen extends StatelessWidget {SizedBox(width: gap),Expanded(flex: _prevFlex, child: label(t.previousCol)),],- for (final h in _headers(mode, repsOnly, sided, exId == null ? fit.units : fit.unitsFor(exId))) ...[+ for (final h in _headers(mode, repsOnly, sided, exId == null ? fit.units : fit.unitsFor(exId),+ exId == null ? fit.distanceUnit : fit.distanceUnitFor(exId))) ...[SizedBox(width: gap),Expanded(flex: _cellFlex, child: label(h)),],@@ -1479,18 +1486,18 @@ class SessionScreen extends StatelessWidget {);Widget distance() => step(gc,- fit.distanceValue(st.km ?? 0),+ fit.distanceValueFor(exId, st.km ?? 0),() => fit.bumpSessionDistance(exIdx, j, -1),() => fit.bumpSessionDistance(exIdx, j, 1),30,onEdit: (context) => _ruler(context,- title: t.distanceTitle(fit.distanceUnit),- value: fit.toDisplayKm(st.km ?? 0),+ title: t.distanceTitle(fit.distanceUnitFor(exId)),+ value: fit.toDisplayKmFor(exId, st.km ?? 0),max: 100,step: 0.1,majorEvery: 10,- unit: fit.distanceUnit,+ unit: fit.distanceUnitFor(exId),onSave: (v) => fit.setSessionDistanceShown(exIdx, j, v),),);@@ -1501,8 +1508,8 @@ class SessionScreen extends StatelessWidget {};}- List<String> _headers(String mode, bool repsOnly, bool sided, String unit) => switch (mode) {- 'cardio' => [t.distanceCol(fit.distanceUnit.toUpperCase()), t.timeCol],+ List<String> _headers(String mode, bool repsOnly, bool sided, String unit, String dist) => switch (mode) {+ 'cardio' => [t.distanceCol(dist.toUpperCase()), t.timeCol],'time' => [sided ? t.timePerSideCol : t.timeCol, if (!repsOnly) t.weightCol(unit.toUpperCase())],_ => [if (sided) ...[t.repsLeftCol, t.repsRightCol] else t.repsCol,@@ -1587,11 +1594,22 @@ class SessionScreen extends StatelessWidget {decoration: BoxDecoration(color: st.done ? gc.sage : Colors.transparent,shape: BoxShape.circle,- border: Border.all(color: st.done ? gc.sage : gc.textTertiary, width: 2),+ border: Border.all(color: st.done || st.half ? gc.sage : gc.textTertiary, width: 2),),child: st.done? Center(child: SvgPathIcon(Ic.checkBold, size: 14, color: Colors.white))- : null,+ : st.half+ ? Padding(+ padding: const EdgeInsets.all(2),+ child: ClipOval(+ child: FractionallySizedBox(+ alignment: AlignmentDirectional.centerStart,+ widthFactor: 0.5,+ child: ColoredBox(color: gc.sage),+ ),+ ),+ )+ : null,),if (fit.liveSetIsRecord(exIdx, j))Positioned(top: -6, right: -8, child: RecordBadge(label: sentenceCase(t.personalRecord))),@@ -2022,7 +2040,7 @@ class SessionScreen extends StatelessWidget {Widget _restPanel(BuildContext context, GymColors gc, WorkoutSession s) {final count = fit.sessionSetCount;return TimerPanel(- label: t.liveResting,+ label: s.restSwitch ? t.switchSides : t.liveResting,remaining: s.restRemaining ?? 0,total: fit.restTotal,elapsed: fit.elapsedLabel,diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex 889ade4..5a1ad58 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -5,17 +5,18 @@ import 'dart:math' as math;import 'dart:ui' as ui;import 'package:file_picker/file_picker.dart';+import 'package:flutter/foundation.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:home_widget/home_widget.dart';import 'package:image_picker/image_picker.dart';-import 'package:path_provider/path_provider.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';-import 'package:share_plus/share_plus.dart';import 'package:url_launcher/url_launcher.dart';+import '../app/desktop.dart';import '../l10n/l10n.dart';import '../models/profile.dart';+import '../services/graphics_mode.dart';import '../services/alarm_store.dart';import '../services/auto_backup.dart';import '../services/backup_zip.dart';@@ -53,6 +54,12 @@ import '../widgets/widget_showcase.dart';import 'profile_screen.dart';import 'strava_sheet.dart';+import '../services/host.dart';+import '../services/file_share.dart';+import '../services/server/server_link.dart';+import '../widgets/server_card.dart';+import 'about_screen.dart';+const _kRepoUrl = 'https://github.com/InlitX/GymMane';const _kBugUrl = '$_kRepoUrl/issues/new?labels=bug';const _kFeatureUrl = '$_kRepoUrl/issues/new?labels=enhancement';@@ -68,7 +75,47 @@ class SettingsScreen extends StatelessWidget {final gc = context.gc;final id = section;WidgetShowcase.warm(context);- if (id == null) return _SettingsHome(screen: this);+ if (id == null && DesktopScope.of(context)) {+ _deskOn = true;+ return Row(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ SizedBox(width: 400, child: _SettingsHome(screen: this)),+ const SizedBox(width: 30),+ Expanded(+ child: ValueListenableBuilder<String>(+ valueListenable: _desk,+ builder: (context, sec, _) => RiseScope(+ id: 'settings-$sec',+ once: false,+ child: SingleChildScrollView(+ key: ValueKey(sec),+ clipBehavior: Clip.none,+ padding: const EdgeInsets.fromLTRB(0, 112, 32, 48),+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ Padding(+ padding: const EdgeInsetsDirectional.only(start: 4, bottom: 18),+ child: Text(titleCase(_sectionTitle(sec)), style: AppTheme.f(24, weight: FontWeight.w800, color: gc.text)),+ ),+ if (sec == 'about')+ Align(+ alignment: AlignmentDirectional.topStart,+ child: ConstrainedBox(+ constraints: const BoxConstraints(maxWidth: 720),+ child: const AboutScreen(embedded: true),+ ),+ )+ else+ ...riseAll(_sectionBody(context, gc, sec)),+ ]),+ ),+ ),+ ),+ ),+ ]);+ }+ if (id == null) {+ _deskOn = false;+ return _SettingsHome(screen: this);+ }return RiseScope(id: 'settings-$id',once: false,@@ -263,6 +310,60 @@ class SettingsScreen extends StatelessWidget {),hint: t.miniRestHint,),+ _prefRow(+ gc,+ PhosphorIconsRegular.timer,+ t.changeRest,+ StepperControl(+ value: fit.changeRestSeconds == 0 ? t.restOff : clockLabel(fit.changeRestSeconds),+ minWidth: 48,+ btnSize: 28,+ gap: 10,+ fontSize: 14,+ onDec: () => fit.setChangeRest(fit.changeRestSeconds - 15),+ onInc: () => fit.setChangeRest(fit.changeRestSeconds == 0 ? fit.restSeconds : fit.changeRestSeconds + 15),+ onEdit: () async {+ final v = await askRuler(context,+ title: t.changeRest,+ value: fit.changeRestSeconds.toDouble(),+ min: 0,+ max: 900,+ step: 5,+ majorEvery: 6,+ format: (v) => clockLabel(v.round()),+ tickLabel: (v) => clockLabel(v.round()));+ if (v != null) fit.setChangeRest(v.round());+ },+ ),+ hint: t.changeRestHint,+ ),+ _prefRow(+ gc,+ PhosphorIconsRegular.arrowsLeftRight,+ t.sideRest,+ StepperControl(+ value: fit.sideRestSeconds == 0 ? t.restOff : clockLabel(fit.sideRestSeconds),+ minWidth: 48,+ btnSize: 28,+ gap: 10,+ fontSize: 14,+ onDec: () => fit.setSideRest(fit.sideRestSeconds - 5),+ onInc: () => fit.setSideRest(fit.sideRestSeconds == 0 ? 15 : fit.sideRestSeconds + 5),+ onEdit: () async {+ final v = await askRuler(context,+ title: t.sideRest,+ value: fit.sideRestSeconds.toDouble(),+ min: 0,+ max: 300,+ step: 5,+ majorEvery: 6,+ format: (v) => clockLabel(v.round()),+ tickLabel: (v) => clockLabel(v.round()));+ if (v != null) fit.setSideRest(v.round());+ },+ ),+ hint: t.sideRestHint,+ ),]),_subhead(gc, t.settingsDuring),_card(gc, [@@ -440,6 +541,7 @@ class SettingsScreen extends StatelessWidget {case 'alerts':return [_card(gc, [+ if (!kIsWeb)GestureDetector(behavior: HitTestBehavior.opaque,onTap: () => _editTrainReminder(context),@@ -463,7 +565,7 @@ class SettingsScreen extends StatelessWidget {hint: t.trainReminderRowHint,),),- if (Platform.isAndroid)+ if (onAndroid)GestureDetector(behavior: HitTestBehavior.opaque,onTap: () => showAppSheet<void>(@@ -486,6 +588,7 @@ class SettingsScreen extends StatelessWidget {hint: t.notifSoundRowHint,),),+ if (!kIsWeb)GestureDetector(behavior: HitTestBehavior.opaque,onTap: () => _editAlarmSound(context),@@ -531,7 +634,7 @@ class SettingsScreen extends StatelessWidget {child: _prefRow(gc, PhosphorIconsRegular.bellSimple, t.toastSoundSetting,TinySwitch(on: fit.toastSound), hint: t.toastSoundHint),),- if (!fit.alarmAllowed) ...[+ if (!kIsWeb && !fit.alarmAllowed) ...[const SizedBox(height: 14),_alarmWarning(context, gc),const SizedBox(height: 14),@@ -648,6 +751,10 @@ class SettingsScreen extends StatelessWidget {];case 'data':return [+ if (kIsWeb && ServerLink.instance.available) ...[+ const ServerCard(),+ const SizedBox(height: 12),+ ],ImportCard(onTap: () => _openImportApps(context)),const SizedBox(height: 12),_linkGroup(gc, [@@ -716,6 +823,7 @@ class SettingsScreen extends StatelessWidget {'widgets' => t.sectionWidgets,'beta' => t.sectionBeta,'data' => t.sectionData,+ 'about' => t.aboutGymmane,_ => titleCase(t.support),};@@ -738,6 +846,8 @@ class SettingsScreen extends StatelessWidget {_Category('training', PhosphorIconsRegular.barbell, _sectionTitle('training'), [(t.restTimer, PhosphorIconsRegular.timer),(t.miniRest, PhosphorIconsRegular.timer),+ (t.changeRest, PhosphorIconsRegular.timer),+ (t.sideRest, PhosphorIconsRegular.arrowsLeftRight),(t.effortSetting, PhosphorIconsRegular.gauge),(t.weightStepSetting, PhosphorIconsRegular.barbell),(t.autoProgressSetting, PhosphorIconsRegular.trendUp),@@ -773,7 +883,7 @@ class SettingsScreen extends StatelessWidget {(t.gamificationSetting, PhosphorIconsRegular.medal),(t.gymPass, PhosphorIconsRegular.qrCode),]),- if (Platform.isAndroid || Platform.isIOS)+ if (onMobile)_Category('widgets', PhosphorIconsRegular.squaresFour, _sectionTitle('widgets'), [(t.addActivityWidget, PhosphorIconsRegular.squaresFour),(t.addStatsWidget, PhosphorIconsRegular.chartBar),@@ -805,7 +915,18 @@ class SettingsScreen extends StatelessWidget {];}- static void _openCategory(String id) => id == 'about' ? fit.goAbout() : fit.pushRoute('preferences/$id');+ static final ValueNotifier<String> _desk = ValueNotifier('general');+ static bool _deskOn = false;++ static void _openCategory(String id) {+ if (_deskOn) {+ _desk.value = id;+ } else if (id == 'about') {+ fit.goAbout();+ } else {+ fit.pushRoute('preferences/$id');+ }+ }Widget _prefRow(GymColors gc, IconData icon, String label, Widget control, {String? hint, Widget? badge}) {if (hint == null) {@@ -956,6 +1077,14 @@ class SettingsScreen extends StatelessWidget {_ => t.perfCustom,};+ Future<void> _switchGraphics(BuildContext context) async {+ final ok = await askConfirm(context,+ title: t.gfxRestartTitle, body: t.gfxRestartBody, confirmLabel: t.gfxRestart);+ if (!ok) return;+ fit.persistNow();+ await GraphicsMode.restartWith(!GraphicsMode.compat);+ }+void _performanceSheet(BuildContext context) {fit.readDisplay();showAppSheet<void>(@@ -1015,6 +1144,9 @@ class SettingsScreen extends StatelessWidget {() => fit.setHighRefresh(!fit.highRefresh)),toggle(PhosphorIconsRegular.waveSine, t.calmMotionSetting, t.calmMotionHint, fit.calmMotion,() => fit.setCalmMotion(!fit.calmMotion)),+ if (GraphicsMode.available)+ toggle(PhosphorIconsRegular.textAa, t.gfxCompat, t.gfxCompatHint, GraphicsMode.compat,+ () => _switchGraphics(sheet)),]),),]);@@ -1090,14 +1222,9 @@ class SettingsScreen extends StatelessWidget {_snack(context, t.nothingToExport);return;}- final dir = await getTemporaryDirectory();final stamp = DateTime.now().toIso8601String().split('T').first;- final file = File('${dir.path}/gymmane-workouts-$stamp.csv');- await file.writeAsString(fit.exportCsv());- if (!context.mounted) return;- await SharePlus.instance.share(- ShareParams(files: [XFile(file.path)], subject: 'GymMane workouts'),- );+ await shareFile('gymmane-workouts-$stamp.csv', utf8Bytes(fit.exportCsv()),+ mime: 'text/csv', subject: 'GymMane workouts');}Future<void> _clearWorkouts(BuildContext context) async {@@ -1129,14 +1256,10 @@ class SettingsScreen extends StatelessWidget {}Future<void> _exportBackup(BuildContext context) async {- final dir = await getTemporaryDirectory();final stamp = DateTime.now().toIso8601String().split('T').first;- final file = File('${dir.path}/gymmane-backup-$stamp.zip');- await file.writeAsBytes(await buildBackupZip(), flush: true);+ final zip = await buildBackupZip();if (!context.mounted) return;- await SharePlus.instance.share(- ShareParams(files: [XFile(file.path)], subject: 'GymMane backup'),- );+ await shareFile('gymmane-backup-$stamp.zip', zip, mime: 'application/zip', subject: 'GymMane backup');}Future<void> _importBackup(BuildContext context) async {@@ -2729,13 +2852,25 @@ class _SettingsHomeState extends State<_SettingsHome> {}Widget _bubble(GymColors gc, _Category c) {+ return ValueListenableBuilder<String>(+ valueListenable: SettingsScreen._desk,+ builder: (context, sec, _) => _bubbleBody(gc, c, SettingsScreen._deskOn && sec == c.id),+ );+ }++ Widget _bubbleBody(GymColors gc, _Category c, bool on) {return Pressable(onTap: () => _go(c, null),scale: 0.975,- child: Container(+ child: AnimatedContainer(+ duration: const Duration(milliseconds: 180),height: 64,padding: const EdgeInsets.symmetric(horizontal: 12),- decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),+ decoration: BoxDecoration(+ color: gc.bgRaised,+ borderRadius: BorderRadius.circular(22),+ border: Border.all(color: on ? gc.text.withValues(alpha: 0.55) : Colors.transparent, width: 1.4),+ ),child: Row(children: [_circle(gc, c.icon),diff --git a/lib/screens/share_sheet.dart b/lib/screens/share_sheet.dartindex 6e70274..2adc5c9 100644--- a/lib/screens/share_sheet.dart+++ b/lib/screens/share_sheet.dart@@ -1,157 +1,152 @@-import 'dart:io';-import 'dart:ui' as ui;--import 'package:flutter/material.dart';-import 'package:flutter/rendering.dart';-import 'package:path_provider/path_provider.dart';-import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';-import 'package:share_plus/share_plus.dart';--import '../l10n/l10n.dart';-import '../state/fit_state.dart';-import '../theme/app_colors.dart';-import '../theme/app_theme.dart';-import '../widgets/glass.dart';-import '../widgets/liquid_notch.dart';-import '../widgets/share_cards.dart';-import '../widgets/ui_kit.dart';--Future<void> showShareSheet(BuildContext context, {ShareKind initial = ShareKind.streak}) =>- showAppSheet<void>(- context: context,- isScrollControlled: true,- backgroundColor: Colors.transparent,- builder: (_) => _ShareSheet(initial: initial),- );--class _ShareSheet extends StatefulWidget {- const _ShareSheet({required this.initial});-- final ShareKind initial;-- @override- State<_ShareSheet> createState() => _ShareSheetState();-}--class _ShareSheetState extends State<_ShareSheet> {- final _cards = {for (final k in ShareKind.values) k: GlobalKey()};- late ShareKind _kind = widget.initial;- bool _busy = false;-- List<ShareKind> get _available => [- ShareKind.streak,- ShareKind.body,- if (fit.comparePair != null) ShareKind.compare,- ];-- String _label(ShareKind k) => switch (k) {- ShareKind.streak => t.shareStreak,- ShareKind.body => t.shareBody,- ShareKind.compare => t.shareCompare,- };-- Future<void> _share() async {- if (_busy) return;- setState(() => _busy = true);- try {- final boundary = _cards[_kind]!.currentContext?.findRenderObject() as RenderRepaintBoundary?;- if (boundary == null) return;- final image = await boundary.toImage(pixelRatio: 3);- final data = await image.toByteData(format: ui.ImageByteFormat.png);- image.dispose();- if (data == null) return;-- final dir = await getTemporaryDirectory();- final file = File('${dir.path}/gymmane-${_kind.name}.png');- await file.writeAsBytes(data.buffer.asUint8List(), flush: true);- if (!mounted) return;- await SharePlus.instance.share(ShareParams(files: [XFile(file.path)], subject: 'GymMane'));- } catch (_) {- if (mounted) {- showNotchToast(context, t.shareFailed, icon: PhosphorIconsFill.warningCircle, accent: context.gc.warn);- }- } finally {- if (mounted) setState(() => _busy = false);- }- }-- @override- Widget build(BuildContext context) {- final gc = context.gc;- final kinds = _available;- final kind = kinds.contains(_kind) ? _kind : kinds.first;-- return Container(- constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.9),- decoration: sheetDecoration(gc),- clipBehavior: Clip.antiAlias,- child: SafeArea(- top: false,- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- const SheetHandle(margin: EdgeInsets.symmetric(vertical: 14)),- Padding(- padding: const EdgeInsets.fromLTRB(20, 4, 20, 12),- child: Row(- children: [- Expanded(- child: Text(t.sharePick,- style: AppTheme.f(20, weight: FontWeight.w800, color: gc.text)),- ),- ],- ),- ),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 20),- child: Align(- alignment: AlignmentDirectional.centerStart,- child: FittedBox(- fit: BoxFit.scaleDown,- child: SegToggle(- [for (final k in kinds) SegOption(_label(k), k == kind, () => setState(() => _kind = k))],- hPad: 14,- vPad: 8,- fontSize: 12.5,- ),- ),- ),- ),- Flexible(- child: SingleChildScrollView(- padding: const EdgeInsets.fromLTRB(20, 16, 20, 8),- child: Center(- child: FittedBox(- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 340),- switchInCurve: Curves.easeOutCubic,- switchOutCurve: Curves.easeInCubic,- transitionBuilder: (child, a) => FadeTransition(- opacity: a,- child: ScaleTransition(scale: Tween(begin: 0.94, end: 1.0).animate(a), child: child),- ),- child: RepaintBoundary(- key: _cards[kind],- child: ShareCard(kind: kind, gc: gc),- ),- ),- ),- ),- ),- ),- Padding(- padding: const EdgeInsets.fromLTRB(20, 10, 20, 6),- child: Text(t.shareHint,- textAlign: TextAlign.center,- style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary, height: 1.4)),- ),- Padding(- padding: const EdgeInsets.fromLTRB(20, 6, 20, 16),- child: PrimaryButton(label: sentenceCase(t.share), height: 52, onTap: _share),- ),- ],- ),- ),- );- }-}+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';++import '../l10n/l10n.dart';+import '../state/fit_state.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import '../widgets/glass.dart';+import '../widgets/liquid_notch.dart';+import '../widgets/share_cards.dart';+import '../widgets/ui_kit.dart';+import '../services/file_share.dart';++Future<void> showShareSheet(BuildContext context, {ShareKind initial = ShareKind.streak}) =>+ showAppSheet<void>(+ context: context,+ isScrollControlled: true,+ backgroundColor: Colors.transparent,+ builder: (_) => _ShareSheet(initial: initial),+ );++class _ShareSheet extends StatefulWidget {+ const _ShareSheet({required this.initial});++ final ShareKind initial;++ @override+ State<_ShareSheet> createState() => _ShareSheetState();+}++class _ShareSheetState extends State<_ShareSheet> {+ final _cards = {for (final k in ShareKind.values) k: GlobalKey()};+ late ShareKind _kind = widget.initial;+ bool _busy = false;++ List<ShareKind> get _available => [+ ShareKind.streak,+ ShareKind.body,+ if (fit.comparePair != null) ShareKind.compare,+ ];++ String _label(ShareKind k) => switch (k) {+ ShareKind.streak => t.shareStreak,+ ShareKind.body => t.shareBody,+ ShareKind.compare => t.shareCompare,+ };++ Future<void> _share() async {+ if (_busy) return;+ setState(() => _busy = true);+ try {+ final boundary = _cards[_kind]!.currentContext?.findRenderObject() as RenderRepaintBoundary?;+ if (boundary == null) return;+ final image = await boundary.toImage(pixelRatio: 3);+ final data = await image.toByteData(format: ui.ImageByteFormat.png);+ image.dispose();+ if (data == null) return;++ if (!mounted) return;+ await shareFile('gymmane-${_kind.name}.png', data.buffer.asUint8List(), mime: 'image/png', subject: 'GymMane');+ } catch (_) {+ if (mounted) {+ showNotchToast(context, t.shareFailed, icon: PhosphorIconsFill.warningCircle, accent: context.gc.warn);+ }+ } finally {+ if (mounted) setState(() => _busy = false);+ }+ }++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final kinds = _available;+ final kind = kinds.contains(_kind) ? _kind : kinds.first;++ return Container(+ constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.9),+ decoration: sheetDecoration(gc),+ clipBehavior: Clip.antiAlias,+ child: SafeArea(+ top: false,+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ const SheetHandle(margin: EdgeInsets.symmetric(vertical: 14)),+ Padding(+ padding: const EdgeInsets.fromLTRB(20, 4, 20, 12),+ child: Row(+ children: [+ Expanded(+ child: Text(t.sharePick,+ style: AppTheme.f(20, weight: FontWeight.w800, color: gc.text)),+ ),+ ],+ ),+ ),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 20),+ child: Align(+ alignment: AlignmentDirectional.centerStart,+ child: FittedBox(+ fit: BoxFit.scaleDown,+ child: SegToggle(+ [for (final k in kinds) SegOption(_label(k), k == kind, () => setState(() => _kind = k))],+ hPad: 14,+ vPad: 8,+ fontSize: 12.5,+ ),+ ),+ ),+ ),+ Flexible(+ child: SingleChildScrollView(+ padding: const EdgeInsets.fromLTRB(20, 16, 20, 8),+ child: Center(+ child: FittedBox(+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 340),+ switchInCurve: Curves.easeOutCubic,+ switchOutCurve: Curves.easeInCubic,+ transitionBuilder: (child, a) => FadeTransition(+ opacity: a,+ child: ScaleTransition(scale: Tween(begin: 0.94, end: 1.0).animate(a), child: child),+ ),+ child: RepaintBoundary(+ key: _cards[kind],+ child: ShareCard(kind: kind, gc: gc),+ ),+ ),+ ),+ ),+ ),+ ),+ Padding(+ padding: const EdgeInsets.fromLTRB(20, 10, 20, 6),+ child: Text(t.shareHint,+ textAlign: TextAlign.center,+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary, height: 1.4)),+ ),+ Padding(+ padding: const EdgeInsets.fromLTRB(20, 6, 20, 16),+ child: PrimaryButton(label: sentenceCase(t.share), height: 52, onTap: _share),+ ),+ ],+ ),+ ),+ );+ }+}diff --git a/lib/screens/strava_sheet.dart b/lib/screens/strava_sheet.dartindex 4a2c3e0..b8a02d2 100644--- a/lib/screens/strava_sheet.dart+++ b/lib/screens/strava_sheet.dart@@ -1,9 +1,7 @@-import 'dart:io';+import 'dart:typed_data';import 'package:flutter/material.dart';-import 'package:path_provider/path_provider.dart';import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';-import 'package:share_plus/share_plus.dart';import '../l10n/l10n.dart';import '../models/workout.dart';@@ -13,6 +11,7 @@ import '../theme/app_colors.dart';import '../theme/app_theme.dart';import '../widgets/glass.dart';import '../widgets/ui_kit.dart';+import '../services/file_share.dart';void showStravaSheet(BuildContext context) => showAppSheet<void>(context: context,@@ -220,11 +219,9 @@ class _StravaSheetState extends State<_StravaSheet> {Future<void> shareWorkoutFit(LoggedSession s) async {try {- final dir = await getTemporaryDirectory();final d = s.date;final stamp = '${d.year}-${d.month.toString().padLeft(2, '0')}-${d.day.toString().padLeft(2, '0')}';- final file = File('${dir.path}/GymMane $stamp.fit');- await file.writeAsBytes(workoutFit(s, pounds: fit.isLb));- await SharePlus.instance.share(ShareParams(files: [XFile(file.path)], text: t.exportForStravaHint));+ await shareFile('GymMane $stamp.fit', Uint8List.fromList(workoutFit(s, pounds: fit.isLb)),+ mime: 'application/vnd.ant.fit', text: t.exportForStravaHint);} catch (_) {}}diff --git a/lib/screens/tool_detail_screen.dart b/lib/screens/tool_detail_screen.dartindex 2f5a419..b0af709 100644--- a/lib/screens/tool_detail_screen.dart+++ b/lib/screens/tool_detail_screen.dart@@ -9,46 +9,55 @@ import '../widgets/glass.dart';import '../widgets/ui_kit.dart';class ToolDetailScreen extends StatelessWidget {- const ToolDetailScreen({super.key});+ const ToolDetailScreen({super.key, this.embedded = false});++ final bool embedded;@overrideWidget build(BuildContext context) {final gc = context.gc;final id = fit.activeToolId;final meta = _meta(id);-+ final body = Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ if (embedded)+ Padding(+ padding: const EdgeInsetsDirectional.only(start: 4),+ child: Text(meta.$1, style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text)),+ )+ else+ ScreenHeader(title: meta.$1, onBack: fit.closeTool, titleSize: 21),+ SizedBox(height: embedded ? 14 : 20),+ Container(+ padding: const EdgeInsets.fromLTRB(22, 24, 22, 24),+ decoration: BoxDecoration(+ color: gc.bgRaised,+ borderRadius: BorderRadius.circular(24),+ ),+ child: Column(children: [+ Text(t.result.toUpperCase(),+ style: AppTheme.f(10.5,+ weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.6)),+ const SizedBox(height: 8),+ Text(meta.$2,+ textAlign: TextAlign.center,+ style: AppTheme.f(40, weight: FontWeight.w800, color: gc.text)),+ const SizedBox(height: 8),+ Text(meta.$3, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary), textAlign: TextAlign.center),+ ]),+ ),+ const SizedBox(height: 18),+ ..._grouped(_inputs(context, gc, id)),+ ],+ );+ if (embedded) return body;return SafeArea(bottom: false,child: SingleChildScrollView(clipBehavior: Clip.none,padding: const EdgeInsets.fromLTRB(20, 12, 20, 32),- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- ScreenHeader(title: meta.$1, onBack: fit.closeTool, titleSize: 21),- const SizedBox(height: 20),- Container(- padding: const EdgeInsets.fromLTRB(22, 24, 22, 24),- decoration: BoxDecoration(- color: gc.bgRaised,- borderRadius: BorderRadius.circular(24),- ),- child: Column(children: [- Text(t.result.toUpperCase(),- style: AppTheme.f(10.5,- weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.6)),- const SizedBox(height: 8),- Text(meta.$2,- textAlign: TextAlign.center,- style: AppTheme.f(40, weight: FontWeight.w800, color: gc.text)),- const SizedBox(height: 8),- Text(meta.$3, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary), textAlign: TextAlign.center),- ]),- ),- const SizedBox(height: 18),- ..._grouped(_inputs(context, gc, id)),- ],- ),+ child: body,),);}@@ -104,6 +113,10 @@ class ToolDetailScreen extends StatelessWidget {return (t.toolTitle('wilks'), fmt(fit.wilksScore), t.dotsLevelName(fit.wilksLevel));case 'ffmi':return (t.toolTitle('ffmi'), fmt(fit.ffmiScore), t.ffmiLevelName(fit.ffmiLevel));+ case 'protein':+ return (t.toolTitle('protein'), ltr('${fit.protLow}-${fit.protHigh} g'), t.toolResultHint('protein'));+ case 'water':+ return (t.toolTitle('water'), ltr('${fmt(fit.waterLiters)} L'), t.toolResultHint('water'));default:return ('', '', '');}@@ -224,6 +237,25 @@ class ToolDetailScreen extends StatelessWidget {ToolRow(label: t.ffmiBodyFat, control: StepperControl(value: '${fmt(fit.ffmiBf)}%', minWidth: 52, onDec: () => fit.bumpFfmiBf(-0.5), onInc: () => fit.bumpFfmiBf(0.5), onEdit: () => _editNumber(context, title: t.ffmiBodyFat, current: fit.ffmiBf, decimal: true, apply: (v) => fit.bumpFfmiBf(v - fit.ffmiBf)))),_note(gc, '${t.ffmiLeanLine(fit.weightLabel(fit.ffmiLean))}\n${t.ffmiExplain}'),];+ case 'protein':+ return [+ ToolRow(+ label: t.proteinGoalLabel,+ control: SegToggle([+ SegOption(t.paceLose, fit.protGoal == 'lose', () => fit.setProtGoal('lose')),+ SegOption(t.paceHold, fit.protGoal == 'hold', () => fit.setProtGoal('hold')),+ SegOption(t.paceGain, fit.protGoal == 'gain', () => fit.setProtGoal('gain')),+ ]),+ ),+ ToolRow(label: t.weightLabel, control: StepperControl(value: ltr('${fit.weightValue(fit.protWeight)} ${fit.units}'), onDec: () => fit.bumpProtWeight(-fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)), onInc: () => fit.bumpProtWeight(fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)), onEdit: () => _editNumber(context, title: t.weightLabel, current: fit.toDisplayWeight(fit.protWeight), decimal: true, apply: (v) => fit.bumpProtWeight(fit.fromDisplayWeight(v) - fit.protWeight)))),+ _note(gc, t.proteinExplain),+ ];+ case 'water':+ return [+ ToolRow(label: t.weightLabel, control: StepperControl(value: ltr('${fit.weightValue(fit.waterWeight)} ${fit.units}'), onDec: () => fit.bumpWaterWeight(-fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)), onInc: () => fit.bumpWaterWeight(fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)), onEdit: () => _editNumber(context, title: t.weightLabel, current: fit.toDisplayWeight(fit.waterWeight), decimal: true, apply: (v) => fit.bumpWaterWeight(fit.fromDisplayWeight(v) - fit.waterWeight)))),+ ToolRow(label: t.waterTrainingLabel, control: StepperControl(value: ltr('${fit.waterMinutes} min'), minWidth: 64, onDec: () => fit.bumpWaterMinutes(-15), onInc: () => fit.bumpWaterMinutes(15), onEdit: () => _editNumber(context, title: t.waterTrainingLabel, current: fit.waterMinutes.toDouble(), decimal: false, apply: (v) => fit.bumpWaterMinutes(v.round() - fit.waterMinutes)))),+ _note(gc, t.waterExplain),+ ];default:return const [];}diff --git a/lib/screens/tools_screen.dart b/lib/screens/tools_screen.dartindex eed9bd2..4a6e8a3 100644--- a/lib/screens/tools_screen.dart+++ b/lib/screens/tools_screen.dart@@ -1,5 +1,6 @@import 'package:flutter/material.dart';+import '../app/desktop.dart';import '../catalog/exercise_catalog.dart';import '../l10n/l10n.dart';import '../models/exercise.dart';@@ -7,6 +8,7 @@ import '../state/fit_state.dart';import '../theme/app_colors.dart';import '../theme/app_theme.dart';import '../widgets/tool_art.dart';+import 'tool_detail_screen.dart';import '../widgets/ui_kit.dart';class ToolsScreen extends StatelessWidget {@@ -16,11 +18,12 @@ class ToolsScreen extends StatelessWidget {Widget build(BuildContext context) {final gc = context.gc;final scale = MediaQuery.textScalerOf(context).scale(1);+ final wide = DesktopScope.of(context);return SafeArea(bottom: false,child: SingleChildScrollView(clipBehavior: Clip.none,- padding: const EdgeInsets.fromLTRB(20, 12, 20, 40),+ padding: wide ? const EdgeInsets.fromLTRB(32, 30, 32, 48) : const EdgeInsets.fromLTRB(20, 12, 20, 40),child: Column(crossAxisAlignment: CrossAxisAlignment.stretch,children: [@@ -31,21 +34,112 @@ class ToolsScreen extends StatelessWidget {subtitle: t.calculatorsCount(kToolMeta.length),),const SizedBox(height: 22),- GridView.count(- crossAxisCount: 2,- shrinkWrap: true,- physics: const NeverScrollableScrollPhysics(),- mainAxisSpacing: 12,- crossAxisSpacing: 12,- childAspectRatio: 1.12 / scale,- children: [for (final tool in kToolMeta) _card(gc, tool, scale)],- ),+ if (wide)+ _desktop(gc, scale)+ else+ GridView.count(+ crossAxisCount: 2,+ shrinkWrap: true,+ physics: const NeverScrollableScrollPhysics(),+ mainAxisSpacing: 12,+ crossAxisSpacing: 12,+ childAspectRatio: 1.12 / scale,+ children: [for (final tool in kToolMeta) _card(gc, tool, scale)],+ ),],),),);}+ Widget _desktop(GymColors gc, double scale) {+ final picked = kToolMeta.any((m) => m.id == fit.activeToolId) ? fit.activeToolId! : kToolMeta.first.id;+ if (fit.activeToolId != picked) fit.activeToolId = picked;+ return Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ for (final (i, g) in [+ (t.kindStrength, const ['rm', 'plate', 'warmup', 'rpe', 'dots', 'wilks']),+ (t.toolGroupBody, const ['bmi', 'bf', 'ffmi']),+ (t.nutrition, const ['cal', 'protein', 'water']),+ ].indexed) ...[+ if (i > 0) const SizedBox(height: 26),+ Padding(+ padding: const EdgeInsetsDirectional.only(start: 4, bottom: 12),+ child: Text(g.$1, style: AppTheme.f(13, weight: FontWeight.w700, color: gc.textTertiary)),+ ),+ LayoutBuilder(+ builder: (context, box) => GridView(+ shrinkWrap: true,+ physics: const NeverScrollableScrollPhysics(),+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(+ crossAxisCount: (box.maxWidth / 300).floor().clamp(1, 3),+ mainAxisSpacing: 14,+ crossAxisSpacing: 14,+ mainAxisExtent: 82 * scale,+ ),+ children: [+ for (final tool in kToolMeta)+ if (g.$2.contains(tool.id)) _row(gc, tool),+ ],+ ),+ ),+ ]+ ]),+ ),+ const SizedBox(width: 24),+ Container(+ width: 400,+ margin: const EdgeInsets.only(top: 26),+ padding: const EdgeInsets.fromLTRB(18, 20, 18, 22),+ decoration: BoxDecoration(color: gc.bgRaised.withValues(alpha: 0.5), borderRadius: BorderRadius.circular(26)),+ child: AnimatedSwitcher(+ duration: const Duration(milliseconds: 200),+ layoutBuilder: (current, previous) => Stack(+ alignment: Alignment.topCenter,+ children: [...previous, ?current],+ ),+ child: ToolDetailScreen(key: ValueKey(fit.activeToolId), embedded: true),+ ),+ ),+ ]);+ }++ Widget _row(GymColors gc, ToolMeta tool) {+ final on = fit.activeToolId == tool.id;+ return Pressable(+ onTap: () => fit.selectTool(tool.id),+ scale: 0.97,+ child: AnimatedContainer(+ duration: const Duration(milliseconds: 180),+ padding: const EdgeInsets.fromLTRB(12, 10, 16, 10),+ decoration: BoxDecoration(+ color: gc.bgRaised,+ borderRadius: BorderRadius.circular(20),+ border: Border.all(color: on ? gc.text.withValues(alpha: 0.55) : Colors.transparent, width: 1.4),+ ),+ child: Row(children: [+ const SizedBox(width: 4),+ ToolArt(tool.id),+ const SizedBox(width: 16),+ Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [+ Text(t.toolName(tool.id),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(15, weight: FontWeight.w800, color: gc.text)),+ const SizedBox(height: 4),+ Text(t.toolDesc(tool.id),+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),+ ]),+ ),+ ]),+ ),+ );+ }+Widget _card(GymColors gc, ToolMeta tool, double scale) {return Pressable(onTap: () => fit.openTool(tool.id),diff --git a/lib/screens/train_screen.dart b/lib/screens/train_screen.dartindex 12876c0..b952cb0 100644--- a/lib/screens/train_screen.dart+++ b/lib/screens/train_screen.dart@@ -229,6 +229,7 @@ class _TrainScreenState extends State<TrainScreen> {const SizedBox(height: 12),if (gearHere.length > 1) ...[SingleChildScrollView(+ key: const PageStorageKey('h-train_screen-232'),scrollDirection: Axis.horizontal,child: Row(children: [_gearChip(gc, t.allExercisesShort, gear == null, null),