Skip to content

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

Rework the progress screen, and let you edit a workout you already saved

InlitXc95f5afcf8fd
diff --git a/lib/screens/progress_screen.dart b/lib/screens/progress_screen.dart
index 8b74683..a1f97c8 100644
--- a/lib/screens/progress_screen.dart
+++ b/lib/screens/progress_screen.dart
@@ -1,8 +1,12 @@
+import 'dart:io';
+
import 'package:flutter/material.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import '../l10n/l10n.dart';
+import '../models/progress_shot.dart';
import '../models/workout.dart';
+import '../services/media_store.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
@@ -10,6 +14,7 @@ import '../widgets/body_map.dart';
import '../widgets/charts.dart';
import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
+import 'share_sheet.dart';
class ProgressScreen extends StatelessWidget {
const ProgressScreen({super.key});
@@ -29,7 +34,28 @@ class ProgressScreen extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- ScreenTitle(t.progress),
+ Row(
+ children: [
+ Expanded(child: ScreenTitle(t.progress)),
+ Semantics(
+ button: true,
+ label: t.share,
+ child: GestureDetector(
+ onTap: () => showShareSheet(context),
+ child: Container(
+ width: 38,
+ height: 38,
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ shape: BoxShape.circle,
+ border: Border.all(color: gc.border),
+ ),
+ child: Icon(PhosphorIconsRegular.shareNetwork, size: 17, color: gc.text),
+ ),
+ ),
+ ),
+ ],
+ ),
const SizedBox(height: 22),
SoftCard(
radius: 24,
@@ -71,8 +97,16 @@ class ProgressScreen extends StatelessWidget {
),
],
),
+ 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),
+ VolumeChart(
+ points: fit.volumeChartPoints,
+ label: fit.volumeValue,
+ unit: fit.volumeUnit,
+ xLabels: ['-30 d', '-15 d', t.noteToday.toLowerCase()],
+ ),
],
),
),
@@ -104,6 +138,8 @@ class ProgressScreen extends StatelessWidget {
),
),
const SizedBox(height: 22),
+ _weekRhythm(gc),
+ const SizedBox(height: 22),
SoftCard(
radius: 20,
child: Column(
@@ -158,6 +194,10 @@ class ProgressScreen extends StatelessWidget {
),
),
const SizedBox(height: 22),
+ _timelineCard(gc),
+ const SizedBox(height: 22),
+ _measuresCard(gc),
+ const SizedBox(height: 22),
_StrengthCard(),
const SizedBox(height: 22),
const _MuscleMapCard(),
@@ -195,13 +235,293 @@ class ProgressScreen extends StatelessWidget {
],
),
),
+ const SizedBox(height: 22),
+ _allTime(gc),
],
),
),
);
}
- Widget _prRow(GymColors gc, ({String name, double topWeight, double oneRm}) pr, bool border) {
+ 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;
+
+ return SoftCard(
+ radius: 20,
+ 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)),
+ ],
+ ),
+ const SizedBox(height: 16),
+ SizedBox(
+ height: 96,
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ for (int i = 0; i < 7; i++) ...[
+ if (i > 0) const SizedBox(width: 8),
+ 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),
+ ),
+ ),
+ const SizedBox(height: 8),
+ Text(t.weekdayInitial(w).toUpperCase(),
+ style: AppTheme.d(11,
+ weight: FontWeight.w600,
+ color: w == today ? gc.text : gc.textTertiary)),
+ ],
+ );
+ }(),
+ ),
+ ],
+ ],
+ ),
+ ),
+ if (fit.sessions.isEmpty) ...[
+ const SizedBox(height: 12),
+ Text(t.weekRhythmEmpty, style: AppTheme.s(13, color: gc.textSecondary)),
+ ],
+ ],
+ ),
+ );
+ }
+
+ Widget _allTime(GymColors gc) {
+ final time = fit.totalTime;
+ final hours = time.inHours;
+ final avg = fit.averageSession;
+
+ 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)),
+ ),
+ ],
+ ),
+ );
+
+ 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)),
+ ],
+ ],
+ ),
+ );
+ }
+
+ Widget _timelineCard(GymColors gc) {
+ final pair = fit.comparePair;
+ final last = fit.lastEntry;
+ final left = fit.daysUntilPhoto;
+
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.goTimeline,
+ child: SoftCard(
+ radius: 20,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: Text(t.timeline,
+ style: AppTheme.d(14,
+ weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
+ ),
+ if (last != null && left != null)
+ Text(fit.photoDue ? t.photoDueNow : t.photoNextIn(left),
+ style: AppTheme.s(11.5,
+ weight: FontWeight.w600,
+ color: fit.photoDue ? gc.accent : gc.textTertiary)),
+ const SizedBox(width: 8),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ],
+ ),
+ const SizedBox(height: 14),
+ if (last == null)
+ Text(t.timelineHint, style: AppTheme.s(13, color: gc.textSecondary, height: 1.5))
+ else
+ Row(
+ children: [
+ if (pair != null) ...[
+ Expanded(child: _shotThumb(gc, pair.from)),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: Icon(PhosphorIconsBold.arrowRight, size: 14, color: gc.accent),
+ ),
+ Expanded(child: _shotThumb(gc, pair.to)),
+ const SizedBox(width: 14),
+ Expanded(
+ flex: 2,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.daysApart(fit.compareDays),
+ style: AppTheme.d(15, weight: FontWeight.w700, color: gc.text)),
+ const SizedBox(height: 2),
+ Text(t.photoCount(fit.shotCount),
+ style: AppTheme.s(12, color: gc.textSecondary)),
+ ],
+ ),
+ ),
+ ] else ...[
+ Expanded(child: _shotThumb(gc, last)),
+ const SizedBox(width: 14),
+ Expanded(
+ flex: 3,
+ child: Text(t.compareNeedTwo,
+ style: AppTheme.s(12.5, color: gc.textSecondary, height: 1.45)),
+ ),
+ ],
+ ],
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _shotThumb(GymColors gc, ProgressEntry entry) {
+ final name = entry.media.isEmpty ? null : entry.media.first;
+ final path = name == null ? null : MediaStore.pathFor(name);
+ return AspectRatio(
+ aspectRatio: 0.78,
+ child: Container(
+ decoration: BoxDecoration(
+ color: gc.bgRaised2,
+ borderRadius: BorderRadius.circular(12),
+ border: Border.all(color: gc.border),
+ ),
+ clipBehavior: Clip.antiAlias,
+ child: path == null
+ ? Icon(PhosphorIconsRegular.imageSquare, size: 16, color: gc.textTertiary)
+ : Image.file(File(path), fit: BoxFit.cover, gaplessPlayback: true,
+ errorBuilder: (_, _, _) =>
+ Icon(PhosphorIconsRegular.imageSquare, size: 16, color: gc.textTertiary)),
+ ),
+ );
+ }
+
+ Widget _measuresCard(GymColors gc) {
+ final tracked = fit.trackedMeasures;
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.goMeasures,
+ child: SoftCard(
+ radius: 20,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: Text(t.measures,
+ style: AppTheme.d(14,
+ weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
+ ),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ],
+ ),
+ const SizedBox(height: 12),
+ if (tracked.isEmpty)
+ Text(t.measuresHint, style: AppTheme.s(13, color: gc.textSecondary, height: 1.5))
+ else
+ Wrap(
+ spacing: 10,
+ runSpacing: 10,
+ children: [
+ for (final key in tracked.take(6)) _measureChip(gc, key),
+ ],
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _measureChip(GymColors gc, String key) {
+ final latest = fit.latestMeasure(key)!;
+ return Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 9),
+ decoration: BoxDecoration(
+ color: gc.bgRaised2,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.measureName(key),
+ style: AppTheme.s(10.5, weight: FontWeight.w600, color: gc.textTertiary)),
+ const SizedBox(height: 3),
+ Text(fit.measureLabel(key, latest.value),
+ style: AppTheme.d(15, weight: FontWeight.w700, color: gc.text)),
+ ],
+ ),
+ );
+ }
+
+ Widget _prRow(GymColors gc, ({String id, String name, double topWeight, double oneRm}) pr, bool border) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
@@ -210,7 +530,9 @@ class ProgressScreen extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Expanded(child: Text(pr.name, style: AppTheme.s(14, weight: FontWeight.w500, color: gc.text))),
+ Expanded(
+ child: Text(t.catalogName(pr.id, pr.name),
+ style: AppTheme.s(14, weight: FontWeight.w500, color: gc.text))),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
@@ -445,7 +767,7 @@ class _StrengthCard extends StatelessWidget {
child: Row(children: [
for (final e in tracked.take(8)) ...[
Pill(
- label: e.name,
+ label: t.catalogName(e.id, e.name),
bg: e.id == id ? gc.ember : gc.bgRaised2,
fg: e.id == id ? gc.onEmber : gc.textSecondary,
onTap: () => fit.setStrengthExercise(e.id),
@@ -475,51 +797,117 @@ class _DaySheet extends StatelessWidget {
final gc = context.gc;
final s = fit.daySummary(date);
return Container(
- padding: const EdgeInsets.fromLTRB(20, 12, 20, 28),
decoration: BoxDecoration(
color: gc.bgRaised,
border: Border.all(color: gc.border),
borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Center(
- child: Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
+ clipBehavior: Clip.antiAlias,
+ child: SingleChildScrollView(
+ padding: const EdgeInsets.fromLTRB(20, 12, 20, 28),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Center(
+ child: Container(
+ width: 40,
+ height: 4,
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
+ ),
),
- ),
- const SizedBox(height: 18),
- Text(t.longDate(date),
- style: AppTheme.d(20, weight: FontWeight.w700, color: gc.text)),
- const SizedBox(height: 14),
- if (s == null)
- Text(t.restDay, style: AppTheme.s(14, color: gc.textSecondary))
- else ...[
- Row(children: [
- Expanded(child: _stat(gc, t.exercisesCaps, '${s.exercises}')),
- const SizedBox(width: 10),
- Expanded(child: _stat(gc, t.setsCaps, '${s.sets}')),
- const SizedBox(width: 10),
- Expanded(child: _stat(gc, t.volume, fit.volumeLabel(s.volume))),
- if (s.durationSec > 0) ...[
+ const SizedBox(height: 18),
+ Text(t.longDate(date),
+ style: AppTheme.d(20, weight: FontWeight.w700, color: gc.text)),
+ const SizedBox(height: 14),
+ if (s == null)
+ Text(t.restDay, style: AppTheme.s(14, color: gc.textSecondary))
+ else ...[
+ Row(children: [
+ Expanded(child: _stat(gc, t.exercisesCaps, '${s.exercises}')),
+ const SizedBox(width: 10),
+ Expanded(child: _stat(gc, t.setsCaps, '${s.sets}')),
const SizedBox(width: 10),
- Expanded(child: _stat(gc, t.timeCaps, '${s.durationSec ~/ 60}m')),
+ Expanded(child: _stat(gc, t.volume, fit.volumeLabel(s.volume))),
+ if (s.durationSec > 0) ...[
+ const SizedBox(width: 10),
+ Expanded(child: _stat(gc, t.timeCaps, '${s.durationSec ~/ 60}m')),
+ ],
+ ]),
+ const SizedBox(height: 16),
+ Text(t.tapToEdit, style: AppTheme.s(11, color: gc.textTertiary)),
+ const SizedBox(height: 10),
+ for (final logged in fit.sessionsOn(date)) ...[
+ _sessionHeader(context, gc, logged),
+ for (final ex in [...logged.exercises]) _loggedRow(context, gc, logged, ex),
+ const SizedBox(height: 6),
],
- ]),
- const SizedBox(height: 16),
- Text(t.tapToDelete, style: AppTheme.s(11, color: gc.textTertiary)),
- const SizedBox(height: 8),
- for (final logged in fit.sessionsOn(date))
- for (final ex in [...logged.exercises])
- _loggedRow(context, gc, logged, ex),
+ ],
],
+ ),
+ ),
+ );
+ }
+
+ Widget _sessionHeader(BuildContext context, GymColors gc, LoggedSession s) {
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 10),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ '${t.setCount(s.setCount)} · ${fit.volumeLabel(s.volume)}',
+ style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 1),
+ ),
+ ),
+ if (!fit.isSessionActive)
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _confirmResume(context, s),
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 7),
+ decoration: BoxDecoration(
+ color: gc.emberSoft,
+ borderRadius: BorderRadius.circular(100),
+ ),
+ child: Row(mainAxisSize: MainAxisSize.min, children: [
+ Icon(PhosphorIconsFill.play, size: 11, color: gc.ember),
+ const SizedBox(width: 6),
+ Text(t.continueWorkout,
+ style: AppTheme.d(11, weight: FontWeight.w700, color: gc.ember, letterSpacing: 1)),
+ ]),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Future<void> _confirmResume(BuildContext context, LoggedSession s) async {
+ final gc = context.gc;
+ final ok = await showDialog<bool>(
+ context: context,
+ builder: (dctx) => AlertDialog(
+ backgroundColor: gc.bgRaised,
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
+ title: Text(t.continueWorkout, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
+ content: Text(t.continueWorkoutBody, style: AppTheme.s(13, color: gc.textSecondary)),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.of(dctx).pop(false),
+ child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
+ ),
+ TextButton(
+ onPressed: () => Navigator.of(dctx).pop(true),
+ child: Text(t.continueWorkout,
+ style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
+ ),
],
),
);
+ if (ok != true || !context.mounted) return;
+ Navigator.of(context).pop();
+ fit.resumeLoggedSession(s);
}
Widget _loggedRow(BuildContext context, GymColors gc, LoggedSession s, LoggedExercise e) {
@@ -542,7 +930,7 @@ class _DaySheet extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(e.name, style: AppTheme.s(13, weight: FontWeight.w600, color: gc.text)),
+ Text(t.catalogName(e.id, e.name), style: AppTheme.s(13, weight: FontWeight.w600, color: gc.text)),
const SizedBox(height: 2),
Text(detail, style: AppTheme.s(11, color: gc.textSecondary)),
],
@@ -550,12 +938,25 @@ class _DaySheet extends StatelessWidget {
),
Semantics(
button: true,
- label: '${t.deleteCaps} ${e.name}',
+ label: '${t.editEntry} ${t.catalogName(e.id, e.name)}',
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => showEditLoggedSheet(context, s, e),
+ child: SizedBox(
+ width: 40,
+ height: 44,
+ child: Icon(PhosphorIconsRegular.pencilSimple, size: 16, color: gc.textTertiary),
+ ),
+ ),
+ ),
+ Semantics(
+ button: true,
+ label: '${t.deleteCaps} ${t.catalogName(e.id, e.name)}',
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _confirmDelete(context, s, e),
child: SizedBox(
- width: 44,
+ width: 40,
height: 44,
child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.textTertiary),
),
@@ -574,7 +975,7 @@ class _DaySheet extends StatelessWidget {
backgroundColor: gc.bgRaised,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
title: Text(t.deleteEntry, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.deleteEntryBody(e.name), style: AppTheme.s(13, color: gc.textSecondary)),
+ content: Text(t.deleteEntryBody(t.catalogName(e.id, e.name)), style: AppTheme.s(13, color: gc.textSecondary)),
actions: [
TextButton(
onPressed: () => Navigator.of(dctx).pop(false),
@@ -689,3 +1090,144 @@ class _LogBodyweightSheetState extends State<_LogBodyweightSheet> {
);
}
}
+
+void showEditLoggedSheet(BuildContext context, LoggedSession s, LoggedExercise e) {
+ final gc = context.gc;
+ showModalBottomSheet<void>(
+ context: context,
+ isScrollControlled: true,
+ backgroundColor: Colors.transparent,
+ builder: (sheetCtx) => AnimatedBuilder(
+ animation: fit,
+ builder: (sheetCtx, _) {
+ if (!s.exercises.contains(e)) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (sheetCtx.mounted) Navigator.of(sheetCtx).pop();
+ });
+ }
+ final repsOnly = fit.isRepsOnly(e.id);
+ return Container(
+ padding: EdgeInsets.only(bottom: MediaQuery.of(sheetCtx).viewInsets.bottom),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ border: Border.all(color: gc.border),
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ child: SafeArea(
+ child: SingleChildScrollView(
+ padding: const EdgeInsets.fromLTRB(20, 12, 20, 24),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Center(
+ child: Container(
+ width: 40,
+ height: 4,
+ decoration:
+ BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
+ ),
+ ),
+ const SizedBox(height: 18),
+ Text(t.catalogName(e.id, e.name), style: AppTheme.d(20, weight: FontWeight.w700, color: gc.text)),
+ const SizedBox(height: 4),
+ Text(t.editEntryHint, style: AppTheme.s(12, color: gc.textSecondary)),
+ const SizedBox(height: 16),
+ for (int i = 0; i < e.sets.length; i++) ...[
+ _editSetRow(gc, s, e, i, repsOnly),
+ const SizedBox(height: 8),
+ ],
+ const SizedBox(height: 4),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.addLoggedSet(e),
+ child: Container(
+ height: 44,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(
+ border: Border.all(color: gc.border),
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Text(t.addSet,
+ style: AppTheme.s(13,
+ weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1)),
+ ),
+ ),
+ const SizedBox(height: 16),
+ PrimaryButton(label: t.done, onTap: () => Navigator.pop(sheetCtx), height: 52),
+ ],
+ ),
+ ),
+ ),
+ );
+ },
+ ),
+ );
+}
+
+Widget _editSetRow(GymColors gc, LoggedSession s, LoggedExercise e, int i, bool repsOnly) {
+ final set = e.sets[i];
+ return Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(14)),
+ child: Row(
+ children: [
+ SizedBox(
+ width: 22,
+ child: Text('${i + 1}', style: AppTheme.d(15, weight: FontWeight.w700, color: gc.text)),
+ ),
+ Expanded(
+ child: Column(
+ children: [
+ Text(t.repsCol,
+ style: AppTheme.s(9.5, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 1)),
+ const SizedBox(height: 2),
+ StepperControl(
+ value: '${set.reps}',
+ onDec: () => fit.bumpLoggedReps(e, i, -1),
+ onInc: () => fit.bumpLoggedReps(e, i, 1),
+ minWidth: 30,
+ btnSize: 26,
+ gap: 8,
+ fontSize: 14,
+ ),
+ ],
+ ),
+ ),
+ if (!repsOnly)
+ Expanded(
+ child: Column(
+ children: [
+ Text(t.weightCol(fit.units.toUpperCase()),
+ style:
+ AppTheme.s(9.5, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 1)),
+ const SizedBox(height: 2),
+ StepperControl(
+ value: fit.weightValue(set.weight),
+ onDec: () => fit.bumpLoggedWeight(e, i, -1),
+ onInc: () => fit.bumpLoggedWeight(e, i, 1),
+ minWidth: 34,
+ btnSize: 26,
+ gap: 8,
+ fontSize: 14,
+ ),
+ ],
+ ),
+ ),
+ Semantics(
+ button: true,
+ label: t.removeSet,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.removeLoggedSet(s, e, i),
+ child: SizedBox(
+ width: 36,
+ height: 40,
+ child: Icon(PhosphorIconsRegular.x, size: 14, color: gc.textTertiary),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+}
diff --git a/lib/widgets/charts.dart b/lib/widgets/charts.dart
index 3aa59ae..e9adb06 100644
--- a/lib/widgets/charts.dart
+++ b/lib/widgets/charts.dart
@@ -3,6 +3,8 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import 'body_map.dart';
import 'svg_icon.dart';
class GoalRing extends StatelessWidget {
@@ -44,44 +46,98 @@ class _RingPainter extends CustomPainter {
}
class VolumeChart extends StatelessWidget {
- const VolumeChart({super.key, required this.points, this.height = 100});
+ const VolumeChart({
+ super.key,
+ required this.points,
+ required this.label,
+ this.unit = '',
+ this.xLabels = const [],
+ this.height = 116,
+ });
+
final List<double> points;
+ final String Function(double value) label;
+ final String unit;
+ final List<String> xLabels;
final double height;
+
+ static const double _pad = 7;
+
@override
Widget build(BuildContext context) {
final gc = context.gc;
- return SizedBox(
- height: height,
- width: double.infinity,
- child: CustomPaint(painter: _VolumePainter(gc, points)),
+ final top = points.isEmpty ? 0.0 : points.reduce(math.max);
+ final style = AppTheme.d(10, weight: FontWeight.w600, color: gc.textTertiary);
+
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ SizedBox(
+ height: height,
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ SizedBox(
+ width: 34,
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ for (final f in [1.0, 0.5, 0.0])
+ FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.centerLeft,
+ child: Text(f == 1 ? '${label(top)} $unit'.trim() : label(top * f),
+ maxLines: 1, style: style),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(width: 6),
+ Expanded(child: CustomPaint(painter: _VolumePainter(gc, points, _pad))),
+ ],
+ ),
+ ),
+ if (xLabels.isNotEmpty) ...[
+ const SizedBox(height: 6),
+ Padding(
+ padding: const EdgeInsets.only(left: 40),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [for (final x in xLabels) Text(x, style: style)],
+ ),
+ ),
+ ],
+ ],
);
}
}
class _VolumePainter extends CustomPainter {
- _VolumePainter(this.gc, this.points);
+ _VolumePainter(this.gc, this.points, this.pad);
final GymColors gc;
final List<double> points;
+ final double pad;
@override
void paint(Canvas canvas, Size size) {
- final sy = size.height / 100;
- final grid = Paint()..color = gc.border..strokeWidth = 1;
- for (final y in [20.0, 50.0, 80.0]) {
- canvas.drawLine(Offset(0, y * sy), Offset(size.width, y * sy), grid);
+ final top = pad, bottom = size.height - pad;
+ final grid = Paint()
+ ..color = gc.border
+ ..strokeWidth = 1;
+ for (final f in [0.0, 0.5, 1.0]) {
+ final y = bottom - (bottom - top) * f;
+ canvas.drawLine(Offset(0, y), Offset(size.width, y), grid);
}
if (points.length < 2) return;
final maxV = points.reduce(math.max);
-
if (maxV <= 0) return;
- Offset m(int i) {
- final x = size.width * i / (points.length - 1);
- final norm = points[i] / maxV;
- final y = size.height * (0.9 - norm * 0.8);
- return Offset(x, y);
- }
+ Offset m(int i) => Offset(
+ size.width * i / (points.length - 1),
+ bottom - (bottom - top) * (points[i] / maxV),
+ );
final line = Path()..moveTo(m(0).dx, m(0).dy);
for (var i = 1; i < points.length; i++) {
@@ -173,18 +229,8 @@ class Heatmap extends StatelessWidget {
final List<int> levels;
final void Function(int index)? onTapDay;
- Color _color(int level, GymColors gc) {
- switch (level) {
- case 3:
- return gc.accent;
- case 2:
- return gc.brass;
- case 1:
- return gc.mutedFill;
- default:
- return gc.heatEmpty;
- }
- }
+ Color _color(int level, GymColors gc) =>
+ level <= 0 ? gc.heatEmpty : heatLevelColor(gc, level);
@override
Widget build(BuildContext context) {