Skip to content

Offline gym log for Android. No account, no ads, no internet.

Rebuild progress as a bento and let the timeline group by any interval

InlitX7d3f65469648
diff --git a/lib/screens/compare_screen.dart b/lib/screens/compare_screen.dart
index 2d96fad..eb9e142 100644
--- a/lib/screens/compare_screen.dart
+++ b/lib/screens/compare_screen.dart
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:flutter/material.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../l10n/l10n.dart';
import '../models/progress_shot.dart';
diff --git a/lib/screens/measures_screen.dart b/lib/screens/measures_screen.dart
index 8fd61b6..f918b2e 100644
--- a/lib/screens/measures_screen.dart
+++ b/lib/screens/measures_screen.dart
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../l10n/l10n.dart';
import '../models/measure.dart';
diff --git a/lib/screens/progress_screen.dart b/lib/screens/progress_screen.dart
index c88c50a..7bf7960 100644
--- a/lib/screens/progress_screen.dart
+++ b/lib/screens/progress_screen.dart
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:flutter/material.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../l10n/l10n.dart';
import '../models/progress_shot.dart';
@@ -13,9 +13,9 @@ import '../theme/app_theme.dart';
import '../widgets/body_map.dart';
import '../widgets/charts.dart';
import '../widgets/dialogs.dart';
-import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
import 'share_sheet.dart';
+import 'start_sheet.dart';
class ProgressScreen extends StatelessWidget {
const ProgressScreen({super.key});
@@ -37,7 +37,10 @@ class ProgressScreen extends StatelessWidget {
children: [
Row(
children: [
- Expanded(child: ScreenTitle(t.progress)),
+ Expanded(
+ child: Text(t.progressTitle,
+ style: AppTheme.f(27, weight: FontWeight.w800, color: gc.text)),
+ ),
Semantics(
button: true,
label: t.share,
@@ -46,330 +49,417 @@ class ProgressScreen extends StatelessWidget {
child: Container(
width: 38,
height: 38,
- decoration: BoxDecoration(
- color: gc.bgRaised,
- shape: BoxShape.circle,
- border: Border.all(color: gc.border),
- ),
+ decoration: BoxDecoration(color: gc.bgRaised, shape: BoxShape.circle),
child: Icon(PhosphorIconsRegular.shareNetwork, size: 17, color: gc.text),
),
),
),
],
),
- const SizedBox(height: 22),
- SoftCard(
- radius: 24,
- padding: const EdgeInsets.all(24),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(t.totalVolume30d,
- style: AppTheme.d(12, weight: FontWeight.w600, color: gc.brass, letterSpacing: 3)),
- const SizedBox(height: 8),
- Row(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- RichText(
- text: TextSpan(
- text: fit.volumeValue(fit.volume30dKg),
- style: AppTheme.d(44, weight: FontWeight.w700, color: gc.text),
- children: [
- TextSpan(text: ' ${fit.volumeUnit}', style: AppTheme.d(20, weight: FontWeight.w700, color: gc.textSecondary)),
- ],
- ),
- ),
- const SizedBox(width: 10),
- if (change != null)
- Padding(
- padding: const EdgeInsets.only(bottom: 6),
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
- decoration: BoxDecoration(
- color: change >= 0 ? gc.sageSoft : gc.accentSoft,
- borderRadius: BorderRadius.circular(8)),
- child: Row(mainAxisSize: MainAxisSize.min, children: [
- SvgPathIcon(Ic.trendUp, size: 12, color: change >= 0 ? gc.sage : gc.accent),
- const SizedBox(width: 4),
- Text(t.vsLastMonth(change),
- style: AppTheme.s(11, weight: FontWeight.w600, color: change >= 0 ? gc.sage : gc.accent)),
- ]),
- ),
- ),
- ],
- ),
- const SizedBox(height: 4),
- Text(t.volumeCumulative,
- style: AppTheme.s(12, color: gc.textSecondary, height: 1.4)),
- const SizedBox(height: 18),
- VolumeChart(
- points: fit.volumeChartPoints,
- label: fit.volumeValue,
- unit: fit.volumeUnit,
- xLabels: ['-30 d', '-15 d', t.noteToday.toLowerCase()],
- ),
- ],
- ),
- ),
- const SizedBox(height: 22),
- SoftCard(
- radius: 20,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(t.consistency,
- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- Text(t.sessionsLogged(fit.totalSessions),
- style: AppTheme.s(12, color: gc.textSecondary)),
- ],
- ),
- const SizedBox(height: 14),
- Heatmap(levels: fit.heatmapLevels, onTapDay: (i) => _showDay(context, i)),
- const SizedBox(height: 14),
- Row(children: [
- SvgPathIcon(Ic.flame, size: 14, color: gc.accent),
- const SizedBox(width: 6),
- Text(t.streakDays(fit.currentStreak),
- style: AppTheme.s(13, weight: FontWeight.w600, color: gc.text)),
- ]),
- ],
- ),
- ),
- const SizedBox(height: 22),
- _weekRhythm(gc),
- const SizedBox(height: 22),
- SoftCard(
- radius: 20,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(t.bodyweight,
- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- const SizedBox(height: 4),
- if (fit.latestBodyweight != null)
- RichText(
- text: TextSpan(
- text: fit.weightValue(fit.latestBodyweight!.kg),
- style: AppTheme.d(26, weight: FontWeight.w700, color: gc.text),
- children: [
- TextSpan(
- text: ' ${fit.units}',
- style: AppTheme.d(14, weight: FontWeight.w700, color: gc.textSecondary)),
- ],
- ),
- )
- else
- Text(t.notLoggedYet, style: AppTheme.s(13, color: gc.textSecondary)),
- ],
- ),
- GestureDetector(
- onTap: () => _logBodyweight(context),
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 9),
- decoration: BoxDecoration(color: gc.emberSoft, borderRadius: BorderRadius.circular(100)),
- child: Text(t.logShort,
- style: AppTheme.d(13, weight: FontWeight.w600, color: gc.ember, letterSpacing: 1)),
- ),
- ),
- ],
- ),
- if (bw.length >= 2) ...[
- const SizedBox(height: 14),
- Sparkline(values: bw),
- ],
- if (fit.bodyweight.isNotEmpty) ...[
- const SizedBox(height: 12),
- for (final e in fit.bodyweightHistory.take(5)) _bwRow(context, gc, e),
- ],
- ],
- ),
- ),
- const SizedBox(height: 22),
- _timelineCard(gc),
- const SizedBox(height: 22),
- _measuresCard(gc),
- const SizedBox(height: 22),
- _StrengthCard(),
- const SizedBox(height: 22),
+ const SizedBox(height: 20),
+ if (fit.sessions.isEmpty) ...[
+ _setupCard(context, gc),
+ const SizedBox(height: 12),
+ ],
+ _heroRow(context, gc, change, bw),
+ if (fit.sessions.isNotEmpty) ...[
+ const SizedBox(height: 12),
+ _consistency(context, gc),
+ ],
+ const SizedBox(height: 12),
+ _totals(gc),
+ const SizedBox(height: 12),
const _MuscleMapCard(),
- const SizedBox(height: 22),
- SoftCard(
- radius: 20,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(t.muscleSplit,
- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- const SizedBox(height: 14),
- if (split.isEmpty)
- Text(t.splitEmpty,
- style: AppTheme.s(13, color: gc.textSecondary))
- else
- SplitBars(entries: split),
- ],
- ),
+ for (final block in _blocks(context, gc, bw, split, prs)) ...[
+ const SizedBox(height: 12),
+ block,
+ ],
+ if (fit.sessions.isNotEmpty && _missing.isNotEmpty) ...[
+ const SizedBox(height: 12),
+ _setupCard(context, gc),
+ ],
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _tile(
+ GymColors gc, {
+ required String label,
+ required String value,
+ String unit = '',
+ String? note,
+ Widget? chart,
+ Widget? badge,
+ VoidCallback? onTap,
+ }) {
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: Container(
+ padding: const EdgeInsets.fromLTRB(18, 16, 18, 16),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(children: [
+ Expanded(
+ child: Text(label.toUpperCase(),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(10,
+ weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
),
- const SizedBox(height: 22),
- SoftCard(
- radius: 20,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(t.personalRecords,
- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- const SizedBox(height: 14),
- if (prs.isEmpty)
- Text(t.prEmpty,
- style: AppTheme.s(13, color: gc.textSecondary))
- else
- for (int i = 0; i < prs.length; i++) _prRow(gc, prs[i], i < prs.length - 1),
+ ?badge,
+ ]),
+ const SizedBox(height: 10),
+ FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.centerLeft,
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.baseline,
+ textBaseline: TextBaseline.alphabetic,
+ children: [
+ Text(value, style: AppTheme.f(28, weight: FontWeight.w800, color: gc.text)),
+ if (unit.isNotEmpty) ...[
+ const SizedBox(width: 5),
+ Text(unit, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
],
- ),
+ ],
),
- const SizedBox(height: 22),
- _allTime(gc),
+ ),
+ if (note != null) ...[
+ const SizedBox(height: 4),
+ Text(note,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),
],
- ),
+ if (chart != null) ...[
+ const SizedBox(height: 12),
+ chart,
+ ],
+ ],
+ ),
),
);
}
- Widget _weekRhythm(GymColors gc) {
- final by = fit.sessionsByWeekday;
- final best = fit.busiestWeekday;
- final top = by.values.fold(0, (m, v) => v > m ? v : m);
- final today = DateTime.now().weekday;
- final bar = gc.accent;
+ Widget _delta(GymColors gc, int pct) {
+ final up = pct >= 0;
+ final color = up ? gc.sage : gc.accent;
+ return Row(mainAxisSize: MainAxisSize.min, children: [
+ Icon(up ? PhosphorIconsBold.trendUp : PhosphorIconsBold.trendDown, size: 11, color: color),
+ const SizedBox(width: 3),
+ Text('${pct.abs()}%', style: AppTheme.f(11, weight: FontWeight.w700, color: color)),
+ ]);
+ }
- return SoftCard(
- radius: 20,
+ Widget _heroRow(BuildContext context, GymColors gc, int? change, List<double> bw) {
+ final weight = fit.latestBodyweight;
+ return IntrinsicHeight(
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(
+ child: _tile(
+ gc,
+ label: t.tileVolume30,
+ value: fit.volumeValue(fit.volume30dKg),
+ unit: fit.volumeUnit,
+ badge: change == null ? null : _delta(gc, change),
+ chart: fit.sessions.isEmpty
+ ? const SizedBox(height: 40)
+ : Sparkline(values: fit.volumeChartPoints, height: 40, color: gc.textSecondary),
+ ),
+ ),
+ const SizedBox(width: 12),
+ Expanded(
+ child: weight == null
+ ? _tile(gc,
+ label: t.weightLabel,
+ value: '—',
+ note: t.tileAddWeight,
+ onTap: () => _logBodyweight(context))
+ : _tile(
+ gc,
+ label: t.weightLabel,
+ value: fit.weightValue(weight.kg),
+ unit: fit.units,
+ note: t.shortDate(weight.date),
+ chart: bw.length < 2
+ ? const SizedBox(height: 40)
+ : Sparkline(values: bw, height: 40, color: gc.textSecondary),
+ onTap: () => _logBodyweight(context),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _consistency(BuildContext context, GymColors gc) {
+ return Container(
+ padding: const EdgeInsets.fromLTRB(18, 16, 18, 18),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text(t.weekRhythm,
- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- Text(best == 0 ? t.weekRhythmHint : t.weekRhythmBest(t.weekday(best).toLowerCase()),
- style: AppTheme.s(12, color: gc.textSecondary)),
+ Text(t.consistency.toUpperCase(),
+ style: AppTheme.f(10,
+ weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
+ const Spacer(),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => showHeatToneSheet(context),
+ child: Semantics(
+ button: true,
+ label: t.heatToneTitle,
+ child: Row(children: [
+ for (final c in heatRamp(gc, fit.heatTone).skip(1))
+ Container(
+ width: 9,
+ height: 9,
+ margin: const EdgeInsets.only(left: 3),
+ decoration:
+ BoxDecoration(color: c, borderRadius: BorderRadius.circular(3)),
+ ),
+ const SizedBox(width: 7),
+ Icon(PhosphorIconsRegular.caretDown, size: 11, color: gc.textTertiary),
+ ]),
+ ),
+ ),
],
),
- const SizedBox(height: 16),
+ const SizedBox(height: 14),
+ Heatmap(levels: fit.heatmapLevels, onTapDay: (i) => _showDay(context, i)),
+ const SizedBox(height: 14),
+ Row(children: [
+ Icon(PhosphorIconsFill.fire, size: 14, color: gc.accent),
+ const SizedBox(width: 7),
+ Text(t.streakDays(fit.currentStreak),
+ style: AppTheme.f(12.5, weight: FontWeight.w600, color: gc.text)),
+ const Spacer(),
+ Text(t.weekOfGoal(fit.sessionsThisWeek, fit.weeklyTarget),
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary)),
+ ]),
+ ],
+ ),
+ );
+ }
+
+ Widget _totals(GymColors gc) {
+ final hours = fit.totalTime.inHours;
+ final cells = <(String, String, String)>[
+ (t.allTimeSessions, '${fit.totalSessions}', ''),
+ (t.allTimeSets, '${fit.totalSets}', ''),
+ (
+ t.allTimeTime,
+ hours >= 1 ? '$hours' : '${fit.totalTime.inMinutes}',
+ hours >= 1 ? t.unitHours : 'min'
+ ),
+ ];
+ return IntrinsicHeight(
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ for (var i = 0; i < cells.length; i++) ...[
+ Expanded(child: _tile(gc, label: cells[i].$1, value: cells[i].$2, unit: cells[i].$3)),
+ if (i < cells.length - 1) const SizedBox(width: 12),
+ ],
+ ],
+ ),
+ );
+ }
+
+ Widget _thisWeek(GymColors gc) {
+ final start = fit.weekStartDate;
+ final sets = List<int>.filled(7, 0);
+ for (final session in fit.sessions) {
+ final day = DateTime(session.date.year, session.date.month, session.date.day);
+ final i = day.difference(start).inDays;
+ if (i >= 0 && i < 7) sets[i] += session.setCount;
+ }
+ final top = sets.fold(0, (m, v) => v > m ? v : m);
+ final todayIndex = fit.todayIndex;
+
+ return Container(
+ padding: const EdgeInsets.fromLTRB(18, 16, 18, 16),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(children: [
+ Text(t.thisWeekTitle.toUpperCase(),
+ style: AppTheme.f(10,
+ weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
+ const Spacer(),
+ Text(t.setsThisWeek(sets.fold(0, (a, b) => a + b)),
+ style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textSecondary)),
+ ]),
+ const SizedBox(height: 18),
SizedBox(
- height: 96,
+ height: 92,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
- for (int i = 0; i < 7; i++) ...[
- if (i > 0) const SizedBox(width: 8),
+ for (var i = 0; i < 7; i++) ...[
Expanded(
- child: () {
- final w = (t.firstWeekday + i - 1) % 7 + 1;
- final n = by[w] ?? 0;
- final h = top == 0 ? 0.0 : 62 * n / top;
- final on = n == top && n > 0;
- return Column(
- mainAxisAlignment: MainAxisAlignment.end,
- children: [
- Text(n == 0 ? '' : '$n',
- style: AppTheme.d(11,
- weight: FontWeight.w700,
- color: on ? gc.accent : gc.textTertiary)),
- const SizedBox(height: 4),
- Container(
- height: h < 4 ? 4 : h,
- decoration: BoxDecoration(
- color: n == 0
- ? gc.heatEmpty
- : bar.withValues(alpha: on ? 1 : 0.3 + 0.4 * n / top),
- borderRadius: BorderRadius.circular(6),
- ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(sets[i] > 0 ? '${sets[i]}' : '',
+ style: AppTheme.f(11,
+ weight: FontWeight.w700,
+ color: i == todayIndex ? gc.text : gc.textSecondary)),
+ const SizedBox(height: 6),
+ Container(
+ height: top == 0 ? 6 : (8 + 52 * sets[i] / top),
+ decoration: BoxDecoration(
+ color: sets[i] == 0
+ ? gc.bgRaised2
+ : (i == todayIndex ? gc.text : gc.text.withValues(alpha: 0.32)),
+ borderRadius: BorderRadius.circular(7),
),
- const SizedBox(height: 8),
- Text(t.weekdayInitial(w).toUpperCase(),
- style: AppTheme.d(11,
- weight: FontWeight.w600,
- color: w == today ? gc.text : gc.textTertiary)),
- ],
- );
- }(),
+ ),
+ ],
+ ),
),
+ if (i < 6) const SizedBox(width: 8),
],
],
),
),
- if (fit.sessions.isEmpty) ...[
- const SizedBox(height: 12),
- Text(t.weekRhythmEmpty, style: AppTheme.s(13, color: gc.textSecondary)),
- ],
+ const SizedBox(height: 10),
+ Row(
+ children: [
+ for (var i = 0; i < 7; i++) ...[
+ Expanded(
+ child: Text(
+ t.weekdayInitial((t.firstWeekday - 1 + i) % 7 + 1),
+ textAlign: TextAlign.center,
+ style: AppTheme.f(11,
+ weight: i == todayIndex ? FontWeight.w700 : FontWeight.w500,
+ color: i == todayIndex ? gc.text : gc.textTertiary),
+ ),
+ ),
+ if (i < 6) const SizedBox(width: 8),
+ ],
+ ],
+ ),
],
),
);
}
- Widget _allTime(GymColors gc) {
- final time = fit.totalTime;
- final hours = time.inHours;
- final avg = fit.averageSession;
+ List<({String label, bool done, String route})> _steps() => [
+ (label: t.setupWorkout, done: fit.sessions.isNotEmpty, route: 'train'),
+ (label: t.setupWeight, done: fit.bodyweight.isNotEmpty, route: 'weight'),
+ (label: t.setupMeasures, done: fit.measures.isNotEmpty, route: 'measures'),
+ (label: t.setupPhoto, done: fit.shotCount > 0, route: 'timeline'),
+ ];
- Widget cell(String label, String value) => Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(label,
- maxLines: 1,
- style: AppTheme.s(9.5,
- weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 1)),
- const SizedBox(height: 4),
- FittedBox(
- fit: BoxFit.scaleDown,
- alignment: Alignment.centerLeft,
- child: Text(value,
- maxLines: 1,
- style: AppTheme.d(20, weight: FontWeight.w700, color: gc.text)),
+ List<String> get _missing =>
+ [for (final s in _steps()) if (!s.done) s.label];
+
+ void _goStep(BuildContext context, String route) {
+ switch (route) {
+ case 'train':
+ fit.startWorkout();
+ case 'weight':
+ _logBodyweight(context);
+ case 'measures':
+ fit.goMeasures();
+ case 'timeline':
+ fit.goTimeline();
+ }
+ }
+
+ Widget _setupCard(BuildContext context, GymColors gc) {
+ return Container(
+ padding: const EdgeInsets.fromLTRB(18, 16, 18, 8),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: BorderRadius.circular(22),
+ border: Border.all(color: gc.border),
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.setupTitle, style: AppTheme.f(15.5, color: gc.text)),
+ const SizedBox(height: 4),
+ Text(t.setupHint,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary, height: 1.4)),
+ const SizedBox(height: 14),
+ for (final step in _steps())
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: step.done ? null : () => _goStep(context, step.route),
+ child: Padding(
+ padding: const EdgeInsets.only(bottom: 13),
+ child: Row(children: [
+ Icon(
+ step.done ? PhosphorIconsFill.checkCircle : PhosphorIconsRegular.circleDashed,
+ size: 17,
+ color: step.done ? gc.sage : gc.textTertiary,
+ ),
+ const SizedBox(width: 11),
+ Expanded(
+ child: Text(step.label,
+ style: AppTheme.f(13,
+ weight: FontWeight.w500,
+ color: step.done ? gc.textTertiary : gc.text)),
+ ),
+ if (!step.done)
+ Icon(PhosphorIconsBold.caretRight, size: 13, color: gc.textTertiary),
+ ]),
),
- ],
- ),
- );
+ ),
+ ],
+ ),
+ );
+ }
+ List<Widget> _blocks(
+ BuildContext context,
+ GymColors gc,
+ List<double> bw,
+ List<({String name, int pct})> split,
+ List<({String id, String name, double topWeight, double oneRm})> prs,
+ ) {
+ return [
+ if (fit.sessions.isNotEmpty) _thisWeek(gc),
+ if (fit.trackedExercises.isNotEmpty) _StrengthCard(),
+ if (prs.isNotEmpty) _prCard(gc, prs),
+ if (fit.shotCount > 0) _timelineCard(gc),
+ if (fit.measures.isNotEmpty) _measuresCard(gc),
+ ];
+ }
+
+ Widget _prCard(
+ GymColors gc, List<({String id, String name, double topWeight, double oneRm})> prs) {
return SoftCard(
radius: 20,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(t.allTime,
- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- const SizedBox(height: 16),
- Row(children: [
- cell(t.allTimeSessions, '${fit.totalSessions}'),
- cell(t.allTimeTime, hours >= 1 ? t.hoursShort(hours) : '${time.inMinutes} min'),
- ]),
- const SizedBox(height: 16),
- Row(children: [
- cell(t.allTimeVolume, fit.volumeLabel(fit.totalVolumeKg)),
- cell(t.allTimeSets, '${fit.totalSets}'),
- ]),
- if (fit.sessions.isNotEmpty) ...[
- const SizedBox(height: 14),
- Text(t.allTimeAvg('${avg.inMinutes} min'),
- style: AppTheme.s(12.5, color: gc.textSecondary)),
- ],
+ Text(t.personalRecords,
+ style: AppTheme.f(10, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
+ const SizedBox(height: 14),
+ if (prs.isEmpty)
+ Text(t.prEmpty,
+ style: AppTheme.s(13, color: gc.textSecondary))
+ else
+ for (int i = 0; i < prs.length; i++) _prRow(gc, prs[i], i < prs.length - 1),
],
),
);
}
+
Widget _timelineCard(GymColors gc) {
final pair = fit.comparePair;
final last = fit.lastEntry;
@@ -546,7 +636,7 @@ class ProgressScreen extends StatelessWidget {
);
}
- Widget _bwRow(BuildContext context, GymColors gc, BodyweightEntry e) {
+ Widget bwRow(BuildContext context, GymColors gc, BodyweightEntry e) {
return Row(
children: [
Expanded(child: Text(t.shortDateYear(e.date), style: AppTheme.s(12, color: gc.textSecondary))),
@@ -621,7 +711,7 @@ class _MuscleMapCardState extends State<_MuscleMapCard> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(t.muscleMap,
- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
+ style: AppTheme.f(10, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
SegToggle(
[
SegOption(t.days7, _days == 7, () => _setDays(7)),
@@ -709,7 +799,7 @@ class _StrengthCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(t.strength1rm,
- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
+ style: AppTheme.f(10, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
const SizedBox(height: 14),
if (id == null)
Text(t.strengthEmpty,
@@ -761,7 +851,7 @@ class _StrengthCard extends StatelessWidget {
],
),
const SizedBox(height: 12),
- Sparkline(values: series, height: 56, color: up ? gc.sage : gc.accent),
+ Sparkline(values: series, height: 56, color: gc.textSecondary),
const SizedBox(height: 12),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
@@ -805,7 +895,7 @@ class _DaySheet extends StatelessWidget {
),
clipBehavior: Clip.antiAlias,
child: SingleChildScrollView(
- padding: const EdgeInsets.fromLTRB(20, 12, 20, 28),
+ padding: sheetPad(context),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -838,12 +928,28 @@ class _DaySheet extends StatelessWidget {
const SizedBox(height: 6),
],
],
+ if (!fit.isSessionActive && !_isFuture) ...[
+ const SizedBox(height: 14),
+ GhostButton(
+ label: t.logWorkoutAction,
+ icon: PhosphorIconsRegular.plus,
+ onTap: () {
+ Navigator.of(context).pop();
+ showStartSheet(context, day: date);
+ },
+ ),
+ ],
],
),
),
);
}
+ bool get _isFuture {
+ final now = DateTime.now();
+ return date.isAfter(DateTime(now.year, now.month, now.day, 23, 59));
+ }
+
Widget _sessionHeader(BuildContext context, GymColors gc, LoggedSession s) {
return Padding(
padding: const EdgeInsets.only(bottom: 10),
@@ -995,7 +1101,7 @@ class _LogBodyweightSheetState extends State<_LogBodyweightSheet> {
Widget build(BuildContext context) {
final gc = context.gc;
return Container(
- padding: EdgeInsets.fromLTRB(20, 12, 20, 20 + MediaQuery.of(context).viewInsets.bottom),
+ padding: EdgeInsets.fromLTRB(20, 12, 20, 20 + MediaQuery.of(context).viewInsets.bottom + MediaQuery.paddingOf(context).bottom),
decoration: BoxDecoration(
color: gc.bgRaised,
border: Border.all(color: gc.border),
@@ -1186,3 +1292,76 @@ Widget _editSetRow(GymColors gc, LoggedSession s, LoggedExercise e, int i, bool
),
);
}
+
+void showHeatToneSheet(BuildContext context) {
+ showModalBottomSheet<void>(
+ context: context,
+ backgroundColor: Colors.transparent,
+ builder: (_) => const _HeatToneSheet(),
+ );
+}
+
+class _HeatToneSheet extends StatefulWidget {
+ const _HeatToneSheet();
+
+ @override
+ State<_HeatToneSheet> createState() => _HeatToneSheetState();
+}
+
+class _HeatToneSheetState extends State<_HeatToneSheet> {
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return Container(
+ padding: sheetPad(context),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ border: Border.all(color: gc.border),
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SheetHandle(),
+ const SizedBox(height: 16),
+ Text(t.heatToneTitle, style: AppTheme.f(19, color: gc.text)),
+ const SizedBox(height: 8),
+ Text(t.heatToneHint,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary)),
+ const SizedBox(height: 20),
+ for (final tone in kHeatTones)
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => setState(() => fit.setHeatTone(tone)),
+ child: Container(
+ margin: const EdgeInsets.only(bottom: 10),
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
+ decoration: BoxDecoration(
+ color: gc.bgRaised2,
+ borderRadius: BorderRadius.circular(16),
+ border: Border.all(
+ color: fit.heatTone == tone ? gc.text : Colors.transparent, width: 1.4),
+ ),
+ child: Row(children: [
+ for (final c in heatRamp(gc, tone))
+ Container(
+ width: 20,
+ height: 20,
+ margin: const EdgeInsets.only(right: 6),
+ decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(6)),
+ ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(t.heatToneName(tone),
+ style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),
+ ),
+ if (fit.heatTone == tone) Icon(PhosphorIconsBold.check, size: 16, color: gc.text),
+ ]),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/lib/screens/timeline_screen.dart b/lib/screens/timeline_screen.dart
index 06ff406..f4bddbc 100644
--- a/lib/screens/timeline_screen.dart
+++ b/lib/screens/timeline_screen.dart
@@ -3,7 +3,7 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../l10n/l10n.dart';
import '../models/progress_shot.dart';
@@ -105,8 +105,11 @@ class _TimelineScreenState extends State<TimelineScreen> {
_bodyEmpty(gc)
else ...[
Text(t.timelineBodyHint,
- style: AppTheme.s(12.5, color: gc.textTertiary, height: 1.4)),
- const SizedBox(height: 14),
+ style: AppTheme.f(12.5,
+ weight: FontWeight.w500, color: gc.textTertiary, height: 1.4)),
+ const SizedBox(height: 16),
+ _intervalPicker(gc, body: true),
+ const SizedBox(height: 18),
_heatLegend(gc),
const SizedBox(height: 22),
for (int i = 0; i < windows.length; i++)
@@ -120,7 +123,7 @@ class _TimelineScreenState extends State<TimelineScreen> {
: [
if (entries.isEmpty) _empty(gc) else _heroBand(gc),
const SizedBox(height: 20),
- _intervalPicker(gc),
+ _intervalPicker(gc, body: false),
const SizedBox(height: 24),
for (int i = 0; i < entries.length; i++)
_entryRow(gc, entries[i], start,
@@ -445,22 +448,34 @@ class _TimelineScreenState extends State<TimelineScreen> {
);
}
- Widget _intervalPicker(GymColors gc) {
+ Future<void> _askInterval(bool body) async {
+ final days = await askNumber(
+ context,
+ title: body ? t.timelineEvery : t.photoEvery,
+ initial: '${fit.photoIntervalDays > 0 ? fit.photoIntervalDays : 30}',
+ decimal: false,
+ );
+ if (days != null) fit.setPhotoInterval(days.round());
+ }
+
+ Widget _intervalPicker(GymColors gc, {required bool body}) {
final left = fit.daysUntilPhoto;
final due = fit.photoDue;
+ final current = fit.photoIntervalDays;
+ final custom = current > 0 && !kPhotoIntervals.contains(current);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
- child: Text(t.photoEvery,
- style: AppTheme.d(12,
- weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 2)),
+ child: Text(titleCase(body ? t.timelineEvery : t.photoEvery),
+ style: AppTheme.f(10.5,
+ weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3)),
),
- if (left != null)
+ if (!body && left != null)
Text(due ? t.photoDueNow : t.photoNextIn(left),
- style: AppTheme.s(12,
+ style: AppTheme.f(12,
weight: FontWeight.w600, color: due ? gc.accent : gc.textTertiary)),
],
),
@@ -469,45 +484,30 @@ class _TimelineScreenState extends State<TimelineScreen> {
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: gc.bgRaised,
- border: Border.all(color: gc.border),
borderRadius: BorderRadius.circular(100),
),
child: Row(
children: [
for (final days in kPhotoIntervals)
- Expanded(
- child: Semantics(
- button: true,
- selected: fit.photoIntervalDays == days,
- label: t.photoInterval(days),
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
+ if (!body || days > 0)
+ Expanded(
+ child: _intervalTab(
+ gc,
+ label: days <= 0 ? t.photoEveryOff : '$days',
+ semantics: t.photoInterval(days),
+ on: current == days,
onTap: () => fit.setPhotoInterval(days),
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 180),
- height: 36,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: fit.photoIntervalDays == days ? gc.ember : Colors.transparent,
- borderRadius: BorderRadius.circular(100),
- ),
- child: FittedBox(
- fit: BoxFit.scaleDown,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 6),
- child: Text(days <= 0 ? t.photoEveryOff : '$days',
- maxLines: 1,
- style: AppTheme.s(13,
- weight: FontWeight.w600,
- color: fit.photoIntervalDays == days
- ? gc.onEmber
- : gc.textSecondary)),
- ),
- ),
- ),
),
),
+ Expanded(
+ child: _intervalTab(
+ gc,
+ label: custom ? '$current' : t.custom,
+ semantics: t.custom,
+ on: custom,
+ onTap: () => _askInterval(body),
),
+ ),
],
),
),
@@ -515,6 +515,41 @@ class _TimelineScreenState extends State<TimelineScreen> {
);
}
+ Widget _intervalTab(GymColors gc,
+ {required String label,
+ required String semantics,
+ required bool on,
+ required VoidCallback onTap}) {
+ return Semantics(
+ button: true,
+ selected: on,
+ label: semantics,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 180),
+ height: 36,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(
+ color: on ? gc.ember : Colors.transparent,
+ borderRadius: BorderRadius.circular(100),
+ ),
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 6),
+ child: Text(label,
+ maxLines: 1,
+ style: AppTheme.f(13,
+ weight: FontWeight.w600, color: on ? gc.onEmber : gc.textSecondary)),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
Widget _entryRow(GymColors gc, ProgressEntry entry, ProgressEntry? start,
{required bool last, required int gap}) {
final dayNo = start == null ? 1 : daysBetween(start.date, entry.date) + 1;
diff --git a/lib/state/stats_state.dart b/lib/state/stats_state.dart
index 4331e96..e88f018 100644
--- a/lib/state/stats_state.dart
+++ b/lib/state/stats_state.dart
@@ -16,6 +16,8 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
int get athleteLevel => 1 + totalSessions ~/ 10;
+ int get sessionsToNextLevel => 10 - totalSessions % 10;
+
BodyweightEntry? get latestBodyweight =>
bodyweight.isEmpty ? null : bodyweight.reduce((a, b) => a.date.isAfter(b.date) ? a : b);
@@ -34,6 +36,8 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
int get todayIndex => DateTime.now().weekday - 1;
+ DateTime get weekStartDate => _weekStart;
+
DateTime get _weekStart {
final t = _dayKey(DateTime.now());
return shiftDays(t, 1 - t.weekday);
@@ -68,6 +72,21 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
bool get hasData => sessions.isNotEmpty;
int get totalSessions => sessions.length;
+ (String, String) get trainedSpan {
+ final secs = sessions.fold<int>(0, (n, s) => n + s.durationSec);
+ final hours = secs ~/ 3600;
+ if (hours < 48) return ('$hours', t.unitHours);
+ return ('${hours ~/ 24}', t.unitDays);
+ }
+
+ (String, String) liftedSpanOf(double kg) {
+ final shown = toDisplayWeight(kg);
+ if (shown < 1000) return (shown.round().toString(), units);
+ final k = shown / 1000;
+ return (k >= 10 ? k.round().toString() : k.toStringAsFixed(1), units == 'kg' ? 't' : 'k $units');
+ }
+
+ (String, String) get liftedSpan => liftedSpanOf(totalVolumeKg);
int get totalSets => sessions.fold(0, (n, s) => n + s.setCount);
double get totalVolumeKg => sessions.fold(0.0, (a, s) => a + s.volume);
@@ -78,6 +97,33 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
? Duration.zero
: Duration(seconds: totalTime.inSeconds ~/ sessions.length);
+ int get statsYear => DateTime.now().year;
+
+ List<int> get sessionsByMonth {
+ final out = List.filled(12, 0);
+ for (final s in sessions) {
+ if (s.date.year == statsYear) out[s.date.month - 1]++;
+ }
+ return out;
+ }
+
+ double get volumeThisYearKg => sessions
+ .where((s) => s.date.year == statsYear)
+ .fold(0.0, (a, s) => a + s.volume);
+
+ int get sessionsThisYear => sessionsByMonth.fold(0, (a, b) => a + b);
+
+ int get monthsTrainedThisYear => sessionsByMonth.where((n) => n > 0).length;
+
+ int get bestMonthThisYear {
+ final months = sessionsByMonth;
+ var best = 0;
+ for (var i = 1; i < 12; i++) {
+ if (months[i] > months[best]) best = i;
+ }
+ return months[best] == 0 ? 0 : best + 1;
+ }
+
Map<int, int> get sessionsByWeekday {
final out = {for (int w = 1; w <= 7; w++) w: 0};
for (final s in sessions) {
@@ -296,6 +342,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
}
_persist();
_refreshWidgets();
+ refreshAwards();
notifyListeners();
}
@@ -308,10 +355,9 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
return sessions.where((s) => _dayKey(s.date) == t).fold(0, (a, s) => a + s.setCount);
}
- int get goalPct {
- final g = profile.weeklyGoal <= 0 ? 4 : profile.weeklyGoal;
- return ((sessionsThisWeek / g) * 100).round().clamp(0, 100);
- }
+ int get weeklyTarget => profile.weeklyGoal <= 0 ? 4 : profile.weeklyGoal;
+
+ int get goalPct => ((sessionsThisWeek / weeklyTarget) * 100).round().clamp(0, 100);
List<({String id, String name, double topWeight, double oneRm})> get personalRecords {
final best = <String, ({String id, String name, double topWeight, double oneRm})>{};
@@ -542,6 +588,63 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
return h.map((r) => _round1(r.ex.bestOneRm)).toList();
}
+ static const _habitWindowDays = 120;
+
+ Iterable<LoggedSession> get _recentSessions {
+ final now = DateTime.now();
+ return sessions.where((s) => now.difference(s.date).inDays <= _habitWindowDays);
+ }
+
+ Map<int, int> get _recentByWeekday {
+ final out = <int, int>{};
+ for (final s in _recentSessions) {
+ out[s.date.weekday] = (out[s.date.weekday] ?? 0) + 1;
+ }
+ return out;
+ }
+
+ List<int> get usualWeekdays {
+ final counts = _recentByWeekday;
+ if (counts.isEmpty) return const [];
+ final best = counts.values.reduce(math.max);
+ if (best < 2) return const [];
+ final cut = (best * 0.6).ceil();
+ final days = counts.entries.where((e) => e.value >= cut).map((e) => e.key).toList()..sort();
+ return days.length > 6 ? days.sublist(0, 6) : days;
+ }
+
+ int? get usualStartMinute {
+ final starts = <int>[];
+ for (final s in _recentSessions) {
+ final start = s.date.subtract(Duration(seconds: s.durationSec));
+ starts.add(start.hour * 60 + start.minute);
+ }
+ if (starts.length < 3) return null;
+ starts.sort();
+ return (starts[starts.length ~/ 2] ~/ 15) * 15;
+ }
+
+ bool get hasTrainingHabit => usualWeekdays.isNotEmpty && usualStartMinute != null;
+
+ String? familyOnWeekday(int weekday) {
+ final onDay = _recentSessions.where((s) => s.date.weekday == weekday).toList();
+ if (onDay.length < 2) return null;
+ final volume = <String, double>{};
+ for (final s in onDay) {
+ for (final e in s.exercises) {
+ final f = muscleFamily(e.primary);
+ volume[f] = (volume[f] ?? 0) + e.volume;
+ }
+ }
+ if (volume.isEmpty) return null;
+ return volume.entries.reduce((a, b) => a.value >= b.value ? a : b).key;
+ }
+
+ bool get trainedToday {
+ final today = _dayKey(DateTime.now());
+ return sessions.any((s) => _dayKey(s.date) == today);
+ }
+
({String title, String subtitle, List<String> muscles}) get suggestedFocus {
final table = {
'push': (title: t.pushDay, subtitle: t.pushFocus, muscles: ['chest', 'shoulders', 'triceps']),
@@ -549,8 +652,10 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
'legs': (title: t.legDay, subtitle: t.legFocus, muscles: ['quads', 'hamstrings', 'glutes']),
};
var last = '';
+ var lastWasRecent = false;
if (sessions.isNotEmpty) {
final s = sessions.reduce((a, b) => a.date.isAfter(b.date) ? a : b);
+ lastWasRecent = daysBetween(s.date, DateTime.now()) <= 1;
final fam = <String, double>{};
for (final e in s.exercises) {
final f = muscleFamily(e.primary);
@@ -561,9 +666,19 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
}
}
const order = ['push', 'pull', 'legs'];
+ final today = DateTime.now().weekday;
+ final habit = familyOnWeekday(today);
+ if (habit != null && order.contains(habit) && !(lastWasRecent && habit == last)) {
+ final picked = table[habit]!;
+ return (
+ title: picked.title,
+ subtitle: t.habitFocus(t.weekday(today)),
+ muscles: picked.muscles,
+ );
+ }
final idx = order.indexOf(last);
- final next = idx >= 0 ? order[(idx + 1) % order.length] : order[DateTime.now().weekday % 3];
+ final next = idx >= 0 ? order[(idx + 1) % order.length] : order[today % 3];
return table[next]!;
}
}
diff --git a/lib/state/timeline_state.dart b/lib/state/timeline_state.dart
index 3e07257..54f4b97 100644
--- a/lib/state/timeline_state.dart
+++ b/lib/state/timeline_state.dart
@@ -156,7 +156,7 @@ mixin TimelineState on FitCore {
}
void setPhotoInterval(int days) {
- photoIntervalDays = kPhotoIntervals.contains(days) ? days : 30;
+ photoIntervalDays = days <= 0 ? 0 : days.clamp(1, 365);
_syncPhotoReminder();
_persist();
notifyListeners();
diff --git a/lib/widgets/body_map.dart b/lib/widgets/body_map.dart
index fb72763..e8456c4 100644
--- a/lib/widgets/body_map.dart
+++ b/lib/widgets/body_map.dart
@@ -20,23 +20,30 @@ String? muscleAt(Offset p) {
Color idleMuscle(GymColors gc) => Color.lerp(gc.bgRaised2, gc.textSecondary, 0.32)!;
-const List<Color> _heatDark = [
- Color(0xFF7A4028),
- Color(0xFFB4632C),
- Color(0xFFE38B3A),
- Color(0xFFFFC168),
-];
-
-const List<Color> _heatLight = [
- Color(0xFFD9B48A),
- Color(0xFFC07A3C),
- Color(0xFF9E4A24),
- Color(0xFF6E2A16),
-];
-
-Color heatLevelColor(GymColors gc, int level) {
+const Map<String, List<Color>> kHeatRampsDark = {
+ 'ember': [Color(0xFF7A4028), Color(0xFFB4632C), Color(0xFFE38B3A), Color(0xFFFFC168)],
+ 'green': [Color(0xFF1B4B2C), Color(0xFF2C7A44), Color(0xFF3FA95C), Color(0xFF63D67F)],
+ 'blue': [Color(0xFF1E3A5C), Color(0xFF2C5E96), Color(0xFF3D86C9), Color(0xFF6EB4F0)],
+ 'mono': [Color(0xFF3A3A3A), Color(0xFF5E5E5E), Color(0xFF8C8C8C), Color(0xFFD8D8D8)],
+};
+
+const Map<String, List<Color>> kHeatRampsLight = {
+ 'ember': [Color(0xFFD9B48A), Color(0xFFC07A3C), Color(0xFF9E4A24), Color(0xFF6E2A16)],
+ 'green': [Color(0xFFBBD9BE), Color(0xFF7FB88A), Color(0xFF488C58), Color(0xFF255E32)],
+ 'blue': [Color(0xFFBACFE8), Color(0xFF7EA5D2), Color(0xFF3F74AE), Color(0xFF1F4876)],
+ 'mono': [Color(0xFFCFC8BC), Color(0xFF9C958A), Color(0xFF6B655C), Color(0xFF3A352F)],
+};
+
+const List<String> kHeatTones = ['ember', 'green', 'blue', 'mono'];
+
+List<Color> heatRamp(GymColors gc, String tone) {
+ final table = gc.bg.computeLuminance() < 0.5 ? kHeatRampsDark : kHeatRampsLight;
+ return table[tone] ?? table['ember']!;
+}
+
+Color heatLevelColor(GymColors gc, int level, {String? tone}) {
if (level <= 0) return idleMuscle(gc);
- final ramp = gc.bg.computeLuminance() < 0.5 ? _heatDark : _heatLight;
+ final ramp = heatRamp(gc, tone ?? fit.heatTone);
return ramp[(level - 1).clamp(0, heatLevels - 1)];
}
diff --git a/lib/widgets/charts.dart b/lib/widgets/charts.dart
index e9adb06..5a71bc2 100644
--- a/lib/widgets/charts.dart
+++ b/lib/widgets/charts.dart
@@ -225,12 +225,18 @@ class _SparkPainter extends CustomPainter {
}
class Heatmap extends StatelessWidget {
- const Heatmap({super.key, required this.levels, this.onTapDay});
+ const Heatmap({super.key, required this.levels, this.onTapDay, this.mono = false});
final List<int> levels;
final void Function(int index)? onTapDay;
+ final bool mono;
- Color _color(int level, GymColors gc) =>
- level <= 0 ? gc.heatEmpty : heatLevelColor(gc, level);
+ static const _monoAlpha = [0.0, 0.30, 0.46, 0.64, 0.82, 1.0];
+
+ Color _color(int level, GymColors gc) {
+ if (level <= 0) return gc.heatEmpty;
+ if (!mono) return heatLevelColor(gc, level);
+ return gc.text.withValues(alpha: _monoAlpha[level.clamp(1, _monoAlpha.length - 1)]);
+ }
@override
Widget build(BuildContext context) {