Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Add workout history by month
InlitXdfae04138406
diff --git a/lib/screens/history_screen.dart b/lib/screens/history_screen.dartnew file mode 100644index 0000000..6b4f24d--- /dev/null+++ b/lib/screens/history_screen.dart@@ -0,0 +1,322 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';++import '../l10n/l10n.dart';+import '../models/workout.dart';+import '../state/fit_state.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import '../widgets/ui_kit.dart';+import 'progress_screen.dart';++class HistoryScreen extends StatelessWidget {+ const HistoryScreen({super.key});++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final month = fit.historyMonth;+ final list = fit.sessionsInMonth(month);+ final records = fit.recordsBySession();+ return SafeArea(+ bottom: false,+ child: GestureDetector(+ behavior: HitTestBehavior.translucent,+ onHorizontalDragEnd: (d) {+ final v = d.primaryVelocity ?? 0;+ if (v.abs() < 300) return;+ final rtl = Directionality.of(context) == TextDirection.rtl;+ final older = rtl ? v < 0 : v > 0;+ if (!older && fit.historyAtLatest) return;+ HapticFeedback.selectionClick();+ fit.shiftHistoryMonth(older ? -1 : 1);+ },+ child: ListView(+ padding: const EdgeInsets.fromLTRB(20, 12, 20, 110),+ children: [+ ScreenHeader(title: sentenceCase(t.historyTitle), onBack: fit.popRoute),+ const SizedBox(height: 16),+ _MonthCard(month: month),+ const SizedBox(height: 22),+ if (list.isEmpty)+ _empty(gc)+ else ...[+ Text(t.historyWorkouts(list.length),+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3)),+ const SizedBox(height: 10),+ for (final s in list) ...[+ WorkoutHistoryCard(session: s, records: records[s] ?? 0),+ const SizedBox(height: 10),+ ],+ ],+ ],+ ),+ ),+ );+ }++ Widget _empty(GymColors gc) => Container(+ padding: const EdgeInsets.symmetric(vertical: 34, horizontal: 24),+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),+ child: Column(children: [+ Icon(PhosphorIconsRegular.calendarBlank, size: 30, color: gc.textTertiary),+ const SizedBox(height: 12),+ Text(t.historyEmpty,+ textAlign: TextAlign.center, style: AppTheme.f(15, weight: FontWeight.w700, color: gc.text)),+ const SizedBox(height: 4),+ Text(t.historyEmptyHint,+ textAlign: TextAlign.center,+ style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),+ ]),+ );+}++class _MonthCard extends StatelessWidget {+ const _MonthCard({required this.month});++ final DateTime month;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final now = fit.monthSummary(month);+ final before = fit.monthSummary(DateTime(month.year, month.month - 1));+ final trained = {for (final s in fit.sessionsInMonth(month)) s.day.day};+ final hours = now.seconds ~/ 3600;+ final minutes = (now.seconds % 3600) ~/ 60;+ return Container(+ padding: const EdgeInsets.fromLTRB(16, 14, 16, 16),+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),+ child: Column(children: [+ Row(children: [+ _arrow(gc, PhosphorIconsBold.caretLeft, t.notePrevMonth, () => fit.shiftHistoryMonth(-1)),+ Expanded(+ child: Text(t.monthYear(month),+ textAlign: TextAlign.center, style: AppTheme.f(16, weight: FontWeight.w800, color: gc.text)),+ ),+ _arrow(gc, PhosphorIconsBold.caretRight, t.noteNextMonth,+ fit.historyAtLatest ? null : () => fit.shiftHistoryMonth(1)),+ ]),+ const SizedBox(height: 16),+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ _stat(gc, '${now.workouts}', t.statWorkouts.toUpperCase(), now.workouts - before.workouts),+ _stat(gc, hours > 0 ? '${hours}h ${minutes.toString().padLeft(2, '0')}' : '${minutes}m', t.timeCaps, null),+ _stat(gc, '${now.sets}', t.setsCaps, null),+ _stat(gc, fit.volumeLabel(now.volume), t.volume, null),+ ]),+ const SizedBox(height: 16),+ Container(height: 1, color: gc.border),+ const SizedBox(height: 12),+ _calendar(context, gc, trained),+ ]),+ );+ }++ Widget _arrow(GymColors gc, IconData icon, String label, VoidCallback? onTap) => Semantics(+ button: true,+ enabled: onTap != null,+ label: label,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap == null+ ? null+ : () {+ HapticFeedback.selectionClick();+ onTap();+ },+ child: Opacity(+ opacity: onTap == null ? 0.3 : 1,+ child: Container(+ width: 34,+ height: 34,+ decoration: BoxDecoration(color: gc.bgRaised2, shape: BoxShape.circle),+ child: Icon(icon, size: 13, color: gc.text),+ ),+ ),+ ),+ );++ Widget _stat(GymColors gc, String value, String label, int? delta) => Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ FitText(value, style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text, height: 1.1)),+ const SizedBox(height: 3),+ FitText(label, style: AppTheme.f(9, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1)),+ if (delta != null && delta != 0) ...[+ const SizedBox(height: 3),+ Row(mainAxisSize: MainAxisSize.min, children: [+ Icon(delta > 0 ? PhosphorIconsBold.arrowUp : PhosphorIconsBold.arrowDown,+ size: 10, color: delta > 0 ? gc.sage : gc.textTertiary),+ const SizedBox(width: 2),+ Text('${delta.abs()}',+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: delta > 0 ? gc.sage : gc.textTertiary)),+ ]),+ ],+ ]),+ );++ Widget _calendar(BuildContext context, GymColors gc, Set<int> trained) {+ final today = DateTime.now();+ final first = DateTime(month.year, month.month);+ final days = DateTime(month.year, month.month + 1, 0).day;+ final lead = (first.weekday - fit.weekStartDay + 7) % 7;+ return Column(children: [+ Row(children: [+ for (var i = 0; i < 7; i++)+ Expanded(+ child: Text(t.weekdayInitial(fit.weekdayAt(i)).toUpperCase(),+ textAlign: TextAlign.center,+ style: AppTheme.f(10, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1)),+ ),+ ]),+ const SizedBox(height: 6),+ for (var row = 0; row * 7 < lead + days; row++)+ Row(children: [+ for (var col = 0; col < 7; col++)+ Expanded(child: () {+ final n = row * 7 + col - lead + 1;+ if (n < 1 || n > days) return const SizedBox(height: 40);+ final day = DateTime(month.year, month.month, n);+ final on = trained.contains(n);+ final isToday = DateUtils.isSameDay(day, today);+ final future = day.isAfter(today);+ return Semantics(+ button: on,+ label: t.fullDate(day),+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: future ? null : () => showDaySheet(context, day),+ child: SizedBox(+ height: 40,+ child: Center(+ child: Container(+ width: 32,+ height: 32,+ alignment: Alignment.center,+ decoration: BoxDecoration(+ color: on ? gc.accent : Colors.transparent,+ shape: BoxShape.circle,+ border: isToday && !on ? Border.all(color: gc.ember, width: 1.4) : null,+ ),+ child: Text('$n',+ style: AppTheme.f(13,+ weight: on || isToday ? FontWeight.w800 : FontWeight.w500,+ color: on+ ? gc.onEmber+ : future+ ? gc.textTertiary.withValues(alpha: 0.5)+ : gc.textSecondary)),+ ),+ ),+ ),+ ),+ );+ }()),+ ]),+ ]);+ }+}++class WorkoutHistoryCard extends StatelessWidget {+ const WorkoutHistoryCard({super.key, required this.session, this.records = 0});++ final LoggedSession session;+ final int records;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final s = session;+ final start = TimeOfDay.fromDateTime(s.day);+ final clock = MaterialLocalizations.of(context)+ .formatTimeOfDay(start, alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context));+ final meta = [clock, if (s.durationSec >= 60) '${(s.durationSec / 60).round()} min'].join(' · ');+ final shown = s.exercises.take(4).toList();+ return Pressable(+ scale: 0.98,+ onTap: () => showDaySheet(context, s.day),+ child: Container(+ padding: const EdgeInsets.fromLTRB(14, 14, 16, 14),+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(20)),+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Container(+ width: 46,+ padding: const EdgeInsets.symmetric(vertical: 6),+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(12)),+ child: Column(children: [+ Text(t.weekdayShort(s.day.weekday).toUpperCase(),+ style: AppTheme.f(9, weight: FontWeight.w800, color: gc.accent, letterSpacing: 0.8)),+ Text('${s.day.day}', style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text, height: 1.15)),+ ]),+ ),+ const SizedBox(width: 12),+ Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Text(fit.sessionHeading(s),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(16, weight: FontWeight.w800, color: gc.text)),+ const SizedBox(height: 2),+ Text(meta, style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary)),+ const SizedBox(height: 6),+ Text(+ [t.exerciseCount(s.exercises.length), t.setCount(s.setCount), if (s.volume > 0) fit.volumeLabel(s.volume)]+ .join(' · '),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textTertiary)),+ ]),+ ),+ if (records > 0) ...[+ const SizedBox(width: 8),+ Container(+ padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),+ decoration: BoxDecoration(color: gc.accentSoft, borderRadius: BorderRadius.circular(100)),+ child: Row(mainAxisSize: MainAxisSize.min, children: [+ Icon(PhosphorIconsFill.trophy, size: 11, color: gc.accent),+ const SizedBox(width: 4),+ Text('$records', style: AppTheme.f(11.5, weight: FontWeight.w800, color: gc.accent)),+ ]),+ ),+ ],+ ]),+ const SizedBox(height: 12),+ Container(height: 1, color: gc.border),+ const SizedBox(height: 10),+ for (final e in shown) _line(gc, e),+ if (s.exercises.length > shown.length)+ Padding(+ padding: const EdgeInsets.only(top: 2),+ child: Text(t.historyMore(s.exercises.length - shown.length),+ style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textTertiary)),+ ),+ ]),+ ),+ );+ }++ Widget _line(GymColors gc, LoggedExercise e) {+ final top = fit.topSetOf(e);+ return Padding(+ padding: const EdgeInsets.only(bottom: 6),+ child: Row(children: [+ SizedBox(+ width: 30,+ child: Text('${e.workingSets.length}×',+ style: AppTheme.f(12.5, weight: FontWeight.w700, color: gc.textTertiary)),+ ),+ Expanded(+ child: Text(t.catalogName(e.id, e.name),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.text)),+ ),+ if (top != null) ...[+ const SizedBox(width: 10),+ Text(fit.loggedSetLabel(top), style: AppTheme.f(12.5, weight: FontWeight.w700, color: gc.textSecondary)),+ ],+ ]),+ );+ }+}diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dartindex 8d88874..ffbfcac 100644--- a/lib/screens/profile_screen.dart+++ b/lib/screens/profile_screen.dart@@ -7,6 +7,7 @@ import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';import '../l10n/l10n.dart';import '../models/profile.dart';+import '../models/workout.dart';import '../services/media_store.dart';import '../state/fit_state.dart';import '../theme/app_colors.dart';@@ -16,6 +17,7 @@ import '../widgets/medal_shelf.dart';import '../widgets/photo_source_sheet.dart';import '../widgets/profile_avatar.dart';import '../widgets/ui_kit.dart';+import 'history_screen.dart';import 'settings_screen.dart';import 'share_sheet.dart';@@ -128,9 +130,23 @@ class _ProfileScreenState extends State<ProfileScreen> {_photoCards(gc),]),),+ if (fit.sessions.isNotEmpty) ...[+ const SizedBox(height: 30),+ Rise(+ index: 3,+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ _heading(gc, t.historyTitle, count: '${fit.sessions.length}', onMore: fit.goHistory),+ const SizedBox(height: 16),+ for (final s in _latest) ...[+ WorkoutHistoryCard(session: s),+ const SizedBox(height: 10),+ ],+ ]),+ ),+ ],const SizedBox(height: 30),Rise(- index: 3,+ index: 4,child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [_heading(gc, t.yearTitle),const SizedBox(height: 16),@@ -146,6 +162,8 @@ class _ProfileScreenState extends State<ProfileScreen> {);}+ List<LoggedSession> get _latest => ([...fit.sessions]..sort((a, b) => b.day.compareTo(a.day))).take(2).toList();+Widget _year(GymColors gc) {final months = fit.sessionsByMonth;final peak = months.fold(1, math.max);@@ -178,7 +196,10 @@ class _ProfileScreenState extends State<ProfileScreen> {for (var m = 1; m <= 12; m++) ...[if (m > 1) const SizedBox(width: 5),Expanded(- child: TweenAnimationBuilder<double>(+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: months[m - 1] > 0 ? () => fit.goHistory(month: DateTime(DateTime.now().year, m)) : null,+ child: TweenAnimationBuilder<double>(tween: Tween(begin: 0, end: months[m - 1] / peak),duration: Duration(milliseconds: 650 + m * 35),curve: Curves.easeOutCubic,@@ -192,6 +213,7 @@ class _ProfileScreenState extends State<ProfileScreen> {),),),+ ),),],],diff --git a/lib/state/stats_state.dart b/lib/state/stats_state.dartindex ad4dd75..2d9be2e 100644--- a/lib/state/stats_state.dart+++ b/lib/state/stats_state.dart@@ -1,6 +1,6 @@part of 'fit_state.dart';-mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {+mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineState {List<Exercise> recommendedExercises(int n) {final muscles = suggestedFocus.muscles;final pool = kExercises.where((e) => !noSuggest.contains(e.id) && !isArchived(e.id) && fitsHere(e));@@ -234,6 +234,95 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {}}+ DateTime historyMonth = DateTime(DateTime.now().year, DateTime.now().month);++ void goHistory({DateTime? month}) {+ final m = month ?? DateTime.now();+ historyMonth = DateTime(m.year, m.month);+ pushRoute('history');+ }++ bool get historyAtLatest {+ final now = DateTime.now();+ return !historyMonth.isBefore(DateTime(now.year, now.month));+ }++ void shiftHistoryMonth(int delta) {+ final next = DateTime(historyMonth.year, historyMonth.month + delta);+ final now = DateTime.now();+ if (next.isAfter(DateTime(now.year, now.month))) return;+ historyMonth = next;+ notifyListeners();+ }++ List<LoggedSession> sessionsInMonth(DateTime month) {+ final list = [+ for (final s in sessions)+ if (s.day.year == month.year && s.day.month == month.month) s,+ ];+ list.sort((a, b) => b.day.compareTo(a.day));+ return list;+ }++ ({int workouts, int seconds, int sets, double volume}) monthSummary(DateTime month) {+ var workouts = 0, seconds = 0, sets = 0;+ var volume = 0.0;+ for (final s in sessions) {+ if (s.day.year != month.year || s.day.month != month.month) continue;+ workouts++;+ seconds += s.durationSec;+ sets += s.setCount;+ volume += s.volume;+ }+ return (workouts: workouts, seconds: seconds, sets: sets, volume: volume);+ }++ double _setScore(String id, LoggedSet s) {+ if ((s.km ?? 0) > 0) return s.km!;+ if (s.weight > 0 || isAssisted(id)) return liftScore(id, s);+ if (s.reps > 0) return s.reps.toDouble();+ return (s.sec ?? 0).toDouble();+ }++ LoggedSet? topSetOf(LoggedExercise e) {+ LoggedSet? best;+ for (final s in e.workingSets) {+ if (best == null || _setScore(e.id, s) > _setScore(e.id, best)) best = s;+ }+ return best;+ }++ Map<LoggedSession, int> recordsBySession() {+ final ordered = [...sessions]..sort((a, b) => a.date.compareTo(b.date));+ final best = <String, double>{};+ final out = <LoggedSession, int>{};+ for (final s in ordered) {+ var n = 0;+ for (final e in s.exercises) {+ final top = topSetOf(e);+ if (top == null) continue;+ final score = _setScore(e.id, top);+ final before = best[e.id];+ if (before != null && score > before + 1e-9) n++;+ if (before == null || score > before) best[e.id] = score;+ }+ if (n > 0) out[s] = n;+ }+ return out;+ }++ String sessionHeading(LoggedSession s) {+ final named = sessionTitle(s);+ if (named != null && named.trim().isNotEmpty) return named;+ final count = <String, int>{};+ for (final e in s.exercises) {+ final g = muscleGroup(e.primary);+ count[g] = (count[g] ?? 0) + e.workingSets.length;+ }+ final groups = count.keys.toList()..sort((a, b) => count[b]!.compareTo(count[a]!));+ return groups.take(2).map(t.muscleGroupName).join(' · ');+ }+String? sessionTitle(LoggedSession s) {final name = s.name;if (name != null) return name;@@ -293,22 +382,46 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {notifyListeners();}- void setLoggedReps(LoggedExercise e, int i, int reps) {+ void _replaceLoggedSet(LoggedExercise e, int i, {int? reps, double? weight, int? sec, double? km}) {if (i < 0 || i >= e.sets.length) return;- e.sets[i] = LoggedSet(reps.clamp(0, 999), e.sets[i].weight);+ final old = e.sets[i];+ e.sets[i] = LoggedSet(+ reps ?? old.reps,+ weight ?? old.weight,+ kind: old.kind,+ rpe: old.rpe,+ sec: sec ?? old.sec,+ km: km ?? old.km,+ );persistNow();_refreshWidgets();notifyListeners();}- void setLoggedWeight(LoggedExercise e, int i, double kg) {+ void setLoggedReps(LoggedExercise e, int i, int reps) => _replaceLoggedSet(e, i, reps: reps.clamp(0, 999));++ void setLoggedWeight(LoggedExercise e, int i, double kg) =>+ _replaceLoggedSet(e, i, weight: _round3(kg.clamp(0, 1000)));++ void bumpLoggedSec(LoggedExercise e, int i, int d) {if (i < 0 || i >= e.sets.length) return;- e.sets[i] = LoggedSet(e.sets[i].reps, _round3(kg.clamp(0, 1000)));- persistNow();- _refreshWidgets();- notifyListeners();+ final now = e.sets[i].sec ?? 0;+ final step = now >= 600 ? 30 : 5;+ _replaceLoggedSet(e, i, sec: ((now ~/ step) * step + d * step).clamp(0, 86400));+ }++ void bumpLoggedKm(LoggedExercise e, int i, int dir) {+ if (i < 0 || i >= e.sets.length) return;+ final shown = toDisplayKm(e.sets[i].km ?? 0);+ final next = math.max(0.0, ((shown / distanceStep).round() + dir) * distanceStep);+ _replaceLoggedSet(e, i, km: _round3(fromDisplayKm(next)));}+ bool loggedTimed(LoggedExercise e) =>+ isTimed(e.id) || e.sets.any((s) => s.sec != null && s.reps <= 0 && (s.km ?? 0) <= 0);++ bool loggedDistance(LoggedExercise e) => isCardio(e.id) || e.sets.any((s) => (s.km ?? 0) > 0);+void setLoggedWeightShown(LoggedExercise e, int i, double shown) =>setLoggedWeight(e, i, fromDisplayWeight(shown));@@ -322,7 +435,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {void addLoggedSet(LoggedExercise e) {final last = e.sets.isNotEmpty ? e.sets.last : LoggedSet(10, isRepsOnly(e.id) ? 0 : 20);- e.sets.add(LoggedSet(last.reps, last.weight));+ e.sets.add(LoggedSet(last.reps, last.weight, sec: last.sec, km: last.km));persistNow();_refreshWidgets();notifyListeners();@@ -462,8 +575,29 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {int get goalPct => ((daysDoneThisWeek / weeklyTarget) * 100).round().clamp(0, 100);+ double headlineWeight(LoggedExercise e) {+ if (!isAssisted(e.id)) return e.topWeight;+ final done = e.workingSets.where((s) => s.reps > 0);+ return done.isEmpty ? e.topWeight : done.map((s) => s.weight).reduce(math.min);+ }++ double get _assistBodyKg => profile.weightKg > 0 ? profile.weightKg : 75;++ double liftScore(String id, LoggedSet s) {+ if (!isAssisted(id)) return s.oneRm;+ if (s.reps <= 0) return 0;+ return math.max(0.0, _assistBodyKg - s.weight) * (1 + s.reps / 30);+ }+PersonalRecord _record(String id, String name, List<LoggedSet> sets) {double top(double Function(LoggedSet) f) => sets.fold(0.0, (m, s) => math.max(m, f(s)));+ if (isAssisted(id)) {+ final done = sets.where((s) => s.reps > 0).toList();+ if (done.isNotEmpty) {+ final least = done.map((s) => s.weight).reduce(math.min);+ return (id: id, name: name, kind: PrKind.weight, best: least, oneRm: top((s) => liftScore(id, s)));+ }+ }final kind = PrKind.values.firstWhere((k) => top(k.score) > 0, orElse: () => PrKind.reps);return (id: id, name: name, kind: kind, best: top(kind.score), oneRm: top((s) => s.oneRm));}@@ -491,11 +625,12 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {}({LoggedSet set, DateTime date})? bestSet(String id) {+ final assisted = isAssisted(id);({LoggedSet set, DateTime date})? best;for (final h in exerciseHistory(id)) {for (final st in h.ex.workingSets) {- if (st.weight <= 0 || st.reps <= 0) continue;- if (best == null || st.oneRm > best.set.oneRm) best = (set: st, date: h.date);+ if (st.reps <= 0 || (!assisted && st.weight <= 0)) continue;+ if (best == null || liftScore(id, st) > liftScore(id, best.set)) best = (set: st, date: h.date);}}return best;@@ -526,8 +661,9 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {PrKind.reps => t.repCount(r.best.round()),};- String recordDetail(PersonalRecord r) =>- r.kind == PrKind.weight ? t.oneRmEst(weightLabel(r.oneRm)) : t.prBestSet;+ String recordDetail(PersonalRecord r) => r.kind == PrKind.weight+ ? (isAssisted(r.id) ? t.assistedRecordHint : t.oneRmEst(weightLabel(r.oneRm)))+ : t.prBestSet;int get prsThisWeek {final kinds = {for (final r in personalRecords) r.id: r.kind};@@ -538,7 +674,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {final kind = kinds[e.id];if (kind == null) continue;for (final st in e.workingSets) {- final score = kind == PrKind.weight ? st.oneRm : kind.score(st);+ final score = kind == PrKind.weight ? liftScore(e.id, st) : kind.score(st);if (score > (bestScore[e.id] ?? 0)) {bestScore[e.id] = score;bestDate[e.id] = s.date;@@ -838,14 +974,21 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {}@override- double bestLift(String id) => oneRmSeries(id).fold(0.0, math.max);+ double bestLift(String id) => isAssisted(id) ? 0 : oneRmSeries(id).fold(0.0, math.max);List<double> oneRmSeries(String id) {final h = exerciseHistory(id).reversed;+ if (isAssisted(id)) {+ return [+ for (final r in h)+ if (r.ex.workingSets.any((s) => s.reps > 0))+ _round1(r.ex.workingSets.where((s) => s.reps > 0).map((s) => s.weight).reduce(math.min)),+ ];+ }return h.map((r) => _round1(r.ex.bestOneRm)).toList();}- bool goalFits(String id) => modeOf(id).isEmpty;+ bool goalFits(String id) => modeOf(id).isEmpty && !isAssisted(id);PrKind goalKind(String id) {final kind = exerciseRecord(id)?.kind;@@ -883,6 +1026,25 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {DateTime heatmapWeekDate(int i, {int weeks = kHeatmapDays ~/ 7}) =>shiftDays(_weekStart, i - (weeks - 1) * 7);+ int get heatmapYearWeeks {+ DateTime? first;+ for (final s in sessions) {+ final d = _dayKey(s.day);+ if (first == null || d.isBefore(first)) first = d;+ }+ for (final d in _checkinDays) {+ if (first == null || d.isBefore(first)) first = d;+ }+ final back = first == null ? 0 : _weekStart.difference(first).inDays;+ return math.max(53, (back / 7).ceil() + 1);+ }++ int get heatmapShownWeeks => heatmapYear ? heatmapYearWeeks : kHeatmapDays ~/ 7;++ List<int> get heatmapShown => heatmapWeeksFor(heatmapShownWeeks);++ DateTime heatmapShownDate(int i) => heatmapWeekDate(i, weeks: heatmapShownWeeks);+List<double> bestRepsSeries(String id) => [for (final r in exerciseHistory(id).reversed)r.ex.sets.where((s) => s.counts).fold(0, (m, s) => math.max(m, s.reps)).toDouble(),