Skip to content

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

RPE load and DOTS calculatorsols

InlitX9b49898a8cd8
diff --git a/lib/catalog/exercise_catalog.dart b/lib/catalog/exercise_catalog.dart
index ce107ac..c343b8e 100644
--- a/lib/catalog/exercise_catalog.dart
+++ b/lib/catalog/exercise_catalog.dart
@@ -7160,6 +7160,8 @@ const List<ToolMeta> kToolMeta = [
ToolMeta('bf', 'Body Fat', 'Body fat percentage'),
ToolMeta('plate', 'Plates', 'Barbell plate calculator'),
ToolMeta('warmup', 'Warm-up', 'Ramp-up sets'),
+ ToolMeta('rpe', 'RPE load', 'Weight for a target effort'),
+ ToolMeta('dots', 'Strength level', 'DOTS score'),
];
const List<String> kFilterMuscles = [
@@ -7194,6 +7196,15 @@ const List<String> kWarmupIds = [
'yuris-shoulder-band-warmup', 'wrist-prep',
];
+const Set<String> kStretchIds = {
+ 'cat-cow-stretch', 'worlds-greatest-stretch', 'leg-swings-stretch', 'childs-pose', 'doorway-chest-stretch',
+ 'cross-body-shoulder-stretch', 'standing-quad-stretch', 'kneeling-hip-flexor-stretch', 'butterfly-stretch',
+ 'wall-calf-stretch', 'LNE3wfo', 'hamstring-stretch', 'seated-forward-fold-stretch',
+ 'yuris-shoulder-band-warmup', 'wrist-prep',
+};
+
+const Set<String> kCalisthenicsEquipment = {'Bodyweight', 'Rings', 'Weighted'};
+
const Set<String> kCardioExtras = {
'jump-rope', 'battle-ropes', 'burpee', 'half-burpee', 'mountain-climber', 'high-knees', 'jumping-jack',
'skater-hop', 'squat-thrust', 'sprawl', 'lateral-shuffle', 'plank-jack',
diff --git a/lib/screens/tool_detail_screen.dart b/lib/screens/tool_detail_screen.dart
index a825a9a..5a91e78 100644
--- a/lib/screens/tool_detail_screen.dart
+++ b/lib/screens/tool_detail_screen.dart
@@ -95,6 +95,11 @@ class ToolDetailScreen extends StatelessWidget {
return (t.toolTitle('plate'), '${fit.weightValue(fit.plateTarget)} ${fit.units}', t.toolResultHint('plate'));
case 'warmup':
return (t.toolTitle('warmup'), '${fit.weightValue(fit.warmupTarget)} ${fit.units}', t.toolResultHint('warmup'));
+ case 'rpe':
+ return (t.toolTitle('rpe'), '${fit.weightValue(fit.rpeResult)} ${fit.units}',
+ t.rpeResultHint(fit.rpeTargetReps, fmt(fit.rpeTargetRpe)));
+ case 'dots':
+ return (t.toolTitle('dots'), fmt(fit.dotsScore), t.dotsLevelName(fit.dotsLevel));
default:
return ('', '', '');
}
@@ -162,11 +167,60 @@ class ToolDetailScreen extends StatelessWidget {
const SizedBox(height: 10),
_warmupCard(gc),
];
+ case 'rpe':
+ final step = fit.fromDisplayWeight(fit.weightStep);
+ return [
+ _sectionLabel(gc, t.rpeYourSet),
+ ToolRow(label: t.weightLifted, control: StepperControl(value: '${fit.weightValue(fit.rpeWeight)} ${fit.units}', onDec: () => fit.bumpRpeWeight(-step), onInc: () => fit.bumpRpeWeight(step), onEdit: () => _editNumber(context, title: t.weightLifted, current: fit.toDisplayWeight(fit.rpeWeight), decimal: true, apply: (v) => fit.bumpRpeWeight(fit.fromDisplayWeight(v) - fit.rpeWeight)))),
+ ToolRow(label: t.repsPerformed, control: StepperControl(value: '${fit.rpeReps}', minWidth: 40, onDec: () => fit.bumpRpeReps(-1), onInc: () => fit.bumpRpeReps(1))),
+ ToolRow(label: t.rpeEffortLabel, control: StepperControl(value: fmt(fit.rpeRpe), minWidth: 40, onDec: () => fit.bumpRpe(-0.5), onInc: () => fit.bumpRpe(0.5))),
+ _sectionLabel(gc, t.rpeGoal),
+ ToolRow(label: t.repsCol, control: StepperControl(value: '${fit.rpeTargetReps}', minWidth: 40, onDec: () => fit.bumpRpeTargetReps(-1), onInc: () => fit.bumpRpeTargetReps(1))),
+ ToolRow(label: t.rpeEffortLabel, control: StepperControl(value: fmt(fit.rpeTargetRpe), minWidth: 40, onDec: () => fit.bumpRpeTarget(-0.5), onInc: () => fit.bumpRpeTarget(0.5))),
+ _note(gc, '${t.rpeOneRmLine(fit.weightLabel(fit.rpeOneRm))}\n${t.rpeExplain}'),
+ ];
+ case 'dots':
+ final step = fit.fromDisplayWeight(fit.weightStep);
+ Widget lift(String label, double kg, void Function(double) bump) => ToolRow(
+ label: label,
+ control: StepperControl(
+ value: '${fit.weightValue(kg)} ${fit.units}',
+ onDec: () => bump(-step),
+ onInc: () => bump(step),
+ onEdit: () => _editNumber(context, title: label, current: fit.toDisplayWeight(kg), decimal: true, apply: (v) => bump(fit.fromDisplayWeight(v) - kg)),
+ ),
+ );
+ return [
+ ToolRow(
+ label: t.sexLabel,
+ control: SegToggle([
+ SegOption(t.male, fit.dotsSex == 'male', () => fit.setDotsSex('male')),
+ SegOption(t.female, fit.dotsSex == 'female', () => fit.setDotsSex('female')),
+ ]),
+ ),
+ lift(t.bodyweight, fit.dotsBody, fit.bumpDotsBody),
+ _sectionLabel(gc, t.dotsBestLifts),
+ lift(t.dotsSquat, fit.dotsSquat, fit.bumpDotsSquat),
+ lift(t.dotsBench, fit.dotsBench, fit.bumpDotsBench),
+ lift(t.dotsDeadlift, fit.dotsDeadlift, fit.bumpDotsDeadlift),
+ _note(gc, '${t.dotsTotalLine(fit.weightLabel(fit.dotsTotal))}\n${t.dotsExplain}'),
+ ];
default:
return const [];
}
}
+ Widget _sectionLabel(GymColors gc, String label) => Padding(
+ padding: const EdgeInsets.fromLTRB(4, 6, 4, 0),
+ child: Text(label.toUpperCase(),
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4)),
+ );
+
+ Widget _note(GymColors gc, String text) => Padding(
+ padding: const EdgeInsets.fromLTRB(4, 4, 4, 0),
+ child: Text(text, style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.5)),
+ );
+
Future<void> _editNumber(
BuildContext context, {
required String title,
@@ -359,7 +413,7 @@ class ToolDetailScreen extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text(t.rampSet(sets[i].pct, sets[i].reps), style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
+ Text('${sets[i].pct} · ${t.repCount(sets[i].reps)}', style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
Text('${fmt(sets[i].weight)} ${fit.units}', style: AppTheme.f(15, weight: FontWeight.w700, color: gc.text)),
],
),
diff --git a/lib/screens/tools_screen.dart b/lib/screens/tools_screen.dart
index 34675e0..eed9bd2 100644
--- a/lib/screens/tools_screen.dart
+++ b/lib/screens/tools_screen.dart
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
-import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../catalog/exercise_catalog.dart';
import '../l10n/l10n.dart';
@@ -7,17 +6,9 @@ import '../models/exercise.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/tool_art.dart';
import '../widgets/ui_kit.dart';
-IconData _toolIcon(String id) => switch (id) {
- 'rm' => PhosphorIconsRegular.barbell,
- 'bmi' => PhosphorIconsRegular.scales,
- 'cal' => PhosphorIconsRegular.fire,
- 'bf' => PhosphorIconsRegular.percent,
- 'plate' => PhosphorIconsRegular.circlesThree,
- _ => PhosphorIconsRegular.trendUp,
- };
-
class ToolsScreen extends StatelessWidget {
const ToolsScreen({super.key});
@@ -56,10 +47,11 @@ class ToolsScreen extends StatelessWidget {
}
Widget _card(GymColors gc, ToolMeta tool, double scale) {
- return GestureDetector(
+ return Pressable(
onTap: () => fit.openTool(tool.id),
+ scale: 0.96,
child: Container(
- padding: const EdgeInsets.all(16),
+ padding: const EdgeInsets.fromLTRB(14, 12, 14, 16),
decoration: BoxDecoration(
color: gc.bgRaised,
borderRadius: BorderRadius.circular(20),
@@ -68,13 +60,7 @@ class ToolsScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
- Container(
- width: 36,
- height: 36,
- decoration:
- BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(12)),
- child: Center(child: Icon(_toolIcon(tool.id), size: 19, color: gc.textSecondary)),
- ),
+ ToolArt(tool.id),
const Spacer(),
Text(t.toolName(tool.id),
maxLines: 1,
diff --git a/lib/state/stats_state.dart b/lib/state/stats_state.dart
index ee365e1..5e81428 100644
--- a/lib/state/stats_state.dart
+++ b/lib/state/stats_state.dart
@@ -83,7 +83,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
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');
+ return (k >= 10 ? k.round().toString() : decimalText(k.toStringAsFixed(1)), units == 'kg' ? 't' : 'k $units');
}
(String, String) get liftedSpan => liftedSpanOf(totalVolumeKg);
@@ -735,6 +735,9 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
notifyListeners();
}
+ @override
+ double bestLift(String id) => oneRmSeries(id).fold(0.0, math.max);
+
List<double> oneRmSeries(String id) {
final h = exerciseHistory(id).reversed;
return h.map((r) => _round1(r.ex.bestOneRm)).toList();
diff --git a/lib/state/tools_state.dart b/lib/state/tools_state.dart
index 7cf73aa..943d3cd 100644
--- a/lib/state/tools_state.dart
+++ b/lib/state/tools_state.dart
@@ -20,6 +20,19 @@ mixin ToolsState on FitCore {
double plateTarget = 100;
double plateBar = 20;
double warmupTarget = 100;
+ double rpeWeight = 100;
+ int rpeReps = 5;
+ double rpeRpe = 8;
+ int rpeTargetReps = 3;
+ double rpeTargetRpe = 9;
+ String dotsSex = 'male';
+ double dotsBody = 80;
+ double dotsSquat = 140;
+ double dotsBench = 100;
+ double dotsDeadlift = 180;
+ bool _dotsSeeded = false;
+
+ static const dotsLifts = ['qXTaZnJ', 'EIeI8Vf', 'ila4NZS'];
void _seedCalculatorsFromProfile() {
calAge = profile.age;
@@ -31,11 +44,25 @@ mixin ToolsState on FitCore {
bmiWeight = profile.weightKg;
bfHeight = profile.heightCm;
bfSex = profile.sex;
+ dotsBody = profile.weightKg;
+ dotsSex = profile.sex;
+ }
+
+ double bestLift(String id) => 0;
+
+ void _seedDots() {
+ if (_dotsSeeded) return;
+ _dotsSeeded = true;
+ final best = [for (final id in dotsLifts) bestLift(id)];
+ if (best[0] > 0) dotsSquat = _round1(best[0]);
+ if (best[1] > 0) dotsBench = _round1(best[1]);
+ if (best[2] > 0) dotsDeadlift = _round1(best[2]);
}
void goTools() => pushRoute('tools');
void openTool(String id) {
+ if (id == 'dots') _seedDots();
activeToolId = id;
pushRoute('tools-detail');
}
@@ -231,5 +258,55 @@ mixin ToolsState on FitCore {
double get plateBarDisplay => _round1(toDisplayWeight(plateBar));
+ static double _effortShare(int reps, double rpe) => rpePercent(reps, rpe) ?? 1 / (1 + reps / 30);
+
+ double get rpeOneRm => _round1(rpeWeight / _effortShare(rpeReps, rpeRpe));
+
+ double get rpeResult {
+ final kg = rpeOneRm * _effortShare(rpeTargetReps, rpeTargetRpe);
+ return fromDisplayWeight(_roundTo(toDisplayWeight(kg), isLb ? 5.0 : 2.5));
+ }
+
+ void bumpRpeWeight(double d) { rpeWeight = _clamp(rpeWeight + d, 0, null); notifyListeners(); }
+
+ void bumpRpeReps(int d) { rpeReps = (rpeReps + d).clamp(1, 12); notifyListeners(); }
+
+ void bumpRpe(double d) { rpeRpe = (rpeRpe + d).clamp(6, 10).toDouble(); notifyListeners(); }
+
+ void bumpRpeTargetReps(int d) { rpeTargetReps = (rpeTargetReps + d).clamp(1, 12); notifyListeners(); }
+
+ void bumpRpeTarget(double d) { rpeTargetRpe = (rpeTargetRpe + d).clamp(6, 10).toDouble(); notifyListeners(); }
+
+ double get dotsTotal => dotsSquat + dotsBench + dotsDeadlift;
+
+ double get dotsScore {
+ final male = dotsSex == 'male';
+ final bw = dotsBody.clamp(40, male ? 210 : 150).toDouble();
+ final c = male
+ ? const [-307.75076, 24.0900756, -0.1918759221, 0.0007391293, -0.000001093]
+ : const [-57.96288, 13.6175032, -0.1126655495, 0.0005158568, -0.0000010706];
+ final den = c[0] + c[1] * bw + c[2] * bw * bw + c[3] * math.pow(bw, 3) + c[4] * math.pow(bw, 4);
+ return _round1(dotsTotal * 500 / den);
+ }
+
+ int get dotsLevel {
+ final s = dotsScore;
+ if (s < 250) return 0;
+ if (s < 325) return 1;
+ if (s < 400) return 2;
+ if (s < 475) return 3;
+ return 4;
+ }
+
+ void setDotsSex(String s) { dotsSex = s; notifyListeners(); }
+
+ void bumpDotsBody(double d) { dotsBody = _clamp(dotsBody + d, 30, 250); notifyListeners(); }
+
+ void bumpDotsSquat(double d) { dotsSquat = _clamp(dotsSquat + d, 0, null); notifyListeners(); }
+
+ void bumpDotsBench(double d) { dotsBench = _clamp(dotsBench + d, 0, null); notifyListeners(); }
+
+ void bumpDotsDeadlift(double d) { dotsDeadlift = _clamp(dotsDeadlift + d, 0, null); notifyListeners(); }
+
void bumpWarmupTarget(double d) { warmupTarget = _clamp(warmupTarget + d, 0, null); notifyListeners(); }
}
diff --git a/lib/widgets/tool_art.dart b/lib/widgets/tool_art.dart
new file mode 100644
index 0000000..08a51fa
--- /dev/null
+++ b/lib/widgets/tool_art.dart
@@ -0,0 +1,288 @@
+import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+
+import '../theme/app_colors.dart';
+import 'routine_folder.dart';
+
+class ToolArt extends StatelessWidget {
+ const ToolArt(this.id, {super.key, this.width = 64, this.height = 54});
+
+ final String id;
+ final double width;
+ final double height;
+
+ @override
+ Widget build(BuildContext context) {
+ final dark = context.gc.bg.computeLuminance() < 0.5;
+ return SizedBox(
+ width: width,
+ height: height,
+ child: CustomPaint(painter: _ToolArtPainter(id, dark)),
+ );
+ }
+}
+
+class _ToolArtPainter extends CustomPainter {
+ _ToolArtPainter(this.id, this.dark);
+
+ final String id;
+ final bool dark;
+
+ Color _hue(int i) => Color.lerp(kFolderHues[i], Colors.black, dark ? 0.08 : 0)!;
+ Color _ink(Color c) => Color.lerp(c, Colors.black, 0.5)!;
+ Color get _steel => dark ? const Color(0xFFD8D3CD) : const Color(0xFFB9B2AA);
+
+ void _shadow(Canvas canvas, Path path, {double blur = 3.5, double dy = 2.5, double alpha = 0.28}) {
+ canvas.drawPath(
+ path.shift(Offset(0, dy)),
+ Paint()
+ ..color = Colors.black.withValues(alpha: dark ? alpha + 0.12 : alpha * 0.6)
+ ..maskFilter = MaskFilter.blur(BlurStyle.normal, blur),
+ );
+ }
+
+ void _fill(Canvas canvas, Path path, Color c) {
+ final b = path.getBounds();
+ canvas.drawPath(
+ path,
+ Paint()
+ ..shader = LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [Color.lerp(c, Colors.white, 0.22)!, Color.lerp(c, Colors.black, 0.12)!],
+ ).createShader(b),
+ );
+ }
+
+ void _gloss(Canvas canvas, RRect rr) {
+ canvas.save();
+ canvas.clipRRect(rr);
+ canvas.drawRRect(
+ rr.deflate(0.6),
+ Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 1.1
+ ..shader = LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [Colors.white.withValues(alpha: 0.5), Colors.white.withValues(alpha: 0)],
+ stops: const [0, 0.5],
+ ).createShader(rr.outerRect),
+ );
+ canvas.restore();
+ }
+
+ RRect _block(Canvas canvas, Rect r, double radius, Color c, {bool shadow = true, bool gloss = true}) {
+ final rr = RRect.fromRectAndRadius(r, Radius.circular(radius));
+ final path = Path()..addRRect(rr);
+ if (shadow) _shadow(canvas, path);
+ _fill(canvas, path, c);
+ if (gloss) _gloss(canvas, rr);
+ return rr;
+ }
+
+ void _plate(Canvas canvas, Rect r, Color c) {
+ _block(canvas, r, math.min(3, r.width / 2), c);
+ canvas.drawRRect(
+ RRect.fromRectAndRadius(Rect.fromCenter(center: r.center, width: 1.4, height: r.height * 0.62), const Radius.circular(1)),
+ Paint()..color = _ink(c).withValues(alpha: 0.28),
+ );
+ }
+
+ void _turn(Canvas canvas, Size s, double angle, void Function() draw) {
+ canvas.save();
+ canvas.translate(s.width / 2, s.height / 2);
+ canvas.rotate(angle);
+ canvas.translate(-s.width / 2, -s.height / 2);
+ draw();
+ canvas.restore();
+ }
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final w = size.width, h = size.height;
+ switch (id) {
+ case 'rm':
+ _turn(canvas, size, -0.14, () {
+ final cy = h / 2;
+ _block(canvas, Rect.fromLTWH(2, cy - 2, w - 4, 4), 2, _steel, gloss: false);
+ for (final left in [true, false]) {
+ double x(double dx, double width) => left ? dx : w - dx - width;
+ _block(canvas, Rect.fromLTWH(x(2, 3.5), cy - 3.5, 3.5, 7), 1.5, _steel, shadow: false, gloss: false);
+ _plate(canvas, Rect.fromLTWH(x(8, 8), cy - 18, 8, 36), _hue(0));
+ _plate(canvas, Rect.fromLTWH(x(16, 5.5), cy - 12, 5.5, 24), _hue(4));
+ _block(canvas, Rect.fromLTWH(x(21.5, 3.5), cy - 5.5, 3.5, 11), 1.5, _steel, shadow: false, gloss: false);
+ }
+ });
+ case 'bmi':
+ _turn(canvas, size, 0.06, () {
+ final body = Rect.fromCenter(center: Offset(w / 2, h / 2 + 2), width: 42, height: 40);
+ _block(canvas, body, 11, _hue(2));
+ final dial = Rect.fromCenter(center: Offset(w / 2, body.top + 15), width: 26, height: 22);
+ canvas.drawArc(dial, math.pi, math.pi, true, Paint()..color = _ink(_hue(2)).withValues(alpha: 0.85));
+ canvas.drawArc(dial.deflate(4), math.pi, math.pi, true, Paint()..color = Color.lerp(_hue(2), Colors.white, 0.75)!);
+ final c = dial.center;
+ canvas.drawLine(c, c + Offset(math.cos(-0.9) * 8, math.sin(-0.9) * 8),
+ Paint()
+ ..color = const Color(0xFFD9774E)
+ ..strokeWidth = 2
+ ..strokeCap = StrokeCap.round);
+ canvas.drawCircle(c, 2, Paint()..color = _ink(_hue(2)));
+ for (final dx in [-10.0, 10.0]) {
+ canvas.drawRRect(
+ RRect.fromRectAndRadius(Rect.fromCenter(center: Offset(w / 2 + dx, body.bottom - 7), width: 9, height: 3),
+ const Radius.circular(2)),
+ Paint()..color = _ink(_hue(2)).withValues(alpha: 0.35));
+ }
+ });
+ case 'cal':
+ final cx = w / 2;
+ Path flame(double scale, double dy) {
+ final fh = 44 * scale, fw = 32 * scale;
+ final top = h - 4 - fh + dy, bottom = h - 4 + dy;
+ return Path()
+ ..moveTo(cx, top)
+ ..cubicTo(cx + fw * 0.15, top + fh * 0.25, cx + fw * 0.55, top + fh * 0.4, cx + fw * 0.5, top + fh * 0.68)
+ ..cubicTo(cx + fw * 0.46, top + fh * 0.92, cx + fw * 0.2, bottom, cx, bottom)
+ ..cubicTo(cx - fw * 0.2, bottom, cx - fw * 0.5, top + fh * 0.92, cx - fw * 0.5, top + fh * 0.66)
+ ..cubicTo(cx - fw * 0.5, top + fh * 0.45, cx - fw * 0.3, top + fh * 0.38, cx - fw * 0.22, top + fh * 0.22)
+ ..cubicTo(cx - fw * 0.08, top + fh * 0.36, cx - fw * 0.02, top + fh * 0.18, cx, top)
+ ..close();
+ }
+ final outer = flame(1, 0);
+ canvas.drawCircle(Offset(cx, h - 16), 18,
+ Paint()
+ ..color = const Color(0xFFF2A46E).withValues(alpha: dark ? 0.22 : 0.16)
+ ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 9));
+ _shadow(canvas, outer);
+ canvas.drawPath(
+ outer,
+ Paint()
+ ..shader = const LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [Color(0xFFF4BC86), Color(0xFFE0745A)],
+ ).createShader(outer.getBounds()));
+ canvas.save();
+ canvas.clipPath(outer);
+ canvas.drawPath(
+ outer.shift(const Offset(-3, 2)),
+ Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 2
+ ..color = Colors.white.withValues(alpha: 0.28));
+ canvas.restore();
+ final inner = flame(0.52, -2);
+ canvas.drawPath(
+ inner,
+ Paint()
+ ..shader = LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [const Color(0xFFF8E2A8), Color.lerp(const Color(0xFFF8E2A8), Colors.white, 0.5)!],
+ ).createShader(inner.getBounds()));
+ case 'bf':
+ _turn(canvas, size, 0.1, () {
+ final sheet = Rect.fromCenter(center: Offset(w / 2, h / 2), width: 40, height: 46);
+ _block(canvas, sheet, 8, _hue(3));
+ final ring = Rect.fromCenter(center: Offset(w / 2, sheet.top + 18), width: 20, height: 20);
+ canvas.drawArc(ring, 0, math.pi * 2, false,
+ Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 5
+ ..color = _ink(_hue(3)).withValues(alpha: 0.3));
+ canvas.drawArc(ring, -math.pi / 2, math.pi * 0.7, false,
+ Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 5
+ ..strokeCap = StrokeCap.round
+ ..color = _hue(5));
+ for (final (dy, f) in [(33.0, 1.0), (38.5, 0.6)]) {
+ canvas.drawRRect(
+ RRect.fromRectAndRadius(Rect.fromLTWH(sheet.left + 8, sheet.top + dy, 24 * f, 2.5), const Radius.circular(2)),
+ Paint()..color = _ink(_hue(3)).withValues(alpha: 0.4));
+ }
+ });
+ case 'plate':
+ _turn(canvas, size, -0.06, () {
+ final cy = h / 2;
+ _block(canvas, Rect.fromLTWH(4, cy - 2.5, w - 8, 5), 2.5, _steel, gloss: false);
+ var x = 12.0;
+ for (final (pw, ph, hue) in [(8.0, 46.0, 3), (6.5, 36.0, 4), (5.5, 27.0, 2), (4.5, 19.0, 0)]) {
+ _plate(canvas, Rect.fromLTWH(x, cy - ph / 2, pw, ph), _hue(hue));
+ x += pw + 1.2;
+ }
+ _block(canvas, Rect.fromLTWH(x + 1, cy - 6, 4, 12), 1.5, _steel, gloss: false);
+ });
+ case 'warmup':
+ final base = h - 6;
+ for (final (i, bh, hue) in [(0, 16.0, 2), (1, 27.0, 4), (2, 40.0, 0)]) {
+ final r = Rect.fromLTWH(10 + i * 15.0, base - bh, 12, bh);
+ _block(canvas, r, 4, _hue(hue));
+ canvas.drawRRect(RRect.fromRectAndRadius(Rect.fromLTWH(r.left + 3, r.top + 4, 6, 2.5), const Radius.circular(2)),
+ Paint()..color = Colors.white.withValues(alpha: 0.5));
+ }
+ case 'rpe':
+ final c = Offset(w / 2, h - 10);
+ final arc = Rect.fromCircle(center: c, radius: 22);
+ final track = Path()..addArc(arc, math.pi, math.pi);
+ _shadow(canvas, track, blur: 3);
+ canvas.drawArc(arc, math.pi, math.pi, false,
+ Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 9
+ ..strokeCap = StrokeCap.round
+ ..shader = LinearGradient(colors: [_hue(2), _hue(4), _hue(0), const Color(0xFFE07A5A)]).createShader(arc));
+ for (var k = 1; k < 5; k++) {
+ final a = math.pi + math.pi * k / 5;
+ canvas.drawLine(c + Offset(math.cos(a) * 18.5, math.sin(a) * 18.5), c + Offset(math.cos(a) * 25.5, math.sin(a) * 25.5),
+ Paint()
+ ..color = Colors.white.withValues(alpha: 0.45)
+ ..strokeWidth = 1.2);
+ }
+ final needle = dark ? const Color(0xFFF2EEE9) : const Color(0xFF3A332D);
+ final tip = c + Offset(math.cos(math.pi * 1.72) * 17, math.sin(math.pi * 1.72) * 17);
+ _shadow(canvas, Path()..addOval(Rect.fromCircle(center: c, radius: 4.5)), blur: 2, dy: 1.5);
+ canvas.drawLine(c, tip,
+ Paint()
+ ..color = needle
+ ..strokeWidth = 3
+ ..strokeCap = StrokeCap.round);
+ canvas.drawCircle(c, 4.5, Paint()..color = needle);
+ canvas.drawCircle(c, 1.6, Paint()..color = _hue(0));
+ case 'dots':
+ final base = h - 4;
+ for (final (x, bh, hue) in [(6.0, 18.0, 1), (22.0, 28.0, 4), (38.0, 12.0, 0)]) {
+ final rr = _block(canvas, Rect.fromLTWH(x, base - bh, 16, bh), 3.5, _hue(hue));
+ canvas.drawRRect(RRect.fromRectAndRadius(Rect.fromLTWH(x + 5, rr.top + 5, 6, 2.2), const Radius.circular(1.1)),
+ Paint()..color = _ink(_hue(hue)).withValues(alpha: 0.35));
+ }
+ final medal = Offset(30, base - 28 - 11);
+ for (final s in [-1.0, 1.0]) {
+ final ribbon = Path()
+ ..moveTo(medal.dx + s * 1.5, medal.dy - 4)
+ ..lineTo(medal.dx + s * 6.5, medal.dy - 12)
+ ..lineTo(medal.dx + s * 10, medal.dy - 10)
+ ..lineTo(medal.dx + s * 5, medal.dy - 2)
+ ..close();
+ canvas.drawPath(ribbon, Paint()..color = s < 0 ? _hue(3) : _hue(5));
+ }
+ final disc = Path()..addOval(Rect.fromCircle(center: medal, radius: 8));
+ _shadow(canvas, disc, blur: 2.5, dy: 1.5);
+ canvas.drawPath(
+ disc,
+ Paint()
+ ..shader = const RadialGradient(center: Alignment(-0.3, -0.4), colors: [Color(0xFFFBE9B8), Color(0xFFD6A55A)])
+ .createShader(Rect.fromCircle(center: medal, radius: 8)));
+ canvas.drawCircle(medal, 4.5,
+ Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 1.4
+ ..color = const Color(0xFF9C7334).withValues(alpha: 0.6));
+ }
+ }
+
+ @override
+ bool shouldRepaint(_ToolArtPainter o) => o.id != id || o.dark != dark;
+}
diff --git a/test/calculators_test.dart b/test/calculators_test.dart
index 3db0bbb..3aca2e2 100644
--- a/test/calculators_test.dart
+++ b/test/calculators_test.dart
@@ -5,7 +5,7 @@ import 'package:gymmane/state/fit_state.dart';
void main() {
test('every tool in the menu has a screen behind it', () {
expect(kToolMeta.map((t) => t.id).toSet(),
- {'rm', 'bmi', 'cal', 'bf', 'plate', 'warmup'});
+ {'rm', 'bmi', 'cal', 'bf', 'plate', 'warmup', 'rpe', 'dots'});
for (final t in kToolMeta) {
expect(t.name.trim(), isNotEmpty);
expect(t.desc.trim(), isNotEmpty);
diff --git a/test/new_tools_test.dart b/test/new_tools_test.dart
new file mode 100644
index 0000000..63d848f
--- /dev/null
+++ b/test/new_tools_test.dart
@@ -0,0 +1,78 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/catalog/exercise_catalog.dart';
+import 'package:gymmane/models/workout.dart';
+import 'package:gymmane/services/local_store.dart';
+import 'package:gymmane/state/fit_state.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ setUp(() async {
+ SharedPreferences.setMockInitialValues({});
+ await Store.instance.init();
+ fit.resetAllData();
+ });
+
+ test('las dos calculadoras nuevas están en la lista', () {
+ expect(kToolMeta.map((m) => m.id), containsAll(['rpe', 'dots']));
+ });
+
+ test('peso por RPE: 100 x 5 a RPE 8 da unos 110 para 3 a RPE 9', () {
+ fit.rpeWeight = 100;
+ fit.rpeReps = 5;
+ fit.rpeRpe = 8;
+ fit.rpeTargetReps = 3;
+ fit.rpeTargetRpe = 9;
+ expect(fit.rpeOneRm, closeTo(123.3, 0.1));
+ expect(fit.rpeResult, 110);
+ });
+
+ test('peso por RPE: misma serie y mismo esfuerzo devuelve el mismo peso', () {
+ fit.rpeWeight = 80;
+ fit.rpeReps = 8;
+ fit.rpeRpe = 7.5;
+ fit.rpeTargetReps = 8;
+ fit.rpeTargetRpe = 7.5;
+ expect(fit.rpeResult, 80);
+ });
+
+ test('peso por RPE: el RPE no sale de 6 a 10 ni las repes de 1 a 12', () {
+ fit.rpeRpe = 10;
+ fit.bumpRpe(0.5);
+ expect(fit.rpeRpe, 10);
+ fit.rpeReps = 12;
+ fit.bumpRpeReps(1);
+ expect(fit.rpeReps, 12);
+ });
+
+ test('DOTS: 80 kg y 500 de total en hombre da unos 345', () {
+ fit.dotsSex = 'male';
+ fit.dotsBody = 80;
+ fit.dotsSquat = 180;
+ fit.dotsBench = 120;
+ fit.dotsDeadlift = 200;
+ expect(fit.dotsScore, closeTo(344.8, 0.5));
+ expect(fit.dotsLevel, 2);
+ });
+
+ test('DOTS: con el mismo total, una mujer puntúa más', () {
+ fit.dotsBody = 60;
+ fit.dotsSquat = 100;
+ fit.dotsBench = 60;
+ fit.dotsDeadlift = 120;
+ fit.dotsSex = 'male';
+ final male = fit.dotsScore;
+ fit.dotsSex = 'female';
+ expect(fit.dotsScore, greaterThan(male));
+ });
+
+ test('DOTS toma tus mejores marcas al abrirla', () {
+ fit.sessions.add(LoggedSession(DateTime.now(), 600, [
+ LoggedExercise('qXTaZnJ', 'Barbell Full Squat', 'quads', [LoggedSet(5, 120)]),
+ ]));
+ fit.openTool('dots');
+ expect(fit.dotsSquat, closeTo(140, 0.1));
+ fit.closeTool();
+ });
+}