Skip to content

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

New look: Nunito, a glass tab bar, home folders, charts with a side scale and entrance animations

InlitXf57ced04cd6d
diff --git a/CREDITS.md b/CREDITS.md
index 2b8fe57..efec480 100644
--- a/CREDITS.md
+++ b/CREDITS.md
@@ -25,5 +25,5 @@ with different equipment.
## Fonts
-Oswald, IBM Plex Sans, Figtree and Barlow Semi Condensed, all under the
-SIL Open Font License.
+Nunito, by the Nunito Project Authors, under the SIL Open Font License
+(`assets/fonts/Nunito-OFL.txt`).
diff --git a/assets/fonts/BarlowSemiCondensed-Bold.ttf b/assets/fonts/BarlowSemiCondensed-Bold.ttf
deleted file mode 100644
index ee04b09..0000000
Binary files a/assets/fonts/BarlowSemiCondensed-Bold.ttf and /dev/null differ
diff --git a/assets/fonts/BarlowSemiCondensed-ExtraBold.ttf b/assets/fonts/BarlowSemiCondensed-ExtraBold.ttf
deleted file mode 100644
index fe820be..0000000
Binary files a/assets/fonts/BarlowSemiCondensed-ExtraBold.ttf and /dev/null differ
diff --git a/assets/fonts/BarlowSemiCondensed-Medium.ttf b/assets/fonts/BarlowSemiCondensed-Medium.ttf
deleted file mode 100644
index 415429b..0000000
Binary files a/assets/fonts/BarlowSemiCondensed-Medium.ttf and /dev/null differ
diff --git a/assets/fonts/BarlowSemiCondensed-SemiBold.ttf b/assets/fonts/BarlowSemiCondensed-SemiBold.ttf
deleted file mode 100644
index 082c763..0000000
Binary files a/assets/fonts/BarlowSemiCondensed-SemiBold.ttf and /dev/null differ
diff --git a/assets/fonts/Figtree-Bold.ttf b/assets/fonts/Figtree-Bold.ttf
deleted file mode 100644
index 6f8ad64..0000000
Binary files a/assets/fonts/Figtree-Bold.ttf and /dev/null differ
diff --git a/assets/fonts/Figtree-ExtraBold.ttf b/assets/fonts/Figtree-ExtraBold.ttf
deleted file mode 100644
index 8589c04..0000000
Binary files a/assets/fonts/Figtree-ExtraBold.ttf and /dev/null differ
diff --git a/assets/fonts/Figtree-Medium.ttf b/assets/fonts/Figtree-Medium.ttf
deleted file mode 100644
index 5b89c89..0000000
Binary files a/assets/fonts/Figtree-Medium.ttf and /dev/null differ
diff --git a/assets/fonts/Figtree-Regular.ttf b/assets/fonts/Figtree-Regular.ttf
deleted file mode 100644
index 4b42cdb..0000000
Binary files a/assets/fonts/Figtree-Regular.ttf and /dev/null differ
diff --git a/assets/fonts/Figtree-SemiBold.ttf b/assets/fonts/Figtree-SemiBold.ttf
deleted file mode 100644
index aa2b78c..0000000
Binary files a/assets/fonts/Figtree-SemiBold.ttf and /dev/null differ
diff --git a/assets/fonts/IBMPlexSans-400.ttf b/assets/fonts/IBMPlexSans-400.ttf
deleted file mode 100644
index fb4b91f..0000000
Binary files a/assets/fonts/IBMPlexSans-400.ttf and /dev/null differ
diff --git a/assets/fonts/IBMPlexSans-500.ttf b/assets/fonts/IBMPlexSans-500.ttf
deleted file mode 100644
index cc8dace..0000000
Binary files a/assets/fonts/IBMPlexSans-500.ttf and /dev/null differ
diff --git a/assets/fonts/IBMPlexSans-600.ttf b/assets/fonts/IBMPlexSans-600.ttf
deleted file mode 100644
index e4be813..0000000
Binary files a/assets/fonts/IBMPlexSans-600.ttf and /dev/null differ
diff --git a/assets/fonts/IBMPlexSans-700.ttf b/assets/fonts/IBMPlexSans-700.ttf
deleted file mode 100644
index 6c31eef..0000000
Binary files a/assets/fonts/IBMPlexSans-700.ttf and /dev/null differ
diff --git a/assets/fonts/Nunito-Black.ttf b/assets/fonts/Nunito-Black.ttf
new file mode 100644
index 0000000..21cdf92
Binary files /dev/null and b/assets/fonts/Nunito-Black.ttf differ
diff --git a/assets/fonts/Nunito-Bold.ttf b/assets/fonts/Nunito-Bold.ttf
new file mode 100644
index 0000000..5a5a95d
Binary files /dev/null and b/assets/fonts/Nunito-Bold.ttf differ
diff --git a/assets/fonts/Nunito-ExtraBold.ttf b/assets/fonts/Nunito-ExtraBold.ttf
new file mode 100644
index 0000000..baf48a9
Binary files /dev/null and b/assets/fonts/Nunito-ExtraBold.ttf differ
diff --git a/assets/fonts/Nunito-Italic.ttf b/assets/fonts/Nunito-Italic.ttf
new file mode 100644
index 0000000..b800986
Binary files /dev/null and b/assets/fonts/Nunito-Italic.ttf differ
diff --git a/assets/fonts/Nunito-Medium.ttf b/assets/fonts/Nunito-Medium.ttf
new file mode 100644
index 0000000..7bc3c1d
Binary files /dev/null and b/assets/fonts/Nunito-Medium.ttf differ
diff --git a/assets/fonts/Nunito-OFL.txt b/assets/fonts/Nunito-OFL.txt
new file mode 100644
index 0000000..c8210f0
--- /dev/null
+++ b/assets/fonts/Nunito-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2014 The Nunito Project Authors (https://github.com/googlefonts/nunito)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/assets/fonts/Nunito-Regular.ttf b/assets/fonts/Nunito-Regular.ttf
new file mode 100644
index 0000000..c42a2b6
Binary files /dev/null and b/assets/fonts/Nunito-Regular.ttf differ
diff --git a/assets/fonts/Nunito-SemiBold.ttf b/assets/fonts/Nunito-SemiBold.ttf
new file mode 100644
index 0000000..619c60e
Binary files /dev/null and b/assets/fonts/Nunito-SemiBold.ttf differ
diff --git a/assets/fonts/Nunito-SemiBoldItalic.ttf b/assets/fonts/Nunito-SemiBoldItalic.ttf
new file mode 100644
index 0000000..03a4ced
Binary files /dev/null and b/assets/fonts/Nunito-SemiBoldItalic.ttf differ
diff --git a/assets/fonts/Oswald-500.ttf b/assets/fonts/Oswald-500.ttf
deleted file mode 100644
index ef4b2d9..0000000
Binary files a/assets/fonts/Oswald-500.ttf and /dev/null differ
diff --git a/assets/fonts/Oswald-600.ttf b/assets/fonts/Oswald-600.ttf
deleted file mode 100644
index e802400..0000000
Binary files a/assets/fonts/Oswald-600.ttf and /dev/null differ
diff --git a/assets/fonts/Oswald-700.ttf b/assets/fonts/Oswald-700.ttf
deleted file mode 100644
index 9e70b31..0000000
Binary files a/assets/fonts/Oswald-700.ttf and /dev/null differ
diff --git a/assets/shaders/edge_fade.frag b/assets/shaders/edge_fade.frag
new file mode 100644
index 0000000..c1d17d5
--- /dev/null
+++ b/assets/shaders/edge_fade.frag
@@ -0,0 +1,27 @@
+#version 460 core
+#include <flutter/runtime_effect.glsl>
+
+precision highp float;
+
+uniform vec2 uSize;
+uniform float uReach;
+uniform float uFrom;
+uniform float uTo;
+uniform float uTop;
+uniform sampler2D uTexture;
+
+out vec4 fragColor;
+
+void main() {
+ vec2 p = FlutterFragCoord().xy;
+ vec2 uv = p / uSize;
+#ifdef IMPELLER_TARGET_OPENGLES
+ uv.y = 1.0 - uv.y;
+#endif
+ float d = uTop > 0.5 ? p.y : uSize.y - p.y;
+ float k = clamp(d / max(uReach, 1.0), 0.0, 1.0);
+ float a = 1.0 - smoothstep(uFrom, uTo, k);
+ vec4 c = texture(uTexture, uv);
+ if (c.a > 0.004) c /= c.a;
+ fragColor = c * a;
+}
diff --git a/lib/app/app_shell.dart b/lib/app/app_shell.dart
index 3906b88..cfef376 100644
--- a/lib/app/app_shell.dart
+++ b/lib/app/app_shell.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:ui' show ImageFilter;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -16,6 +17,7 @@ import '../screens/note_edit_screen.dart';
import '../screens/notes_screen.dart';
import '../screens/onboarding_screen.dart';
import '../screens/places_screen.dart';
+import '../screens/plan_import_sheet.dart';
import '../screens/progress_screen.dart';
import '../screens/routine_edit_screen.dart';
import '../screens/routines_screen.dart';
@@ -29,12 +31,16 @@ import '../screens/timeline_screen.dart';
import '../screens/tool_detail_screen.dart';
import '../screens/tools_screen.dart';
import '../screens/train_screen.dart';
+import '../services/incoming_share.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/app_background.dart';
import '../widgets/award_celebration.dart';
import '../widgets/dialogs.dart';
+import '../widgets/glass.dart';
+import '../widgets/liquid_notch.dart';
+import '../widgets/start_countdown.dart';
class AppShell extends StatefulWidget {
const AppShell({super.key});
@@ -44,8 +50,23 @@ class AppShell extends StatefulWidget {
}
class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
- static const _firstAwardWait = Duration(milliseconds: 2500);
- static const _nextAwardWait = Duration(milliseconds: 3500);
+ static const _blurTop = {
+ 'home',
+ 'progress',
+ 'session',
+ 'about',
+ 'ai-plan',
+ 'awards',
+ 'exercise-detail',
+ 'measures',
+ 'routines',
+ 'preferences',
+ 'tools',
+ 'tools-detail',
+ };
+
+ static const _firstAwardWait = Duration(milliseconds: 4000);
+ static const _nextAwardWait = Duration(milliseconds: 6000);
String _lastRoute = fit.route;
int _lastDepth = fit.routeDepth;
@@ -54,6 +75,9 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
AwardId? _celebrating;
bool _celebratedOne = false;
Timer? _awardWait;
+ String? _incoming;
+ bool _scrolled = false;
+ int _restTick = fit.restDoneTick;
@override
void initState() {
@@ -61,11 +85,58 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
WidgetsBinding.instance.addObserver(this);
fit.refreshAlarmPermission();
fit.addListener(_queueCelebration);
+ fit.addListener(_offerIncoming);
+ fit.addListener(_restOver);
_queueCelebration();
+ IncomingShare.listen(_receive);
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
+ final text = await IncomingShare.take();
+ if (text != null) _receive(text);
+ });
+ }
+
+ void _receive(String text) {
+ _incoming = text;
+ _offerIncoming();
+ }
+
+ void _offerIncoming() {
+ final text = _incoming;
+ if (text == null || !mounted || !fit.onboarded || fit.isSessionActive) return;
+ _incoming = null;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) showPlanImportSheet(context, text: text);
+ });
+ }
+
+ void _restOver() {
+ if (fit.restDoneTick == _restTick) return;
+ _restTick = fit.restDoneTick;
+ final s = fit.session;
+ final ex = fit.currentExercise;
+ if (!mounted || s == null || ex == null) return;
+ final done = ex.sets.where((st) => st.done).length;
+ final next = done < ex.sets.length ? t.liveSet(done + 1, ex.sets.length) : t.liveAllDone;
+ showNotchToast(
+ context,
+ t.restOverTitle,
+ subtitle: '${t.catalogName(ex.id, ex.name)} · $next',
+ icon: PhosphorIconsFill.timer,
+ accent: context.gc.sage,
+ );
+ }
+
+ bool _onScroll(ScrollNotification n) {
+ if (n.depth != 0 || n.metrics.axis != Axis.vertical) return false;
+ final scrolled = n.metrics.pixels > 6;
+ if (scrolled != _scrolled) setState(() => _scrolled = scrolled);
+ return false;
}
@override
void dispose() {
+ fit.removeListener(_restOver);
+ fit.removeListener(_offerIncoming);
fit.removeListener(_queueCelebration);
_awardWait?.cancel();
WidgetsBinding.instance.removeObserver(this);
@@ -92,6 +163,9 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
fit.celebrationShown();
}
+ @override
+ void didChangePlatformBrightness() => fit.systemBrightnessChanged();
+
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.inactive ||
@@ -117,6 +191,10 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
canPop: false,
onPopInvokedWithResult: (didPop, _) async {
if (didPop) return;
+ if (fit.isSessionActive && fit.sessionLocked) {
+ HapticFeedback.mediumImpact();
+ return;
+ }
if (fit.isSessionActive) {
if (await _confirmDiscard(context)) fit.discardSession();
return;
@@ -129,7 +207,8 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
},
child: AnnotatedRegion<SystemUiOverlayStyle>(
value: fit.dark ? _overlayDark : _overlayLight,
- child: Stack(
+ child: BackdropGroup(
+ child: Stack(
children: [
Positioned.fill(child: ColoredBox(color: context.gc.bg)),
Positioned.fill(
@@ -143,15 +222,39 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
backgroundColor: Colors.transparent,
body: Padding(
padding: EdgeInsets.only(bottom: MediaQuery.viewPaddingOf(context).bottom),
- child: _animatedScreen(),
+ child: NotificationListener<ScrollNotification>(
+ onNotification: _onScroll,
+ child: _animatedScreen(),
+ ),
+ ),
+ ),
+ Positioned(
+ left: 0,
+ right: 0,
+ top: 0,
+ child: AnimatedOpacity(
+ opacity: _scrolled && _blurTop.contains(fit.route) ? 1 : 0,
+ duration: const Duration(milliseconds: 220),
+ child: EdgeBlur(height: MediaQuery.viewPaddingOf(context).top + 64, sigma: 14),
),
),
+ if (fit.showNav)
+ Positioned(
+ left: 0,
+ right: 0,
+ bottom: 0,
+ child: EdgeBlur(top: false, height: 128 + MediaQuery.viewPaddingOf(context).bottom),
+ ),
if (fit.showNav && MediaQuery.viewInsetsOf(context).bottom < 60)
Positioned(
left: 18,
right: 18,
bottom: 18 + MediaQuery.viewPaddingOf(context).bottom,
- child: _NavBar(),
+ child: Directionality(textDirection: TextDirection.ltr, child: _NavBar()),
+ ),
+ if (fit.countdownUntil != null && fit.session != null)
+ Positioned.fill(
+ child: StartCountdown(key: ValueKey(fit.countdownUntil), until: fit.countdownUntil!),
),
if (fit.route != 'session' && _celebrating != null)
Positioned.fill(
@@ -162,6 +265,7 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
),
),
],
+ ),
),
),
);
@@ -180,8 +284,9 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
Widget _animatedScreen() {
final route = fit.route;
if (route != _lastRoute) {
- final from = _NavBar._routes.indexOf(_lastRoute);
- final to = _NavBar._routes.indexOf(route);
+ _scrolled = false;
+ final from = _NavBarState._routes.indexOf(_lastRoute);
+ final to = _NavBarState._routes.indexOf(route);
_sideways = from >= 0 && to >= 0;
_forward = _sideways ? to > from : fit.routeDepth >= _lastDepth;
_lastRoute = route;
@@ -191,34 +296,39 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
final dir = _forward ? 1.0 : -1.0;
return AnimatedSwitcher(
- duration: const Duration(milliseconds: 260),
+ duration: const Duration(milliseconds: 380),
switchInCurve: const Interval(0.3, 1, curve: Curves.easeOutCubic),
- switchOutCurve: const Interval(0.6, 1, curve: Curves.easeOutCubic),
+ switchOutCurve: const Interval(0.7, 1, curve: Curves.easeInCubic),
transitionBuilder: (child, animation) {
final incoming = (child.key as ValueKey?)?.value == fit.route;
- final Offset begin;
- if (sideways) {
- begin = Offset(incoming ? 30 * dir : -30 * dir, 0);
- } else if (incoming) {
- begin = Offset(0, 30 * dir);
- } else {
- begin = Offset.zero;
- }
- final slide = Tween<Offset>(begin: begin, end: Offset.zero)
- .animate(CurvedAnimation(parent: animation, curve: Curves.easeOutCubic));
- return FadeTransition(
- opacity: animation,
- child: AnimatedBuilder(
- animation: slide,
- builder: (_, inner) => Transform.translate(offset: slide.value, child: inner),
- child: child,
- ),
+ return AnimatedBuilder(
+ animation: animation,
+ child: child,
+ builder: (_, inner) {
+ final v = animation.value.clamp(0.0, 1.0);
+ final away = 1 - v;
+ final shift = sideways
+ ? Offset((incoming ? 26 : -18) * dir * away, 0)
+ : Offset(0, incoming ? 22 * dir * away : -8 * dir * away);
+ final blur = 10 * away;
+ return Opacity(
+ opacity: v,
+ child: ImageFiltered(
+ enabled: blur > 0.25,
+ imageFilter: ImageFilter.blur(sigmaX: blur, sigmaY: blur, tileMode: TileMode.decal),
+ child: Transform.translate(
+ offset: shift,
+ child: Transform.scale(scale: incoming ? 1 + 0.03 * away : 1 - 0.04 * away, child: inner),
+ ),
+ ),
+ );
+ },
);
},
layoutBuilder: (currentChild, previousChildren) => Stack(
children: <Widget>[
- for (final c in previousChildren) Positioned.fill(child: c),
- if (currentChild != null) Positioned.fill(child: currentChild),
+ for (final c in previousChildren) Positioned.fill(key: c.key, child: c),
+ if (currentChild != null) Positioned.fill(key: currentChild.key, child: currentChild),
],
),
child: KeyedSubtree(key: ValueKey(fit.route), child: _screen()),
@@ -296,81 +406,142 @@ final _overlayLight = _overlayBase.copyWith(
systemNavigationBarIconBrightness: Brightness.dark,
);
-class _NavBar extends StatelessWidget {
+class _NavBar extends StatefulWidget {
const _NavBar();
+ @override
+ State<_NavBar> createState() => _NavBarState();
+}
+
+class _NavBarState extends State<_NavBar> {
static const _iw = 58.0;
static const _fabW = 54.0;
static const _routes = ['home', 'progress', 'exercises', 'settings'];
+ double? _dragX;
+ int? _hover;
+ double _slotW = 0;
+ double _gap = 0;
+
int get _selectedIndex {
+ if (_hover != null) return _hover!;
final i = _routes.indexOf(fit.route);
return i < 0 ? 0 : i;
}
+ double _slotX(int i) => switch (i) {
+ 0 => 0,
+ 1 => _iw + _gap,
+ 2 => 2 * _iw + 3 * _gap + _fabW,
+ _ => 3 * _iw + 4 * _gap + _fabW,
+ };
+
+ void _go(int i) => [fit.goHome, fit.goProgress, fit.goExercises, fit.goSettings][i]();
+
+ int _nearest(double x) {
+ var best = 0;
+ for (var i = 1; i < 4; i++) {
+ if ((_slotX(i) + _iw / 2 - x).abs() < (_slotX(best) + _iw / 2 - x).abs()) best = i;
+ }
+ return best;
+ }
+
+ void _dragTo(double x) {
+ final near = _nearest(x);
+ if (near != _hover) HapticFeedback.selectionClick();
+ setState(() {
+ _dragX = x.clamp(_iw / 2, _slotW - _iw / 2);
+ _hover = near;
+ });
+ }
+
+ void _dragEnd() {
+ final target = _hover;
+ setState(() {
+ _dragX = null;
+ _hover = null;
+ });
+ if (target != null && target != _routes.indexOf(fit.route)) _go(target);
+ }
+
@override
Widget build(BuildContext context) {
final gc = context.gc;
- return Container(
+ return SizedBox(
height: 74,
- decoration: BoxDecoration(
- color: gc.bgRaised,
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(28),
- boxShadow: [BoxShadow(color: const Color(0x59000000), blurRadius: 32, offset: const Offset(0, 12))],
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: LayoutBuilder(
- builder: (context, c) {
- final w = c.maxWidth;
- final gap = ((w - 4 * _iw - _fabW) / 4).clamp(0.0, 40.0);
-
- double slotX(int i) {
- switch (i) {
- case 0:
- return 0;
- case 1:
- return _iw + gap;
- case 2:
- return 2 * _iw + 3 * gap + _fabW;
- default:
- return 3 * _iw + 4 * gap + _fabW;
- }
- }
+ child: LayoutBuilder(
+ builder: (context, c) {
+ _slotW = c.maxWidth - 16;
+ _gap = ((_slotW - 4 * _iw - _fabW) / 4).clamp(0.0, 40.0);
+ final drag = _dragX;
- return Stack(
- alignment: Alignment.center,
- children: [
- AnimatedPositioned(
- duration: const Duration(milliseconds: 340),
- curve: Curves.easeOutCubic,
- left: slotX(_selectedIndex),
- top: 10,
- bottom: 10,
- width: _iw,
- child: DecoratedBox(
- decoration: BoxDecoration(
- color: gc.bgRaised2,
- borderRadius: BorderRadius.circular(18),
- ),
+ return Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned.fill(
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(28),
+ boxShadow: [
+ BoxShadow(color: const Color(0x4D000000), blurRadius: 32, offset: const Offset(0, 12)),
+ ],
),
+ child: const GlassSurface(radius: 28, blur: 16, child: SizedBox.expand()),
),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- _item(context, 0, PhosphorIconsRegular.house, PhosphorIconsFill.house, t.home, fit.goHome),
- _item(context, 1, PhosphorIconsRegular.chartLineUp, PhosphorIconsFill.chartLineUp, t.progress, fit.goProgress),
- _fab(context),
- _item(context, 2, PhosphorIconsRegular.barbell, PhosphorIconsFill.barbell, t.exercises, fit.goExercises),
- _item(context, 3, PhosphorIconsRegular.userCircle, PhosphorIconsFill.userCircle, t.profile, fit.goSettings),
- ],
+ ),
+ Positioned(
+ left: 8,
+ right: 8,
+ top: 0,
+ bottom: 0,
+ child: _LiquidPill(
+ left: _slotX(_selectedIndex),
+ dragLeft: drag == null ? null : drag - _iw / 2,
+ width: _iw,
+ color: gc.text.withValues(alpha: fit.dark ? 0.1 : 0.07),
),
- ],
- );
- },
- ),
+ ),
+ Positioned(
+ left: 8,
+ right: 8,
+ top: 0,
+ bottom: 0,
+ child: GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onHorizontalDragStart: (d) {
+ final fab = 2 * _iw + 2 * _gap + _fabW / 2;
+ if ((d.localPosition.dx - fab).abs() < _fabW / 2 + 4) return;
+ HapticFeedback.selectionClick();
+ _dragTo(d.localPosition.dx);
+ },
+ onHorizontalDragUpdate: (d) {
+ if (_dragX != null) _dragTo(d.localPosition.dx);
+ },
+ onHorizontalDragEnd: (_) {
+ if (_dragX != null) _dragEnd();
+ },
+ onHorizontalDragCancel: () {
+ if (_dragX != null) _dragEnd();
+ },
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ _item(context, 0, PhosphorIconsRegular.house, PhosphorIconsFill.house, t.home, fit.goHome),
+ _item(context, 1, PhosphorIconsRegular.chartLineUp, PhosphorIconsFill.chartLineUp, t.progress,
+ fit.goProgress),
+ _fab(context),
+ _item(context, 2, PhosphorIconsRegular.barbell, PhosphorIconsFill.barbell, t.exercises,
+ fit.goExercises),
+ _item(context, 3, PhosphorIconsRegular.userCircle, PhosphorIconsFill.userCircle, t.profile,
+ fit.goSettings),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ },
),
);
}
@@ -378,13 +549,27 @@ class _NavBar extends StatelessWidget {
Widget _item(BuildContext context, int index, IconData icon, IconData iconFill, String label, VoidCallback onTap) {
final gc = context.gc;
final selected = _selectedIndex == index;
+ final lifted = selected && _dragX != null;
final color = selected ? gc.text : gc.textTertiary;
const dur = Duration(milliseconds: 300);
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
- child: SizedBox(
+ onLongPressStart: (d) {
+ HapticFeedback.mediumImpact();
+ _dragTo(_slotX(index) + d.localPosition.dx);
+ },
+ onLongPressMoveUpdate: (d) => _dragTo(_slotX(index) + d.localPosition.dx),
+ onLongPressEnd: (_) => _dragEnd(),
+ onLongPressCancel: () {
+ if (_dragX != null) _dragEnd();
+ },
+ child: AnimatedScale(
+ scale: lifted ? 1.06 : 1,
+ duration: const Duration(milliseconds: 220),
+ curve: Curves.easeOutCubic,
+ child: SizedBox(
width: _iw,
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -415,6 +600,7 @@ class _NavBar extends StatelessWidget {
],
),
),
+ ),
);
}
@@ -451,3 +637,109 @@ class _NavBar extends StatelessWidget {
);
}
}
+
+class _LiquidPill extends StatefulWidget {
+ const _LiquidPill({required this.left, required this.width, required this.color, this.dragLeft});
+
+ final double left;
+ final double? dragLeft;
+ final double width;
+ final Color color;
+
+ @override
+ State<_LiquidPill> createState() => _LiquidPillState();
+}
+
+class _LiquidPillState extends State<_LiquidPill> with TickerProviderStateMixin {
+ late final AnimationController _move =
+ AnimationController(vsync: this, duration: const Duration(milliseconds: 460), value: 1);
+ late final AnimationController _lift = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 260),
+ reverseDuration: const Duration(milliseconds: 380),
+ );
+ late double _from = widget.left;
+ late double _shown = widget.left;
+
+ @override
+ void didUpdateWidget(_LiquidPill old) {
+ super.didUpdateWidget(old);
+ final dragging = widget.dragLeft != null;
+ if (dragging != (old.dragLeft != null)) {
+ dragging ? _lift.forward() : _lift.reverse();
+ }
+ if (dragging) return;
+ if (old.left == widget.left && old.dragLeft == null) return;
+ _from = _shown;
+ _move.forward(from: 0);
+ }
+
+ static double _lerp(double a, double b, double t) => a + (b - a) * t;
+
+ static const _liftCurve = Cubic(0.3, 1.25, 0.5, 1);
+
+ @override
+ void dispose() {
+ _move.dispose();
+ _lift.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return AnimatedBuilder(
+ animation: Listenable.merge([_move, _lift]),
+ builder: (context, _) {
+ final lift = _liftCurve.transform(_lift.value.clamp(0.0, 1.0));
+ final double l, r;
+ var squash = 1.0;
+ final drag = widget.dragLeft;
+ if (drag != null) {
+ l = drag;
+ r = drag + widget.width;
+ } else {
+ final t = _move.value;
+ final to = widget.left;
+ final right = to >= _from;
+ final lead = Curves.easeOutCubic.transform(t);
+ final trail = Curves.easeInOutCubic.transform(t);
+ l = _lerp(_from, to, right ? trail : lead);
+ r = _lerp(_from + widget.width, to + widget.width, right ? lead : trail);
+ squash = 1 - 0.14 * (1 - (2 * t - 1).abs()) * (to == _from ? 0 : 1);
+ }
+ _shown = l;
+ final base = Color.lerp(widget.color, widget.color.withValues(alpha: (widget.color.a * 2.4).clamp(0.0, 1.0)), lift)!;
+ final grow = 6 * lift;
+ final inset = 10 + 12 * (1 - squash) - 6 * lift;
+ return Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned(
+ left: l - grow,
+ width: r - l + 2 * grow,
+ top: inset,
+ bottom: inset,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(24),
+ border: Border.all(color: Colors.white.withValues(alpha: 0.16 * lift), width: 1),
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ Color.alphaBlend(Colors.white.withValues(alpha: 0.12 * lift), base),
+ base,
+ ],
+ ),
+ boxShadow: lift <= 0
+ ? null
+ : [BoxShadow(color: Colors.black.withValues(alpha: 0.28 * lift), blurRadius: 22, offset: const Offset(0, 8))],
+ ),
+ ),
+ ),
+ ],
+ );
+ },
+ );
+ }
+}
diff --git a/lib/catalog/exercise_catalog.dart b/lib/catalog/exercise_catalog.dart
index cb03153..77c970a 100644
--- a/lib/catalog/exercise_catalog.dart
+++ b/lib/catalog/exercise_catalog.dart
@@ -8659,6 +8659,128 @@ const List<Exercise> kExercises = [
'Come down the same way, under control, one step at a time.',
],
),
+ Exercise(
+ id: 'plank-hold',
+ name: 'Plank',
+ primary: 'abdomen',
+ secondary: ['shoulders', 'glutes'],
+ equipment: 'Bodyweight',
+ difficulty: 'Beginner',
+ art: 'plank',
+ steps: [
+ 'Set your forearms on the floor, elbows under your shoulders.',
+ 'Step your feet back until your body is one straight line from head to heels.',
+ 'Squeeze your glutes and brace your abs.',
+ 'Keep your hips level, neither sagging nor piked up.',
+ 'Breathe steadily and hold for the time you set.',
+ ],
+ ),
+ Exercise(
+ id: 'side-plank-hold',
+ name: 'Side Plank',
+ primary: 'obliques',
+ secondary: ['abdomen', 'shoulders'],
+ equipment: 'Bodyweight',
+ difficulty: 'Beginner',
+ art: 'side-plank',
+ steps: [
+ 'Lie on your side with your elbow under your shoulder and your legs stacked.',
+ 'Lift your hips until your body forms a straight line.',
+ 'Keep your top hip stacked over the bottom one without rolling forward.',
+ 'Hold, breathing steadily, then switch sides.',
+ ],
+ ),
+ Exercise(
+ id: 'dead-hang-hold',
+ name: 'Dead Hang',
+ primary: 'forearm',
+ secondary: ['back', 'shoulders'],
+ equipment: 'Bodyweight',
+ difficulty: 'Beginner',
+ art: 'dead-hang',
+ steps: [
+ 'Grab a pull-up bar with an overhand grip, hands shoulder-width apart.',
+ 'Lift your feet and hang with straight arms.',
+ 'Let your shoulders stretch while keeping a light brace in your abs.',
+ 'Hold for the time you set, then step down under control.',
+ ],
+ ),
+ Exercise(
+ id: 'outdoor-run',
+ name: 'Outdoor Run',
+ primary: 'quads',
+ secondary: ['hamstrings', 'calves', 'glutes'],
+ equipment: 'Bodyweight',
+ difficulty: 'Beginner',
+ art: 'running',
+ steps: [
+ 'Start with five minutes of easy jogging to warm up.',
+ 'Run tall, with relaxed shoulders and a slight forward lean.',
+ 'Land under your hips with short, quick steps.',
+ 'Keep a pace you could hold a conversation at, unless it is an interval day.',
+ 'Finish with a few minutes of walking.',
+ ],
+ ),
+ Exercise(
+ id: 'outdoor-cycling',
+ name: 'Outdoor Cycling',
+ primary: 'quads',
+ secondary: ['glutes', 'hamstrings', 'calves'],
+ equipment: 'Other',
+ difficulty: 'Beginner',
+ art: 'cycling',
+ steps: [
+ 'Set the saddle so your knee stays slightly bent at the bottom of each pedal stroke.',
+ 'Start in an easy gear for the first few minutes.',
+ 'Keep a smooth cadence instead of mashing the pedals.',
+ 'Shift early on climbs to keep the effort steady.',
+ ],
+ ),
+ Exercise(
+ id: 'outdoor-walk',
+ name: 'Walk',
+ primary: 'quads',
+ secondary: ['calves', 'glutes'],
+ equipment: 'Bodyweight',
+ difficulty: 'Beginner',
+ art: 'walking',
+ steps: [
+ 'Walk tall with your shoulders relaxed and your arms swinging.',
+ 'Roll through each step from heel to toe.',
+ 'Pick a pace that raises your breathing without leaving you out of breath.',
+ ],
+ ),
+ Exercise(
+ id: 'outdoor-hike',
+ name: 'Hiking',
+ primary: 'glutes',
+ secondary: ['quads', 'calves', 'hamstrings'],
+ equipment: 'Bodyweight',
+ difficulty: 'Beginner',
+ art: 'treadmill-incline-walk',
+ steps: [
+ 'Wear shoes with good grip and bring water.',
+ 'Shorten your stride on steep climbs and keep a steady rhythm.',
+ 'Lean slightly into the slope going up and bend your knees going down.',
+ 'Take short breaks before you are exhausted, not after.',
+ ],
+ ),
+ Exercise(
+ id: 'swim',
+ name: 'Swimming',
+ primary: 'back',
+ secondary: ['shoulders', 'chest', 'triceps'],
+ equipment: 'Other',
+ difficulty: 'Intermediate',
+ art: 'swimming',
+ steps: [
+ 'Warm up with a few easy lengths.',
+ 'Keep your body long and flat, with your head in line with your spine.',
+ 'Reach forward on each stroke and pull the water back past your hips.',
+ 'Breathe to the side in rhythm with your strokes.',
+ 'Log the total distance and the time you spent swimming.',
+ ],
+ ),
];
const List<ToolMeta> kToolMeta = [
@@ -8682,3 +8804,46 @@ const List<String> kEquipment = [
const List<String> kFilterEquipment = [
'Bodyweight', 'Dumbbell', 'Barbell', 'Machine', 'Cable', 'Band', 'Kettlebell', 'Rings', 'Weighted'
];
+
+const Map<String, String> kExerciseModes = {
+ 'running': 'cardio',
+ 'walking': 'cardio',
+ 'treadmill-incline-walk': 'cardio',
+ 'cycling': 'cardio',
+ 'assault-bike': 'cardio',
+ 'elliptical': 'cardio',
+ 'rowing': 'cardio',
+ 'stair-climber': 'cardio',
+ 'jump-rope': 'time',
+ 'battle-ropes': 'time',
+ 'VBAWRPG': 'time',
+ 'active-hang': 'time',
+ 'superman-hold': 'time',
+ '5VXmnV5': 'time',
+ 'cable-pallof-hold': 'time',
+ 'hollow-body-hold': 'time',
+ 'bear-plank': 'time',
+ 'l-sit-hold': 'time',
+ 'wall-sit': 'time',
+ 'kettlebell-farmer-carry': 'time',
+ 'rNGclsi': 'time',
+ 'rNGdsup': 'time',
+ 'cat-cow-stretch': 'time',
+ 'doorway-chest-stretch': 'time',
+ 'cross-body-shoulder-stretch': 'time',
+ 'childs-pose': 'time',
+ 'standing-quad-stretch': 'time',
+ 'kneeling-hip-flexor-stretch': 'time',
+ 'butterfly-stretch': 'time',
+ 'wall-calf-stretch': 'time',
+ 'hamstring-stretch': 'time',
+ 'hiking': 'cardio',
+ 'plank-hold': 'time',
+ 'side-plank-hold': 'time',
+ 'dead-hang-hold': 'time',
+ 'outdoor-run': 'cardio',
+ 'outdoor-cycling': 'cardio',
+ 'outdoor-walk': 'cardio',
+ 'outdoor-hike': 'cardio',
+ 'swim': 'cardio',
+};
diff --git a/lib/catalog/program_templates.dart b/lib/catalog/program_templates.dart
index 4c34d6c..4750e3f 100644
--- a/lib/catalog/program_templates.dart
+++ b/lib/catalog/program_templates.dart
@@ -96,6 +96,69 @@ const List<ProgramTemplate> kProgramTemplates = [
('Standing Calf Raise', 4),
], weekday: 5),
]),
+ ProgramTemplate('abcd', 'ABCD Split', [
+ ProgramDay('A · Chest & Triceps', [
+ ('Barbell Bench Press', 4),
+ ('Incline Dumbbell Press', 3),
+ ('Cable Fly', 3),
+ ('Triceps Pushdown', 3),
+ ('Skull Crushers', 3),
+ ], weekday: 1),
+ ProgramDay('B · Back & Biceps', [
+ ('Pull Up', 4),
+ ('Barbell Row', 4),
+ ('Lat Pulldown', 3),
+ ('Barbell Curl', 3),
+ ('Hammer Curl', 3),
+ ], weekday: 2),
+ ProgramDay('C · Legs', [
+ ('Barbell Squat', 4),
+ ('Romanian Deadlift', 3),
+ ('Leg Press', 3),
+ ('Leg Curl', 3),
+ ('Standing Calf Raise', 4),
+ ], weekday: 4),
+ ProgramDay('D · Shoulders & Abs', [
+ ('Overhead Press', 4),
+ ('Lateral Raise', 3),
+ ('Face Pull', 3),
+ ('Hanging Leg Raise', 3),
+ ('Plank', 3),
+ ], weekday: 5),
+ ]),
+ ProgramTemplate('abcde', 'ABCDE Split', [
+ ProgramDay('A · Chest', [
+ ('Barbell Bench Press', 4),
+ ('Incline Dumbbell Press', 4),
+ ('Cable Fly', 3),
+ ('Triceps Dip', 3),
+ ], weekday: 1),
+ ProgramDay('B · Back', [
+ ('Deadlift', 3),
+ ('Pull Up', 4),
+ ('Barbell Row', 4),
+ ('Seated Cable Row', 3),
+ ], weekday: 2),
+ ProgramDay('C · Legs', [
+ ('Barbell Squat', 4),
+ ('Leg Press', 4),
+ ('Leg Extension', 3),
+ ('Leg Curl', 3),
+ ('Standing Calf Raise', 4),
+ ], weekday: 3),
+ ProgramDay('D · Shoulders', [
+ ('Overhead Press', 4),
+ ('Dumbbell Standing Overhead Press', 3),
+ ('Lateral Raise', 4),
+ ('Face Pull', 3),
+ ], weekday: 4),
+ ProgramDay('E · Arms', [
+ ('Barbell Curl', 4),
+ ('Skull Crushers', 4),
+ ('Hammer Curl', 3),
+ ('Triceps Pushdown', 3),
+ ], weekday: 5),
+ ]),
ProgramTemplate('stronglifts', 'StrongLifts 5×5', [
ProgramDay('Workout A', [
('Barbell Squat', 5),
diff --git a/lib/main.dart b/lib/main.dart
index 795cd24..477651b 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -4,11 +4,15 @@ import 'package:intl/date_symbol_data_local.dart';
import 'app/gymmane_app.dart';
import 'services/alarm_store.dart';
+import 'services/device_kind.dart';
import 'services/home_widget_bridge.dart';
+import 'services/live_workout.dart';
import 'services/local_store.dart';
import 'services/media_store.dart';
import 'services/rest_alarm.dart';
+import 'services/screen_awake.dart';
import 'state/fit_state.dart';
+import 'wear/wear_app.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
@@ -30,8 +34,23 @@ Future<void> main() async {
fit.syncPhotoReminder();
fit.syncTrainReminder();
+ final watch = await DeviceKind.isWatch();
+ fit.addListener(_sessionSideEffects);
+ _sessionSideEffects();
+
+ if (watch) {
+ runApp(const WearApp());
+ return;
+ }
+
fit.onWidgetsShouldUpdate = HomeWidgetBridge.update;
runApp(const GymManeApp());
WidgetsBinding.instance.addPostFrameCallback((_) => HomeWidgetBridge.update());
}
+
+void _sessionSideEffects() {
+ LiveWorkout.sync();
+ final live = fit.isSessionActive && fit.session?.manual == false;
+ ScreenAwake.keepOn(fit.keepScreenOn && live);
+}
diff --git a/lib/models/exercise.dart b/lib/models/exercise.dart
index 8ca68da..26febc0 100644
--- a/lib/models/exercise.dart
+++ b/lib/models/exercise.dart
@@ -17,6 +17,7 @@ class Exercise {
required this.difficulty,
required this.art,
required this.steps,
+ this.mode = '',
});
final String id;
final String name;
@@ -26,6 +27,27 @@ class Exercise {
final String difficulty;
final String art;
final List<String> steps;
+ final String mode;
+
+ Exercise copyWith({
+ String? name,
+ String? primary,
+ String? equipment,
+ String? difficulty,
+ List<String>? steps,
+ String? mode,
+ }) =>
+ Exercise(
+ id: id,
+ name: name ?? this.name,
+ primary: primary ?? this.primary,
+ secondary: secondary,
+ equipment: equipment ?? this.equipment,
+ difficulty: difficulty ?? this.difficulty,
+ art: art,
+ steps: steps ?? this.steps,
+ mode: mode ?? this.mode,
+ );
Map<String, dynamic> toJson() => {
'id': id,
@@ -33,6 +55,8 @@ class Exercise {
'p': primary,
'e': equipment,
'd': difficulty,
+ if (steps.isNotEmpty) 'st': steps,
+ if (mode.isNotEmpty) 'k': mode,
};
factory Exercise.fromJson(Map<String, dynamic> j) => Exercise(
id: j['id'] as String,
@@ -42,10 +66,13 @@ class Exercise {
equipment: (j['e'] as String?) ?? 'Other',
difficulty: (j['d'] as String?) ?? 'Beginner',
art: '',
- steps: const [],
+ steps: ((j['st'] as List?) ?? const []).whereType<String>().toList(),
+ mode: kExerciseModeIds.contains(j['k']) ? j['k'] as String : '',
);
}
+const List<String> kExerciseModeIds = ['cardio', 'time'];
+
class ToolMeta {
const ToolMeta(this.id, this.name, this.desc);
final String id;
diff --git a/lib/screens/about_screen.dart b/lib/screens/about_screen.dart
index 8588d43..f7b19c9 100644
--- a/lib/screens/about_screen.dart
+++ b/lib/screens/about_screen.dart
@@ -7,9 +7,10 @@ import '../l10n/l10n.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/entrance.dart';
import '../widgets/ui_kit.dart';
-const _kVersion = '1.2.0';
+const _kVersion = '1.3.0';
const _kAuthor = 'InlitX';
const _kAuthorUrl = 'https://github.com/InlitX';
const _kRepoUrl = 'https://github.com/InlitX/GymMane';
@@ -21,13 +22,17 @@ class AboutScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final gc = context.gc;
- return SafeArea(
+ return RiseScope(
+ id: 'about',
+ once: false,
+ child: SafeArea(
bottom: false,
child: SingleChildScrollView(
+ clipBehavior: Clip.none,
padding: const EdgeInsets.fromLTRB(20, 12, 20, 36),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
+ children: riseAll([
ScreenHeader(
title: t.about,
onBack: fit.backFromAbout,
@@ -57,9 +62,10 @@ class AboutScreen extends StatelessWidget {
style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textTertiary, height: 1.6)),
const SizedBox(height: 20),
_credits(gc),
- ],
+ ]),
),
),
+ ),
);
}
diff --git a/lib/screens/awards_screen.dart b/lib/screens/awards_screen.dart
index 5db62e8..a5ec506 100644
--- a/lib/screens/awards_screen.dart
+++ b/lib/screens/awards_screen.dart
@@ -21,6 +21,7 @@ class AwardsScreen extends StatelessWidget {
return SafeArea(
bottom: false,
child: SingleChildScrollView(
+ clipBehavior: Clip.none,
padding: const EdgeInsets.fromLTRB(20, 12, 20, 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
diff --git a/lib/screens/exercise_detail_screen.dart b/lib/screens/exercise_detail_screen.dart
index 062cabc..8fb3e15 100644
--- a/lib/screens/exercise_detail_screen.dart
+++ b/lib/screens/exercise_detail_screen.dart
@@ -9,10 +9,15 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/charts.dart';
+import '../widgets/entrance.dart';
import '../widgets/exercise_media.dart';
+import '../widgets/ruler_picker.dart';
+import '../widgets/glass.dart';
import '../widgets/stopwatch_card.dart';
import '../widgets/svg_icon.dart';
+import '../widgets/timer_panel.dart';
import '../widgets/ui_kit.dart';
+import 'exercises_screen.dart' show showCreateExerciseSheet;
class ExerciseDetailScreen extends StatefulWidget {
const ExerciseDetailScreen({super.key});
@@ -47,14 +52,20 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
final history = fit.exerciseHistory(ex.id);
final hasMedia = fit.hasCustomMedia(ex.id);
final repsOnly = fit.isRepsOnly(ex.id);
+ final mode = fit.modeOf(ex.id);
+ final custom = fit.isCustom(ex.id);
- return SafeArea(
+ return RiseScope(
+ id: 'exercise',
+ once: false,
+ child: SafeArea(
bottom: false,
child: SingleChildScrollView(
+ clipBehavior: Clip.none,
padding: const EdgeInsets.only(top: 12, bottom: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
+ children: riseAll([
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 16),
child: Row(
@@ -62,7 +73,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
children: [
RoundBtn(icon: Ic.chevronLeft, onTap: fit.closeExerciseDetail),
Row(children: [
- if (fit.isCustom(ex.id)) ...[
+ if (custom) ...[
RoundAction(
onTap: () {
fit.closeExerciseDetail();
@@ -71,6 +82,15 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.textSecondary),
),
const SizedBox(width: 10),
+ Semantics(
+ button: true,
+ label: t.editExercise,
+ child: RoundAction(
+ onTap: () => showCreateExerciseSheet(context, editing: ex),
+ child: Icon(PhosphorIconsRegular.pencilSimple, size: 16, color: gc.textSecondary),
+ ),
+ ),
+ const SizedBox(width: 10),
],
RoundAction(
onTap: () => fit.toggleFavorite(ex.id),
@@ -131,9 +151,18 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
),
const SizedBox(height: 18),
_group(gc, [
- _repsOnlyRow(gc, ex.id, repsOnly),
+ _modeRow(context, gc, ex.id, mode),
+ if (mode != 'cardio') _repsOnlyRow(gc, ex.id, repsOnly),
_restRow(gc, ex.id),
- if (!repsOnly) ...[
+ _switchRow(
+ gc,
+ PhosphorIconsRegular.sparkle,
+ t.suggestInWorkouts,
+ t.suggestInWorkoutsHint,
+ fit.suggests(ex.id),
+ () => fit.toggleSuggest(ex.id),
+ ),
+ if (!repsOnly && mode.isEmpty) ...[
_progressRow(gc, ex.id),
_switchRow(
gc,
@@ -148,7 +177,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
const SizedBox(height: 20),
const StopwatchCard(),
const SizedBox(height: 20),
- if (pr != null) ...[
+ if (pr != null && mode.isEmpty) ...[
Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
@@ -180,7 +209,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
),
if (oneRm.length > 2) ...[
const SizedBox(height: 16),
- Sparkline(values: oneRm, height: 52, color: gc.accent),
+ TrendChart(values: [for (final v in oneRm) fit.toDisplayWeight(v)], height: 84, scale: fmt),
],
],
),
@@ -198,13 +227,42 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary))
else
for (int i = 0; i < history.length && i < 8; i++)
- _historyRow(gc, history[i], i < history.length - 1 && i < 7),
+ _historyRow(gc, history[i], i < history.length - 1 && i < 7, mode),
const SizedBox(height: 24),
_notesRow(gc, ex.id),
const SizedBox(height: 24),
- if (steps.isNotEmpty) ...[
- _section(gc, t.howTo),
+ if (steps.isNotEmpty || custom) ...[
+ Row(children: [
+ Expanded(child: _section(gc, t.howTo)),
+ if (custom && steps.isNotEmpty)
+ Semantics(
+ button: true,
+ label: t.editExercise,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => showCreateExerciseSheet(context, editing: ex),
+ child: Padding(
+ padding: const EdgeInsets.all(6),
+ child: Icon(PhosphorIconsRegular.pencilSimple, size: 17, color: gc.textTertiary),
+ ),
+ ),
+ ),
+ ]),
const SizedBox(height: 14),
+ if (steps.isEmpty) ...[
+ Text(t.noStepsYet,
+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary, height: 1.45)),
+ const SizedBox(height: 12),
+ Align(
+ alignment: Alignment.centerLeft,
+ child: Pill(
+ label: t.addSteps,
+ bg: gc.bgRaised2,
+ fg: gc.accent,
+ onTap: () => showCreateExerciseSheet(context, editing: ex),
+ ),
+ ),
+ ],
for (int i = 0; i < steps.length; i++) ...[
_step(gc, i + 1, steps[i]),
if (i < steps.length - 1) const SizedBox(height: 14),
@@ -223,9 +281,10 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
],
),
),
- ],
+ ]),
),
),
+ ),
);
}
@@ -271,11 +330,50 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
final rpe = e.sets.map((s) => s.rpe).whereType<double>().toList();
final sets = t.setCount(e.sets.length);
if (rpe.isEmpty) return sets;
- return '$sets · RPE ${fmt(rpe.reduce((a, b) => a > b ? a : b))}';
+ return '$sets · ${fit.effortLabel(rpe.reduce((a, b) => a > b ? a : b))}';
+ }
+
+ String _bestOf(LoggedExercise e, String mode) {
+ final working = e.workingSets;
+ if (working.isEmpty) return '';
+ if (mode == 'cardio') {
+ final km = working.fold<double>(0, (s, x) => s + (x.km ?? 0));
+ return km > 0
+ ? fit.distanceLabel(km)
+ : durationLabel(working.fold<int>(0, (s, x) => s + (x.sec ?? 0)));
+ }
+ return durationLabel(working.fold<int>(0, (s, x) => (x.sec ?? 0) > s ? x.sec! : s));
}
- Widget _historyRow(GymColors gc, ({DateTime date, LoggedExercise ex}) h, bool border) {
+ Widget _historyRow(GymColors gc, ({DateTime date, LoggedExercise ex}) h, bool border, String mode) {
final e = h.ex;
+ if (mode.isNotEmpty) {
+ return Container(
+ padding: const EdgeInsets.symmetric(vertical: 13),
+ decoration: BoxDecoration(
+ border: border ? Border(bottom: BorderSide(color: gc.border.withValues(alpha: 0.55))) : null,
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(_fmtDate(h.date), style: AppTheme.f(14.5, weight: FontWeight.w600, color: gc.text)),
+ const SizedBox(height: 3),
+ Text(fit.setsSummary(e.sets),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),
+ ],
+ ),
+ ),
+ const SizedBox(width: 12),
+ Text(_bestOf(e, mode), style: AppTheme.f(17, weight: FontWeight.w700, color: gc.text)),
+ ],
+ ),
+ );
+ }
return Container(
padding: const EdgeInsets.symmetric(vertical: 13),
decoration: BoxDecoration(
@@ -497,6 +595,18 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
btnRadius: 10,
onDec: () => fit.setExerciseRest(id, seconds - 15),
onInc: () => fit.setExerciseRest(id, seconds + 15),
+ onEdit: () async {
+ final v = await askRuler(context,
+ title: t.restForExercise,
+ value: seconds.toDouble(),
+ min: 0,
+ max: 600,
+ step: 5,
+ majorEvery: 6,
+ format: (v) => clockLabel(v.round()),
+ tickLabel: (v) => clockLabel(v.round()));
+ if (v != null) fit.setExerciseRest(id, v.round());
+ },
),
],
),
@@ -683,6 +793,86 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
);
}
+ String _modeName(String mode) => switch (mode) {
+ 'cardio' => t.typeCardio,
+ 'time' => t.typeTime,
+ _ => t.typeReps,
+ };
+
+ Widget _modeRow(BuildContext context, GymColors gc, String id, String mode) {
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _pickMode(context, id),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
+ child: Row(
+ children: [
+ _rowIcon(gc, mode == 'cardio' ? PhosphorIconsRegular.personSimpleRun : PhosphorIconsRegular.listNumbers,
+ mode.isNotEmpty),
+ Expanded(
+ child: Text(t.exerciseTypeLabel,
+ style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text)),
+ ),
+ Text(_modeName(mode), style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary)),
+ const SizedBox(width: 6),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ],
+ ),
+ ),
+ );
+ }
+
+ void _pickMode(BuildContext context, String id) {
+ showAppSheet<void>(
+ context: context,
+ backgroundColor: Colors.transparent,
+ builder: (sheet) => AnimatedBuilder(
+ animation: fit,
+ builder: (sheet, _) {
+ final gc = sheet.gc;
+ final now = fit.modeOf(id);
+ return Container(
+ padding: sheetPad(sheet),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SheetHandle(),
+ const SizedBox(height: 16),
+ SheetTitle(t.exerciseTypeLabel),
+ const SizedBox(height: 14),
+ OptionGroup([
+ for (final (value, icon) in [
+ ('', PhosphorIconsRegular.barbell),
+ ('time', PhosphorIconsRegular.timer),
+ ('cardio', PhosphorIconsRegular.personSimpleRun),
+ ])
+ OptionItem(
+ _modeName(value),
+ icon: icon,
+ selected: now == value,
+ onTap: () {
+ fit.setExerciseMode(id, value);
+ Navigator.of(sheet).pop();
+ },
+ ),
+ ]),
+ const SizedBox(height: 12),
+ Text(t.exerciseTypeHint,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary, height: 1.4)),
+ ],
+ ),
+ );
+ },
+ ),
+ );
+ }
+
Widget _mediaBtn(GymColors gc, IconData icon, String semantic, VoidCallback onTap) {
return Semantics(
button: true,
diff --git a/lib/screens/exercises_screen.dart b/lib/screens/exercises_screen.dart
index 6eb537e..2aed5f2 100644
--- a/lib/screens/exercises_screen.dart
+++ b/lib/screens/exercises_screen.dart
@@ -12,6 +12,7 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/exercise_media.dart';
+import '../widgets/glass.dart';
import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
@@ -290,16 +291,19 @@ class _FilterChipData {
final VoidCallback onTap;
}
-void showCreateExerciseSheet(BuildContext context, {void Function(String id)? onCreated}) {
+void showCreateExerciseSheet(BuildContext context,
+ {void Function(String id)? onCreated, Exercise? editing}) {
final gc = context.gc;
- final nameCtrl = TextEditingController();
- String muscle = kMuscles.first.id;
- String equipment = kEquipment.first;
- String difficulty = kDifficulties.first;
+ final nameCtrl = TextEditingController(text: editing?.name ?? '');
+ final stepsCtrl = TextEditingController(text: editing?.steps.join('\n') ?? '');
+ String muscle = editing?.primary ?? kMuscles.first.id;
+ String equipment = editing?.equipment ?? kEquipment.first;
+ String difficulty = editing?.difficulty ?? kDifficulties.first;
+ String mode = editing?.mode ?? '';
bool advanced = false;
String? mediaPath;
bool busy = false;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
isScrollControlled: true,
backgroundColor: gc.bgRaised,
@@ -324,12 +328,12 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Text(titleCase(t.newExercise),
+ Text(titleCase(editing == null ? t.newExercise : t.editExercise),
style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text)),
const SizedBox(height: 16),
TextField(
controller: nameCtrl,
- autofocus: true,
+ autofocus: editing == null,
style: AppTheme.f(15, weight: FontWeight.w500, color: gc.text),
cursorColor: gc.accent,
textCapitalization: TextCapitalization.words,
@@ -388,6 +392,48 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
),
]),
const SizedBox(height: 16),
+ _filterLabel(gc, t.exerciseTypeLabel),
+ const SizedBox(height: 8),
+ Wrap(spacing: 8, runSpacing: 8, children: [
+ for (final (id, label) in [
+ ('', t.typeReps),
+ ('time', t.typeTime),
+ ('cardio', t.typeCardio),
+ ])
+ Pill(
+ label: label,
+ bg: mode == id ? gc.ember : gc.bgRaised2,
+ fg: mode == id ? gc.onEmber : gc.textSecondary,
+ onTap: () => setSheet(() => mode = id),
+ vPad: 7,
+ fontSize: 12,
+ ),
+ ]),
+ const SizedBox(height: 16),
+ _filterLabel(gc, t.howToLabel),
+ const SizedBox(height: 8),
+ TextField(
+ controller: stepsCtrl,
+ minLines: 3,
+ maxLines: 8,
+ keyboardType: TextInputType.multiline,
+ textCapitalization: TextCapitalization.sentences,
+ style: AppTheme.f(14, weight: FontWeight.w500, color: gc.text, height: 1.45),
+ cursorColor: gc.accent,
+ decoration: InputDecoration(
+ hintText: t.howToHint,
+ hintStyle: AppTheme.f(14, weight: FontWeight.w500, color: gc.textTertiary),
+ filled: true,
+ fillColor: gc.bgRaised2,
+ contentPadding: const EdgeInsets.all(14),
+ enabledBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(14), borderSide: BorderSide(color: gc.border)),
+ focusedBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(14), borderSide: BorderSide(color: gc.accent)),
+ ),
+ ),
+ const SizedBox(height: 16),
+ if (editing == null)
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => setSheet(() => advanced = !advanced),
@@ -479,12 +525,29 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
],
const SizedBox(height: 20),
PrimaryButton(
- label: t.addExercise,
+ label: editing == null ? t.addExercise : t.saveChanges,
onTap: () async {
if (busy || nameCtrl.text.trim().isEmpty) return;
busy = true;
+ final steps = stepsCtrl.text.split('\n');
+ if (editing != null) {
+ fit.updateCustomExercise(editing.id,
+ name: nameCtrl.text,
+ primary: muscle,
+ equipment: equipment,
+ difficulty: difficulty,
+ steps: steps,
+ mode: mode);
+ Navigator.pop(sheetCtx);
+ return;
+ }
final id = fit.addCustomExercise(
- name: nameCtrl.text, primary: muscle, equipment: equipment, difficulty: difficulty);
+ name: nameCtrl.text,
+ primary: muscle,
+ equipment: equipment,
+ difficulty: difficulty,
+ steps: steps,
+ mode: mode);
if (mediaPath != null) {
await fit.attachExerciseMedia(id, mediaPath!);
}
@@ -515,7 +578,7 @@ void _clearFilters(VoidCallback? onClear) {
void showExerciseFilters(BuildContext context, {VoidCallback? onClear}) {
final gc = context.gc;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index a07794f..600ae37 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -7,9 +7,13 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/charts.dart';
+import '../widgets/entrance.dart';
import '../widgets/exercise_media.dart';
+import '../widgets/glass.dart';
+import '../widgets/home_folder.dart';
import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
+import 'progress_screen.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@@ -19,18 +23,21 @@ class HomeScreen extends StatelessWidget {
final gc = context.gc;
final recommended = fit.recommendedExercises(8);
- return SafeArea(
+ return RiseScope(
+ id: 'home',
+ child: SafeArea(
bottom: false,
child: SingleChildScrollView(
+ clipBehavior: Clip.none,
padding: const EdgeInsets.fromLTRB(20, 14, 20, 116),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
+ children: riseAll([
_topBar(gc),
const SizedBox(height: 20),
_hero(context, gc),
const SizedBox(height: 14),
- _weekCard(gc),
+ _weekCard(context, gc),
if (fit.photoDue) ...[
const SizedBox(height: 14),
_photoNudge(gc),
@@ -45,7 +52,10 @@ class HomeScreen extends StatelessWidget {
SoftCard(
radius: 22,
padding: const EdgeInsets.fromLTRB(18, 18, 18, 16),
- child: Heatmap(levels: fit.heatmapLevels, mono: true),
+ child: Heatmap(
+ levels: fit.heatmapLevels,
+ onTapDay: (i) => showDaySheet(context, fit.heatmapDate(i)),
+ ),
),
if (recommended.isNotEmpty) ...[
const SizedBox(height: 30),
@@ -63,22 +73,40 @@ class HomeScreen extends StatelessWidget {
],
const SizedBox(height: 30),
Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
- child: _tile(gc, PhosphorIconsRegular.listChecks, t.routines, fit.goRoutines),
+ child: HomeFolder(
+ title: _tc(t.routines),
+ detail: t.routineCount(fit.routines.length),
+ peek: const RoutinesPeek(),
+ onTap: fit.goRoutines,
+ ),
),
- const SizedBox(width: 12),
- Expanded(child: _tile(gc, PhosphorIconsRegular.wrench, t.tools, fit.goTools)),
- const SizedBox(width: 12),
+ const SizedBox(width: 10),
Expanded(
- child: _tile(gc, PhosphorIconsRegular.notebook, t.journal, fit.goNotes,
- badge: fit.notes.length),
+ child: HomeFolder(
+ title: _tc(t.tools),
+ detail: t.calculatorsInside,
+ peek: const ToolsPeek(),
+ onTap: fit.goTools,
+ ),
+ ),
+ const SizedBox(width: 10),
+ Expanded(
+ child: HomeFolder(
+ title: _tc(t.journal),
+ detail: t.noteCount(fit.notes.length),
+ peek: const NotesPeek(),
+ onTap: fit.goNotes,
+ ),
),
],
),
- ],
+ ]),
),
),
+ ),
);
}
@@ -161,11 +189,29 @@ class HomeScreen extends StatelessWidget {
child: Stack(
children: [
Positioned(
- right: -6,
- top: -2,
- bottom: 62,
+ left: -52,
+ top: 34,
+ child: Container(
+ width: 176,
+ height: 176,
+ decoration: BoxDecoration(color: gc.accentSoft, shape: BoxShape.circle),
+ ),
+ ),
+ Positioned(
+ left: 150,
+ top: -44,
+ child: Container(
+ width: 92,
+ height: 92,
+ decoration: BoxDecoration(color: gc.emberSoft, shape: BoxShape.circle),
+ ),
+ ),
+ Positioned(
+ right: 4,
+ top: 12,
+ bottom: 76,
child: Opacity(
- opacity: 0.45,
+ opacity: 0.6,
child: Image.asset('assets/img/runner.png', fit: BoxFit.fitHeight),
),
),
@@ -207,25 +253,29 @@ class HomeScreen extends StatelessWidget {
);
}
- Widget _weekCard(GymColors gc) {
+ Widget _weekCard(BuildContext context, GymColors gc) {
return SoftCard(
radius: 22,
padding: const EdgeInsets.fromLTRB(14, 16, 14, 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [for (int i = 0; i < 7; i++) _weekDay(gc, i)],
+ children: [for (int i = 0; i < 7; i++) _weekDay(context, gc, i)],
),
);
}
- Widget _weekDay(GymColors gc, int i) {
+ Widget _weekDay(BuildContext context, GymColors gc, int i) {
final done = fit.isDayDone(i);
final isToday = i == fit.todayIndex;
final isFuture = i > fit.todayIndex;
return GestureDetector(
behavior: HitTestBehavior.opaque,
- onTap: isFuture ? null : () => fit.toggleCheckin(i),
+ onTap: isFuture
+ ? null
+ : fit.isSessionDay(i)
+ ? () => showDaySheet(context, fit.dateForWeekday(i))
+ : () => fit.toggleCheckin(i),
child: Opacity(
opacity: isFuture ? 0.5 : 1,
child: Column(
@@ -306,10 +356,11 @@ class HomeScreen extends StatelessWidget {
textBaseline: TextBaseline.alphabetic,
children: [
Flexible(
- child: Text(value,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: AppTheme.f(23, weight: FontWeight.w800, color: gc.text)),
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.centerLeft,
+ child: RollIn(value, style: AppTheme.f(23, weight: FontWeight.w800, color: gc.text)),
+ ),
),
if (unit.isNotEmpty) ...[
const SizedBox(width: 3),
@@ -322,36 +373,6 @@ class HomeScreen extends StatelessWidget {
);
}
- Widget _tile(GymColors gc, IconData icon, String label, VoidCallback onTap, {int badge = 0}) {
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onTap,
- child: SoftCard(
- radius: 20,
- padding: const EdgeInsets.fromLTRB(14, 16, 14, 14),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Icon(icon, size: 20, color: gc.textSecondary),
- const Spacer(),
- if (badge > 0)
- Text('$badge',
- style: AppTheme.f(11, weight: FontWeight.w700, color: gc.textTertiary)),
- ],
- ),
- const SizedBox(height: 14),
- Text(_tc(label),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: AppTheme.f(13, weight: FontWeight.w700, color: gc.text)),
- ],
- ),
- ),
- );
- }
-
Widget _photoNudge(GymColors gc) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -412,7 +433,7 @@ class HomeScreen extends StatelessWidget {
void showWeeklyGoalSheet(BuildContext context) {
final gc = context.gc;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
builder: (sheet) => StatefulBuilder(
diff --git a/lib/screens/note_edit_screen.dart b/lib/screens/note_edit_screen.dart
index 91bb779..9fc7ab8 100644
--- a/lib/screens/note_edit_screen.dart
+++ b/lib/screens/note_edit_screen.dart
@@ -11,6 +11,7 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/dialogs.dart';
+import '../widgets/glass.dart';
import '../widgets/note_kit.dart';
import '../widgets/ui_kit.dart';
@@ -156,35 +157,43 @@ class _NoteEditScreenState extends State<NoteEditScreen> {
),
),
),
- const SizedBox(height: 22),
- _label(gc, t.noteDateLabel),
- _row(
- gc,
- icon: PhosphorIconsRegular.calendarBlank,
- value: t.shortDateYear(_date),
- onTap: _pickDate,
- ),
const SizedBox(height: 14),
- _label(gc, t.noteExerciseLabel),
- _row(
- gc,
- icon: PhosphorIconsRegular.barbell,
- value: exercise == null ? t.noteGeneral : exerciseName(exercise),
- muted: exercise == null,
- trailing: exercise == null
- ? null
- : Semantics(
- button: true,
- label: t.noteGeneral,
- child: GestureDetector(
- onTap: () => setState(() => _exerciseId = ''),
- child: Padding(
- padding: const EdgeInsets.all(6),
- child: Icon(PhosphorIconsBold.x, size: 14, color: gc.textTertiary),
- ),
- ),
- ),
- onTap: _pickExercise,
+ ClipRRect(
+ borderRadius: BorderRadius.circular(20),
+ child: ColoredBox(
+ color: gc.bgRaised,
+ child: Column(children: [
+ _row(
+ gc,
+ icon: PhosphorIconsRegular.calendarBlank,
+ label: t.noteDateLabel,
+ value: t.shortDateYear(_date),
+ onTap: _pickDate,
+ ),
+ Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border),
+ _row(
+ gc,
+ icon: PhosphorIconsRegular.barbell,
+ label: t.noteExerciseLabel,
+ value: exercise == null ? t.noteGeneral : exerciseName(exercise),
+ muted: exercise == null,
+ trailing: exercise == null
+ ? null
+ : Semantics(
+ button: true,
+ label: t.noteGeneral,
+ child: GestureDetector(
+ onTap: () => setState(() => _exerciseId = ''),
+ child: Padding(
+ padding: const EdgeInsets.all(6),
+ child: Icon(PhosphorIconsBold.x, size: 13, color: gc.textTertiary),
+ ),
+ ),
+ ),
+ onTap: _pickExercise,
+ ),
+ ]),
+ ),
),
const SizedBox(height: 22),
_label(gc, t.noteMediaLabel),
@@ -215,6 +224,7 @@ class _NoteEditScreenState extends State<NoteEditScreen> {
Widget _row(
GymColors gc, {
required IconData icon,
+ required String label,
required String value,
required VoidCallback onTap,
Widget? trailing,
@@ -223,23 +233,28 @@ class _NoteEditScreenState extends State<NoteEditScreen> {
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
- child: SoftCard(
- radius: 14,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
- child: Row(
- children: [
- Icon(icon, size: 17, color: gc.textSecondary),
- const SizedBox(width: 12),
- Expanded(
- child: Text(value,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: AppTheme.f(14,
- weight: FontWeight.w500, color: muted ? gc.textTertiary : gc.text)),
- ),
- trailing ??
- Icon(PhosphorIconsRegular.caretRight, size: 14, color: gc.textTertiary),
- ],
+ child: SizedBox(
+ height: 54,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Row(
+ children: [
+ Icon(icon, size: 19, color: gc.textSecondary),
+ const SizedBox(width: 14),
+ Text(sentenceCase(label), style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text)),
+ const SizedBox(width: 12),
+ Expanded(
+ child: Text(value,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.right,
+ style: AppTheme.f(13,
+ weight: FontWeight.w600, color: muted ? gc.textTertiary : gc.textSecondary)),
+ ),
+ const SizedBox(width: 6),
+ trailing ?? Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ],
+ ),
),
),
);
@@ -251,10 +266,12 @@ class _NoteEditScreenState extends State<NoteEditScreen> {
children: [
for (int i = 0; i < _media.length; i++)
GestureDetector(
- onTap: () => showNoteMedia(context, _media, i),
+ onTap: () => showNoteMedia(context, _media, i, scope: 'edit'),
child: NoteThumb(
name: _media[i],
size: 74,
+ natural: true,
+ scope: 'edit',
onRemove: () => setState(() => _media.removeAt(i)),
),
),
@@ -268,7 +285,7 @@ class _NoteEditScreenState extends State<NoteEditScreen> {
height: 74,
decoration: BoxDecoration(
color: gc.bgRaised,
- borderRadius: BorderRadius.circular(16),
+ borderRadius: BorderRadius.circular(18),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -286,18 +303,20 @@ class _NoteEditScreenState extends State<NoteEditScreen> {
}
Future<void> _pickExercise() async {
- final picked = await showModalBottomSheet<String>(
+ final picked = await showAppSheet<String>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
- builder: (_) => const _ExercisePickerSheet(),
+ builder: (_) => _ExercisePickerSheet(current: _exerciseId),
);
if (picked != null && mounted) setState(() => _exerciseId = picked);
}
}
class _ExercisePickerSheet extends StatefulWidget {
- const _ExercisePickerSheet();
+ const _ExercisePickerSheet({required this.current});
+
+ final String current;
@override
State<_ExercisePickerSheet> createState() => _ExercisePickerSheetState();
@@ -327,47 +346,42 @@ class _ExercisePickerSheetState extends State<_ExercisePickerSheet> {
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Container(
height: MediaQuery.of(context).size.height * 0.72,
+ padding: sheetPad(context, bottom: 16),
decoration: BoxDecoration(
- color: gc.bg,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(26)),
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
),
- clipBehavior: Clip.antiAlias,
child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- SheetHandle(color: gc.border, margin: const EdgeInsets.symmetric(vertical: 12)),
- Padding(
- padding: const EdgeInsets.fromLTRB(20, 0, 20, 12),
- child: TextField(
- controller: _q,
- autofocus: true,
- onChanged: (_) => setState(() {}),
- cursorColor: gc.accent,
- style: AppTheme.f(14, weight: FontWeight.w500, color: gc.text),
- decoration: InputDecoration(
- hintText: t.searchAllExercises,
- hintStyle: AppTheme.f(14, weight: FontWeight.w500, color: gc.textTertiary),
- filled: true,
- fillColor: gc.bgRaised,
- prefixIcon: Icon(PhosphorIconsRegular.magnifyingGlass, size: 17, color: gc.textTertiary),
- contentPadding: const EdgeInsets.symmetric(vertical: 12),
- enabledBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(14), borderSide: BorderSide(color: gc.border)),
- focusedBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(14), borderSide: BorderSide(color: gc.accent)),
- ),
- ),
+ const SheetHandle(),
+ const SizedBox(height: 16),
+ SheetTitle(sentenceCase(t.noteExerciseLabel)),
+ const SizedBox(height: 14),
+ SearchField(
+ controller: _q,
+ hint: t.searchAllExercises,
+ color: gc.bgRaised2,
+ onChanged: (_) => setState(() {}),
),
- Expanded(
- child: ListView.builder(
- padding: EdgeInsets.fromLTRB(20, 0, 20, 24 + MediaQuery.paddingOf(context).bottom),
- itemCount: results.length + 1,
- itemBuilder: (context, i) {
- if (i == 0) {
- return _tile(gc, t.noteGeneral, muted: true, onTap: () => Navigator.of(context).pop(''));
- }
- final ex = results[i - 1];
- return _tile(gc, exerciseName(ex), onTap: () => Navigator.of(context).pop(ex.id));
- },
+ const SizedBox(height: 12),
+ Flexible(
+ child: OptionGroup(
+ scroll: true,
+ [
+ OptionItem(
+ t.noteGeneral,
+ icon: PhosphorIconsRegular.notebook,
+ selected: widget.current.isEmpty,
+ onTap: () => Navigator.of(context).pop(''),
+ ),
+ for (final ex in results)
+ OptionItem(
+ exerciseName(ex),
+ selected: widget.current == ex.id,
+ onTap: () => Navigator.of(context).pop(ex.id),
+ ),
+ ],
),
),
],
@@ -375,17 +389,4 @@ class _ExercisePickerSheetState extends State<_ExercisePickerSheet> {
),
);
}
-
- Widget _tile(GymColors gc, String label, {required VoidCallback onTap, bool muted = false}) =>
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onTap,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 14),
- decoration: BoxDecoration(border: Border(bottom: BorderSide(color: gc.border))),
- child: Text(label,
- style: AppTheme.f(14,
- weight: FontWeight.w500, color: muted ? gc.textTertiary : gc.text)),
- ),
- );
}
diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dart
index c81771a..b19b89e 100644
--- a/lib/screens/profile_screen.dart
+++ b/lib/screens/profile_screen.dart
@@ -11,6 +11,7 @@ import '../services/media_store.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/entrance.dart';
import '../widgets/medal_shelf.dart';
import '../widgets/photo_source_sheet.dart';
import '../widgets/profile_avatar.dart';
@@ -78,7 +79,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
@override
Widget build(BuildContext context) {
final gc = context.gc;
- return CustomScrollView(
+ return RiseScope(
+ id: 'profile',
+ child: CustomScrollView(
slivers: [
SliverPersistentHeader(
pinned: true,
@@ -92,32 +95,48 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
SliverToBoxAdapter(
child: Padding(
- padding: const EdgeInsets.fromLTRB(20, 20, 0, 0),
- child: _stats(gc),
+ padding: const EdgeInsets.fromLTRB(20, 6, 0, 0),
+ child: Rise(index: 0, child: _stats(gc)),
),
),
SliverToBoxAdapter(
child: Padding(
- padding: const EdgeInsets.fromLTRB(20, 32, 20, 110),
+ padding: const EdgeInsets.fromLTRB(20, 24, 20, 110),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- _heading(gc, t.awardsTitle, count: '${fit.awardCount}', onMore: fit.goAwards),
- const SizedBox(height: 16),
- const MedalShelf(size: 66),
- const SizedBox(height: 34),
- _heading(gc, t.snapshots, onMore: fit.goMoments),
- const SizedBox(height: 16),
- _photoCards(gc),
- const SizedBox(height: 34),
- _heading(gc, t.yearTitle),
- const SizedBox(height: 16),
- _year(gc),
+ Rise(
+ index: 1,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ _heading(gc, t.awardsTitle, count: '${fit.awardCount}', onMore: fit.goAwards),
+ const SizedBox(height: 16),
+ const MedalShelf(size: 66),
+ ]),
+ ),
+ const SizedBox(height: 30),
+ Rise(
+ index: 2,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ _heading(gc, t.snapshots, onMore: fit.goMoments),
+ const SizedBox(height: 16),
+ _photoCards(gc),
+ ]),
+ ),
+ const SizedBox(height: 30),
+ Rise(
+ index: 3,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ _heading(gc, t.yearTitle),
+ const SizedBox(height: 16),
+ _year(gc),
+ ]),
+ ),
],
),
),
),
],
+ ),
);
}
@@ -153,13 +172,18 @@ class _ProfileScreenState extends State<ProfileScreen> {
for (var m = 1; m <= 12; m++) ...[
if (m > 1) const SizedBox(width: 5),
Expanded(
- child: Container(
- height: 6 + 52 * (months[m - 1] / peak),
- decoration: BoxDecoration(
- color: m == thisMonth
- ? gc.ember
- : (months[m - 1] > 0 ? gc.textTertiary : gc.bgRaised2),
- borderRadius: BorderRadius.circular(5),
+ child: TweenAnimationBuilder<double>(
+ tween: Tween(begin: 0, end: months[m - 1] / peak),
+ duration: Duration(milliseconds: 650 + m * 35),
+ curve: Curves.easeOutCubic,
+ builder: (context, v, _) => Container(
+ height: 6 + 52 * v,
+ decoration: BoxDecoration(
+ color: m == thisMonth
+ ? gc.ember
+ : (months[m - 1] > 0 ? gc.textTertiary : gc.bgRaised2),
+ borderRadius: BorderRadius.circular(5),
+ ),
),
),
),
@@ -208,7 +232,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
- Text(value, style: AppTheme.f(26, weight: FontWeight.w800, color: gc.text)),
+ RollIn(value, style: AppTheme.f(26, weight: FontWeight.w800, color: gc.text)),
if (unit.isNotEmpty)
Text(unit,
style: AppTheme.f(12.5, weight: FontWeight.w600, color: gc.textSecondary)),
@@ -271,7 +295,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
- Text(value, style: AppTheme.f(23, weight: FontWeight.w800, color: gc.text)),
+ RollIn(value, style: AppTheme.f(23, weight: FontWeight.w800, color: gc.text)),
if (unit.isNotEmpty) ...[
const SizedBox(width: 4),
Text(unit,
diff --git a/lib/screens/progress_screen.dart b/lib/screens/progress_screen.dart
index 7bf7960..ff91068 100644
--- a/lib/screens/progress_screen.dart
+++ b/lib/screens/progress_screen.dart
@@ -1,4 +1,5 @@
import 'dart:io';
+import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
@@ -13,6 +14,12 @@ import '../theme/app_theme.dart';
import '../widgets/body_map.dart';
import '../widgets/charts.dart';
import '../widgets/dialogs.dart';
+import '../widgets/entrance.dart';
+import '../widgets/exercise_media.dart';
+import '../widgets/glass.dart';
+import '../widgets/muscle_radar.dart';
+import '../widgets/rolling_text.dart';
+import '../widgets/ruler_picker.dart';
import '../widgets/ui_kit.dart';
import 'share_sheet.dart';
import 'start_sheet.dart';
@@ -28,13 +35,16 @@ class ProgressScreen extends StatelessWidget {
final prs = fit.personalRecords;
final bw = fit.bodyweightSeries;
- return SafeArea(
+ return RiseScope(
+ id: 'progress',
+ child: SafeArea(
bottom: false,
child: SingleChildScrollView(
+ clipBehavior: Clip.none,
padding: const EdgeInsets.fromLTRB(20, 12, 20, 110),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
+ children: riseAll([
Row(
children: [
Expanded(
@@ -70,6 +80,10 @@ class ProgressScreen extends StatelessWidget {
_totals(gc),
const SizedBox(height: 12),
const _MuscleMapCard(),
+ if (fit.sessions.isNotEmpty) ...[
+ const SizedBox(height: 12),
+ const MuscleRadarCard(),
+ ],
for (final block in _blocks(context, gc, bw, split, prs)) ...[
const SizedBox(height: 12),
block,
@@ -78,9 +92,10 @@ class ProgressScreen extends StatelessWidget {
const SizedBox(height: 12),
_setupCard(context, gc),
],
- ],
+ ]),
),
),
+ ),
);
}
@@ -121,7 +136,7 @@ class ProgressScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
- Text(value, style: AppTheme.f(28, weight: FontWeight.w800, color: gc.text)),
+ RollIn(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)),
@@ -171,7 +186,12 @@ class ProgressScreen extends StatelessWidget {
badge: change == null ? null : _delta(gc, change),
chart: fit.sessions.isEmpty
? const SizedBox(height: 40)
- : Sparkline(values: fit.volumeChartPoints, height: 40, color: gc.textSecondary),
+ : Sparkline(
+ values: [for (final v in fit.volumeChartPoints) fit.toDisplayWeight(v) / 1000],
+ height: 40,
+ color: gc.textSecondary,
+ scale: fmt,
+ ),
),
),
const SizedBox(width: 12),
@@ -190,7 +210,12 @@ class ProgressScreen extends StatelessWidget {
note: t.shortDate(weight.date),
chart: bw.length < 2
? const SizedBox(height: 40)
- : Sparkline(values: bw, height: 40, color: gc.textSecondary),
+ : Sparkline(
+ values: [for (final v in bw) fit.toDisplayWeight(v)],
+ height: 40,
+ color: gc.textSecondary,
+ scale: fmt,
+ ),
onTap: () => _logBodyweight(context),
),
),
@@ -433,33 +458,12 @@ class ProgressScreen extends StatelessWidget {
return [
if (fit.sessions.isNotEmpty) _thisWeek(gc),
if (fit.trackedExercises.isNotEmpty) _StrengthCard(),
- if (prs.isNotEmpty) _prCard(gc, prs),
+ if (prs.isNotEmpty) _PrCard(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.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;
@@ -470,15 +474,22 @@ class ProgressScreen extends StatelessWidget {
onTap: fit.goTimeline,
child: SoftCard(
radius: 20,
+ padding: const EdgeInsets.fromLTRB(18, 16, 18, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
+ Container(
+ width: 34,
+ height: 34,
+ decoration: BoxDecoration(color: gc.accentSoft, shape: BoxShape.circle),
+ child: Icon(PhosphorIconsBold.clockCounterClockwise, size: 16, color: gc.accent),
+ ),
+ const SizedBox(width: 11),
Expanded(
child: Text(t.timeline,
- style: AppTheme.d(14,
- weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
+ 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),
@@ -489,50 +500,110 @@ class ProgressScreen extends StatelessWidget {
Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
],
),
- const SizedBox(height: 14),
+ const SizedBox(height: 16),
if (last == null)
Text(t.timelineHint, style: AppTheme.s(13, color: gc.textSecondary, height: 1.5))
- else
+ else if (pair == null)
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)),
- ],
+ SizedBox(width: 66, child: _shotThumb(gc, last)),
+ const SizedBox(width: 12),
+ Expanded(child: _track(gc, [last.date], last.date, last.date, null)),
+ const SizedBox(width: 12),
+ SizedBox(
+ width: 66,
+ child: AspectRatio(
+ aspectRatio: 0.78,
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(12),
+ border: Border.all(color: gc.border, width: 1.4),
+ ),
+ child: Icon(PhosphorIconsRegular.plus, size: 16, color: gc.textTertiary),
),
),
- ] 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)),
+ ),
+ ],
+ )
+ else
+ Row(
+ children: [
+ SizedBox(width: 66, child: _shotThumb(gc, pair.from)),
+ const SizedBox(width: 12),
+ Expanded(
+ child: _track(
+ gc,
+ [for (final e in fit.timelineAsc) e.date],
+ pair.from.date,
+ pair.to.date,
+ t.daysApart(fit.compareDays),
),
- ],
+ ),
+ const SizedBox(width: 12),
+ SizedBox(width: 66, child: _shotThumb(gc, pair.to)),
+ ],
+ ),
+ if (last != null) ...[
+ const SizedBox(height: 10),
+ Row(
+ children: [
+ SizedBox(
+ width: 66,
+ child: Text(t.shortDate((pair?.from ?? last).date),
+ textAlign: TextAlign.center,
+ style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textTertiary)),
+ ),
+ Expanded(
+ child: Text(pair == null ? t.compareNeedTwo : t.photoCount(fit.shotCount),
+ textAlign: TextAlign.center,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.s(11, weight: FontWeight.w500, color: gc.textTertiary)),
+ ),
+ SizedBox(
+ width: 66,
+ child: pair == null
+ ? null
+ : Text(t.shortDate(pair.to.date),
+ textAlign: TextAlign.center,
+ style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textTertiary)),
+ ),
],
),
+ ],
],
),
),
);
}
+ Widget _track(GymColors gc, List<DateTime> dates, DateTime from, DateTime to, String? label) {
+ final span = to.difference(from).inMinutes.abs();
+ final spots = [
+ for (final d in dates)
+ if (!d.isBefore(from) && !d.isAfter(to)) span == 0 ? 0.0 : d.difference(from).inMinutes / span,
+ ];
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (label != null) ...[
+ Text(label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.d(13.5, weight: FontWeight.w700, color: gc.text)),
+ const SizedBox(height: 8),
+ ],
+ SizedBox(
+ height: 14,
+ child: CustomPaint(
+ size: const Size(double.infinity, 14),
+ painter: _TrackPainter(spots, gc.accent, gc.border, gc.bgRaised, open: label == null),
+ ),
+ ),
+ ],
+ );
+ }
+
Widget _shotThumb(GymColors gc, ProgressEntry entry) {
final name = entry.media.isEmpty ? null : entry.media.first;
final path = name == null ? null : MediaStore.pathFor(name);
@@ -612,30 +683,6 @@ class ProgressScreen extends StatelessWidget {
);
}
- 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(
- border: border ? Border(bottom: BorderSide(color: gc.border)) : null,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(
- child: Text(t.catalogName(pr.id, pr.name),
- style: AppTheme.s(14, weight: FontWeight.w500, color: gc.text))),
- Column(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Text(fit.weightLabel(pr.topWeight), style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- Text(t.oneRmEst(fit.weightLabel(pr.oneRm)), style: AppTheme.s(11, color: gc.textSecondary)),
- ],
- ),
- ],
- ),
- );
- }
-
Widget bwRow(BuildContext context, GymColors gc, BodyweightEntry e) {
return Row(
children: [
@@ -658,18 +705,11 @@ class ProgressScreen extends StatelessWidget {
);
}
- void _showDay(BuildContext context, int index) {
- final date = fit.heatmapDate(index);
- showModalBottomSheet(
- context: context,
- backgroundColor: Colors.transparent,
- builder: (_) => _DaySheet(date: date),
- );
- }
+ void _showDay(BuildContext context, int index) => showDaySheet(context, fit.heatmapDate(index));
void _logBodyweight(BuildContext context) {
final start = fit.latestBodyweight?.kg ?? fit.profile.weightKg;
- showModalBottomSheet(
+ showAppSheet(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
@@ -697,6 +737,7 @@ class _MuscleMapCardState extends State<_MuscleMapCard> {
@override
Widget build(BuildContext context) {
final gc = context.gc;
+ if (_days == 0) return _recoveryCard(gc);
final sets = fit.muscleSetsOver(_days);
final heat = fit.muscleHeatOver(_days);
final focus = _focus;
@@ -712,15 +753,7 @@ class _MuscleMapCardState extends State<_MuscleMapCard> {
children: [
Text(t.muscleMap,
style: AppTheme.f(10, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
- SegToggle(
- [
- SegOption(t.days7, _days == 7, () => _setDays(7)),
- SegOption(t.days30, _days == 30, () => _setDays(30)),
- ],
- hPad: 11,
- vPad: 5,
- fontSize: 11,
- ),
+ _modes(),
],
),
const SizedBox(height: 16),
@@ -768,6 +801,128 @@ class _MuscleMapCardState extends State<_MuscleMapCard> {
);
}
+ Widget _modes() => SegToggle(
+ [
+ SegOption(t.days7, _days == 7, () => _setDays(7)),
+ SegOption(t.days30, _days == 30, () => _setDays(30)),
+ SegOption(t.recoveryTab, _days == 0, () => _setDays(0)),
+ ],
+ hPad: 10,
+ vPad: 5,
+ fontSize: 11,
+ );
+
+ Widget _recoveryCard(GymColors gc) {
+ final recovery = fit.muscleRecovery();
+ final overall = fit.overallRecovery();
+ final tired = fit.stillRecovering();
+ final focus = _focus;
+ return SoftCard(
+ radius: 20,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(t.muscleMap,
+ style: AppTheme.f(10, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
+ _modes(),
+ ],
+ ),
+ const SizedBox(height: 14),
+ Row(children: [
+ SizedBox(
+ width: 46,
+ height: 46,
+ child: Stack(alignment: Alignment.center, children: [
+ SizedBox.expand(
+ child: CircularProgressIndicator(
+ value: overall / 100,
+ strokeWidth: 4.5,
+ strokeCap: StrokeCap.round,
+ backgroundColor: gc.bgRaised2,
+ color: recoveryColor(gc, overall / 100),
+ ),
+ ),
+ Text('$overall', style: AppTheme.f(14, weight: FontWeight.w800, color: gc.text)),
+ ]),
+ ),
+ const SizedBox(width: 14),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.recoveryOverall(overall),
+ style: AppTheme.f(15, weight: FontWeight.w700, color: gc.text)),
+ const SizedBox(height: 2),
+ Text(tired.isEmpty ? t.recoveryAllFresh : t.recoveryStill(tired.take(3).map(t.muscle).join(' · ')),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.s(12, color: gc.textSecondary)),
+ ],
+ ),
+ ),
+ ]),
+ const SizedBox(height: 16),
+ BodyRecoveryMap(
+ recovery: recovery,
+ focus: focus,
+ onTap: (id) => setState(() => _focus = focus == id ? null : id),
+ ),
+ const SizedBox(height: 16),
+ Row(children: [
+ Text(t.recoveryTired, style: AppTheme.s(11, color: gc.textTertiary)),
+ const SizedBox(width: 8),
+ for (var i = 0; i <= 4; i++) ...[
+ if (i > 0) const SizedBox(width: 3),
+ Expanded(
+ child: Container(
+ height: 7,
+ decoration: BoxDecoration(
+ color: recoveryColor(gc, i / 4),
+ borderRadius: BorderRadius.circular(2),
+ ),
+ ),
+ ),
+ ],
+ const SizedBox(width: 8),
+ Text(t.recoveryFresh, style: AppTheme.s(11, color: gc.textTertiary)),
+ ]),
+ const SizedBox(height: 14),
+ Container(
+ constraints: const BoxConstraints(minHeight: 36),
+ alignment: Alignment.centerLeft,
+ child: focus == null
+ ? Text(t.recoveryHint, style: AppTheme.s(13, color: gc.textSecondary))
+ : _recoveryReadout(gc, focus, recovery[focus] ?? 1),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _recoveryReadout(GymColors gc, String id, double value) {
+ final hours = fit.hoursUntilRecovered(id);
+ return Row(children: [
+ Container(
+ width: 10,
+ height: 10,
+ decoration: BoxDecoration(color: recoveryColor(gc, value), shape: BoxShape.circle),
+ ),
+ const SizedBox(width: 8),
+ Text(t.muscle(id), style: AppTheme.s(13, weight: FontWeight.w600, color: gc.text)),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(
+ hours == null
+ ? t.recoveryPct((value * 100).round())
+ : '${t.recoveryPct((value * 100).round())} · ${t.readyInHours(hours)}',
+ style: AppTheme.s(13, color: gc.textSecondary)),
+ ),
+ ]);
+ }
+
Widget _readout(GymColors gc, String id, double sets, double heat) {
return Row(children: [
Container(
@@ -795,6 +950,7 @@ class _StrengthCard extends StatelessWidget {
return SoftCard(
radius: 20,
+ padding: const EdgeInsets.fromLTRB(18, 18, 18, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -802,33 +958,66 @@ class _StrengthCard extends StatelessWidget {
style: AppTheme.f(10, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
const SizedBox(height: 14),
if (id == null)
- Text(t.strengthEmpty,
- style: AppTheme.s(13, color: gc.textSecondary))
+ Text(t.strengthEmpty, style: AppTheme.s(13, color: gc.textSecondary))
else
- ..._chart(gc, id, tracked),
+ ..._chart(context, gc, id, tracked),
],
),
);
}
List<Widget> _chart(
+ BuildContext context,
GymColors gc,
String id,
List<({String id, String name, int sessions})> tracked,
) {
- final series = fit.oneRmSeries(id);
+ final history = fit.exerciseHistory(id).reversed.toList();
+ final recent = history.length > 24 ? history.sublist(history.length - 24) : history;
+ final series = [for (final h in recent) (h.ex.bestOneRm * 10).round() / 10];
final first = series.first, last = series.last;
final delta = last - first;
final up = delta >= 0;
+ final name = tracked.firstWhere((e) => e.id == id, orElse: () => tracked.first).name;
+ final pickable = tracked.length > 1;
return [
+ Semantics(
+ button: pickable,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: pickable ? () => _pick(context, id, tracked) : null,
+ child: Row(
+ children: [
+ _PrThumb(id: id, size: 40),
+ const SizedBox(width: 12),
+ Expanded(
+ child: Text(t.catalogName(id, name),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(15, weight: FontWeight.w700, color: gc.text)),
+ ),
+ if (pickable) ...[
+ const SizedBox(width: 8),
+ Container(
+ width: 30,
+ height: 30,
+ decoration: BoxDecoration(color: gc.bgRaised2, shape: BoxShape.circle),
+ child: Icon(PhosphorIconsBold.caretDown, size: 13, color: gc.textSecondary),
+ ),
+ ],
+ ],
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
RichText(
text: TextSpan(
text: fit.weightValue(last),
- style: AppTheme.d(32, weight: FontWeight.w700, color: gc.text),
+ style: AppTheme.d(34, weight: FontWeight.w800, color: gc.text),
children: [
TextSpan(
text: ' ${fit.units}',
@@ -836,44 +1025,246 @@ class _StrengthCard extends StatelessWidget {
],
),
),
- const SizedBox(width: 10),
+ const Spacer(),
if (delta.abs() >= 0.1)
Padding(
- padding: const EdgeInsets.only(bottom: 5),
+ padding: const EdgeInsets.only(bottom: 6),
child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
+ padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 5),
decoration: BoxDecoration(
- color: up ? gc.sageSoft : gc.accentSoft, borderRadius: BorderRadius.circular(8)),
- child: Text('${up ? '+' : ''}${fit.weightLabel(delta)}',
- style: AppTheme.s(11, weight: FontWeight.w600, color: up ? gc.sage : gc.accent)),
+ color: up ? gc.sageSoft : gc.accentSoft, borderRadius: BorderRadius.circular(100)),
+ child: Row(mainAxisSize: MainAxisSize.min, children: [
+ Icon(up ? PhosphorIconsBold.trendUp : PhosphorIconsBold.trendDown,
+ size: 12, color: up ? gc.sage : gc.accent),
+ const SizedBox(width: 4),
+ Text('${up ? '+' : ''}${fit.weightLabel(delta)}',
+ style: AppTheme.s(11.5, weight: FontWeight.w700, color: up ? gc.sage : gc.accent)),
+ ]),
),
),
],
),
const SizedBox(height: 12),
- Sparkline(values: series, height: 56, color: gc.textSecondary),
- const SizedBox(height: 12),
- SingleChildScrollView(
- scrollDirection: Axis.horizontal,
- child: Row(children: [
- for (final e in tracked.take(8)) ...[
- Pill(
- 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),
- hPad: 12,
- vPad: 7,
- fontSize: 12,
- ),
- const SizedBox(width: 8),
- ],
- ]),
+ TrendChart(values: [for (final v in series) fit.toDisplayWeight(v)], height: 96, scale: fmt),
+ const SizedBox(height: 8),
+ Row(
+ children: [
+ Text(t.shortDate(recent.first.date),
+ style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textTertiary)),
+ const Spacer(),
+ Text(t.sessionCount(series.length),
+ style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textTertiary)),
+ const Spacer(),
+ Text(t.shortDate(recent.last.date),
+ style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textTertiary)),
+ ],
),
];
}
+
+ void _pick(BuildContext context, String current, List<({String id, String name, int sessions})> tracked) {
+ showAppSheet<void>(
+ context: context,
+ backgroundColor: Colors.transparent,
+ isScrollControlled: true,
+ builder: (sheet) {
+ final gc = sheet.gc;
+ return Container(
+ padding: sheetPad(sheet),
+ constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.8),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SheetHandle(),
+ const SizedBox(height: 16),
+ SheetTitle(sentenceCase(t.strength1rm)),
+ const SizedBox(height: 14),
+ Flexible(
+ child: OptionGroup(
+ [
+ for (final e in tracked)
+ OptionItem(
+ t.catalogName(e.id, e.name),
+ leading: _PrThumb(id: e.id, size: 34),
+ detail: t.sessionCount(e.sessions),
+ selected: e.id == current,
+ onTap: () {
+ fit.setStrengthExercise(e.id);
+ Navigator.of(sheet).pop();
+ },
+ ),
+ ],
+ scroll: true,
+ ),
+ ),
+ ],
+ ),
+ );
+ },
+ );
+ }
+}
+
+class _PrThumb extends StatelessWidget {
+ const _PrThumb({required this.id, this.size = 44});
+
+ final String id;
+ final double size;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final ex = fit.exerciseById(id);
+ return SizedBox(
+ width: size,
+ height: size,
+ child: ex == null
+ ? Container(
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(size * 0.28)),
+ child: Icon(PhosphorIconsRegular.barbell, size: size * 0.45, color: gc.textTertiary),
+ )
+ : ExerciseMedia(ex: ex, height: size, radius: size * 0.28, bordered: false),
+ );
+ }
}
+class _PrCard extends StatefulWidget {
+ const _PrCard(this.prs);
+
+ final List<({String id, String name, double topWeight, double oneRm})> prs;
+
+ @override
+ State<_PrCard> createState() => _PrCardState();
+}
+
+class _PrCardState extends State<_PrCard> {
+ static const _shown = 5;
+ bool _all = false;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final prs = widget.prs;
+ final rows = _all ? prs : prs.take(_shown).toList();
+ final hidden = prs.length - rows.length;
+ return SoftCard(
+ radius: 20,
+ padding: const EdgeInsets.fromLTRB(18, 18, 18, 8),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(children: [
+ Icon(PhosphorIconsFill.trophy, size: 14, color: gc.accent),
+ const SizedBox(width: 7),
+ Expanded(
+ child: Text(t.personalRecords,
+ style: AppTheme.f(10, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 0.9)),
+ ),
+ Text('${prs.length}', style: AppTheme.f(12, weight: FontWeight.w700, color: gc.textSecondary)),
+ ]),
+ const SizedBox(height: 8),
+ AnimatedSize(
+ duration: const Duration(milliseconds: 280),
+ curve: Curves.easeOutCubic,
+ alignment: Alignment.topCenter,
+ child: Column(
+ children: [
+ for (var i = 0; i < rows.length; i++) _row(gc, rows[i], i, i < rows.length - 1 || hidden > 0),
+ ],
+ ),
+ ),
+ if (prs.length > _shown)
+ Semantics(
+ button: true,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => setState(() => _all = !_all),
+ child: SizedBox(
+ height: 44,
+ child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
+ if (!_all)
+ Text('+$hidden',
+ style: AppTheme.f(12.5, weight: FontWeight.w700, color: gc.textSecondary)),
+ const SizedBox(width: 6),
+ AnimatedRotation(
+ turns: _all ? 0.5 : 0,
+ duration: const Duration(milliseconds: 240),
+ child: Icon(PhosphorIconsBold.caretDown, size: 13, color: gc.textSecondary),
+ ),
+ ]),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _row(GymColors gc, ({String id, String name, double topWeight, double oneRm}) pr, int rank, bool border) {
+ final medal = rank < 3 ? [gc.brass, gc.textSecondary, gc.accent][rank] : null;
+ return Container(
+ padding: const EdgeInsets.symmetric(vertical: 11),
+ decoration: BoxDecoration(
+ border: border ? Border(bottom: BorderSide(color: gc.border.withValues(alpha: 0.6))) : null,
+ ),
+ child: Row(
+ children: [
+ Stack(
+ clipBehavior: Clip.none,
+ children: [
+ _PrThumb(id: pr.id),
+ if (medal != null)
+ Positioned(
+ right: -4,
+ top: -4,
+ child: Container(
+ width: 18,
+ height: 18,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(
+ color: medal,
+ shape: BoxShape.circle,
+ border: Border.all(color: gc.bgRaised, width: 2),
+ ),
+ child: Text('${rank + 1}', style: AppTheme.f(9, weight: FontWeight.w800, color: gc.bgRaised)),
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(width: 13),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.catalogName(pr.id, pr.name),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.s(14, weight: FontWeight.w600, color: gc.text, height: 1.25)),
+ const SizedBox(height: 3),
+ Text(t.oneRmEst(fit.weightLabel(pr.oneRm)),
+ style: AppTheme.s(11.5, weight: FontWeight.w500, color: gc.textTertiary)),
+ ],
+ ),
+ ),
+ const SizedBox(width: 12),
+ Text(fit.weightLabel(pr.topWeight), style: AppTheme.d(19, weight: FontWeight.w800, color: gc.text)),
+ ],
+ ),
+ );
+ }
+}
+
+void showDaySheet(BuildContext context, DateTime date) => showAppSheet(
+ context: context,
+ backgroundColor: Colors.transparent,
+ builder: (_) => _DaySheet(date: date),
+ );
+
class _DaySheet extends StatelessWidget {
const _DaySheet({required this.date});
@@ -961,6 +1352,19 @@ class _DaySheet extends StatelessWidget {
style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 1),
),
),
+ Semantics(
+ button: true,
+ label: t.deleteWorkout,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _confirmDeleteWorkout(context, s),
+ child: SizedBox(
+ width: 40,
+ height: 36,
+ child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.textTertiary),
+ ),
+ ),
+ ),
if (!fit.isSessionActive)
GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -984,6 +1388,19 @@ class _DaySheet extends StatelessWidget {
);
}
+ Future<void> _confirmDeleteWorkout(BuildContext context, LoggedSession s) async {
+ final ok = await askConfirm(
+ context,
+ title: t.deleteWorkout,
+ body: t.deleteWorkoutBody,
+ confirmLabel: t.delete,
+ danger: true,
+ );
+ if (!ok) return;
+ fit.deleteSession(s);
+ if (context.mounted && fit.sessionsOn(date).isEmpty) Navigator.of(context).pop();
+ }
+
Future<void> _confirmResume(BuildContext context, LoggedSession s) async {
final ok = await askConfirm(
context,
@@ -1095,8 +1512,6 @@ class _LogBodyweightSheet extends StatefulWidget {
class _LogBodyweightSheetState extends State<_LogBodyweightSheet> {
late double _shown = ((fit.toDisplayWeight(widget.start)) * 10).round() / 10;
- void _bump(double d) => setState(() => _shown = ((_shown + d) * 10).round() / 10);
-
@override
Widget build(BuildContext context) {
final gc = context.gc;
@@ -1116,23 +1531,29 @@ class _LogBodyweightSheetState extends State<_LogBodyweightSheet> {
style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 2)),
const SizedBox(height: 4),
Text(t.trackWeight, style: AppTheme.s(13, color: gc.textSecondary)),
- const SizedBox(height: 22),
+ const SizedBox(height: 18),
Row(
- mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.baseline,
+ textBaseline: TextBaseline.alphabetic,
children: [
- _round(gc, '–', () => _bump(-0.1)),
- const SizedBox(width: 22),
- SizedBox(
- width: 130,
- child: Text('${fmt(_shown)} ${fit.units}',
- textAlign: TextAlign.center,
- style: AppTheme.d(40, weight: FontWeight.w700, color: gc.text)),
- ),
- const SizedBox(width: 22),
- _round(gc, '+', () => _bump(0.1)),
+ RollingText(_shown.toStringAsFixed(1),
+ style: AppTheme.f(52, weight: FontWeight.w800, color: gc.text, height: 1.1)),
+ const SizedBox(width: 6),
+ Text(fit.units, style: AppTheme.f(18, weight: FontWeight.w700, color: gc.textSecondary)),
],
),
- const SizedBox(height: 22),
+ const SizedBox(height: 16),
+ RulerPicker(
+ value: _shown,
+ min: fit.isLb ? 60 : 25,
+ max: fit.isLb ? 660 : 300,
+ step: 0.1,
+ majorEvery: 10,
+ label: (v) => '${v.round()}',
+ onChanged: (v) => setState(() => _shown = v),
+ ),
+ const SizedBox(height: 18),
PrimaryButton(
label: t.save,
onTap: () {
@@ -1145,23 +1566,11 @@ class _LogBodyweightSheetState extends State<_LogBodyweightSheet> {
);
}
- Widget _round(GymColors gc, String glyph, VoidCallback onTap) {
- return GestureDetector(
- onTap: onTap,
- child: Container(
- width: 52,
- height: 52,
- decoration: BoxDecoration(color: gc.bgRaised2, shape: BoxShape.circle),
- alignment: Alignment.center,
- child: Text(glyph, style: TextStyle(color: gc.text, fontSize: 26, height: 1)),
- ),
- );
- }
}
void showEditLoggedSheet(BuildContext context, LoggedSession s, LoggedExercise e) {
final gc = context.gc;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
@@ -1294,7 +1703,7 @@ Widget _editSetRow(GymColors gc, LoggedSession s, LoggedExercise e, int i, bool
}
void showHeatToneSheet(BuildContext context) {
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
builder: (_) => const _HeatToneSheet(),
@@ -1365,3 +1774,56 @@ class _HeatToneSheetState extends State<_HeatToneSheet> {
);
}
}
+
+class _TrackPainter extends CustomPainter {
+ _TrackPainter(this.spots, this.color, this.rail, this.bg, {this.open = false});
+ final List<double> spots;
+ final Color color;
+ final Color rail;
+ final Color bg;
+ final bool open;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final y = size.height / 2;
+ final line = Paint()
+ ..color = rail
+ ..strokeWidth = 2
+ ..strokeCap = StrokeCap.round;
+ if (open) {
+ for (var x = 0.0; x < size.width; x += 8) {
+ canvas.drawLine(Offset(x, y), Offset(math.min(x + 4, size.width), y), line);
+ }
+ canvas.drawCircle(Offset(5, y), 5, Paint()..color = color);
+ return;
+ }
+ canvas.drawLine(Offset(0, y), Offset(size.width, y), line);
+ const inset = 5.0;
+ final w = size.width - inset * 2;
+ canvas.drawLine(
+ Offset(inset, y),
+ Offset(inset + w, y),
+ Paint()
+ ..shader = LinearGradient(colors: [color.withValues(alpha: 0.25), color])
+ .createShader(Rect.fromLTWH(0, 0, size.width, size.height))
+ ..strokeWidth = 2
+ ..strokeCap = StrokeCap.round,
+ );
+ for (final s in spots) {
+ final c = Offset(inset + w * s, y);
+ final edge = s <= 0.001 || s >= 0.999;
+ canvas.drawCircle(c, edge ? 5 : 3.5, Paint()..color = bg);
+ canvas.drawCircle(
+ c,
+ edge ? 5 : 3.5,
+ Paint()
+ ..color = edge ? color : color.withValues(alpha: 0.7)
+ ..style = edge ? PaintingStyle.fill : PaintingStyle.stroke
+ ..strokeWidth = 2);
+ }
+ }
+
+ @override
+ bool shouldRepaint(_TrackPainter o) =>
+ o.spots != spots || o.color != color || o.rail != rail || o.open != open;
+}
diff --git a/lib/screens/routine_edit_screen.dart b/lib/screens/routine_edit_screen.dart
index 85e9287..e19ebcf 100644
--- a/lib/screens/routine_edit_screen.dart
+++ b/lib/screens/routine_edit_screen.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../catalog/exercise_catalog.dart';
@@ -10,9 +11,16 @@ import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/dialogs.dart';
import '../widgets/exercise_media.dart';
+import '../widgets/ruler_picker.dart';
+import '../widgets/glass.dart';
+import '../widgets/routine_folder.dart';
+import '../widgets/liquid_notch.dart';
+import '../widgets/set_kind.dart';
import '../widgets/svg_icon.dart';
+import '../widgets/timer_panel.dart';
import '../widgets/ui_kit.dart';
import 'exercises_screen.dart';
+import 'plan_import_sheet.dart';
class RoutineEditScreen extends StatefulWidget {
const RoutineEditScreen({super.key});
@@ -50,13 +58,14 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
return const SizedBox.shrink();
}
final list = _filtered;
+ final start = routine.exerciseIds.isNotEmpty;
return SafeArea(
bottom: false,
- child: Column(
+ child: Stack(
children: [
- Expanded(
+ Positioned.fill(
child: ListView.builder(
- padding: const EdgeInsets.fromLTRB(20, 12, 20, 20),
+ padding: EdgeInsets.fromLTRB(20, 12, 20, start ? 104 : 20),
itemCount: (list.isEmpty ? 1 : list.length) + 1,
itemBuilder: (context, i) {
if (i == 0) return _header(gc, routine.exerciseIds.length);
@@ -65,20 +74,76 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
},
),
),
- if (routine.exerciseIds.isNotEmpty)
- Padding(
- padding: const EdgeInsets.fromLTRB(20, 8, 20, 16),
- child: PrimaryButton(
- label: t.startWorkout,
- icon: Ic.play,
- onTap: () => fit.startRoutine(routine),
- ),
+ if (start) ...[
+ const Positioned(left: 0, right: 0, bottom: 0, child: EdgeBlur(top: false, height: 112, sigma: 11, shade: 0.35)),
+ Positioned(
+ left: 20,
+ right: 20,
+ bottom: 16,
+ child: Row(children: [
+ Expanded(
+ flex: 2,
+ child: Pressable(
+ onTap: fit.closeRoutineEdit,
+ child: Container(
+ height: 56,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(100)),
+ child: Text(t.save, style: AppTheme.f(15.5, weight: FontWeight.w700, color: gc.text)),
+ ),
+ ),
+ ),
+ const SizedBox(width: 10),
+ Expanded(
+ flex: 3,
+ child: PrimaryButton(
+ label: t.startWorkout,
+ icon: Ic.play,
+ onTap: () => fit.startRoutine(routine),
+ ),
+ ),
+ ]),
),
+ ],
],
),
);
}
+ Widget _colors(GymColors gc, Routine routine) {
+ final current = folderHue(routine);
+ return Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ for (var i = 0; i < kFolderHues.length; i++)
+ Semantics(
+ button: true,
+ selected: kFolderHues[i] == current,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.setRoutineColor(_id, i),
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 200),
+ width: 40,
+ height: 40,
+ padding: EdgeInsets.all(kFolderHues[i] == current ? 4 : 0),
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ border: Border.all(
+ color: kFolderHues[i] == current ? gc.text : Colors.transparent,
+ width: 2,
+ ),
+ ),
+ child: DecoratedBox(
+ decoration: BoxDecoration(color: kFolderHues[i], shape: BoxShape.circle),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
Widget _header(GymColors gc, int count) {
final routine = fit.activeRoutine!;
return Column(
@@ -103,6 +168,19 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
),
),
),
+ if (routine.exerciseIds.isNotEmpty)
+ Semantics(
+ button: true,
+ label: t.shareRoutine,
+ child: GestureDetector(
+ onTap: () => _shareIntro(routine),
+ child: Padding(
+ padding: const EdgeInsets.all(6),
+ child: Icon(PhosphorIconsRegular.shareNetwork, size: 19, color: gc.textTertiary),
+ ),
+ ),
+ ),
+ const SizedBox(width: 4),
Semantics(
button: true,
label: t.duplicateRoutine,
@@ -123,7 +201,9 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
),
),
]),
- const SizedBox(height: 20),
+ const SizedBox(height: 18),
+ _colors(gc, routine),
+ const SizedBox(height: 22),
Text(t.schedule, style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1.5)),
const SizedBox(height: 10),
Row(
@@ -283,10 +363,164 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
);
}
+ Widget _rail(GymColors gc, {required bool top, required bool bottom}) => Center(
+ child: Container(
+ width: 4,
+ margin: EdgeInsets.only(top: top ? 10 : 0, bottom: bottom ? 10 : 0),
+ decoration: BoxDecoration(
+ color: gc.brass,
+ borderRadius: BorderRadius.vertical(
+ top: Radius.circular(top ? 4 : 0),
+ bottom: Radius.circular(bottom ? 4 : 0),
+ ),
+ ),
+ ),
+ );
+
+ String _planLine(List<PlannedSet> plan) {
+ final warm = plan.where((p) => p.kind == SetKind.warmup).length;
+ final work = plan.where((p) => p.kind != SetKind.warmup).toList();
+ String one(PlannedSet p) {
+ final load = [
+ if (p.km != null) fit.distanceValue(p.km!),
+ if (p.sec != null) durationLabel(p.sec!),
+ if (p.reps != null) '${p.reps}',
+ if (p.weightKg != null) fit.weightValue(p.weightKg!),
+ ].join(' × ');
+ final tag = setKindTag(p.kind);
+ return [if (tag.isNotEmpty) tag, if (load.isNotEmpty) load].join(' ');
+ }
+
+ final parts = <String>[
+ if (warm > 0) '$warm ${setKindTag(SetKind.warmup)}',
+ for (final p in work.take(4)) one(p),
+ if (work.length > 4) '…',
+ ].where((s) => s.trim().isNotEmpty).toList();
+ final unit = plan.any((p) => p.weightKg != null)
+ ? fit.units
+ : plan.any((p) => p.km != null)
+ ? fit.distanceUnit
+ : '';
+ return unit.isEmpty ? parts.join(' · ') : '${parts.join(' · ')} $unit';
+ }
+
+ void _remove(Exercise ex) {
+ final undo = fit.removeRoutineExercise(_id, ex.id);
+ if (undo == null) return;
+ HapticFeedback.lightImpact();
+ showNotchToast(
+ context,
+ t.removedFromRoutine,
+ subtitle: exerciseName(ex),
+ icon: PhosphorIconsFill.trash,
+ accent: context.gc.warn,
+ action: t.undo,
+ onTap: undo,
+ );
+ }
+
+ void _shareIntro(Routine routine) {
+ showAppSheet<void>(
+ context: context,
+ backgroundColor: Colors.transparent,
+ builder: (sheet) {
+ final gc = sheet.gc;
+ return Container(
+ padding: sheetPad(sheet),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SheetHandle(),
+ const SizedBox(height: 22),
+ Center(child: _ShareArt(gc: gc)),
+ const SizedBox(height: 18),
+ Text(t.shareIntroTitle,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(21, weight: FontWeight.w800, color: gc.text)),
+ const SizedBox(height: 8),
+ Text(t.shareIntroBody,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(13.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),
+ const SizedBox(height: 18),
+ Container(
+ padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(16)),
+ child: Row(children: [
+ Icon(PhosphorIconsFill.listChecks, size: 20, color: gc.ember),
+ const SizedBox(width: 12),
+ Expanded(
+ child: Text(fit.routineTitle(routine),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text)),
+ ),
+ Text(t.exerciseCount(routine.exerciseIds.length),
+ style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textTertiary)),
+ ]),
+ ),
+ const SizedBox(height: 16),
+ PrimaryButton(
+ label: t.shareRoutine,
+ onTap: () {
+ Navigator.of(sheet).pop();
+ sharePlan([routine]);
+ },
+ ),
+ ],
+ ),
+ );
+ },
+ );
+ }
+
Widget _chosenRow(GymColors gc, Routine routine, Exercise ex, int index) {
- return Container(
+ final linksNext = fit.chainsToNext(routine, ex.id);
+ final fromPrev = index > 0 && fit.chainsToNext(routine, routine.exerciseIds[index - 1]);
+ final inChain = linksNext || fromPrev;
+ final plan = fit.plannedSets(routine, ex.id);
+ final anyChain = [
+ for (var i = 0; i < routine.exerciseIds.length - 1; i++) fit.chainsToNext(routine, routine.exerciseIds[i]),
+ ].any((x) => x);
+ return Padding(
key: ValueKey(ex.id),
- margin: const EdgeInsets.only(bottom: 8),
+ padding: EdgeInsets.only(bottom: linksNext ? 0 : 8),
+ child: Dismissible(
+ key: ValueKey('swipe-${ex.id}'),
+ direction: DismissDirection.endToStart,
+ onDismissed: (_) => _remove(ex),
+ background: Container(
+ margin: EdgeInsets.only(bottom: linksNext ? 4 : 0),
+ alignment: Alignment.centerRight,
+ padding: const EdgeInsets.only(right: 22),
+ decoration: BoxDecoration(color: gc.warn.withValues(alpha: 0.16), borderRadius: BorderRadius.circular(14)),
+ child: Icon(PhosphorIconsFill.trash, size: 20, color: gc.warn),
+ ),
+ child: IntrinsicHeight(
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (anyChain)
+ SizedBox(
+ width: 12,
+ child: inChain ? _rail(gc, top: !fromPrev, bottom: !linksNext) : null,
+ ),
+ Expanded(child: _chosenCard(gc, routine, ex, index, inChain, plan, linksNext)),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _chosenCard(GymColors gc, Routine routine, Exercise ex, int index, bool inChain,
+ List<PlannedSet> plan, bool linksNext) {
+ return Container(
+ margin: EdgeInsets.only(bottom: linksNext ? 4 : 0),
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: gc.bgRaised,
@@ -304,16 +538,40 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
),
),
),
- SizedBox(width: 44, child: ExerciseMedia(ex: ex, height: 44, radius: 10)),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _openPlan(ex),
+ child: SizedBox(width: 44, child: ExerciseMedia(ex: ex, height: 44, radius: 10)),
+ ),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(exerciseName(ex),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),
+ Semantics(
+ button: true,
+ label: t.planSets,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _openPlan(ex),
+ child: Row(children: [
+ Flexible(
+ child: Text(exerciseName(ex),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),
+ ),
+ const SizedBox(width: 5),
+ Icon(PhosphorIconsRegular.slidersHorizontal,
+ size: 13, color: plan.isEmpty ? gc.textTertiary : gc.ember),
+ ]),
+ ),
+ ),
+ if (inChain) ...[
+ const SizedBox(height: 2),
+ Text(t.superset.toUpperCase(),
+ style: AppTheme.f(9.5, weight: FontWeight.w700, color: gc.brass, letterSpacing: 1)),
+ ],
const SizedBox(height: 2),
StepperControl(
value: t.setCount(fit.routineSets(routine, ex.id)),
@@ -325,6 +583,13 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
onDec: () => fit.bumpRoutineSets(_id, ex.id, -1),
onInc: () => fit.bumpRoutineSets(_id, ex.id, 1),
),
+ if (plan.isNotEmpty) ...[
+ const SizedBox(height: 3),
+ Text(_planLine(plan),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(11, weight: FontWeight.w500, color: gc.textSecondary)),
+ ],
],
),
),
@@ -356,18 +621,11 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
label: t.removeFromRoutine,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
- onTap: () => fit.toggleRoutineExercise(_id, ex.id),
+ onTap: () => _remove(ex),
child: SizedBox(
- width: 44,
+ width: 38,
height: 44,
- child: Center(
- child: Container(
- width: 30,
- height: 30,
- decoration: BoxDecoration(color: gc.bgRaised2, shape: BoxShape.circle),
- child: SvgPathIcon(Ic.close, size: 14, color: gc.textSecondary),
- ),
- ),
+ child: Center(child: Icon(PhosphorIconsRegular.trash, size: 18, color: gc.textTertiary)),
),
),
),
@@ -418,9 +676,258 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
);
}
+ void _openPlan(Exercise ex) {
+ showAppSheet<void>(
+ context: context,
+ isScrollControlled: true,
+ backgroundColor: Colors.transparent,
+ builder: (sheet) => AnimatedBuilder(
+ animation: fit,
+ builder: (sheet, _) {
+ final gc = sheet.gc;
+ final routine = fit.routines.where((r) => r.id == _id).firstOrNull;
+ if (routine == null || !routine.exerciseIds.contains(ex.id)) return const SizedBox.shrink();
+ final mode = fit.modeOf(ex.id);
+ final repsOnly = fit.isRepsOnly(ex.id);
+ final plan = fit.hasPlan(routine, ex.id)
+ ? fit.plannedSets(routine, ex.id)
+ : List.generate(fit.routineSets(routine, ex.id), (_) => const PlannedSet());
+ void save(List<PlannedSet> next) => fit.setPlannedSets(_id, ex.id, next);
+ void edit(int i, PlannedSet p) => save([...plan]..[i] = p);
+ var working = 0;
+ return Container(
+ padding: sheetPad(sheet),
+ constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.9),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SheetHandle(),
+ const SizedBox(height: 18),
+ Text(exerciseName(ex), style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text)),
+ const SizedBox(height: 4),
+ Text(t.planSetsHint,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),
+ const SizedBox(height: 16),
+ _planHeader(gc, mode, repsOnly),
+ const SizedBox(height: 8),
+ for (var i = 0; i < plan.length; i++)
+ _planRow(sheet, gc, plan, i, plan[i].kind == SetKind.warmup ? 0 : ++working, mode,
+ repsOnly, edit, save),
+ const SizedBox(height: 8),
+ Row(children: [
+ Expanded(
+ child: GhostButton(
+ label: t.addSet.replaceFirst(RegExp(r'^\+\s*'), ''),
+ icon: PhosphorIconsRegular.plus,
+ onTap: () => save([
+ ...plan,
+ plan.lastWhere((p) => p.kind != SetKind.warmup, orElse: () => const PlannedSet())
+ .copyWith(kind: SetKind.normal),
+ ]),
+ ),
+ ),
+ if (mode.isEmpty) ...[
+ const SizedBox(width: 8),
+ Expanded(
+ child: GhostButton(
+ label: t.addWarmup,
+ icon: PhosphorIconsRegular.fire,
+ onTap: () => save([const PlannedSet(reps: 10, kind: SetKind.warmup), ...plan]),
+ ),
+ ),
+ ],
+ ]),
+ if (fit.hasPlan(routine, ex.id))
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => save(const []),
+ child: Container(
+ height: 44,
+ alignment: Alignment.center,
+ child: Text(t.clearPlan,
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.accent)),
+ ),
+ ),
+ const SizedBox(height: 10),
+ PrimaryButton(label: t.done, onTap: () => Navigator.of(sheet).pop()),
+ ],
+ ),
+ ),
+ );
+ },
+ ),
+ );
+ }
+
+ Widget _planHeader(GymColors gc, String mode, bool repsOnly) {
+ final labels = switch (mode) {
+ 'cardio' => [t.distanceCol(fit.distanceUnit.toUpperCase()), t.timeCol],
+ 'time' => [t.timeCol, if (!repsOnly) t.weightCol(fit.units.toUpperCase())],
+ _ => [t.repsCol, if (!repsOnly) t.weightCol(fit.units.toUpperCase())],
+ };
+ final style = AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1);
+ return Row(children: [
+ SizedBox(width: 40, child: Center(child: Text(t.setCol, style: style))),
+ const SizedBox(width: 8),
+ for (final l in labels) ...[
+ Expanded(
+ child: Center(
+ child: FittedBox(fit: BoxFit.scaleDown, child: Text(l, maxLines: 1, style: style)),
+ ),
+ ),
+ const SizedBox(width: 6),
+ ],
+ const SizedBox(width: 30),
+ ]);
+ }
+
+ Widget _planRow(
+ BuildContext sheet,
+ GymColors gc,
+ List<PlannedSet> plan,
+ int i,
+ int number,
+ String mode,
+ bool repsOnly,
+ void Function(int, PlannedSet) edit,
+ void Function(List<PlannedSet>) save,
+ ) {
+ final p = plan[i];
+ final kinds = SetKind.values;
+ final auto = t.autoValue;
+ Widget cell(String value, VoidCallback dec, VoidCallback inc, VoidCallback onEdit) => Expanded(
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ child: StepperControl(
+ value: value,
+ minWidth: 44,
+ btnSize: 26,
+ gap: 4,
+ fontSize: 13,
+ btnRadius: 8,
+ onDec: dec,
+ onInc: inc,
+ onEdit: onEdit,
+ ),
+ ),
+ );
+ Future<void> ask(String title, double value, double max, double step, int major, String unit,
+ void Function(double) apply,
+ {String Function(double)? format}) async {
+ final v = await askRuler(sheet,
+ title: title,
+ value: value,
+ min: 0,
+ max: max,
+ step: step,
+ unit: unit,
+ majorEvery: major,
+ format: format,
+ tickLabel: format);
+ if (v != null) apply(v);
+ }
+
+ final weight = cell(
+ p.weightKg == null ? auto : fit.weightValue(p.weightKg!),
+ () {
+ final shown = p.weightKg == null ? 0.0 : fit.toDisplayWeight(p.weightKg!) - fit.weightStep;
+ edit(i, shown <= 0 ? p.copyWith(autoWeight: true) : p.copyWith(weightKg: fit.fromDisplayWeight(shown)));
+ },
+ () {
+ final shown = p.weightKg == null ? fit.weightStep * 8 : fit.toDisplayWeight(p.weightKg!) + fit.weightStep;
+ edit(i, p.copyWith(weightKg: fit.fromDisplayWeight(shown)));
+ },
+ () => ask(
+ t.weightTitle(fit.units.toUpperCase()),
+ p.weightKg == null ? (fit.isLb ? 45 : 20) : fit.toDisplayWeight(p.weightKg!),
+ fit.isLb ? 660 : 300,
+ fit.isLb ? 1 : 0.5,
+ 10,
+ fit.units,
+ (v) => edit(i, v <= 0 ? p.copyWith(autoWeight: true) : p.copyWith(weightKg: fit.fromDisplayWeight(v)))),
+ );
+ final reps = cell(
+ p.reps == null ? auto : '${p.reps}',
+ () => edit(i, p.copyWith(reps: ((p.reps ?? 10) - 1).clamp(1, 999))),
+ () => edit(i, p.copyWith(reps: ((p.reps ?? 10) + 1).clamp(1, 999))),
+ () => ask(t.repsTitle, (p.reps ?? 10).toDouble(), 100, 1, 5, '',
+ (v) => edit(i, p.copyWith(reps: v.round().clamp(1, 999)))),
+ );
+ final cardio = mode == 'cardio';
+ final step = cardio ? 60 : 15;
+ final time = cell(
+ p.sec == null ? auto : durationLabel(p.sec!),
+ () => edit(i, p.copyWith(sec: ((p.sec ?? (cardio ? 1200 : 30)) - step).clamp(step, 24 * 3600))),
+ () => edit(i, p.copyWith(sec: ((p.sec ?? (cardio ? 1200 : 30)) + step).clamp(step, 24 * 3600))),
+ () => cardio
+ ? ask(t.timeMinutesTitle, ((p.sec ?? 1200) / 60).roundToDouble(), 300, 1, 5, 'min',
+ (v) => edit(i, p.copyWith(sec: (v * 60).round())))
+ : ask(t.timeSecondsTitle, (p.sec ?? 30).toDouble(), 900, 5, 6, '',
+ (v) => edit(i, p.copyWith(sec: v.round())),
+ format: (v) => clockLabel(v.round())),
+ );
+ final distance = cell(
+ p.km == null ? auto : fit.distanceValue(p.km!),
+ () => edit(i, p.copyWith(km: fit.fromDisplayKm((fit.toDisplayKm(p.km ?? 0) - 0.5).clamp(0, 1000)))),
+ () => edit(i, p.copyWith(km: fit.fromDisplayKm(fit.toDisplayKm(p.km ?? 0) + 0.5))),
+ () => ask(t.distanceTitle(fit.distanceUnit), fit.toDisplayKm(p.km ?? 5), 100, 0.1, 10, fit.distanceUnit,
+ (v) => edit(i, p.copyWith(km: fit.fromDisplayKm(v)))),
+ );
+ final cells = switch (mode) {
+ 'cardio' => [distance, time],
+ 'time' => [time, if (!repsOnly) weight],
+ _ => [reps, if (!repsOnly) weight],
+ };
+ final tag = setKindTag(p.kind);
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 8),
+ child: Row(children: [
+ Semantics(
+ button: true,
+ label: '${t.setType} · ${setKindLabel(p.kind)}',
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => edit(i, p.copyWith(kind: kinds[(p.kind.index + 1) % kinds.length])),
+ child: Container(
+ width: 40,
+ height: 34,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(
+ color: gc.bgRaised2,
+ borderRadius: BorderRadius.circular(10),
+ border: Border.all(
+ color: p.kind == SetKind.normal ? Colors.transparent : setKindColor(gc, p.kind)),
+ ),
+ child: Text(p.kind == SetKind.warmup ? tag : (tag.isEmpty ? '$number' : '$number$tag'),
+ style: AppTheme.f(12.5, weight: FontWeight.w700, color: setKindColor(gc, p.kind))),
+ ),
+ ),
+ ),
+ const SizedBox(width: 8),
+ for (final c in cells) ...[c, const SizedBox(width: 6)],
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: plan.length > 1 ? () => save([...plan]..removeAt(i)) : null,
+ child: SizedBox(
+ width: 30,
+ height: 34,
+ child: Icon(PhosphorIconsRegular.x,
+ size: 14, color: plan.length > 1 ? gc.textTertiary : Colors.transparent),
+ ),
+ ),
+ ]),
+ );
+ }
+
void _pickGroup(Routine routine) {
final gc = context.gc;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
builder: (sheet) => Container(
@@ -434,21 +941,29 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.routineGroup,
- textAlign: TextAlign.center,
- style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),
const SizedBox(height: 16),
- _groupOption(gc, t.noGroup, routine.group.isEmpty, () {
- fit.setRoutineGroup(_id, '');
- Navigator.pop(sheet);
- }),
- for (final group in fit.routineGroups)
- _groupOption(gc, group, routine.group == group, () {
- fit.setRoutineGroup(_id, group);
- Navigator.pop(sheet);
- }),
- const SizedBox(height: 6),
+ SheetTitle(t.routineGroup),
+ const SizedBox(height: 14),
+ OptionGroup([
+ OptionItem(
+ t.noGroup,
+ selected: routine.group.isEmpty,
+ onTap: () {
+ fit.setRoutineGroup(_id, '');
+ Navigator.pop(sheet);
+ },
+ ),
+ for (final group in fit.routineGroups)
+ OptionItem(
+ group,
+ selected: routine.group == group,
+ onTap: () {
+ fit.setRoutineGroup(_id, group);
+ Navigator.pop(sheet);
+ },
+ ),
+ ]),
+ const SizedBox(height: 12),
GhostButton(
label: t.newGroup,
icon: PhosphorIconsRegular.plus,
@@ -463,35 +978,10 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
);
}
- Widget _groupOption(GymColors gc, String label, bool selected, VoidCallback onTap) {
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onTap,
- child: Container(
- margin: const EdgeInsets.only(bottom: 8),
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
- decoration: BoxDecoration(
- color: selected ? gc.emberSoft : gc.bgRaised2,
- borderRadius: BorderRadius.circular(14),
- border: Border.all(color: selected ? gc.ember : Colors.transparent),
- ),
- child: Row(
- children: [
- Expanded(
- child: Text(label,
- style: AppTheme.f(14, weight: FontWeight.w600, color: selected ? gc.ember : gc.text)),
- ),
- if (selected) SvgPathIcon(Ic.checkBold, size: 16, color: gc.ember),
- ],
- ),
- ),
- );
- }
-
Future<void> _newGroup() async {
final gc = context.gc;
final controller = TextEditingController();
- final name = await showDialog<String>(
+ final name = await showAppDialog<String>(
context: context,
builder: (dctx) => appDialog(
gc,
@@ -525,7 +1015,7 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
void _confirmDelete() {
final gc = context.gc;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: gc.bgRaised,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(24))),
@@ -564,3 +1054,41 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
);
}
}
+
+class _ShareArt extends StatelessWidget {
+ const _ShareArt({required this.gc});
+
+ final GymColors gc;
+
+ Widget _bubble(IconData icon, Color bg, Color fg, double size) => Container(
+ width: size,
+ height: size,
+ decoration: BoxDecoration(color: bg, shape: BoxShape.circle, border: Border.all(color: gc.bgRaised, width: 3)),
+ child: Icon(icon, size: size * 0.44, color: fg),
+ );
+
+ @override
+ Widget build(BuildContext context) {
+ return SizedBox(
+ width: 190,
+ height: 86,
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+ Positioned(left: 0, top: 20, child: _bubble(PhosphorIconsFill.heart, gc.bgRaised2, gc.textSecondary, 50)),
+ Positioned(right: 0, top: 20, child: _bubble(PhosphorIconsFill.usersThree, gc.bgRaised2, gc.textSecondary, 50)),
+ Container(
+ width: 80,
+ height: 80,
+ decoration: BoxDecoration(
+ color: gc.emberSoft,
+ borderRadius: BorderRadius.circular(26),
+ border: Border.all(color: gc.bgRaised, width: 3),
+ ),
+ child: Icon(PhosphorIconsFill.paperPlaneTilt, size: 34, color: gc.ember),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 8fb38d2..fe9aa03 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -23,9 +23,15 @@ import '../services/workout_import.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/body_rulers.dart';
import '../widgets/dialogs.dart';
+import '../widgets/entrance.dart';
+import '../widgets/glass.dart';
+import '../widgets/liquid_notch.dart';
import '../widgets/photo_source_sheet.dart';
import '../widgets/profile_avatar.dart';
+import '../widgets/ruler_picker.dart';
+import '../widgets/timer_panel.dart';
import 'profile_screen.dart';
import '../widgets/ui_kit.dart';
@@ -40,13 +46,17 @@ class SettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final gc = context.gc;
- return SafeArea(
+ return RiseScope(
+ id: 'settings',
+ once: false,
+ child: SafeArea(
bottom: false,
child: SingleChildScrollView(
+ clipBehavior: Clip.none,
padding: const EdgeInsets.fromLTRB(20, 12, 20, 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
+ children: riseAll([
ScreenHeader(title: t.settings, onBack: fit.backFromPreferences),
const SizedBox(height: 20),
_sectionLabel(gc, t.preferences),
@@ -57,10 +67,20 @@ class SettingsScreen extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
- _prefRow(gc, PhosphorIconsRegular.moon, t.theme, SegToggle([
- SegOption(t.darkTheme, fit.dark, fit.setThemeDark),
- SegOption(t.lightTheme, !fit.dark, fit.setThemeLight),
- ])),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.moon,
+ t.theme,
+ [
+ ('system', t.themeAuto, PhosphorIconsRegular.circleHalf),
+ ('dark', t.darkTheme, PhosphorIconsRegular.moon),
+ ('light', t.lightTheme, PhosphorIconsRegular.sun),
+ ],
+ () => fit.themePref,
+ fit.setThemePref,
+ hint: t.themeAutoHint,
+ ),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _editLanguage(context),
@@ -94,6 +114,18 @@ class SettingsScreen extends StatelessWidget {
fontSize: 14,
onDec: () => fit.setRestSeconds(fit.restSeconds - 15),
onInc: () => fit.setRestSeconds(fit.restSeconds + 15),
+ onEdit: () async {
+ final v = await askRuler(context,
+ title: t.restTimer,
+ value: fit.restSeconds.toDouble(),
+ min: 0,
+ max: 600,
+ step: 5,
+ majorEvery: 6,
+ format: (v) => clockLabel(v.round()),
+ tickLabel: (v) => clockLabel(v.round()));
+ if (v != null) fit.setRestSeconds(v.round());
+ },
),
),
GestureDetector(
@@ -141,6 +173,20 @@ class SettingsScreen extends StatelessWidget {
]),
),
),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.vibrate,
+ t.alarmStyleTitle,
+ [
+ ('loud', t.alarmStyleLoud, PhosphorIconsRegular.bellRinging),
+ ('quiet', t.alarmStyleQuiet, PhosphorIconsRegular.bellSimpleSlash),
+ ('vibrate', t.alarmStyleVibrate, PhosphorIconsRegular.vibrate),
+ ],
+ () => fit.alarmStyle,
+ fit.setAlarmStyle,
+ hint: t.alarmStyleHint,
+ ),
if (!fit.alarmAllowed) ...[
const SizedBox(height: 14),
_alarmWarning(context, gc),
@@ -151,11 +197,19 @@ class SettingsScreen extends StatelessWidget {
child: _prefRow(gc, PhosphorIconsRegular.target, t.focusCard,
TinySwitch(on: fit.showFocus)),
),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleLogRpe,
- child: _prefRow(gc, PhosphorIconsRegular.gauge, t.logRpe,
- TinySwitch(on: fit.logRpe)),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.gauge,
+ t.effortSetting,
+ [
+ ('', t.restOff, PhosphorIconsRegular.prohibit),
+ ('rpe', 'RPE', PhosphorIconsRegular.gauge),
+ ('rir', 'RIR', PhosphorIconsRegular.arrowCounterClockwise),
+ ],
+ () => fit.effortMode,
+ fit.setEffortMode,
+ hint: t.effortHint,
),
GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -163,6 +217,31 @@ class SettingsScreen extends StatelessWidget {
child: _prefRow(gc, PhosphorIconsRegular.skipForward, t.autoAdvance,
TinySwitch(on: fit.autoAdvance)),
),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleStartCountdown,
+ child: _prefRow(gc, PhosphorIconsRegular.timer, t.countdownSetting,
+ TinySwitch(on: fit.startCountdown)),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleKeepScreenOn,
+ child: _prefRow(gc, PhosphorIconsRegular.sun, t.keepScreenOn,
+ TinySwitch(on: fit.keepScreenOn)),
+ ),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.filmStrip,
+ t.demoSizeTitle,
+ [
+ ('large', t.demoLarge, PhosphorIconsRegular.rectangle),
+ ('small', t.demoSmall, PhosphorIconsRegular.square),
+ ('off', t.demoOff, PhosphorIconsRegular.eyeSlash),
+ ],
+ () => fit.demoSize,
+ fit.setDemoSize,
+ ),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _editBackground(context),
@@ -182,7 +261,7 @@ class SettingsScreen extends StatelessWidget {
),
),
const SizedBox(height: 18),
- if (Platform.isAndroid) ...[
+ if (Platform.isAndroid || Platform.isIOS) ...[
_sectionLabel(gc, t.homeWidgets),
const SizedBox(height: 8),
_linkGroup(gc, [
@@ -190,6 +269,7 @@ class SettingsScreen extends StatelessWidget {
(PhosphorIconsRegular.chartBar, t.addStatsWidget, () => _addWidget(context, 'StatsWidgetProvider')),
(PhosphorIconsRegular.person, t.addBodyWidget, () => _addWidget(context, 'BodyWidgetProvider')),
(PhosphorIconsRegular.checkCircle, t.addTodayWidget, () => _addWidget(context, 'TodayWidgetProvider')),
+ (PhosphorIconsRegular.calendarCheck, t.addWeekWidget, () => _addWidget(context, 'WeekWidgetProvider')),
]),
const SizedBox(height: 18),
],
@@ -219,9 +299,10 @@ class SettingsScreen extends StatelessWidget {
_linkGroup(gc, [
(PhosphorIconsRegular.info, t.aboutGymmane, fit.goAbout),
]),
- ],
+ ]),
),
),
+ ),
);
}
@@ -243,6 +324,102 @@ class SettingsScreen extends StatelessWidget {
);
}
+ Widget _choiceRow(
+ BuildContext context,
+ GymColors gc,
+ IconData icon,
+ String label,
+ List<(String, String, IconData)> options,
+ String Function() current,
+ void Function(String) onPick, {
+ String? hint,
+ }) {
+ final now = current();
+ final shown = options.firstWhere((o) => o.$1 == now, orElse: () => options.first);
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _choiceSheet(context, label, options, current, onPick, hint: hint),
+ child: _prefRow(
+ gc,
+ icon,
+ label,
+ Row(mainAxisSize: MainAxisSize.min, children: [
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 128),
+ child: Text(
+ shown.$2,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.right,
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),
+ ),
+ ),
+ const SizedBox(width: 6),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ]),
+ ),
+ );
+ }
+
+ void _choiceSheet(
+ BuildContext context,
+ String title,
+ List<(String, String, IconData)> options,
+ String Function() current,
+ void Function(String) onPick, {
+ String? hint,
+ }) {
+ showAppSheet<void>(
+ context: context,
+ backgroundColor: Colors.transparent,
+ isScrollControlled: true,
+ builder: (sheet) => AnimatedBuilder(
+ animation: fit,
+ builder: (sheet, _) {
+ final gc = sheet.gc;
+ final now = current();
+ return Container(
+ padding: sheetPad(sheet),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SheetHandle(),
+ const SizedBox(height: 16),
+ SheetTitle(title),
+ const SizedBox(height: 14),
+ OptionGroup([
+ for (final o in options)
+ OptionItem(
+ o.$2,
+ icon: o.$3,
+ selected: now == o.$1,
+ onTap: () {
+ onPick(o.$1);
+ Navigator.of(sheet).pop();
+ },
+ ),
+ ]),
+ if (hint != null) ...[
+ const SizedBox(height: 12),
+ Text(hint,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary, height: 1.4)),
+ ],
+ ],
+ ),
+ ),
+ );
+ },
+ ),
+ );
+ }
+
Widget _rowIcon(GymColors gc, IconData icon, {Color? color}) => Padding(
padding: const EdgeInsets.only(right: 14),
child: SizedBox(
@@ -398,7 +575,7 @@ class SettingsScreen extends StatelessWidget {
void _openImportApps(BuildContext context) {
final gc = context.gc;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
@@ -414,20 +591,32 @@ class SettingsScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.importFromApp,
- textAlign: TextAlign.center,
- style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),
- const SizedBox(height: 18),
+ const SizedBox(height: 16),
+ SheetTitle(t.importFromApp),
+ const SizedBox(height: 16),
Text(t.importApps,
style: AppTheme.f(10, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.5)),
const SizedBox(height: 10),
- _appRow(gc, 'Hevy', 'workout_data.csv'),
- _appRow(gc, 'Strong', 'strong.csv'),
- _appRow(gc, 'FitNotes', '.fitnotes'),
- _appRow(gc, 'openGym', 'opengym-backup.json'),
- _appRow(gc, 'CSV', t.importOtherCsv),
- const SizedBox(height: 8),
+ ClipRRect(
+ borderRadius: BorderRadius.circular(18),
+ child: ColoredBox(
+ color: gc.bgRaised2,
+ child: Column(children: [
+ for (final (i, (name, what)) in const [
+ ('Hevy', 'workout_data.csv'),
+ ('Strong', 'strong.csv'),
+ ('Lyfta', 'LyftaExport.csv'),
+ ('FitNotes', '.fitnotes'),
+ ('openGym', 'opengym-backup.json'),
+ ('CSV', ''),
+ ].indexed) ...[
+ if (i > 0) Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border),
+ _appRow(gc, name, what.isEmpty ? t.importOtherCsv : what),
+ ],
+ ]),
+ ),
+ ),
+ const SizedBox(height: 12),
Text(t.importHint, style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary, height: 1.4)),
const SizedBox(height: 18),
PrimaryButton(
@@ -466,20 +655,20 @@ class SettingsScreen extends StatelessWidget {
}
Widget _appRow(GymColors gc, String name, String what) {
- return Container(
- margin: const EdgeInsets.only(bottom: 8),
- padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(14)),
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
- width: 76,
- child: Text(name, style: AppTheme.f(13.5, weight: FontWeight.w700, color: gc.text)),
+ width: 80,
+ child: Text(name, style: AppTheme.f(14.5, weight: FontWeight.w700, color: gc.text)),
),
const SizedBox(width: 8),
Expanded(
- child: Text(what, style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.35)),
+ child: Text(what,
+ textAlign: TextAlign.right,
+ style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.35)),
),
],
),
@@ -562,7 +751,7 @@ class SettingsScreen extends StatelessWidget {
Future<bool?> _askImportUnit(BuildContext context) {
final gc = context.gc;
- return showDialog<bool>(
+ return showAppDialog<bool>(
context: context,
builder: (dctx) => appDialog(
gc,
@@ -622,7 +811,7 @@ class SettingsScreen extends StatelessWidget {
final gc = context.gc;
var minutes = fit.trainReminderMin ?? 19 * 60;
var smart = fit.smartReminder;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
builder: (sheet) => StatefulBuilder(
@@ -637,10 +826,8 @@ class SettingsScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.trainReminder,
- textAlign: TextAlign.center,
- style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),
+ const SizedBox(height: 16),
+ SheetTitle(t.trainReminder),
const SizedBox(height: 16),
Center(
child: SegToggle([
@@ -738,7 +925,7 @@ class SettingsScreen extends StatelessWidget {
void _editBackground(BuildContext context) {
final gc = context.gc;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
@@ -757,19 +944,37 @@ class SettingsScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.background,
- textAlign: TextAlign.center,
- style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),
- const SizedBox(height: 18),
- for (final pattern in ['none', 'dots', 'grid'])
- _bgOption(gc, _bgName(pattern), fit.bgPattern == pattern,
- () => setSheet(() => fit.setBgPattern(pattern))),
- if (photo != null)
- _bgOption(gc, t.bgPhoto, fit.bgPattern == 'photo',
- () => setSheet(() => fit.setBgPattern('photo')),
- thumb: photo),
- const SizedBox(height: 8),
+ const SizedBox(height: 16),
+ SheetTitle(t.background),
+ const SizedBox(height: 14),
+ OptionGroup([
+ for (final (pattern, icon) in const [
+ ('none', PhosphorIconsRegular.square),
+ ('dots', PhosphorIconsRegular.dotsNine),
+ ('grid', PhosphorIconsRegular.gridFour),
+ ])
+ OptionItem(
+ _bgName(pattern),
+ icon: icon,
+ selected: fit.bgPattern == pattern,
+ onTap: () => setSheet(() => fit.setBgPattern(pattern)),
+ ),
+ if (photo != null)
+ OptionItem(
+ t.bgPhoto,
+ selected: fit.bgPattern == 'photo',
+ leading: ClipRRect(
+ borderRadius: BorderRadius.circular(6),
+ child: Image.file(File(photo),
+ width: 26,
+ height: 20,
+ fit: BoxFit.cover,
+ errorBuilder: (_, _, _) => const SizedBox(width: 26, height: 20)),
+ ),
+ onTap: () => setSheet(() => fit.setBgPattern('photo')),
+ ),
+ ]),
+ const SizedBox(height: 16),
if (photo != null) ...[
Text(t.bgDim,
style: AppTheme.f(10, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.5)),
@@ -820,42 +1025,6 @@ class SettingsScreen extends StatelessWidget {
);
}
- Widget _bgOption(GymColors gc, String label, bool selected, VoidCallback onTap, {String? thumb}) {
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onTap,
- child: Container(
- margin: const EdgeInsets.only(bottom: 8),
- padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
- decoration: BoxDecoration(
- color: selected ? gc.emberSoft : gc.bgRaised2,
- borderRadius: BorderRadius.circular(14),
- border: Border.all(color: selected ? gc.ember : Colors.transparent),
- ),
- child: Row(
- children: [
- if (thumb != null) ...[
- ClipRRect(
- borderRadius: BorderRadius.circular(8),
- child: Image.file(File(thumb),
- width: 40,
- height: 30,
- fit: BoxFit.cover,
- errorBuilder: (_, _, _) => const SizedBox(width: 40, height: 30)),
- ),
- const SizedBox(width: 12),
- ],
- Expanded(
- child: Text(label,
- style: AppTheme.f(14, weight: FontWeight.w600, color: selected ? gc.ember : gc.text)),
- ),
- if (selected) Icon(PhosphorIconsBold.check, size: 14, color: gc.ember),
- ],
- ),
- ),
- );
- }
-
Future<void> _pickBackground() async {
try {
final result = await FilePicker.platform.pickFiles(type: FileType.image);
@@ -865,15 +1034,16 @@ class SettingsScreen extends StatelessWidget {
}
void _editLanguage(BuildContext context) {
- showModalBottomSheet(
+ showAppSheet(
context: context,
+ isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (_) => _LanguageSheet(),
);
}
void _editAlarmSound(BuildContext context) {
- showModalBottomSheet(
+ showAppSheet(
context: context,
backgroundColor: Colors.transparent,
builder: (_) => _AlarmSoundSheet(
@@ -945,26 +1115,18 @@ class SettingsScreen extends StatelessWidget {
void _snack(BuildContext context, String msg) {
- final gc = context.gc;
- ScaffoldMessenger.of(context).showSnackBar(SnackBar(
- content: Text(msg, style: AppTheme.f(13, weight: FontWeight.w600, color: gc.onEmber)),
- backgroundColor: gc.ember,
- behavior: SnackBarBehavior.floating,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
- margin: const EdgeInsets.fromLTRB(20, 0, 20, 100),
- duration: const Duration(seconds: 2),
- ));
+ showNotchToast(context, msg, icon: PhosphorIconsFill.checkCircle, accent: context.gc.sage);
}
}
class _LanguageSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final gc = context.gc;
return Container(
+ constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(context).height * 0.66),
padding: sheetPad(context),
decoration: BoxDecoration(
- color: gc.bgRaised,
+ color: context.gc.bgRaised,
borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
),
child: Column(
@@ -972,39 +1134,26 @@ class _LanguageSheet extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.languageLabel,
- textAlign: TextAlign.center,
- style: AppTheme.f(17, weight: FontWeight.w700, color: gc.text)),
- const SizedBox(height: 18),
- for (final code in appLanguages) ...[
- _option(context, code),
- const SizedBox(height: 10),
- ],
- ],
- ),
- );
- }
-
- Widget _option(BuildContext context, String code) {
- final gc = context.gc;
- final active = fit.language == code;
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- fit.setLanguage(code);
- Navigator.of(context).pop();
- },
- child: SoftCard(
- radius: 16,
- padding: const EdgeInsets.all(16),
- child: Row(children: [
- Expanded(
- child: Text(languageNameOf(code),
- style: AppTheme.f(14, weight: FontWeight.w600, color: active ? gc.ember : gc.text)),
+ const SizedBox(height: 16),
+ SheetTitle(t.languageLabel),
+ const SizedBox(height: 14),
+ Flexible(
+ child: OptionGroup(
+ scroll: true,
+ [
+ for (final code in appLanguages)
+ OptionItem(
+ languageNameOf(code),
+ selected: fit.language == code,
+ onTap: () {
+ fit.setLanguage(code);
+ Navigator.of(context).pop();
+ },
+ ),
+ ],
+ ),
),
- if (active) Icon(PhosphorIconsFill.check, size: 16, color: gc.ember),
- ]),
+ ],
),
);
}
@@ -1019,12 +1168,11 @@ class _AlarmSoundSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final gc = context.gc;
final current = fit.alarmSoundName ?? t.alarmDefaultName;
return Container(
padding: sheetPad(context),
decoration: BoxDecoration(
- color: gc.bgRaised,
+ color: context.gc.bgRaised,
borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
),
child: Column(
@@ -1032,46 +1180,23 @@ class _AlarmSoundSheet extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.alarmSound,
- textAlign: TextAlign.center,
- style: AppTheme.f(17, weight: FontWeight.w700, color: gc.text)),
- const SizedBox(height: 4),
- Text('$current · ${t.alarmSoundHint}',
- textAlign: TextAlign.center, style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),
- const SizedBox(height: 18),
- _option(context, PhosphorIconsRegular.play, t.alarmPreview, onPreview),
- const SizedBox(height: 10),
- _option(context, PhosphorIconsRegular.uploadSimple, t.alarmChoose, onChoose),
- if (onReset != null) ...[
- const SizedBox(height: 10),
- _option(context, PhosphorIconsRegular.arrowCounterClockwise, t.alarmReset, onReset!),
- ],
+ const SizedBox(height: 16),
+ SheetTitle(t.alarmSound, subtitle: '$current · ${t.alarmSoundHint}'),
+ const SizedBox(height: 14),
+ OptionGroup([
+ OptionItem(t.alarmPreview, icon: PhosphorIconsRegular.play, onTap: onPreview),
+ OptionItem(t.alarmChoose, icon: PhosphorIconsRegular.uploadSimple, onTap: onChoose),
+ if (onReset != null)
+ OptionItem(t.alarmReset, icon: PhosphorIconsRegular.arrowCounterClockwise, onTap: onReset!),
+ ]),
],
),
);
}
-
- Widget _option(BuildContext context, IconData icon, String label, VoidCallback onTap) {
- final gc = context.gc;
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onTap,
- child: SoftCard(
- radius: 16,
- padding: const EdgeInsets.all(16),
- child: Row(children: [
- Icon(icon, size: 20, color: gc.textSecondary),
- const SizedBox(width: 14),
- Expanded(child: Text(label, style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text))),
- ]),
- ),
- );
- }
}
void showProfileSheet(BuildContext context) {
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
@@ -1172,13 +1297,14 @@ class _ProfileSheetState extends State<_ProfileSheet> {
SegOption(t.female, p.sex == 'female', () => _up(() => fit.updateProfile(sex: 'female'))),
])),
const SizedBox(height: 12),
- _stepRow(gc, t.ageLabel, '${p.age}', () => _up(() => fit.updateProfile(ageDelta: -1)), () => _up(() => fit.updateProfile(ageDelta: 1))),
+ _stepRow(gc, t.ageLabel, '${p.age}', () => _up(() => fit.updateProfile(ageDelta: -1)), () => _up(() => fit.updateProfile(ageDelta: 1)), edit: editAge),
const SizedBox(height: 12),
- _stepRow(gc, t.heightLabel, '${fmt(p.heightCm)} cm', () => _up(() => fit.updateProfile(heightDelta: -1)), () => _up(() => fit.updateProfile(heightDelta: 1))),
+ _stepRow(gc, t.heightLabel, fit.heightLabel(p.heightCm), () => _up(() => fit.updateProfile(heightDelta: -fit.heightStep)), () => _up(() => fit.updateProfile(heightDelta: fit.heightStep)), edit: editHeight),
const SizedBox(height: 12),
_stepRow(gc, t.weightLabel, fit.weightLabel(p.weightKg),
() => _up(() => fit.updateProfile(weightDelta: -fit.fromDisplayWeight(fit.isLb ? 1 : 0.5))),
- () => _up(() => fit.updateProfile(weightDelta: fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)))),
+ () => _up(() => fit.updateProfile(weightDelta: fit.fromDisplayWeight(fit.isLb ? 1 : 0.5))),
+ edit: editBodyWeight),
const SizedBox(height: 12),
_stepRow(gc, t.weeklyGoal, '${p.weeklyGoal}×', () => _up(() => fit.updateProfile(weeklyGoalDelta: -1)), () => _up(() => fit.updateProfile(weeklyGoalDelta: 1))),
const SizedBox(height: 12),
@@ -1351,8 +1477,21 @@ class _ProfileSheetState extends State<_ProfileSheet> {
);
}
- Widget _stepRow(GymColors gc, String label, String value, VoidCallback dec, VoidCallback inc) {
- return _row(gc, label, StepperControl(value: value, minWidth: 64, btnSize: 30, gap: 12, fontSize: 15, onDec: dec, onInc: inc));
+ Widget _stepRow(GymColors gc, String label, String value, VoidCallback dec, VoidCallback inc,
+ {Future<void> Function(BuildContext)? edit}) {
+ return _row(
+ gc,
+ label,
+ StepperControl(
+ value: value,
+ minWidth: 64,
+ btnSize: 30,
+ gap: 12,
+ fontSize: 15,
+ onDec: dec,
+ onInc: inc,
+ onEdit: edit == null ? null : () => edit(context).then((_) => _up(() {})),
+ ));
}
Widget _act(GymColors gc, String label, double v) {
diff --git a/lib/screens/start_sheet.dart b/lib/screens/start_sheet.dart
index ae0bd6d..e8b5c35 100644
--- a/lib/screens/start_sheet.dart
+++ b/lib/screens/start_sheet.dart
@@ -6,10 +6,11 @@ import '../models/workout.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/glass.dart';
import '../widgets/ui_kit.dart';
void showStartSheet(BuildContext context, {DateTime? day}) {
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
diff --git a/lib/screens/sticker_screen.dart b/lib/screens/sticker_screen.dart
new file mode 100644
index 0000000..b22ebdf
--- /dev/null
+++ b/lib/screens/sticker_screen.dart
@@ -0,0 +1,731 @@
+import 'dart:io';
+import 'dart:ui' as ui;
+
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+import 'package:flutter/services.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:intl/intl.dart';
+import 'package:path_provider/path_provider.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+import 'package:share_plus/share_plus.dart';
+
+import '../l10n/l10n.dart';
+import '../models/workout.dart';
+import '../services/gallery.dart';
+import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import '../widgets/liquid_notch.dart';
+import '../widgets/ui_kit.dart';
+
+Future<void> showStickerEditor(BuildContext context, LoggedSession session, {int prs = 0}) =>
+ Navigator.of(context).push(PageRouteBuilder<void>(
+ transitionDuration: const Duration(milliseconds: 340),
+ reverseTransitionDuration: const Duration(milliseconds: 240),
+ pageBuilder: (_, _, _) => StickerEditor(session: session, prs: prs),
+ transitionsBuilder: (_, animation, _, child) {
+ final a = CurvedAnimation(parent: animation, curve: Curves.easeOutCubic);
+ return FadeTransition(
+ opacity: a,
+ child: SlideTransition(
+ position: Tween(begin: const Offset(0, 0.04), end: Offset.zero).animate(a),
+ child: child,
+ ),
+ );
+ },
+ ));
+
+class StickerEditor extends StatefulWidget {
+ const StickerEditor({super.key, required this.session, this.prs = 0});
+
+ final LoggedSession session;
+ final int prs;
+
+ @override
+ State<StickerEditor> createState() => _StickerEditorState();
+}
+
+class _StickerEditorState extends State<StickerEditor> {
+ static const _base = 360.0;
+
+ final _canvas = GlobalKey();
+ File? _photo;
+ bool _streak = false;
+ bool _date = true;
+ int _layout = 0;
+ int _swatch = 0;
+ Offset _pos = const Offset(0.5, 0.68);
+ double _scale = 1;
+ double _turn = 0;
+ double _startScale = 1;
+ double _startTurn = 0;
+ bool _busy = false;
+
+ List<Color> _swatches(GymColors gc) => [
+ Colors.white,
+ const Color(0xFF111111),
+ gc.accent,
+ gc.brass,
+ gc.sage,
+ const Color(0xFFE8E1D7),
+ ];
+
+ Future<void> _pick(ImageSource source) async {
+ try {
+ final shot = await ImagePicker()
+ .pickImage(source: source, maxWidth: 2160, maxHeight: 3840, imageQuality: 92);
+ if (shot == null || !mounted) return;
+ setState(() => _photo = File(shot.path));
+ } catch (_) {}
+ }
+
+ Future<Uint8List?> _render() async {
+ final boundary = _canvas.currentContext?.findRenderObject() as RenderRepaintBoundary?;
+ if (boundary == null) return null;
+ final image = await boundary.toImage(pixelRatio: 1080 / boundary.size.width);
+ final data = await image.toByteData(format: ui.ImageByteFormat.png);
+ image.dispose();
+ return data?.buffer.asUint8List();
+ }
+
+ Future<void> _run(Future<void> Function(Uint8List png) job) async {
+ if (_busy) return;
+ setState(() => _busy = true);
+ try {
+ final png = await _render();
+ if (png == null) throw StateError('render');
+ await job(png);
+ } catch (_) {
+ if (mounted) {
+ showNotchToast(context, t.shareFailed,
+ icon: PhosphorIconsFill.warningCircle, accent: context.gc.warn);
+ }
+ } finally {
+ if (mounted) setState(() => _busy = false);
+ }
+ }
+
+ Future<void> _share() => _run((png) async {
+ final dir = await getTemporaryDirectory();
+ final file = File('${dir.path}/gymmane-sticker.png');
+ await file.writeAsBytes(png, flush: true);
+ await SharePlus.instance.share(ShareParams(files: [XFile(file.path)], subject: 'GymMane'));
+ });
+
+ Future<void> _save() => _run((png) async {
+ final ok = await saveImageToGallery(png, 'gymmane-${DateTime.now().millisecondsSinceEpoch}.png');
+ if (!ok) throw StateError('save');
+ HapticFeedback.lightImpact();
+ if (mounted) {
+ showNotchToast(context, t.stickerSaved,
+ icon: PhosphorIconsFill.checkCircle, accent: context.gc.sage);
+ }
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final color = _swatches(gc)[_swatch];
+ return Scaffold(
+ backgroundColor: gc.bg,
+ body: SafeArea(
+ child: Column(
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, 4),
+ child: Row(children: [
+ RoundAction(
+ label: MaterialLocalizations.of(context).closeButtonLabel,
+ onTap: () => Navigator.of(context).pop(),
+ child: Icon(PhosphorIconsRegular.x, size: 18, color: gc.text),
+ ),
+ const SizedBox(width: 12),
+ Expanded(
+ child: Text(t.stickerHint,
+ maxLines: 2,
+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary, height: 1.3)),
+ ),
+ ]),
+ ),
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(24, 10, 24, 12),
+ child: Center(
+ child: AspectRatio(
+ aspectRatio: 9 / 16,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(22),
+ child: LayoutBuilder(builder: (context, c) => _stage(gc, c.biggest, color)),
+ ),
+ ),
+ ),
+ ),
+ ),
+ _controls(gc),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _stage(GymColors gc, Size size, Color color) {
+ final unit = size.width / _base;
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onScaleStart: (_) {
+ _startScale = _scale;
+ _startTurn = _turn;
+ },
+ onScaleUpdate: (d) => setState(() {
+ _pos = Offset(
+ (_pos.dx + d.focalPointDelta.dx / size.width).clamp(0.0, 1.0),
+ (_pos.dy + d.focalPointDelta.dy / size.height).clamp(0.0, 1.0),
+ );
+ if (d.pointerCount > 1) {
+ _scale = (_startScale * d.scale).clamp(0.45, 2.6);
+ _turn = _startTurn + d.rotation;
+ }
+ }),
+ onDoubleTap: () => setState(() => _turn = 0),
+ child: Stack(
+ fit: StackFit.expand,
+ children: [
+ if (_photo == null) CustomPaint(painter: _Checker(gc.bgRaised, gc.bgRaised2)),
+ RepaintBoundary(
+ key: _canvas,
+ child: Stack(
+ fit: StackFit.expand,
+ children: [
+ if (_photo != null) Image.file(_photo!, fit: BoxFit.cover),
+ Positioned(
+ left: _pos.dx * size.width,
+ top: _pos.dy * size.height,
+ child: FractionalTranslation(
+ translation: const Offset(-0.5, -0.5),
+ child: Transform.rotate(
+ angle: _turn,
+ child: Transform.scale(
+ scale: _scale * unit,
+ child: _Sticker(
+ session: widget.session,
+ prs: widget.prs,
+ streak: _streak,
+ layout: _layout,
+ showDate: _date,
+ color: color,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _controls(GymColors gc) {
+ final swatches = _swatches(gc);
+ return Container(
+ padding: const EdgeInsets.fromLTRB(16, 14, 16, 12),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(26)),
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Row(children: [
+ _chip(gc, PhosphorIconsRegular.image, t.stickerGallery, false, () => _pick(ImageSource.gallery)),
+ const SizedBox(width: 8),
+ _chip(gc, PhosphorIconsRegular.camera, t.stickerCamera, false, () => _pick(ImageSource.camera)),
+ const SizedBox(width: 8),
+ _chip(gc, PhosphorIconsRegular.checkerboard, t.stickerNoPhoto, _photo == null,
+ () => setState(() => _photo = null)),
+ ]),
+ const SizedBox(height: 12),
+ Row(children: [
+ SegToggle([
+ SegOption(t.stickerWorkout, !_streak, () => setState(() => _streak = false)),
+ SegOption(t.stickerStreak, _streak, () => setState(() => _streak = true)),
+ ]),
+ const Spacer(),
+ Pill(
+ label: t.stickerDate,
+ bg: _date ? gc.emberSoft : gc.bgRaised2,
+ fg: _date ? gc.text : gc.textTertiary,
+ fontSize: 12,
+ onTap: () => setState(() => _date = !_date),
+ ),
+ ]),
+ const SizedBox(height: 10),
+ Row(children: [
+ for (final (i, icon) in [
+ PhosphorIconsRegular.rows,
+ PhosphorIconsRegular.columns,
+ PhosphorIconsRegular.textAa,
+ PhosphorIconsRegular.squaresFour,
+ PhosphorIconsRegular.listBullets,
+ PhosphorIconsRegular.equals,
+ ].indexed) ...[
+ if (i > 0) const SizedBox(width: 6),
+ Expanded(child: _iconToggle(gc, icon, _layout == i, () => setState(() => _layout = i))),
+ ],
+ ]),
+ const SizedBox(height: 12),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ for (final (i, c) in swatches.indexed)
+ Pressable(
+ onTap: () => setState(() => _swatch = i),
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 180),
+ width: 34,
+ height: 34,
+ padding: const EdgeInsets.all(3),
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ border: Border.all(color: i == _swatch ? gc.text : Colors.transparent, width: 2),
+ ),
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ color: c,
+ shape: BoxShape.circle,
+ border: Border.all(color: gc.border),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 14),
+ Row(children: [
+ Expanded(
+ child: PrimaryButton(
+ label: t.save,
+ height: 52,
+ bg: gc.bgRaised2,
+ fg: gc.text,
+ onTap: _save,
+ ),
+ ),
+ const SizedBox(width: 10),
+ Expanded(child: PrimaryButton(label: t.share, height: 52, onTap: _share)),
+ ]),
+ ],
+ ),
+ );
+ }
+
+ Widget _chip(GymColors gc, IconData icon, String label, bool on, VoidCallback onTap) => Expanded(
+ child: Pressable(
+ onTap: onTap,
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 180),
+ height: 44,
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ decoration: BoxDecoration(
+ color: on ? gc.emberSoft : gc.bgRaised2,
+ borderRadius: BorderRadius.circular(14),
+ ),
+ child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
+ Icon(icon, size: 16, color: on ? gc.text : gc.textSecondary),
+ const SizedBox(width: 6),
+ Flexible(
+ child: Text(label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(12, weight: FontWeight.w700, color: on ? gc.text : gc.textSecondary)),
+ ),
+ ]),
+ ),
+ ),
+ );
+
+ Widget _iconToggle(GymColors gc, IconData icon, bool on, VoidCallback onTap) => Pressable(
+ onTap: onTap,
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 180),
+ height: 38,
+ decoration: BoxDecoration(
+ color: on ? gc.emberSoft : gc.bgRaised2,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Icon(icon, size: 17, color: on ? gc.text : gc.textTertiary),
+ ),
+ );
+}
+
+class _Sticker extends StatelessWidget {
+ const _Sticker({
+ required this.session,
+ required this.prs,
+ required this.streak,
+ required this.layout,
+ required this.showDate,
+ required this.color,
+ });
+
+ final LoggedSession session;
+ final int prs;
+ final bool streak;
+ final int layout;
+ final bool showDate;
+ final Color color;
+
+ bool get _light => color.computeLuminance() > 0.5;
+
+ List<Shadow> get _shadow =>
+ _light ? const [Shadow(color: Color(0x59000000), blurRadius: 12, offset: Offset(0, 1))] : const [];
+
+ TextStyle _s(double size, FontWeight w, {double alpha = 1, double spacing = 0, double height = 1.05}) =>
+ AppTheme.f(size, weight: w, color: color.withValues(alpha: alpha), letterSpacing: spacing, height: height)
+ .copyWith(shadows: _shadow, fontFeatures: const [ui.FontFeature.tabularFigures()]);
+
+ String get _dateLine {
+ final d = session.date;
+ return '${t.longDate(d)} · ${DateFormat.Hm(intlLocale).format(d)}';
+ }
+
+ String get _duration => durationClock(session.durationSec);
+ String get _volume => fit.volumeLabel(session.volume);
+ String get _sets => '${session.setCount}';
+
+ static const _widths = [230.0, 300.0, 260.0, 280.0, 280.0, 320.0];
+
+ @override
+ Widget build(BuildContext context) {
+ return SizedBox(
+ width: _widths[layout.clamp(0, 5)],
+ child: streak ? _streakBody() : _workoutBody(),
+ );
+ }
+
+ Widget _mark({double size = 12}) => Row(mainAxisSize: MainAxisSize.min, children: [
+ Image.asset(
+ 'assets/img/runner.png',
+ height: size + 5,
+ color: color.withValues(alpha: 0.9),
+ colorBlendMode: BlendMode.srcIn,
+ ),
+ const SizedBox(width: 5),
+ Text('GymMane', style: _s(size, FontWeight.w900, alpha: 0.9, spacing: 0.2)),
+ ]);
+
+ Widget _kicker(String text) =>
+ Text(text.toUpperCase(), style: _s(10.5, FontWeight.w800, alpha: 0.75, spacing: 2.2));
+
+ Widget _date({TextAlign align = TextAlign.left}) =>
+ Text(_dateLine, textAlign: align, style: _s(12, FontWeight.w600, alpha: 0.75, height: 1.2));
+
+ Widget _stat(String label, String value, {double size = 30}) => Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(label.toUpperCase(), style: _s(9.5, FontWeight.w700, alpha: 0.7, spacing: 1.5)),
+ const SizedBox(height: 2),
+ Text(value, maxLines: 1, style: _s(size, FontWeight.w900)),
+ ],
+ );
+
+ Widget _panel(Widget child) => Container(
+ padding: const EdgeInsets.fromLTRB(18, 16, 18, 16),
+ decoration: BoxDecoration(
+ color: (_light ? Colors.black : Colors.white).withValues(alpha: 0.34),
+ borderRadius: BorderRadius.circular(24),
+ border: Border.all(color: color.withValues(alpha: 0.18)),
+ ),
+ child: child,
+ );
+
+ Widget _prs({TextAlign align = TextAlign.left}) =>
+ Text(t.prCount(prs), textAlign: align, style: _s(12, FontWeight.w800, alpha: 0.9));
+
+ Widget _workoutBody() {
+ switch (layout) {
+ case 1:
+ return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ _kicker(t.stickerWorkout),
+ if (showDate) ...[const SizedBox(height: 3), _date()],
+ const SizedBox(height: 14),
+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Expanded(child: _stat(t.duration, _duration, size: 24)),
+ Expanded(child: _stat(t.volume, _volume, size: 24)),
+ Expanded(child: _stat(t.setsCaps, _sets, size: 24)),
+ ]),
+ if (prs > 0) ...[const SizedBox(height: 10), _prs()],
+ const SizedBox(height: 14),
+ _mark(),
+ ]);
+ case 2:
+ return Column(mainAxisSize: MainAxisSize.min, children: [
+ _kicker(t.stickerWorkout),
+ if (showDate) ...[const SizedBox(height: 3), _date(align: TextAlign.center)],
+ const SizedBox(height: 6),
+ FittedBox(child: Text(_volume, style: _s(64, FontWeight.w900, height: 1))),
+ const SizedBox(height: 6),
+ Text('$_duration · $_sets ${t.setsCaps.toLowerCase()}', style: _s(15, FontWeight.w700, alpha: 0.85)),
+ if (prs > 0) ...[const SizedBox(height: 6), _prs(align: TextAlign.center)],
+ const SizedBox(height: 14),
+ _mark(),
+ ]);
+ case 3:
+ return _panel(Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ Row(children: [
+ Expanded(child: _kicker(t.stickerWorkout)),
+ _mark(size: 11),
+ ]),
+ if (showDate) ...[const SizedBox(height: 4), _date()],
+ const SizedBox(height: 16),
+ Row(children: [
+ Expanded(child: _stat(t.duration, _duration, size: 26)),
+ Expanded(child: _stat(t.volume, _volume, size: 26)),
+ ]),
+ const SizedBox(height: 14),
+ Row(children: [
+ Expanded(child: _stat(t.setsCaps, _sets, size: 26)),
+ Expanded(child: _stat(t.exercises, '${session.exercises.length}', size: 26)),
+ ]),
+ if (prs > 0) ...[const SizedBox(height: 12), _prs()],
+ ]));
+ case 4:
+ final shown = session.exercises.take(5).toList();
+ final more = session.exercises.length - shown.length;
+ return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ _kicker(t.stickerWorkout),
+ if (showDate) ...[const SizedBox(height: 3), _date()],
+ const SizedBox(height: 12),
+ for (final e in shown) ...[
+ Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [
+ Expanded(
+ child: Text(t.catalogName(e.id, e.name),
+ maxLines: 1, overflow: TextOverflow.ellipsis, style: _s(14, FontWeight.w800, height: 1.2)),
+ ),
+ const SizedBox(width: 10),
+ Text(_best(e), style: _s(12.5, FontWeight.w700, alpha: 0.8)),
+ ]),
+ const SizedBox(height: 7),
+ ],
+ if (more > 0) ...[
+ Text('+$more', style: _s(12, FontWeight.w700, alpha: 0.7)),
+ const SizedBox(height: 7),
+ ],
+ Container(height: 1, color: color.withValues(alpha: 0.3)),
+ const SizedBox(height: 9),
+ Text('$_duration · $_volume · $_sets ${t.setsCaps.toLowerCase()}',
+ style: _s(12.5, FontWeight.w800, alpha: 0.9)),
+ const SizedBox(height: 12),
+ _mark(),
+ ]);
+ case 5:
+ final sep = Container(width: 1, height: 30, color: color.withValues(alpha: 0.35));
+ return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ Row(children: [
+ _mark(size: 11),
+ if (showDate) ...[
+ const SizedBox(width: 10),
+ Flexible(child: Text(_dateLine, maxLines: 1, overflow: TextOverflow.ellipsis,
+ style: _s(11, FontWeight.w600, alpha: 0.7))),
+ ],
+ ]),
+ const SizedBox(height: 10),
+ Row(children: [
+ Expanded(child: _stat(t.duration, _duration, size: 21)),
+ sep,
+ const SizedBox(width: 12),
+ Expanded(child: _stat(t.volume, _volume, size: 21)),
+ sep,
+ const SizedBox(width: 12),
+ Expanded(child: _stat(t.setsCaps, _sets, size: 21)),
+ ]),
+ ]);
+ default:
+ return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ _kicker(t.stickerWorkout),
+ if (showDate) ...[const SizedBox(height: 3), _date()],
+ const SizedBox(height: 16),
+ _stat(t.duration, _duration, size: 34),
+ const SizedBox(height: 12),
+ _stat(t.volume, _volume, size: 34),
+ const SizedBox(height: 12),
+ _stat(t.setsCaps, _sets, size: 34),
+ if (prs > 0) ...[const SizedBox(height: 12), _prs()],
+ const SizedBox(height: 16),
+ _mark(),
+ ]);
+ }
+ }
+
+ String _best(LoggedExercise e) {
+ final sets = e.workingSets.isEmpty ? e.sets : e.workingSets;
+ if (sets.isEmpty) return '';
+ final top = sets.reduce((a, b) => a.weight * (a.reps + 1) >= b.weight * (b.reps + 1) ? a : b);
+ if (top.weight > 0 && top.reps > 0 && (top.km ?? 0) <= 0) return '${fit.weightLabel(top.weight)} × ${top.reps}';
+ return fit.loggedSetLabel(top);
+ }
+
+ Widget _streakBody() {
+ final start = fit.weekStartDate;
+ final trained = <int>{};
+ for (final s in fit.sessions) {
+ final d = DateTime(s.date.year, s.date.month, s.date.day).difference(start).inDays;
+ if (d >= 0 && d < 7) trained.add(d);
+ }
+ final now = DateTime.now();
+ final todayIdx = DateTime(now.year, now.month, now.day).difference(start).inDays;
+ final days = fit.currentStreak;
+
+ Widget week({double dot = 20, double gap = 4}) => Row(mainAxisSize: MainAxisSize.min, children: [
+ for (var i = 0; i < 7; i++)
+ Padding(
+ padding: EdgeInsets.symmetric(horizontal: gap),
+ child: Column(mainAxisSize: MainAxisSize.min, children: [
+ Container(
+ width: dot,
+ height: dot,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: trained.contains(i) ? color : Colors.transparent,
+ border: Border.all(color: color.withValues(alpha: i == todayIdx ? 0.95 : 0.4), width: 1.6),
+ ),
+ ),
+ const SizedBox(height: 5),
+ Text(t.weekdayInitial(start.add(Duration(days: i)).weekday).toUpperCase(),
+ style: _s(9.5, FontWeight.w700, alpha: 0.7)),
+ ]),
+ ),
+ ]);
+
+ Widget big(double size) => Row(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Icon(PhosphorIconsFill.fire, size: size * 0.7, color: color, shadows: _shadow),
+ const SizedBox(width: 6),
+ Text('$days', style: _s(size, FontWeight.w900, height: 1)),
+ ],
+ );
+
+ final label = Text(t.shareStreakLabel, style: _s(10.5, FontWeight.w800, alpha: 0.75, spacing: 1.4));
+ final weekCount = _stat(t.stickerWeek, '${trained.length}/7', size: 22);
+
+ switch (layout) {
+ case 1:
+ return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ _kicker(t.stickerStreak),
+ if (showDate) ...[const SizedBox(height: 3), _date()],
+ const SizedBox(height: 10),
+ Row(children: [
+ big(46),
+ const SizedBox(width: 12),
+ Expanded(child: label),
+ ]),
+ const SizedBox(height: 14),
+ week(),
+ const SizedBox(height: 14),
+ _mark(),
+ ]);
+ case 2:
+ return Column(mainAxisSize: MainAxisSize.min, children: [
+ _kicker(t.stickerStreak),
+ if (showDate) ...[const SizedBox(height: 3), _date(align: TextAlign.center)],
+ const SizedBox(height: 8),
+ Icon(PhosphorIconsFill.fire, size: 46, color: color, shadows: _shadow),
+ Text('$days', style: _s(96, FontWeight.w900, height: 1)),
+ label,
+ const SizedBox(height: 16),
+ _mark(),
+ ]);
+ case 3:
+ return _panel(Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ Row(children: [
+ Expanded(child: _kicker(t.stickerStreak)),
+ _mark(size: 11),
+ ]),
+ if (showDate) ...[const SizedBox(height: 4), _date()],
+ const SizedBox(height: 12),
+ big(50),
+ const SizedBox(height: 2),
+ label,
+ const SizedBox(height: 14),
+ week(dot: 18, gap: 3.5),
+ ]));
+ case 4:
+ return Column(mainAxisSize: MainAxisSize.min, children: [
+ _kicker(t.stickerWeek),
+ if (showDate) ...[const SizedBox(height: 3), _date(align: TextAlign.center)],
+ const SizedBox(height: 14),
+ week(dot: 26, gap: 5),
+ const SizedBox(height: 14),
+ Text(t.streakDays(days), style: _s(13, FontWeight.w800, alpha: 0.9)),
+ const SizedBox(height: 14),
+ _mark(),
+ ]);
+ case 5:
+ return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ Row(children: [
+ _mark(size: 11),
+ if (showDate) ...[
+ const SizedBox(width: 10),
+ Flexible(child: Text(t.longDate(session.date), maxLines: 1, overflow: TextOverflow.ellipsis,
+ style: _s(11, FontWeight.w600, alpha: 0.7))),
+ ],
+ ]),
+ const SizedBox(height: 10),
+ Row(children: [
+ big(30),
+ const SizedBox(width: 10),
+ Flexible(child: label),
+ const SizedBox(width: 12),
+ Container(width: 1, height: 26, color: color.withValues(alpha: 0.35)),
+ const SizedBox(width: 12),
+ weekCount,
+ ]),
+ ]);
+ default:
+ return Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
+ _kicker(t.stickerStreak),
+ if (showDate) ...[const SizedBox(height: 3), _date()],
+ const SizedBox(height: 12),
+ big(64),
+ const SizedBox(height: 2),
+ label,
+ const SizedBox(height: 16),
+ week(dot: 18, gap: 3),
+ const SizedBox(height: 16),
+ _mark(),
+ ]);
+ }
+ }
+}
+
+String durationClock(int sec) {
+ final h = sec ~/ 3600, m = (sec % 3600) ~/ 60, s = sec % 60;
+ final ss = s.toString().padLeft(2, '0');
+ return h > 0 ? '$h:${m.toString().padLeft(2, '0')}:$ss' : '$m:$ss';
+}
+
+class _Checker extends CustomPainter {
+ _Checker(this.a, this.b);
+
+ final Color a, b;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ canvas.drawRect(Offset.zero & size, Paint()..color = a);
+ final p = Paint()..color = b;
+ const cell = 14.0;
+ for (var y = 0; y * cell < size.height; y++) {
+ for (var x = (y % 2); x * cell < size.width; x += 2) {
+ canvas.drawRect(Rect.fromLTWH(x * cell, y * cell, cell, cell), p);
+ }
+ }
+ }
+
+ @override
+ bool shouldRepaint(_Checker old) => old.a != a || old.b != b;
+}
diff --git a/lib/screens/timeline_screen.dart b/lib/screens/timeline_screen.dart
index f4bddbc..8ef599d 100644
--- a/lib/screens/timeline_screen.dart
+++ b/lib/screens/timeline_screen.dart
@@ -13,6 +13,7 @@ import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/body_map.dart';
import '../widgets/dialogs.dart';
+import '../widgets/glass.dart';
import '../widgets/note_kit.dart';
import '../widgets/photo_source_sheet.dart';
import '../widgets/svg_icon.dart';
@@ -683,7 +684,7 @@ class _TimelineScreenState extends State<TimelineScreen> {
Future<void> _poseSheet(DateTime day) async {
final gc = context.gc;
- final pose = await showModalBottomSheet<String>(
+ final pose = await showAppSheet<String>(
context: context,
backgroundColor: Colors.transparent,
builder: (sheet) => Container(
diff --git a/lib/screens/tool_detail_screen.dart b/lib/screens/tool_detail_screen.dart
index 33cc7ac..fd918e5 100644
--- a/lib/screens/tool_detail_screen.dart
+++ b/lib/screens/tool_detail_screen.dart
@@ -5,6 +5,7 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/dialogs.dart';
+import '../widgets/glass.dart';
import '../widgets/ui_kit.dart';
class ToolDetailScreen extends StatelessWidget {
@@ -19,6 +20,7 @@ class ToolDetailScreen extends StatelessWidget {
return SafeArea(
bottom: false,
child: SingleChildScrollView(
+ clipBehavior: Clip.none,
padding: const EdgeInsets.fromLTRB(20, 12, 20, 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -44,13 +46,40 @@ class ToolDetailScreen extends StatelessWidget {
]),
),
const SizedBox(height: 18),
- ..._inputs(context, gc, id),
+ ..._grouped(_inputs(context, gc, id)),
],
),
),
);
}
+ List<Widget> _grouped(List<Widget> items) {
+ final out = <Widget>[];
+ final run = <ToolRow>[];
+ void add(Widget w) {
+ if (out.isNotEmpty) out.add(const SizedBox(height: 10));
+ out.add(w);
+ }
+
+ void flush() {
+ if (run.isEmpty) return;
+ add(ToolGroup([...run]));
+ run.clear();
+ }
+
+ for (final w in items) {
+ if (w is SizedBox) continue;
+ if (w is ToolRow) {
+ run.add(w);
+ continue;
+ }
+ flush();
+ add(w);
+ }
+ flush();
+ return out;
+ }
+
(String, String, String) _meta(String? id) {
switch (id) {
case 'rm':
@@ -81,7 +110,7 @@ class ToolDetailScreen extends StatelessWidget {
];
case 'bmi':
return [
- ToolRow(label: t.heightLabel, control: StepperControl(value: fit.cmLabel(fit.bmiHeight), onDec: () => fit.bumpBmiHeight(-fit.cmStep), onInc: () => fit.bumpBmiHeight(fit.cmStep), onEdit: () => _editNumber(context, title: t.heightLabel, current: fit.toDisplayCm(fit.bmiHeight), decimal: true, apply: (v) => fit.bumpBmiHeight(fit.fromDisplayCm(v) - fit.bmiHeight)))),
+ ToolRow(label: t.heightLabel, control: StepperControl(value: fit.heightLabel(fit.bmiHeight), onDec: () => fit.bumpBmiHeight(-fit.heightStep), onInc: () => fit.bumpBmiHeight(fit.heightStep), onEdit: () => _editNumber(context, title: t.heightLabel, current: fit.toDisplayCm(fit.bmiHeight), decimal: true, apply: (v) => fit.bumpBmiHeight(fit.fromDisplayCm(v) - fit.bmiHeight)))),
const SizedBox(height: 10),
ToolRow(label: t.weightLabel, control: StepperControl(value: '${fit.weightValue(fit.bmiWeight)} ${fit.units}', onDec: () => fit.bumpBmiWeight(-fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)), onInc: () => fit.bumpBmiWeight(fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)), onEdit: () => _editNumber(context, title: t.weightLabel, current: fit.toDisplayWeight(fit.bmiWeight), decimal: true, apply: (v) => fit.bumpBmiWeight(fit.fromDisplayWeight(v) - fit.bmiWeight)))),
];
@@ -97,7 +126,7 @@ class ToolDetailScreen extends StatelessWidget {
const SizedBox(height: 10),
ToolRow(label: t.ageLabel, control: StepperControl(value: '${fit.calAge}', minWidth: 40, onDec: () => fit.bumpCalAge(-1), onInc: () => fit.bumpCalAge(1), onEdit: () => _editNumber(context, title: t.ageLabel, current: fit.calAge.toDouble(), decimal: false, apply: (v) => fit.bumpCalAge(v.round() - fit.calAge)))),
const SizedBox(height: 10),
- ToolRow(label: t.heightLabel, control: StepperControl(value: fit.cmLabel(fit.calHeight), onDec: () => fit.bumpCalHeight(-fit.cmStep), onInc: () => fit.bumpCalHeight(fit.cmStep), onEdit: () => _editNumber(context, title: t.heightLabel, current: fit.toDisplayCm(fit.calHeight), decimal: true, apply: (v) => fit.bumpCalHeight(fit.fromDisplayCm(v) - fit.calHeight)))),
+ ToolRow(label: t.heightLabel, control: StepperControl(value: fit.heightLabel(fit.calHeight), onDec: () => fit.bumpCalHeight(-fit.heightStep), onInc: () => fit.bumpCalHeight(fit.heightStep), onEdit: () => _editNumber(context, title: t.heightLabel, current: fit.toDisplayCm(fit.calHeight), decimal: true, apply: (v) => fit.bumpCalHeight(fit.fromDisplayCm(v) - fit.calHeight)))),
const SizedBox(height: 10),
ToolRow(label: t.weightLabel, control: StepperControl(value: '${fit.weightValue(fit.calWeight)} ${fit.units}', onDec: () => fit.bumpCalWeight(-fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)), onInc: () => fit.bumpCalWeight(fit.fromDisplayWeight(fit.isLb ? 1 : 0.5)), onEdit: () => _editNumber(context, title: t.weightLabel, current: fit.toDisplayWeight(fit.calWeight), decimal: true, apply: (v) => fit.bumpCalWeight(fit.fromDisplayWeight(v) - fit.calWeight)))),
const SizedBox(height: 10),
@@ -107,7 +136,7 @@ class ToolDetailScreen extends StatelessWidget {
];
case 'bf':
return [
- ToolRow(label: t.heightLabel, control: StepperControl(value: fit.cmLabel(fit.bfHeight), onDec: () => fit.bumpBfHeight(-fit.cmStep), onInc: () => fit.bumpBfHeight(fit.cmStep), onEdit: () => _editNumber(context, title: t.heightLabel, current: fit.toDisplayCm(fit.bfHeight), decimal: true, apply: (v) => fit.bumpBfHeight(fit.fromDisplayCm(v) - fit.bfHeight)))),
+ ToolRow(label: t.heightLabel, control: StepperControl(value: fit.heightLabel(fit.bfHeight), onDec: () => fit.bumpBfHeight(-fit.heightStep), onInc: () => fit.bumpBfHeight(fit.heightStep), onEdit: () => _editNumber(context, title: t.heightLabel, current: fit.toDisplayCm(fit.bfHeight), decimal: true, apply: (v) => fit.bumpBfHeight(fit.fromDisplayCm(v) - fit.bfHeight)))),
const SizedBox(height: 10),
ToolRow(label: t.neck, control: StepperControl(value: fit.cmLabel(fit.bfNeck), onDec: () => fit.bumpBfNeck(-fit.girthStep), onInc: () => fit.bumpBfNeck(fit.girthStep), onEdit: () => _editNumber(context, title: t.neck, current: fit.toDisplayCm(fit.bfNeck), decimal: true, apply: (v) => fit.bumpBfNeck(fit.fromDisplayCm(v) - fit.bfNeck)))),
const SizedBox(height: 10),
@@ -160,7 +189,8 @@ class ToolDetailScreen extends StatelessWidget {
}
return SoftCard(
- radius: 14,
+ radius: 20,
+ borderColor: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -181,7 +211,8 @@ class ToolDetailScreen extends StatelessWidget {
Widget _macros(GymColors gc) {
Widget card(String label, String value) => Expanded(
child: SoftCard(
- radius: 14,
+ radius: 20,
+ borderColor: Colors.transparent,
padding: const EdgeInsets.all(12),
child: Column(children: [
Text(label, style: AppTheme.f(10, weight: FontWeight.w600, color: gc.textSecondary)),
@@ -218,7 +249,8 @@ class ToolDetailScreen extends StatelessWidget {
final bars = fit.barOptions;
return SoftCard(
- radius: 14,
+ radius: 20,
+ borderColor: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -241,7 +273,8 @@ class ToolDetailScreen extends StatelessWidget {
final target = fit.toDisplayWeight(fit.plateTarget);
final loadable = fit.loadableTotal(target, fit.plateBarDisplay);
return SoftCard(
- radius: 14,
+ radius: 20,
+ borderColor: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -273,7 +306,8 @@ class ToolDetailScreen extends StatelessWidget {
Widget _warmupCard(GymColors gc) {
final sets = fit.warmupSets;
return SoftCard(
- radius: 14,
+ radius: 20,
+ borderColor: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Column(
children: [
@@ -300,7 +334,7 @@ class ToolDetailScreen extends StatelessWidget {
void showPlateSheet(BuildContext context, double displayTarget) {
final gc = context.gc;
var bar = fit.defaultBar;
- showModalBottomSheet<void>(
+ showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
builder: (sheet) => StatefulBuilder(
@@ -318,10 +352,8 @@ void showPlateSheet(BuildContext context, double displayTarget) {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.toolTitle('plate'),
- textAlign: TextAlign.center,
- style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),
+ const SizedBox(height: 16),
+ SheetTitle(t.toolTitle('plate')),
const SizedBox(height: 4),
Text('${fmt(displayTarget)} ${fit.units}',
textAlign: TextAlign.center,
diff --git a/lib/screens/tools_screen.dart b/lib/screens/tools_screen.dart
index bb51913..1b1994f 100644
--- a/lib/screens/tools_screen.dart
+++ b/lib/screens/tools_screen.dart
@@ -27,6 +27,7 @@ class ToolsScreen extends StatelessWidget {
return SafeArea(
bottom: false,
child: SingleChildScrollView(
+ clipBehavior: Clip.none,
padding: const EdgeInsets.fromLTRB(20, 12, 20, 40),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
diff --git a/lib/screens/train_screen.dart b/lib/screens/train_screen.dart
index fa84a2c..81b46d6 100644
--- a/lib/screens/train_screen.dart
+++ b/lib/screens/train_screen.dart
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+import '../catalog/exercise_catalog.dart';
import '../l10n/l10n.dart';
import '../models/exercise.dart';
import '../state/fit_state.dart';
@@ -8,7 +10,9 @@ import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/body_map.dart';
import '../widgets/exercise_media.dart';
+import '../widgets/liquid_notch.dart';
import '../widgets/svg_icon.dart';
+import '../widgets/glass.dart';
import '../widgets/ui_kit.dart';
import 'exercises_screen.dart' show showCreateExerciseSheet;
@@ -22,6 +26,7 @@ class TrainScreen extends StatefulWidget {
class _TrainScreenState extends State<TrainScreen> {
final TextEditingController _searchCtrl = TextEditingController();
String _q = '';
+ String? _gear;
void _clearSearch() {
_searchCtrl.clear();
@@ -54,12 +59,21 @@ class _TrainScreenState extends State<TrainScreen> {
),
),
Expanded(
- child: SingleChildScrollView(
- padding: const EdgeInsets.fromLTRB(20, 20, 20, 12),
- child: review ? _review(context, gc) : _select(context, gc),
+ child: Stack(
+ children: [
+ Positioned.fill(
+ child: SingleChildScrollView(
+ padding: EdgeInsets.fromLTRB(20, 20, 20, review ? 112 : 12),
+ child: review ? _review(context, gc) : _select(context, gc),
+ ),
+ ),
+ if (review) ...[
+ const Positioned(left: 0, right: 0, bottom: 0, child: EdgeBlur(top: false, height: 112, sigma: 11, shade: 0.35)),
+ Positioned(left: 0, right: 0, bottom: 0, child: _startBar(context, gc)),
+ ],
+ ],
),
),
- if (review) _startBar(context, gc),
],
),
);
@@ -67,7 +81,7 @@ class _TrainScreenState extends State<TrainScreen> {
Widget _startBar(BuildContext context, GymColors gc) {
final n = fit.sessionPicks.length;
- return Container(
+ return Padding(
padding: EdgeInsets.fromLTRB(20, 8, 20, 14 + MediaQuery.of(context).padding.bottom),
child: PrimaryButton(
label: n == 0 ? t.pickAnExercise : t.startCount(n),
@@ -145,7 +159,15 @@ class _TrainScreenState extends State<TrainScreen> {
Widget _review(BuildContext context, GymColors gc) {
final searching = _q.trim().isNotEmpty;
- final exercises = searching ? fit.trainSearchResults(_q) : fit.reviewExercises();
+ final all = searching ? fit.trainSearchResults(_q) : fit.reviewExercises();
+ final gearHere = <String>[
+ for (final e in kFilterEquipment)
+ if (all.any((x) => x.equipment == e)) e,
+ ];
+ final gear = gearHere.contains(_gear) ? _gear : null;
+ final exercises = gear == null ? all : all.where((e) => e.equipment == gear).toList();
+ final seeded = searching ? const <Exercise>[] : exercises.where((e) => fit.pickSeed.contains(e.id)).toList();
+ final others = searching ? exercises : exercises.where((e) => !fit.pickSeed.contains(e.id)).toList();
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -169,23 +191,80 @@ class _TrainScreenState extends State<TrainScreen> {
),
const SizedBox(height: 14),
_searchRow(context, gc),
- const SizedBox(height: 14),
- if (!searching && exercises.isNotEmpty) ...[
- Text(t.pickedHint(exercises.length),
+ const SizedBox(height: 12),
+ if (gearHere.length > 1) ...[
+ SingleChildScrollView(
+ scrollDirection: Axis.horizontal,
+ child: Row(children: [
+ _gearChip(gc, t.allExercisesShort, gear == null, null),
+ for (final e in gearHere) _gearChip(gc, t.equipment(e), gear == e, e),
+ ]),
+ ),
+ const SizedBox(height: 14),
+ ],
+ if (!searching && all.isNotEmpty) ...[
+ Text(t.pickedHint(all.length),
style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary)),
const SizedBox(height: 12),
],
if (exercises.isEmpty)
_emptyReview(context, gc, searching)
- else
- for (final ex in exercises) ...[
- _pickRow(gc, ex),
+ else ...[
+ if (seeded.isNotEmpty) ...[
+ _sectionLabel(gc, t.suggestedPicks),
+ for (final ex in seeded) ...[
+ _pickRow(context, gc, ex),
+ const SizedBox(height: 10),
+ ],
+ if (others.isNotEmpty) ...[
+ const SizedBox(height: 10),
+ _sectionLabel(gc, t.moreOptions),
+ ],
+ ],
+ for (final ex in others) ...[
+ _pickRow(context, gc, ex),
const SizedBox(height: 10),
],
+ ],
],
);
}
+ Widget _sectionLabel(GymColors gc, String label) => Padding(
+ padding: const EdgeInsets.only(bottom: 10, left: 2),
+ child: Text(label.toUpperCase(),
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3)),
+ );
+
+ Widget _gearChip(GymColors gc, String label, bool on, String? value) => Padding(
+ padding: const EdgeInsets.only(right: 8),
+ child: Pill(
+ label: label,
+ bg: on ? gc.ember : gc.bgRaised2,
+ fg: on ? gc.onEmber : gc.textSecondary,
+ onTap: () => setState(() => _gear = value),
+ hPad: 12,
+ vPad: 6,
+ fontSize: 12,
+ ),
+ );
+
+ void _hideFromSuggestions(BuildContext context, Exercise ex) {
+ if (!fit.suggests(ex.id)) return;
+ HapticFeedback.mediumImpact();
+ fit.toggleSuggest(ex.id);
+ showNotchToast(
+ context,
+ t.noLongerSuggested,
+ subtitle: exerciseName(ex),
+ icon: PhosphorIconsFill.eyeSlash,
+ accent: context.gc.warn,
+ action: t.undo,
+ onTap: () => fit.toggleSuggest(ex.id),
+ duration: const Duration(milliseconds: 3200),
+ );
+ }
+
Widget _searchRow(BuildContext context, GymColors gc) {
final hasQuery = _q.isNotEmpty;
return Row(
@@ -228,6 +307,26 @@ class _TrainScreenState extends State<TrainScreen> {
),
),
const SizedBox(width: 10),
+ GestureDetector(
+ onTap: () => setState(() => fit.toggleResetPicks()),
+ child: Container(
+ width: 48,
+ height: 48,
+ decoration: BoxDecoration(
+ color: fit.sessionPicks.isNotEmpty ? gc.emberSoft : gc.bgRaised,
+ borderRadius: BorderRadius.circular(14),
+ border: Border.all(
+ color: fit.sessionPicks.isNotEmpty ? gc.ember.withValues(alpha: 0.3) : gc.border,
+ ),
+ ),
+ child: Icon(
+ PhosphorIconsRegular.arrowCounterClockwise,
+ size: 20,
+ color: fit.sessionPicks.isNotEmpty ? gc.ember : gc.textTertiary,
+ ),
+ ),
+ ),
+ const SizedBox(width: 10),
GestureDetector(
onTap: () => showCreateExerciseSheet(context, onCreated: (id) {
fit.togglePick(id);
@@ -286,11 +385,12 @@ class _TrainScreenState extends State<TrainScreen> {
);
}
- Widget _pickRow(GymColors gc, Exercise ex) {
+ Widget _pickRow(BuildContext context, GymColors gc, Exercise ex) {
final picked = fit.isPicked(ex.id);
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => fit.togglePick(ex.id),
+ onLongPress: () => _hideFromSuggestions(context, ex),
child: AnimatedContainer(
duration: const Duration(milliseconds: 160),
padding: const EdgeInsets.all(14),
diff --git a/lib/services/local_store.dart b/lib/services/local_store.dart
index 5482f0f..89cfc66 100644
--- a/lib/services/local_store.dart
+++ b/lib/services/local_store.dart
@@ -26,6 +26,10 @@ class Store {
}
}
+ String? note(String key) => _prefs?.getString('gm_$key');
+
+ void setNote(String key, String value) => _prefs?.setString('gm_$key', value);
+
Future<void> save(Map<String, dynamic> data) async {
try {
await _prefs?.setString(_key, jsonEncode(data));
@@ -36,7 +40,8 @@ class Store {
const JsonEncoder.withIndent(' ').convert(data);
String exportCsv(List<LoggedSession> sessions) {
- final rows = StringBuffer('date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg\n');
+ final rows = StringBuffer(
+ 'date,exercise,muscle,set,reps,weight_kg,volume_kg,est_1rm_kg,distance_km,duration_s,rpe\n');
final ordered = [...sessions]..sort((a, b) => a.date.compareTo(b.date));
for (final s in ordered) {
final day = s.date.toIso8601String().split('T').first;
@@ -52,6 +57,9 @@ class Store {
_num(st.weight),
_num(st.volume),
_num(st.oneRm),
+ st.km == null ? '' : _num(st.km!),
+ st.sec ?? '',
+ st.rpe == null ? '' : _num(st.rpe!),
].join(','));
}
}
diff --git a/lib/services/progress_reminder.dart b/lib/services/progress_reminder.dart
index 6c2a904..bb2847c 100644
--- a/lib/services/progress_reminder.dart
+++ b/lib/services/progress_reminder.dart
@@ -23,6 +23,13 @@ class ProgressReminder {
playSound: true,
);
+ DarwinNotificationDetails get _darwin => const DarwinNotificationDetails(
+ presentAlert: true,
+ presentBanner: true,
+ presentList: true,
+ presentSound: true,
+ );
+
Future<void> scheduleFor(DateTime day, int intervalDays) async {
if (!enabled) return;
await cancel();
@@ -36,7 +43,7 @@ class ProgressReminder {
title: t.notifPhotoTitle,
body: t.notifPhotoBody(intervalDays),
scheduledDate: when,
- notificationDetails: NotificationDetails(android: _android),
+ notificationDetails: NotificationDetails(android: _android, iOS: _darwin),
androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
);
} catch (e) {
diff --git a/lib/services/train_reminder.dart b/lib/services/train_reminder.dart
index 9f1de4c..0c1a5ae 100644
--- a/lib/services/train_reminder.dart
+++ b/lib/services/train_reminder.dart
@@ -24,6 +24,13 @@ class TrainReminder {
playSound: true,
);
+ DarwinNotificationDetails get _darwin => const DarwinNotificationDetails(
+ presentAlert: true,
+ presentBanner: true,
+ presentList: true,
+ presentSound: true,
+ );
+
Future<void> cancel() async {
if (!enabled) return;
for (var i = 0; i < _slots; i++) {
@@ -52,7 +59,7 @@ class TrainReminder {
title: t.notifTrainTitle,
body: t.notifTrainBody,
scheduledDate: atLocal(day),
- notificationDetails: NotificationDetails(android: _android),
+ notificationDetails: NotificationDetails(android: _android, iOS: _darwin),
androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
);
slot++;
diff --git a/lib/state/fit_core.dart b/lib/state/fit_core.dart
index cb2954e..10eeb3a 100644
--- a/lib/state/fit_core.dart
+++ b/lib/state/fit_core.dart
@@ -60,6 +60,10 @@ abstract class FitCore extends ChangeNotifier {
final Set<String> repsOnly = {};
final Set<String> repsOnlyOff = {};
+
+ final Set<String> noSuggest = {};
+
+ final Map<String, String> modeOverride = {};
VoidCallback? onWidgetsShouldUpdate;
void refreshWidgets() => _refreshWidgets();
@@ -164,4 +168,26 @@ abstract class FitCore extends ChangeNotifier {
String volumeValue(double kg) => fmt(_round1(toDisplayWeight(kg) / 1000));
String volumeLabel(double kg) => '${volumeValue(kg)} $volumeUnit';
+
+ static const _kmPerMile = 1.609344;
+
+ String get distanceUnit => isLb ? 'mi' : 'km';
+
+ double toDisplayKm(double km) => isLb ? km / _kmPerMile : km;
+
+ double fromDisplayKm(double shown) => isLb ? shown * _kmPerMile : shown;
+
+ String distanceValue(double km) => fmt((toDisplayKm(km) * 100).round() / 100);
+
+ String distanceLabel(double km) => '${distanceValue(km)} $distanceUnit';
+
+ double get distanceStep => 0.1;
+}
+
+String durationLabel(int sec) {
+ final s = sec < 0 ? 0 : sec;
+ final h = s ~/ 3600;
+ final m = (s % 3600) ~/ 60;
+ final r = (s % 60).toString().padLeft(2, '0');
+ return h > 0 ? '$h:${m.toString().padLeft(2, '0')}:$r' : '$m:$r';
}
diff --git a/lib/state/fit_state.dart b/lib/state/fit_state.dart
index 74694aa..d598276 100644
--- a/lib/state/fit_state.dart
+++ b/lib/state/fit_state.dart
@@ -1,11 +1,11 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math' as math;
-import 'dart:typed_data';
import 'dart:ui' show PlatformDispatcher;
import 'package:app_settings/app_settings.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import '../catalog/exercise_catalog.dart';
import '../catalog/program_templates.dart';
@@ -19,6 +19,7 @@ import '../models/profile.dart';
import '../models/progress_shot.dart';
import '../models/workout.dart';
import '../services/alarm_store.dart';
+import '../services/beeper.dart';
import '../services/exercise_match.dart';
import '../services/local_store.dart';
import '../services/media_store.dart';
@@ -54,7 +55,7 @@ class FitState extends FitCore
profile.name = kDefaultName;
}
- dark = data['dark'] as bool? ?? true;
+ themePref = _themeFrom(data, fallback: 'dark');
units = data['units'] as String? ?? 'kg';
_applyLanguage(data['language'] as String? ?? language);
@@ -139,11 +140,32 @@ class FitState extends FitCore
profile.since = DateTime(first.year, first.month, first.day);
}
+ static String _themeFrom(Map<String, dynamic> data, {required String fallback}) {
+ final pref = data['theme'];
+ if (pref is String && const ['system', 'dark', 'light'].contains(pref)) return pref;
+ final dark = data['dark'];
+ if (dark is bool) return dark ? 'dark' : 'light';
+ return fallback;
+ }
+
void _loadToggles(Map<String, dynamic> data) {
+ demoSize = data['demo'] as String? ?? 'large';
+ alarmStyle = data['alarmStyle'] as String? ?? 'quiet';
+ RestAlarm.instance.style = alarmStyle;
+ noSuggest
+ ..clear()
+ ..addAll(((data['noSuggest'] as List?) ?? const []).cast<String>());
+ modeOverride
+ ..clear()
+ ..addAll(((data['exMode'] as Map?) ?? const {}).map((k, v) => MapEntry(k as String, v as String))
+ ..removeWhere((_, v) => !const ['weight', 'cardio', 'time'].contains(v)));
bgDim = (data['bgDim'] as num?)?.toDouble() ?? 0.55;
showFocus = data['showFocus'] as bool? ?? true;
autoAdvance = data['autoAdvance'] as bool? ?? true;
+ keepScreenOn = data['keepAwake'] as bool? ?? true;
+ startCountdown = data['countdown'] as bool? ?? true;
logRpe = data['rpe'] as bool? ?? false;
+ effortScale = data['effort'] == 'rir' ? 'rir' : 'rpe';
trainReminderMin = (data['trainAt'] as num?)?.toInt();
smartReminder = data['trainSmart'] as bool? ?? false;
progressStep
@@ -283,6 +305,7 @@ class FitState extends FitCore
Map<String, dynamic> toJson() => {
'profile': profile.toJson(),
'dark': dark,
+ 'theme': themePref,
'units': units,
'language': language,
'rest': restSeconds,
@@ -293,7 +316,14 @@ class FitState extends FitCore
'bgDim': bgDim,
'showFocus': showFocus,
'autoAdvance': autoAdvance,
+ 'keepAwake': keepScreenOn,
+ 'countdown': startCountdown,
'rpe': logRpe,
+ 'effort': effortScale,
+ 'demo': demoSize,
+ 'alarmStyle': alarmStyle,
+ 'noSuggest': noSuggest.toList(),
+ 'exMode': modeOverride,
'trainAt': trainReminderMin,
'trainSmart': smartReminder,
'alarmAskedAt': alarmAskedAt,
@@ -362,6 +392,9 @@ class FitState extends FitCore
exerciseRest.clear();
progressStep.clear();
autoWarmup.clear();
+ noSuggest.clear();
+ modeOverride.clear();
+ demoSize = 'large';
MediaStore.clearAll();
favorites.clear();
sessionPicks.clear();
@@ -369,7 +402,9 @@ class FitState extends FitCore
profile = Profile();
showFocus = true;
autoAdvance = true;
+ startCountdown = true;
logRpe = false;
+ effortScale = 'rpe';
trainReminderMin = null;
smartReminder = false;
TrainReminder.instance.cancel();
@@ -405,7 +440,7 @@ class FitState extends FitCore
Map<String, String>? restoredMoments}) {
_loading = true;
profile = Profile.fromJson((map['profile'] as Map?)?.cast<String, dynamic>() ?? {});
- dark = map['dark'] as bool? ?? dark;
+ themePref = _themeFrom(map, fallback: themePref);
units = map['units'] as String? ?? units;
_applyLanguage(map['language'] as String? ?? language);
restSeconds = (map['rest'] as num?)?.toInt() ?? restSeconds;
@@ -547,52 +582,232 @@ class FitState extends FitCore
return made;
}
+ static const planTemplate = '{\n'
+ ' "program": "Upper Lower",\n'
+ ' "unit": "kg",\n'
+ ' "routines": [\n'
+ ' {\n'
+ ' "name": "Upper A",\n'
+ ' "days": ["Monday", "Thursday"],\n'
+ ' "exercises": [\n'
+ ' {"name": "Barbell Bench Press", "sets": 4, "reps": 8, "weight": 60, "rest": 120,\n'
+ ' "plan": [{"type": "warmup", "reps": 10, "weight": 30}]},\n'
+ ' {"name": "Barbell Bent Over Row", "sets": 4, "reps": 8, "superset": true},\n'
+ ' {"name": "Dumbbell Biceps Curl", "sets": 3, "reps": 12}\n'
+ ' ]\n'
+ ' }\n'
+ ' ]\n'
+ '}';
+
+ static const planWeeksTemplate = '{"program": "12 weeks", "weeks": [\n'
+ ' {"name": "Week 1", "routines": [{"name": "Day A", "exercises": [{"name": "Barbell Full Squat", "sets": 3, "reps": 8}]}]},\n'
+ ' {"name": "Week 2", "routines": [{"name": "Day A", "exercises": [{"name": "Barbell Full Squat", "sets": 4, "reps": 8}]}]}\n'
+ ']}';
+
String planRequestText() {
final here = allExercises.where(fitsHere).toList();
final lines = <String>[
'GymMane · ${activePlace?.name ?? t.placeAll}',
t.planIntro,
t.planFormat,
- '{"name": "Push", "exercises": [{"name": "Barbell Bench Press", "sets": 3}]}',
+ planTemplate,
+ t.planFormatNotes,
+ planWeeksTemplate,
'',
];
for (final ex in here) {
final local = exerciseName(ex);
final label = local == ex.name ? ex.name : '${ex.name} ($local)';
- lines.add('$label | ${ex.primary} | ${ex.equipment} | ${ex.difficulty}');
+ final mode = modeOf(ex.id);
+ lines.add('$label | ${ex.primary} | ${ex.equipment} | ${ex.difficulty}${mode.isEmpty ? '' : ' | $mode'}');
}
return lines.join('\n');
}
- ({int added, List<String> missed, bool readable}) importPlan(String raw) {
+ ({int added, List<String> missed, bool readable}) importPlan(String raw, {bool schedule = false}) {
final plans = parsePlan(raw);
if (plans.isEmpty) return (added: 0, missed: const [], readable: false);
- var added = 0;
+ final result = applyPlan(plans, schedule: schedule);
+ return (added: result.added, missed: result.missed, readable: true);
+ }
+
+ Exercise? _planExercise(PlanItem item, {bool create = false}) {
+ final byId = item.id == null ? null : exerciseById(item.id!);
+ if (byId != null && (item.name.isEmpty || !isCustom(byId.id) || byId.name == item.name)) return byId;
+ final byName = matchExerciseByName(item.name);
+ if (byName != null) return byName;
+ if (!create || (item.muscle ?? '').isEmpty) return null;
+ final muscle = kMuscles.any((m) => m.id == item.muscle) ? item.muscle! : 'chest';
+ final gear = kEquipment.contains(item.equipment) ? item.equipment! : 'Other';
+ final level = kDifficulties.contains(item.level) ? item.level! : 'Beginner';
+ final id = addCustomExercise(
+ name: item.name, primary: muscle, equipment: gear, difficulty: level, steps: item.steps, mode: item.mode);
+ return exerciseById(id);
+ }
+
+ ({int routines, int added, List<String> missed}) previewPlan(List<PlanRoutine> plans) {
+ var made = 0, added = 0;
final missed = <String>[];
for (final plan in plans) {
- final ids = <String, int>{};
+ var found = 0;
+ for (final item in plan.items) {
+ final known = _planExercise(item) != null || (item.muscle ?? '').isNotEmpty;
+ if (known) {
+ found++;
+ } else if (!missed.contains(item.name)) {
+ missed.add(item.name);
+ }
+ }
+ if (found > 0) made++;
+ added += found;
+ }
+ return (routines: made, added: added, missed: missed);
+ }
+
+ bool _sameRoutine(Routine r, String name, List<String> ids) =>
+ r.name.trim().toLowerCase() == name.trim().toLowerCase() &&
+ r.exerciseIds.length == ids.length &&
+ [for (var i = 0; i < ids.length; i++) r.exerciseIds[i] == ids[i]].every((x) => x);
+
+ ({int routines, int added, List<String> missed}) applyPlan(List<PlanRoutine> plans,
+ {bool schedule = false}) {
+ var made = 0, added = 0;
+ final missed = <String>[];
+ for (final plan in plans) {
+ final picked = <(Exercise, PlanItem)>[];
for (final item in plan.items) {
- final ex = matchExerciseByName(item.name);
+ final ex = _planExercise(item, create: true);
if (ex == null) {
if (!missed.contains(item.name)) missed.add(item.name);
continue;
}
- if (ids.containsKey(ex.id)) continue;
- ids[ex.id] = (item.sets ?? kDefaultRoutineSets).clamp(1, 12);
+ if (picked.any((p) => p.$1.id == ex.id)) continue;
+ picked.add((ex, item));
}
- if (ids.isEmpty) continue;
- final id = createRoutine(plan.name.isEmpty ? t.newRoutineName : plan.name);
- for (final entry in ids.entries) {
- toggleRoutineExercise(id, entry.key);
- bumpRoutineSets(id, entry.key, entry.value - kDefaultRoutineSets);
+ if (picked.isEmpty) continue;
+ final name = plan.name.isEmpty ? t.newRoutineName : plan.name;
+ final ids = [for (final p in picked) p.$1.id];
+ final existing = routines.where((r) => _sameRoutine(r, name, ids) && r.group == plan.group).firstOrNull;
+ final id = existing?.id ?? createRoutine(name);
+ if (existing == null) {
+ setRoutineGroup(id, plan.group);
+ for (final (ex, item) in picked) {
+ toggleRoutineExercise(id, ex.id);
+ final sets = _plannedFrom(item);
+ if (sets.isNotEmpty) {
+ setPlannedSets(id, ex.id, sets);
+ } else if (item.sets != null) {
+ setRoutineSetCount(id, ex.id, item.sets!);
+ }
+ if (item.superset) toggleChain(id, ex.id);
+ final rest = item.restSec;
+ if (rest != null && !hasCustomRest(ex.id)) setExerciseRest(ex.id, rest);
+ }
+ made++;
+ added += picked.length;
+ }
+ if (schedule) {
+ for (final d in plan.days) {
+ weeklyPlan[d] = id;
+ }
}
- added += ids.length;
}
- if (added > 0) {
+ if (added > 0 || schedule) {
persistNow();
+ syncTrainReminder();
notifyListeners();
}
- return (added: added, missed: missed, readable: true);
+ return (routines: made, added: added, missed: missed);
+ }
+
+ List<PlannedSet> _plannedFrom(PlanItem item) {
+ final explicit = [
+ for (final p in item.plan)
+ PlannedSet(
+ reps: p.reps ?? item.reps,
+ weightKg: p.weightKg ?? (p.kind == SetKind.warmup.index ? null : item.weightKg),
+ kind: setKindFrom(p.kind),
+ sec: p.sec,
+ km: p.km,
+ ),
+ ];
+ final working = explicit.where((p) => p.kind != SetKind.warmup).length;
+ final simple = item.reps == null && item.weightKg == null;
+ final wanted = item.sets ?? (working > 0 || simple ? working : kDefaultRoutineSets);
+ if (simple && explicit.isEmpty) return const [];
+ return [
+ ...explicit,
+ for (var i = working; i < wanted.clamp(0, 20); i++) PlannedSet(reps: item.reps, weightKg: item.weightKg),
+ ];
+ }
+
+ static const _kindNames = ['normal', 'warmup', 'drop', 'failure', 'restpause'];
+
+ String exportPlanJson(List<Routine> list, {bool withSchedule = true}) {
+ return encodePlan({
+ 'gymmane': 'plan',
+ 'v': 1,
+ 'unit': 'kg',
+ 'routines': [
+ for (final r in list)
+ {
+ 'name': routineTitle(r),
+ if (r.group.isNotEmpty) 'group': r.group,
+ if (withSchedule)
+ 'days': [for (var d = 1; d <= 7; d++) if (weeklyPlan[d] == r.id) d],
+ 'exercises': [
+ for (final id in r.exerciseIds)
+ if (exerciseById(id) case final ex?)
+ {
+ 'id': id,
+ 'name': ex.name,
+ 'sets': routineSets(r, id),
+ if (hasPlan(r, id))
+ 'plan': [
+ for (final p in plannedSets(r, id))
+ {
+ if (p.kind != SetKind.normal) 'type': _kindNames[p.kind.index],
+ if (p.reps != null) 'reps': p.reps,
+ if (p.weightKg != null) 'weight': _round3(p.weightKg!),
+ if (p.sec != null) 'time': p.sec,
+ if (p.km != null) 'distance': p.km,
+ },
+ ],
+ if (chainsToNext(r, id)) 'superset': true,
+ if (hasCustomRest(id)) 'rest': restFor(id),
+ if (isCustom(id))
+ 'custom': {
+ 'muscle': ex.primary,
+ 'equipment': ex.equipment,
+ 'level': ex.difficulty,
+ if (ex.steps.isNotEmpty) 'steps': ex.steps,
+ if (modeOf(id).isNotEmpty) 'track': modeOf(id),
+ },
+ },
+ ],
+ },
+ ],
+ });
+ }
+
+ String planSummaryText(List<Routine> list) {
+ final out = <String>[];
+ for (final r in list) {
+ final days = [for (var d = 1; d <= 7; d++) if (weeklyPlan[d] == r.id) t.weekdayShort(d)];
+ out.add(days.isEmpty ? routineTitle(r) : '${routineTitle(r)} · ${days.join(', ')}');
+ for (final id in r.exerciseIds) {
+ final ex = exerciseById(id);
+ if (ex == null) continue;
+ final planned = plannedSets(r, id).where((p) => p.kind != SetKind.warmup).toList();
+ final reps = planned.isEmpty ? null : planned.first.reps;
+ final kg = planned.isEmpty ? null : planned.first.weightKg;
+ final detail = StringBuffer('${routineSets(r, id)}')..write(reps == null ? '' : ' × $reps');
+ if (kg != null) detail.write(' @ ${weightLabel(kg)}');
+ out.add('• ${exerciseName(ex)} — $detail${chainsToNext(r, id) ? ' +' : ''}');
+ }
+ out.add('');
+ }
+ return out.join('\n').trim();
}
static String _sessionKey(LoggedSession s) =>
@@ -610,7 +825,7 @@ class FitState extends FitCore
final primary =
match?.primary ?? (kFilterMuscles.contains(hint) ? hint : guessMuscle(pe.name) ?? 'other');
exs.add(LoggedExercise(id, match?.name ?? pe.name, primary,
- [for (final s in pe.sets) LoggedSet(s.reps, s.weightKg)]));
+ [for (final s in pe.sets) LoggedSet(s.reps, s.weightKg, rpe: s.rpe)]));
}
if (exs.isEmpty) continue;
final ls = LoggedSession(ps.date, ps.durationSec, exs);
diff --git a/lib/state/library_state.dart b/lib/state/library_state.dart
index 3d57ea4..2c05849 100644
--- a/lib/state/library_state.dart
+++ b/lib/state/library_state.dart
@@ -115,6 +115,8 @@ mixin LibraryState on FitCore {
required String primary,
required String equipment,
String difficulty = 'Beginner',
+ List<String> steps = const [],
+ String mode = '',
}) {
final id = 'c${DateTime.now().microsecondsSinceEpoch}-${_customSeq++}';
customExercises.add(Exercise(
@@ -125,16 +127,76 @@ mixin LibraryState on FitCore {
equipment: equipment,
difficulty: difficulty,
art: '',
- steps: const [],
+ steps: _cleanSteps(steps),
+ mode: kExerciseModeIds.contains(mode) ? mode : '',
));
_persist();
notifyListeners();
return id;
}
+ void updateCustomExercise(
+ String id, {
+ required String name,
+ required String primary,
+ required String equipment,
+ required String difficulty,
+ required List<String> steps,
+ required String mode,
+ }) {
+ final i = customExercises.indexWhere((e) => e.id == id);
+ if (i < 0 || name.trim().isEmpty) return;
+ customExercises[i] = customExercises[i].copyWith(
+ name: name.trim(),
+ primary: primary,
+ equipment: equipment,
+ difficulty: difficulty,
+ steps: _cleanSteps(steps),
+ mode: kExerciseModeIds.contains(mode) ? mode : '',
+ );
+ modeOverride.remove(id);
+ _persist();
+ notifyListeners();
+ }
+
+ static final _bullet = RegExp(r'^(\d+[.)]|[-•*])\s*');
+
+ static List<String> _cleanSteps(List<String> raw) => [
+ for (final s in raw.map((s) => s.trim().replaceFirst(_bullet, '')))
+ if (s.isNotEmpty) s,
+ ];
+
+ String modeOf(String id) {
+ final forced = modeOverride[id];
+ if (forced != null) return forced == 'weight' ? '' : forced;
+ for (final e in customExercises) {
+ if (e.id == id) return e.mode;
+ }
+ return kExerciseModes[id] ?? '';
+ }
+
+ bool isCardio(String id) => modeOf(id) == 'cardio';
+
+ bool isTimed(String id) => modeOf(id) == 'time';
+
+ void setExerciseMode(String id, String mode) {
+ final base = customExercises.where((e) => e.id == id).map((e) => e.mode).firstOrNull ??
+ kExerciseModes[id] ??
+ '';
+ final wanted = mode == 'weight' ? '' : mode;
+ if (wanted == base) {
+ modeOverride.remove(id);
+ } else {
+ modeOverride[id] = mode.isEmpty ? 'weight' : mode;
+ }
+ _persist();
+ notifyListeners();
+ }
+
void deleteCustomExercise(String id) {
clearExerciseMedia(id);
customExercises.removeWhere((e) => e.id == id);
+ modeOverride.remove(id);
for (final r in routines) {
r.exerciseIds.remove(id);
}
@@ -192,5 +254,5 @@ mixin LibraryState on FitCore {
notifyListeners();
}
- bool isCustom(String id) => id.startsWith('c');
+ bool isCustom(String id) => customExercises.any((e) => e.id == id);
}
diff --git a/lib/state/settings_state.dart b/lib/state/settings_state.dart
index c89db3f..fcddab0 100644
--- a/lib/state/settings_state.dart
+++ b/lib/state/settings_state.dart
@@ -3,8 +3,22 @@ part of 'fit_state.dart';
const String kBgPhotoId = 'bg';
mixin SettingsState on FitCore, ToolsState, LibraryState {
- bool dark = true;
- ThemeMode get themeMode => dark ? ThemeMode.dark : ThemeMode.light;
+ String themePref = 'dark';
+
+ bool get dark => themePref == 'system'
+ ? PlatformDispatcher.instance.platformBrightness == Brightness.dark
+ : themePref == 'dark';
+
+ set dark(bool on) => themePref = on ? 'dark' : 'light';
+
+ ThemeMode get themeMode => switch (themePref) {
+ 'system' => ThemeMode.system,
+ 'light' => ThemeMode.light,
+ _ => ThemeMode.dark,
+ };
+
+ String demoSize = 'large';
+ String alarmStyle = 'quiet';
int restSeconds = 90;
String? alarmSound;
String? alarmSoundName;
@@ -15,7 +29,10 @@ mixin SettingsState on FitCore, ToolsState, LibraryState {
double bgDim = 0.55;
bool showFocus = true;
bool autoAdvance = true;
+ bool keepScreenOn = true;
+ bool startCountdown = true;
bool logRpe = false;
+ String effortScale = 'rpe';
int? trainReminderMin;
bool smartReminder = false;
bool onboarded = false;
@@ -23,34 +40,46 @@ mixin SettingsState on FitCore, ToolsState, LibraryState {
int? alarmAskedAt;
String language = 'en';
- Locale get locale => Locale(language);
+ Locale get locale => localeOf(language);
void _adoptDeviceLanguage() =>
- _applyLanguage(PlatformDispatcher.instance.locale.languageCode);
+ _applyLanguage(PlatformDispatcher.instance.locale.toLanguageTag());
void _applyLanguage(String code) {
setAppLanguage(code);
language = appLanguage;
}
- void toggleTheme() {
- dark = !dark;
+ void setThemePref(String pref) {
+ if (!const ['system', 'dark', 'light'].contains(pref)) return;
+ themePref = pref;
_persist();
_refreshWidgets();
notifyListeners();
}
- void setThemeDark() {
- dark = true;
- _persist();
+ void setThemeDark() => setThemePref('dark');
+
+ void setThemeLight() => setThemePref('light');
+
+ void systemBrightnessChanged() {
+ if (themePref != 'system') return;
_refreshWidgets();
notifyListeners();
}
- void setThemeLight() {
- dark = false;
+ void setDemoSize(String size) {
+ if (!const ['large', 'small', 'off'].contains(size)) return;
+ demoSize = size;
+ _persist();
+ notifyListeners();
+ }
+
+ void setAlarmStyle(String style) {
+ if (!const ['loud', 'quiet', 'vibrate'].contains(style)) return;
+ alarmStyle = style;
+ RestAlarm.instance.style = style;
_persist();
- _refreshWidgets();
notifyListeners();
}
@@ -187,7 +216,8 @@ mixin SettingsState on FitCore, ToolsState, LibraryState {
notifyListeners();
}
- int restFor(String exerciseId) => exerciseRest[exerciseId] ?? restSeconds;
+ int restFor(String exerciseId) =>
+ exerciseRest[exerciseId] ?? (modeOf(exerciseId) == 'cardio' ? 0 : restSeconds);
bool hasCustomRest(String exerciseId) => exerciseRest.containsKey(exerciseId);
@@ -246,12 +276,39 @@ mixin SettingsState on FitCore, ToolsState, LibraryState {
notifyListeners();
}
+ String get effortMode => logRpe ? effortScale : '';
+
+ void setEffortMode(String mode) {
+ logRpe = mode.isNotEmpty;
+ if (logRpe) effortScale = mode;
+ _persist();
+ notifyListeners();
+ }
+
+ bool get usesRir => effortScale == 'rir';
+
+ String effortLabel(double rpe) => usesRir ? 'RIR ${fmt(10 - rpe)}' : 'RPE ${fmt(rpe)}';
+
+ String effortTag(double rpe) => usesRir ? 'R${fmt(10 - rpe)}' : '@${fmt(rpe)}';
+
void toggleAutoAdvance() {
autoAdvance = !autoAdvance;
_persist();
notifyListeners();
}
+ void toggleStartCountdown() {
+ startCountdown = !startCountdown;
+ _persist();
+ notifyListeners();
+ }
+
+ void toggleKeepScreenOn() {
+ keepScreenOn = !keepScreenOn;
+ _persist();
+ notifyListeners();
+ }
+
double? progressFor(String exerciseId) => progressStep[exerciseId];
bool hasProgress(String exerciseId) => (progressStep[exerciseId] ?? 0) > 0;
diff --git a/lib/state/stats_state.dart b/lib/state/stats_state.dart
index e88f018..3bb048c 100644
--- a/lib/state/stats_state.dart
+++ b/lib/state/stats_state.dart
@@ -3,11 +3,12 @@ part of 'fit_state.dart';
mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
List<Exercise> recommendedExercises(int n) {
final muscles = suggestedFocus.muscles;
+ final pool = kExercises.where((e) => !noSuggest.contains(e.id));
final picks = [
- for (final m in muscles) ...kExercises.where((e) => e.primary == m).take(1),
+ for (final m in muscles) ...pool.where((e) => e.primary == m).take(1),
];
- for (final e in kExercises) {
+ for (final e in pool) {
if (picks.length >= n) break;
if (muscles.contains(e.primary) && !picks.contains(e)) picks.add(e);
}
@@ -316,6 +317,8 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
DateTime _dateForWeekday(int i) => shiftDays(_weekStart, i);
+ DateTime dateForWeekday(int i) => _dateForWeekday(i);
+
bool _hasSessionOn(DateTime day) {
final k = _dayKey(day);
return sessions.any((s) => _dayKey(s.date) == k);
@@ -508,6 +511,78 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
};
}
+ static const Map<String, double> _recoveryHours = {
+ 'chest': 60,
+ 'back': 60,
+ 'quads': 72,
+ 'hamstrings': 72,
+ 'glutes': 72,
+ 'shoulders': 48,
+ 'trapezius': 48,
+ 'biceps': 48,
+ 'triceps': 48,
+ 'forearm': 36,
+ 'calves': 36,
+ 'abdomen': 36,
+ 'obliques': 36,
+ };
+
+ static const double _fullFatigue = 8;
+
+ double _tau(String muscle) => (_recoveryHours[muscle] ?? 48) / 3;
+
+ double _setEffort(LoggedSet st) {
+ final rpe = st.rpe;
+ if (rpe == null) return st.kind == SetKind.failure ? 1.2 : 1;
+ return ((rpe - 5) / 4).clamp(0.4, 1.3);
+ }
+
+ Map<String, double> muscleFatigue({DateTime? now}) {
+ final at = now ?? DateTime.now();
+ final out = <String, double>{};
+ for (final s in sessions) {
+ final hours = at.difference(s.date).inMinutes / 60;
+ if (hours < 0 || hours > 24 * 8) continue;
+ for (final e in s.exercises) {
+ final effort = e.workingSets.fold<double>(0, (sum, st) => sum + _setEffort(st));
+ if (effort <= 0) continue;
+ void add(String m, double share) =>
+ out[m] = (out[m] ?? 0) + effort * share * math.exp(-hours / _tau(m));
+ add(e.primary, 1);
+ for (final m in exerciseById(e.id)?.secondary ?? const <String>[]) {
+ add(m, 0.5);
+ }
+ }
+ }
+ return out;
+ }
+
+ Map<String, double> muscleRecovery({DateTime? now}) {
+ final fatigue = muscleFatigue(now: now);
+ return {
+ for (final m in kMuscles) m.id: (1 - (fatigue[m.id] ?? 0) / _fullFatigue).clamp(0.0, 1.0),
+ };
+ }
+
+ int overallRecovery({DateTime? now}) {
+ final r = muscleRecovery(now: now);
+ if (r.isEmpty) return 100;
+ return (r.values.reduce((a, b) => a + b) / r.length * 100).round();
+ }
+
+ int? hoursUntilRecovered(String muscle, {DateTime? now}) {
+ final fatigue = muscleFatigue(now: now)[muscle] ?? 0;
+ final limit = _fullFatigue * 0.2;
+ if (fatigue <= limit) return null;
+ return (_tau(muscle) * math.log(fatigue / limit)).ceil();
+ }
+
+ List<String> stillRecovering({DateTime? now}) {
+ final r = muscleRecovery(now: now);
+ final ids = r.keys.where((k) => r[k]! < 0.8).toList()..sort((a, b) => r[a]!.compareTo(r[b]!));
+ return ids;
+ }
+
List<String> neglectedMuscles(int days) {
final sets = muscleSetsOver(days);
if (sets.isEmpty) return const [];
@@ -536,7 +611,19 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
String? lastSummaryFor(String id) {
final sets = lastSetsFor(id);
if (sets.isEmpty) return null;
- return sets.map((s) => '${weightValue(s.weight)}×${s.reps}').join(' · ');
+ return setsSummary(sets);
+ }
+
+ String setsSummary(List<LoggedSet> sets) => sets.map(loggedSetLabel).join(' · ');
+
+ String loggedSetLabel(LoggedSet s) {
+ final km = s.km ?? 0;
+ final sec = s.sec;
+ if (km > 0) return sec == null ? distanceLabel(km) : '${distanceLabel(km)} · ${durationLabel(sec)}';
+ if (sec != null && s.reps <= 0) {
+ return s.weight > 0 ? '${weightValue(s.weight)} × ${durationLabel(sec)}' : durationLabel(sec);
+ }
+ return '${weightValue(s.weight)}×${s.reps}';
}
({double topWeight, double oneRm})? exercisePr(String id) {
diff --git a/lib/theme/app_theme.dart b/lib/theme/app_theme.dart
index aa1fe07..e761217 100644
--- a/lib/theme/app_theme.dart
+++ b/lib/theme/app_theme.dart
@@ -5,9 +5,9 @@ import 'app_colors.dart';
class AppTheme {
AppTheme._();
- static const String disp = 'Oswald';
- static const String sans = 'IBM Plex Sans';
- static const String round = 'Figtree';
+ static const String disp = 'Nunito';
+ static const String sans = 'Nunito';
+ static const String round = 'Nunito';
static ThemeData get dark => _build(Brightness.dark, GymColors.dark);
static ThemeData get light => _build(Brightness.light, GymColors.light);
diff --git a/lib/widgets/body_map.dart b/lib/widgets/body_map.dart
index e8456c4..e7110dd 100644
--- a/lib/widgets/body_map.dart
+++ b/lib/widgets/body_map.dart
@@ -99,6 +99,35 @@ class BodyHeatMap extends StatelessWidget {
}
}
+Color recoveryColor(GymColors gc, double recovered) {
+ final v = recovered.clamp(0.0, 1.0);
+ final fresh = Color.lerp(idleMuscle(gc), gc.sage, 0.62)!;
+ if (v < 0.5) return Color.lerp(gc.danger, gc.warn, v / 0.5)!;
+ return Color.lerp(gc.warn, fresh, (v - 0.5) / 0.5)!;
+}
+
+class BodyRecoveryMap extends StatelessWidget {
+ const BodyRecoveryMap({super.key, required this.recovery, this.focus, this.onTap});
+
+ final Map<String, double> recovery;
+ final String? focus;
+ final ValueChanged<String>? onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return _BodyCanvas(
+ onTap: onTap,
+ painter: BodyPainter(
+ gc: gc,
+ token: 'r${heatToken(recovery)}',
+ color: (id) => recoveryColor(gc, recovery[id] ?? 1),
+ outline: focus,
+ ),
+ );
+ }
+}
+
class BodyHeatArt extends StatelessWidget {
const BodyHeatArt({super.key, required this.gc, required this.intensity, required this.width});
diff --git a/lib/widgets/celebration.dart b/lib/widgets/celebration.dart
new file mode 100644
index 0000000..891864c
--- /dev/null
+++ b/lib/widgets/celebration.dart
@@ -0,0 +1,163 @@
+import 'dart:async';
+import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+void celebrate(BuildContext context, {required List<Color> colors}) {
+ HapticFeedback.heavyImpact();
+ Timer(const Duration(milliseconds: 110), HapticFeedback.lightImpact);
+ Timer(const Duration(milliseconds: 220), HapticFeedback.lightImpact);
+ if (MediaQuery.maybeDisableAnimationsOf(context) ?? false) return;
+ final overlay = Overlay.maybeOf(context, rootOverlay: true);
+ if (overlay == null) return;
+ late final OverlayEntry entry;
+ entry = OverlayEntry(
+ builder: (_) => IgnorePointer(
+ child: Confetti(colors: colors, onDone: () => entry.remove()),
+ ),
+ );
+ overlay.insert(entry);
+}
+
+class Confetti extends StatefulWidget {
+ const Confetti({super.key, required this.colors, required this.onDone});
+
+ final List<Color> colors;
+ final VoidCallback onDone;
+
+ @override
+ State<Confetti> createState() => _ConfettiState();
+}
+
+class _ConfettiState extends State<Confetti> with SingleTickerProviderStateMixin {
+ late final AnimationController _c = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 3400),
+ )
+ ..addStatusListener((s) {
+ if (s == AnimationStatus.completed) widget.onDone();
+ })
+ ..forward();
+
+ late final List<_Bit> _bits = _spawn();
+
+ List<_Bit> _spawn() {
+ final r = math.Random();
+ final out = <_Bit>[];
+ for (var side = 0; side < 2; side++) {
+ for (var i = 0; i < 34; i++) {
+ final angle = (62 + r.nextDouble() * 24) * math.pi / 180;
+ final speed = 1250 + r.nextDouble() * 650;
+ out.add(_Bit(
+ left: side == 0,
+ vx: math.cos(angle) * speed * (side == 0 ? 1 : -1),
+ vy: -math.sin(angle) * speed,
+ delay: r.nextDouble() * 0.12,
+ color: widget.colors[r.nextInt(widget.colors.length)],
+ shape: r.nextInt(3),
+ size: 0.8 + r.nextDouble() * 0.5,
+ spin: (r.nextDouble() - 0.5) * 9,
+ flip: 5 + r.nextDouble() * 7,
+ phase: r.nextDouble() * math.pi * 2,
+ sway: 10 + r.nextDouble() * 22,
+ ));
+ }
+ }
+ return out;
+ }
+
+ @override
+ void dispose() {
+ _c.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return RepaintBoundary(
+ child: CustomPaint(
+ size: Size.infinite,
+ painter: _ConfettiPainter(_bits, _c),
+ ),
+ );
+ }
+}
+
+class _Bit {
+ _Bit({
+ required this.left,
+ required this.vx,
+ required this.vy,
+ required this.delay,
+ required this.color,
+ required this.shape,
+ required this.size,
+ required this.spin,
+ required this.flip,
+ required this.phase,
+ required this.sway,
+ });
+
+ final bool left;
+ final double vx, vy, delay, size, spin, flip, phase, sway;
+ final Color color;
+ final int shape;
+}
+
+class _ConfettiPainter extends CustomPainter {
+ _ConfettiPainter(this.bits, this.anim) : super(repaint: anim);
+
+ final List<_Bit> bits;
+ final Animation<double> anim;
+
+ static const _k = 2.7;
+ static const _g = 760.0;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final total = anim.value * 3.4;
+ final paint = Paint();
+ for (final b in bits) {
+ final t = total - b.delay;
+ if (t <= 0) continue;
+ final decay = (1 - math.exp(-_k * t)) / _k;
+ final x0 = b.left ? -6.0 : size.width + 6;
+ final y0 = size.height * 0.92;
+ final settle = (t * 1.4).clamp(0.0, 1.0);
+ final x = x0 + b.vx * decay + math.sin(t * 3.2 + b.phase) * b.sway * settle;
+ final y = y0 + (_g / _k) * t + (b.vy - _g / _k) * decay;
+ if (y > size.height + 30) continue;
+ final fade = ((3.4 - total) / 0.9).clamp(0.0, 1.0);
+ paint.color = b.color.withValues(alpha: b.color.a * 0.92 * fade);
+ canvas.save();
+ canvas.translate(x, y);
+ canvas.rotate(b.spin * t + b.phase);
+ canvas.scale(1, math.cos(b.flip * t + b.phase));
+ switch (b.shape) {
+ case 0:
+ canvas.drawRRect(
+ RRect.fromRectAndRadius(
+ Rect.fromCenter(center: Offset.zero, width: 8 * b.size, height: 5 * b.size),
+ const Radius.circular(1.4),
+ ),
+ paint,
+ );
+ case 1:
+ canvas.drawRRect(
+ RRect.fromRectAndRadius(
+ Rect.fromCenter(center: Offset.zero, width: 12 * b.size, height: 2.6 * b.size),
+ const Radius.circular(1.3),
+ ),
+ paint,
+ );
+ default:
+ canvas.drawCircle(Offset.zero, 2.8 * b.size, paint);
+ }
+ canvas.restore();
+ }
+ }
+
+ @override
+ bool shouldRepaint(_ConfettiPainter old) => false;
+}
diff --git a/lib/widgets/charts.dart b/lib/widgets/charts.dart
index 5a71bc2..213318c 100644
--- a/lib/widgets/charts.dart
+++ b/lib/widgets/charts.dart
@@ -167,33 +167,122 @@ class _VolumePainter extends CustomPainter {
bool shouldRepaint(_VolumePainter o) => o.gc != gc || o.points != points;
}
+(double, double) niceBounds(List<double> values) {
+ var lo = values.reduce(math.min), hi = values.reduce(math.max);
+ if ((hi - lo).abs() < 1e-9) {
+ final pad = lo.abs() < 1e-9 ? 1.0 : lo.abs() * 0.1;
+ lo -= pad;
+ hi += pad;
+ }
+ final rough = (hi - lo) / 4;
+ final mag = math.pow(10, (math.log(rough) / math.ln10).floor()).toDouble();
+ final r = rough / mag;
+ final step = (r <= 1 ? 1 : r <= 2 ? 2 : r <= 2.5 ? 2.5 : r <= 5 ? 5 : 10) * mag;
+ final a = (lo / step).floorToDouble() * step;
+ var n = (((hi / step).ceilToDouble() * step - a) / step).round();
+ if (n < 2) n = 2;
+ if (n.isOdd) n++;
+ return (a, a + n * step);
+}
+
+class ChartScale extends StatelessWidget {
+ const ChartScale({
+ super.key,
+ required this.bounds,
+ required this.stops,
+ required this.label,
+ required this.child,
+ this.fontSize = 10,
+ });
+
+ final (double, double) bounds;
+ final (double, double) stops;
+ final String Function(double) label;
+ final Widget child;
+ final double fontSize;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final (lo, hi) = bounds;
+ final (top, bottom) = stops;
+ final marks = [
+ (top, label(hi)),
+ if (fontSize >= 10) ((top + bottom) / 2, label((hi + lo) / 2)),
+ (bottom, label(lo)),
+ ];
+ final style = AppTheme.f(fontSize, weight: FontWeight.w600, color: gc.textTertiary, height: 1);
+ final scaler = MediaQuery.textScalerOf(context);
+ final width = marks
+ .map((m) => (TextPainter(
+ text: TextSpan(text: m.$2, style: style),
+ textDirection: TextDirection.ltr,
+ textScaler: scaler,
+ )..layout())
+ .width)
+ .reduce(math.max);
+ return LayoutBuilder(
+ builder: (context, box) => Row(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(child: child),
+ SizedBox(width: fontSize),
+ SizedBox(
+ width: width + 1,
+ child: LayoutBuilder(
+ builder: (context, col) => Stack(
+ clipBehavior: Clip.none,
+ children: [
+ for (final (y, text) in marks)
+ Positioned(
+ right: 0,
+ top: col.maxHeight * y - fontSize * scaler.scale(1) / 2,
+ child: Text(text, maxLines: 1, style: style),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
class Sparkline extends StatelessWidget {
- const Sparkline({super.key, required this.values, this.height = 48, this.color});
+ const Sparkline({super.key, required this.values, this.height = 48, this.color, this.scale});
final List<double> values;
final double height;
final Color? color;
+ final String Function(double)? scale;
@override
Widget build(BuildContext context) {
final gc = context.gc;
+ final label = scale;
+ final bounds = label == null || values.length < 2 ? null : niceBounds(values);
+ final chart = CustomPaint(painter: _SparkPainter(values, color ?? gc.accent, gc.bgRaised, bounds));
return SizedBox(
height: height,
width: double.infinity,
- child: CustomPaint(painter: _SparkPainter(values, color ?? gc.accent, gc.bgRaised)),
+ child: label == null || bounds == null
+ ? chart
+ : ChartScale(bounds: bounds, stops: (0.15, 0.85), label: label, fontSize: 9, child: chart),
);
}
}
class _SparkPainter extends CustomPainter {
- _SparkPainter(this.values, this.color, this.dotBg);
+ _SparkPainter(this.values, this.color, this.dotBg, [this.bounds]);
final List<double> values;
final Color color;
final Color dotBg;
+ final (double, double)? bounds;
@override
void paint(Canvas canvas, Size size) {
if (values.length < 2) return;
- final maxV = values.reduce(math.max);
- final minV = values.reduce(math.min);
+ final maxV = bounds?.$2 ?? values.reduce(math.max);
+ final minV = bounds?.$1 ?? values.reduce(math.min);
final range = (maxV - minV).abs() < 1e-6 ? 1.0 : (maxV - minV);
Offset m(int i) {
final x = size.width * i / (values.length - 1);
@@ -221,22 +310,130 @@ class _SparkPainter extends CustomPainter {
}
@override
- bool shouldRepaint(_SparkPainter o) => o.values != values || o.color != color;
+ bool shouldRepaint(_SparkPainter o) => o.values != values || o.color != color || o.bounds != bounds;
+}
+
+class TrendChart extends StatelessWidget {
+ const TrendChart({super.key, required this.values, this.height = 90, this.color, this.scale});
+ final List<double> values;
+ final double height;
+ final Color? color;
+ final String Function(double)? scale;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final label = scale;
+ final bounds = label == null || values.length < 2 ? null : niceBounds(values);
+ final chart = CustomPaint(painter: _TrendPainter(values, color ?? gc.accent, gc.bgRaised, gc.border, bounds));
+ return SizedBox(
+ height: height,
+ width: double.infinity,
+ child: label == null || bounds == null
+ ? chart
+ : ChartScale(bounds: bounds, stops: (0.12, 0.88), label: label, child: chart),
+ );
+ }
+}
+
+class _TrendPainter extends CustomPainter {
+ _TrendPainter(this.values, this.color, this.dotBg, this.grid, [this.bounds]);
+ final List<double> values;
+ final Color color;
+ final Color dotBg;
+ final Color grid;
+ final (double, double)? bounds;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final gridPaint = Paint()
+ ..color = grid.withValues(alpha: 0.5)
+ ..strokeWidth = 1;
+ for (final f in const [0.12, 0.5, 0.88]) {
+ final y = size.height * f;
+ for (var x = 0.0; x < size.width; x += 7) {
+ canvas.drawLine(Offset(x, y), Offset(math.min(x + 3, size.width), y), gridPaint);
+ }
+ }
+ if (values.length < 2) return;
+ final maxV = bounds?.$2 ?? values.reduce(math.max);
+ final minV = bounds?.$1 ?? values.reduce(math.min);
+ final range = (maxV - minV).abs() < 1e-6 ? 1.0 : (maxV - minV);
+ const inset = 6.0;
+ final pts = [
+ for (var i = 0; i < values.length; i++)
+ Offset(
+ inset + (size.width - inset * 2) * i / (values.length - 1),
+ size.height * (0.88 - (values[i] - minV) / range * 0.76),
+ ),
+ ];
+ final n = pts.length;
+ final slope = [for (var i = 0; i < n - 1; i++) (pts[i + 1].dy - pts[i].dy) / (pts[i + 1].dx - pts[i].dx)];
+ final tangent = List<double>.filled(n, 0);
+ tangent[0] = slope.first;
+ tangent[n - 1] = slope.last;
+ for (var i = 1; i < n - 1; i++) {
+ tangent[i] = slope[i - 1] * slope[i] <= 0 ? 0 : (slope[i - 1] + slope[i]) / 2;
+ }
+ for (var i = 0; i < n - 1; i++) {
+ if (slope[i] == 0) {
+ tangent[i] = 0;
+ tangent[i + 1] = 0;
+ continue;
+ }
+ final a = tangent[i] / slope[i], b = tangent[i + 1] / slope[i];
+ final h = a * a + b * b;
+ if (h > 9) {
+ final k = 3 / math.sqrt(h);
+ tangent[i] = k * a * slope[i];
+ tangent[i + 1] = k * b * slope[i];
+ }
+ }
+ final line = Path()..moveTo(pts.first.dx, pts.first.dy);
+ for (var i = 0; i < n - 1; i++) {
+ final dx = (pts[i + 1].dx - pts[i].dx) / 3;
+ line.cubicTo(pts[i].dx + dx, pts[i].dy + tangent[i] * dx, pts[i + 1].dx - dx,
+ pts[i + 1].dy - tangent[i + 1] * dx, pts[i + 1].dx, pts[i + 1].dy);
+ }
+ final area = Path.from(line)
+ ..lineTo(pts.last.dx, size.height)
+ ..lineTo(pts.first.dx, size.height)
+ ..close();
+ canvas.drawPath(
+ area,
+ Paint()
+ ..shader = LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [color.withValues(alpha: 0.28), color.withValues(alpha: 0)],
+ ).createShader(Offset.zero & size),
+ );
+ canvas.drawPath(
+ line,
+ Paint()
+ ..color = color
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 2.5
+ ..strokeCap = StrokeCap.round
+ ..strokeJoin = StrokeJoin.round,
+ );
+ final end = pts.last;
+ canvas.drawCircle(end, 8, Paint()..color = color.withValues(alpha: 0.22));
+ canvas.drawCircle(end, 4.5, Paint()..color = dotBg);
+ canvas.drawCircle(end, 4.5, Paint()..color = color..style = PaintingStyle.stroke..strokeWidth = 2.5);
+ }
+
+ @override
+ bool shouldRepaint(_TrendPainter o) =>
+ o.values != values || o.color != color || o.grid != grid || o.bounds != bounds;
}
class Heatmap extends StatelessWidget {
- const Heatmap({super.key, required this.levels, this.onTapDay, this.mono = false});
+ const Heatmap({super.key, required this.levels, this.onTapDay});
final List<int> levels;
final void Function(int index)? onTapDay;
- final bool mono;
- 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)]);
- }
+ Color _color(int level, GymColors gc) => level <= 0 ? gc.heatEmpty : heatLevelColor(gc, level);
@override
Widget build(BuildContext context) {
diff --git a/lib/widgets/dialogs.dart b/lib/widgets/dialogs.dart
index 71e1920..848088d 100644
--- a/lib/widgets/dialogs.dart
+++ b/lib/widgets/dialogs.dart
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../l10n/l10n.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import 'glass.dart';
import 'ui_kit.dart';
AlertDialog appDialog(
@@ -44,7 +45,7 @@ Future<bool> askConfirm(
bool danger = false,
}) async {
final gc = context.gc;
- final ok = await showDialog<bool>(
+ final ok = await showAppDialog<bool>(
context: context,
builder: (dctx) => appDialog(
gc,
@@ -72,7 +73,7 @@ Future<double?> askNumber(
final controller = TextEditingController(text: initial)
..selection = TextSelection(baseOffset: 0, extentOffset: initial.length);
- final raw = await showDialog<String>(
+ final raw = await showAppDialog<String>(
context: context,
builder: (dctx) => appDialog(
gc,
diff --git a/lib/widgets/entrance.dart b/lib/widgets/entrance.dart
new file mode 100644
index 0000000..b1803c7
--- /dev/null
+++ b/lib/widgets/entrance.dart
@@ -0,0 +1,239 @@
+import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+
+import '../services/local_store.dart';
+import 'rolling_text.dart';
+
+class RiseScope extends StatefulWidget {
+ const RiseScope({super.key, required this.id, required this.child, this.once = true});
+
+ final String id;
+ final Widget child;
+ final bool once;
+
+ static final _played = <String>{};
+
+ static bool animates(BuildContext context) =>
+ context.dependOnInheritedWidgetOfExactType<_RiseFlag>()?.on ?? true;
+
+ @override
+ State<RiseScope> createState() => _RiseScopeState();
+}
+
+class _RiseScopeState extends State<RiseScope> {
+ late final bool _on = _decide();
+
+ bool _decide() {
+ if (!widget.once) return true;
+ if (!RiseScope._played.add(widget.id)) return false;
+ final now = DateTime.now();
+ final today = '${now.year}-${now.month}-${now.day}';
+ final key = 'rise_${widget.id}';
+ final last = Store.instance.note(key);
+ Store.instance.setNote(key, today);
+ return last != today;
+ }
+
+ @override
+ Widget build(BuildContext context) => _RiseFlag(on: _on, child: widget.child);
+}
+
+class _RiseFlag extends InheritedWidget {
+ const _RiseFlag({required this.on, required super.child});
+
+ final bool on;
+
+ @override
+ bool updateShouldNotify(_RiseFlag old) => old.on != on;
+}
+
+List<Widget> riseAll(List<Widget> children) {
+ var i = 0;
+ return [
+ for (final c in children) c is SizedBox && c.child == null ? c : Rise(index: i++, child: c),
+ ];
+}
+
+class Rise extends StatefulWidget {
+ const Rise({super.key, required this.index, required this.child});
+
+ final int index;
+ final Widget child;
+
+ @override
+ State<Rise> createState() => _RiseState();
+}
+
+class _RiseState extends State<Rise> with SingleTickerProviderStateMixin {
+ static const _motion = 560;
+
+ late final int _delay = 40 + widget.index.clamp(0, 7) * 70;
+ late final AnimationController _c =
+ AnimationController(vsync: this, duration: Duration(milliseconds: _delay + _motion));
+ late final Animation<double> _v = CurvedAnimation(
+ parent: _c,
+ curve: Interval(_delay / (_delay + _motion), 1, curve: Curves.easeOutCubic),
+ );
+ bool? _animate;
+
+ @override
+ void didChangeDependencies() {
+ super.didChangeDependencies();
+ if (_animate != null) return;
+ final reduce = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
+ _animate = RiseScope.animates(context) && !reduce;
+ _animate! ? _c.forward() : _c.value = 1;
+ }
+
+ @override
+ void dispose() {
+ _c.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ if (_animate != true) return widget.child;
+ return AnimatedBuilder(
+ animation: _v,
+ child: widget.child,
+ builder: (context, child) {
+ final v = _v.value;
+ return Opacity(
+ opacity: v,
+ child: Transform.translate(
+ offset: Offset(0, 22 * (1 - v)),
+ child: Transform.scale(scale: 0.97 + 0.03 * v, child: child),
+ ),
+ );
+ },
+ );
+ }
+}
+
+class RollIn extends StatefulWidget {
+ const RollIn(this.text, {super.key, required this.style, this.textAlign = TextAlign.left});
+
+ final String text;
+ final TextStyle style;
+ final TextAlign textAlign;
+
+ @override
+ State<RollIn> createState() => _RollInState();
+}
+
+class _RollInState extends State<RollIn> with SingleTickerProviderStateMixin {
+ static const _run = Duration(milliseconds: 1150);
+
+ AnimationController? _c;
+
+ @override
+ void initState() {
+ super.initState();
+ if (!widget.text.contains(RegExp('[1-9]'))) return;
+ _c = AnimationController(vsync: this, duration: _run)
+ ..addStatusListener((s) {
+ if (s == AnimationStatus.completed && mounted) setState(() {});
+ });
+ }
+
+ @override
+ void didChangeDependencies() {
+ super.didChangeDependencies();
+ final c = _c;
+ if (c == null || c.isAnimating || c.isCompleted) return;
+ final reduce = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
+ reduce || !RiseScope.animates(context) ? c.value = 1 : c.forward();
+ }
+
+ @override
+ void dispose() {
+ _c?.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final c = _c;
+ if (c == null || c.isCompleted) {
+ return RollingText(
+ widget.text,
+ style: widget.style,
+ textAlign: widget.textAlign,
+ countsDown: false,
+ duration: const Duration(milliseconds: 620),
+ );
+ }
+ final chars = widget.text.characters.toList();
+ final digits = [for (var i = 0; i < chars.length; i++) if (_isDigit(chars[i])) i];
+ final total = int.parse(digits.map((i) => chars[i]).join());
+ final line = (widget.style.fontSize ?? 14) * (widget.style.height ?? 1.2);
+ final cell = digitCell(widget.style, MediaQuery.textScalerOf(context));
+ return Semantics(
+ label: widget.text,
+ excludeSemantics: true,
+ child: AnimatedBuilder(
+ animation: c,
+ builder: (context, _) {
+ final count = total * Curves.easeOutCubic.transform(c.value);
+ return Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ for (var i = 0; i < chars.length; i++)
+ if (!_isDigit(chars[i]))
+ SizedBox(
+ height: line,
+ child: Stack(
+ alignment: Alignment.center,
+ children: [Text(chars[i], style: widget.style, textHeightBehavior: _tight)],
+ ),
+ )
+ else
+ _wheel(count, digits.length - 1 - digits.indexOf(i), line, cell),
+ ],
+ );
+ },
+ ),
+ );
+ }
+
+ Widget _wheel(double count, int place, double line, double cell) {
+ final scaled = count / math.pow(10, place);
+ final whole = scaled.floor();
+ var pos = whole.toDouble();
+ if (place == 0) {
+ pos = scaled;
+ } else {
+ final lower = count / math.pow(10, place - 1);
+ if (lower.floor() % 10 == 9) pos += lower - lower.floor();
+ }
+ final low = pos.floor();
+ final frac = pos - low;
+ Widget digit(int v, double dy) => Transform.translate(
+ offset: Offset(0, dy),
+ child: Text('${v % 10}', style: widget.style, textHeightBehavior: _tight),
+ );
+ return Opacity(
+ opacity: place == 0 ? 1 : scaled.clamp(0.0, 1.0),
+ child: ClipRect(
+ child: SizedBox(
+ width: cell,
+ height: line,
+ child: Stack(
+ alignment: Alignment.center,
+ clipBehavior: Clip.none,
+ children: [
+ digit(low, -frac * line),
+ if (frac > 0.001) digit(low + 1, (1 - frac) * line),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ static bool _isDigit(String c) => c.length == 1 && c.codeUnitAt(0) >= 48 && c.codeUnitAt(0) <= 57;
+}
+
+const _tight = TextHeightBehavior(applyHeightToFirstAscent: false, applyHeightToLastDescent: false);
diff --git a/lib/widgets/exercise_art.dart b/lib/widgets/exercise_art.dart
index bc6659b..85bef46 100644
--- a/lib/widgets/exercise_art.dart
+++ b/lib/widgets/exercise_art.dart
@@ -7,6 +7,7 @@ import 'package:path_drawing/path_drawing.dart';
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../theme/app_colors.dart';
+import 'shimmer.dart';
class ExerciseArtData {
const ExerciseArtData(this.frames, this.bounds);
@@ -128,7 +129,7 @@ class _ExerciseArtState extends State<ExerciseArt> with SingleTickerProviderStat
if (widget.slug.isEmpty || _failed) {
child = _fallback(gc, widget.height);
} else if (art == null) {
- child = const SizedBox.shrink();
+ child = Shimmer(radius: widget.radius);
} else if (widget.live && art.frames.length > 1 && _c != null) {
final c = _c!;
child = AnimatedBuilder(
diff --git a/lib/widgets/exercise_media.dart b/lib/widgets/exercise_media.dart
index 79fd173..6d911d4 100644
--- a/lib/widgets/exercise_media.dart
+++ b/lib/widgets/exercise_media.dart
@@ -1,6 +1,6 @@
import 'dart:io';
-import 'package:flutter/material.dart';
+import 'package:flutter/cupertino.dart';
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import 'package:video_player/video_player.dart';
@@ -9,6 +9,7 @@ import '../services/media_store.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import 'exercise_art.dart';
+import 'shimmer.dart';
class ExerciseMedia extends StatelessWidget {
const ExerciseMedia({
@@ -167,9 +168,10 @@ class _VideoTileState extends State<_VideoTile> {
} else if (_failed) {
child = _fallbackIcon(context, widget.height);
} else {
- child = const Center(
- child: SizedBox(width: 22, height: 22, child: CircularProgressIndicator(strokeWidth: 2)),
- );
+ child = Stack(children: [
+ Positioned.fill(child: Shimmer(radius: widget.radius)),
+ const Center(child: CupertinoActivityIndicator()),
+ ]);
}
return _MediaFrame(height: widget.height, radius: widget.radius, child: child);
}
diff --git a/lib/widgets/glass.dart b/lib/widgets/glass.dart
new file mode 100644
index 0000000..6932a7a
--- /dev/null
+++ b/lib/widgets/glass.dart
@@ -0,0 +1,286 @@
+import 'dart:ui' as ui;
+
+import 'package:flutter/material.dart';
+
+import '../theme/app_colors.dart';
+
+const double kSheetBlur = 14;
+
+Future<T?> showAppSheet<T>({
+ required BuildContext context,
+ required WidgetBuilder builder,
+ bool isScrollControlled = false,
+ Color? backgroundColor,
+ ShapeBorder? shape,
+ bool isDismissible = true,
+ bool enableDrag = true,
+ bool useSafeArea = false,
+}) {
+ final nav = Navigator.of(context);
+ return nav.push(_GlassSheetRoute<T>(
+ builder: builder,
+ isScrollControlled: isScrollControlled,
+ backgroundColor: backgroundColor,
+ shape: shape,
+ isDismissible: isDismissible,
+ enableDrag: enableDrag,
+ useSafeArea: useSafeArea,
+ modalBarrierColor: Colors.black.withValues(alpha: 0.32),
+ capturedThemes: InheritedTheme.capture(from: context, to: nav.context),
+ barrierLabel: MaterialLocalizations.of(context).scrimLabel,
+ ));
+}
+
+class _GlassSheetRoute<T> extends ModalBottomSheetRoute<T> {
+ _GlassSheetRoute({
+ required super.builder,
+ required super.isScrollControlled,
+ super.backgroundColor,
+ super.shape,
+ super.isDismissible,
+ super.enableDrag,
+ super.useSafeArea,
+ super.modalBarrierColor,
+ super.capturedThemes,
+ super.barrierLabel,
+ });
+
+ @override
+ Widget buildModalBarrier() => _BlurBarrier(animation: animation!, child: super.buildModalBarrier());
+}
+
+Future<T?> showAppDialog<T>({required BuildContext context, required WidgetBuilder builder}) {
+ final nav = Navigator.of(context);
+ return nav.push(_GlassDialogRoute<T>(
+ context: context,
+ builder: builder,
+ barrierColor: Colors.black.withValues(alpha: 0.36),
+ themes: InheritedTheme.capture(from: context, to: nav.context),
+ barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
+ ));
+}
+
+class _GlassDialogRoute<T> extends DialogRoute<T> {
+ _GlassDialogRoute({
+ required super.context,
+ required super.builder,
+ super.barrierColor,
+ super.themes,
+ super.barrierLabel,
+ });
+
+ @override
+ Widget buildModalBarrier() => _BlurBarrier(animation: animation!, child: super.buildModalBarrier());
+
+ @override
+ Widget buildTransitions(
+ BuildContext context, Animation<double> animation, Animation<double> secondary, Widget child) {
+ final curved = CurvedAnimation(parent: animation, curve: Curves.easeOutBack, reverseCurve: Curves.easeInCubic);
+ return FadeTransition(
+ opacity: CurvedAnimation(parent: animation, curve: Curves.easeOut),
+ child: ScaleTransition(scale: Tween<double>(begin: 0.92, end: 1).animate(curved), child: child),
+ );
+ }
+}
+
+class _BlurBarrier extends StatelessWidget {
+ const _BlurBarrier({required this.animation, required this.child});
+
+ final Animation<double> animation;
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) {
+ return AnimatedBuilder(
+ animation: animation,
+ child: child,
+ builder: (context, barrier) {
+ final sigma = kSheetBlur * Curves.easeOut.transform(animation.value.clamp(0.0, 1.0));
+ if (sigma < 0.3) return barrier!;
+ return BackdropFilter(
+ filter: ui.ImageFilter.blur(sigmaX: sigma, sigmaY: sigma),
+ child: barrier,
+ );
+ },
+ );
+ }
+}
+
+class EdgeBlur extends StatefulWidget {
+ const EdgeBlur({super.key, required this.height, this.top = true, this.sigma = 16, this.shade = 1});
+
+ final double height;
+ final bool top;
+ final double sigma;
+ final double shade;
+
+ @override
+ State<EdgeBlur> createState() => _EdgeBlurState();
+}
+
+class _EdgeBlurState extends State<EdgeBlur> {
+ static Future<ui.FragmentProgram>? _loading;
+ static ui.FragmentProgram? _program;
+
+ final _shaders = <ui.FragmentShader>[];
+ List<ui.ImageFilter>? _filters;
+ Object? _filtersFor;
+
+ @override
+ void initState() {
+ super.initState();
+ if (_program != null || !ui.ImageFilter.isShaderFilterSupported) return;
+ (_loading ??= ui.FragmentProgram.fromAsset('assets/shaders/edge_fade.frag')).then((p) {
+ _program = p;
+ if (mounted) setState(() {});
+ }, onError: (_) {});
+ }
+
+ @override
+ void dispose() {
+ _dropShaders();
+ super.dispose();
+ }
+
+ void _dropShaders() {
+ for (final s in _shaders) {
+ s.dispose();
+ }
+ _shaders.clear();
+ }
+
+ List<ui.ImageFilter> _layers(ui.FragmentProgram program, double dpr) {
+ final key = (widget.height, widget.top, widget.sigma, dpr);
+ if (_filters != null && _filtersFor == key) return _filters!;
+ _dropShaders();
+ ui.ImageFilter layer(double sigma, double from, double to) {
+ final shader = program.fragmentShader()
+ ..setFloat(2, widget.height * dpr)
+ ..setFloat(3, from)
+ ..setFloat(4, to)
+ ..setFloat(5, widget.top ? 1 : 0);
+ _shaders.add(shader);
+ return ui.ImageFilter.compose(
+ outer: ui.ImageFilter.shader(shader),
+ inner: ui.ImageFilter.blur(sigmaX: sigma, sigmaY: sigma, tileMode: TileMode.clamp),
+ );
+ }
+
+ _filtersFor = key;
+ return _filters = [
+ layer(widget.sigma * 0.35, 0.2, 1),
+ layer(widget.sigma, 0.08, 0.66),
+ ];
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final program = _program;
+ return IgnorePointer(
+ child: SizedBox(
+ height: widget.height,
+ child: Stack(
+ children: [
+ if (program != null)
+ for (final f in _layers(program, MediaQuery.devicePixelRatioOf(context)))
+ Positioned.fill(
+ child: ClipRect(child: BackdropFilter.grouped(filter: f, child: const SizedBox.expand())),
+ )
+ else
+ ..._strips(),
+ Positioned.fill(
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ gradient: LinearGradient(
+ begin: widget.top ? Alignment.topCenter : Alignment.bottomCenter,
+ end: widget.top ? Alignment.bottomCenter : Alignment.topCenter,
+ colors: [
+ for (final a in const [0.82, 0.62, 0.38, 0.17, 0.05, 0.0]) gc.bg.withValues(alpha: a * widget.shade),
+ ],
+ stops: const [0, 0.2, 0.42, 0.64, 0.84, 1],
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ List<Widget> _strips() {
+ const n = 6;
+ final strip = widget.height * 0.8 / n;
+ return [
+ for (var i = 0; i < n; i++)
+ Positioned(
+ left: 0,
+ right: 0,
+ top: widget.top ? strip * i : widget.height - strip * (i + 1),
+ height: strip + 0.5,
+ child: ClipRect(
+ child: BackdropFilter.grouped(
+ filter: ui.ImageFilter.blur(
+ sigmaX: widget.sigma * (1 - i / n) * 0.7,
+ sigmaY: widget.sigma * (1 - i / n) * 0.7,
+ ),
+ child: const SizedBox.expand(),
+ ),
+ ),
+ ),
+ ];
+ }
+}
+
+class GlassSurface extends StatelessWidget {
+ const GlassSurface({
+ super.key,
+ required this.child,
+ this.radius = 28,
+ this.blur = 22,
+ this.tint,
+ this.padding,
+ });
+
+ final Widget child;
+ final double radius;
+ final double blur;
+ final Color? tint;
+ final EdgeInsetsGeometry? padding;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final dark = gc.bg.computeLuminance() < 0.5;
+ final shape = BorderRadius.circular(radius);
+ return ClipRRect(
+ borderRadius: shape,
+ child: BackdropFilter.grouped(
+ filter: ui.ImageFilter.blur(sigmaX: blur, sigmaY: blur),
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: shape,
+ color: tint ?? gc.bgRaised.withValues(alpha: dark ? 0.66 : 0.74),
+ ),
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: shape,
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ Colors.white.withValues(alpha: dark ? 0.07 : 0.3),
+ Colors.white.withValues(alpha: 0),
+ ],
+ stops: const [0, 0.6],
+ ),
+ border: Border.all(color: Colors.white.withValues(alpha: dark ? 0.08 : 0.5), width: 0.8),
+ ),
+ child: padding == null ? child : Padding(padding: padding!, child: child),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/home_folder.dart b/lib/widgets/home_folder.dart
new file mode 100644
index 0000000..ade4f0e
--- /dev/null
+++ b/lib/widgets/home_folder.dart
@@ -0,0 +1,367 @@
+import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+
+import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import 'routine_folder.dart';
+import 'ui_kit.dart';
+
+class HomeFolder extends StatelessWidget {
+ const HomeFolder({
+ super.key,
+ required this.title,
+ required this.detail,
+ required this.peek,
+ required this.onTap,
+ });
+
+ final String title;
+ final String detail;
+ final Widget peek;
+ final VoidCallback onTap;
+
+ static const height = 150.0;
+ static const _front = 60.0;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final dark = gc.bg.computeLuminance() < 0.5;
+ return Semantics(
+ button: true,
+ label: '$title, $detail',
+ child: Pressable(
+ onTap: onTap,
+ scale: 0.96,
+ child: SizedBox(
+ height: height,
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned.fill(
+ top: 26,
+ child: CustomPaint(
+ painter: _BackPainter(Color.lerp(gc.bgRaised, gc.bg, dark ? 0.45 : 0.6)!),
+ ),
+ ),
+ Positioned(left: 10, right: 10, top: 22, height: _front + 6, child: peek),
+ Positioned.fill(
+ top: _front,
+ child: CustomPaint(
+ painter: _FrontPainter(
+ top: Color.lerp(gc.bgRaised, dark ? Colors.white : gc.bgRaised, dark ? 0.1 : 0)!,
+ bottom: Color.lerp(gc.bgRaised, dark ? Colors.white : gc.bg, dark ? 0.02 : 0.35)!,
+ edge: dark ? Colors.white.withValues(alpha: 0.08) : gc.border,
+ shadow: Colors.black.withValues(alpha: dark ? 0.5 : 0.12),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(13, 24, 10, 12),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.centerLeft,
+ child: Text(title,
+ maxLines: 1,
+ style: AppTheme.f(15.5, weight: FontWeight.w800, color: gc.text)),
+ ),
+ const Spacer(),
+ Text(detail,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(11, weight: FontWeight.w600, color: gc.textSecondary)),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+Path _folderPath(Size s, {required bool tabLeft, double tab = 12}) {
+ const r = 16.0;
+ final w = s.width, h = s.height;
+ final split = w * 0.48;
+ final p = Path();
+ if (tabLeft) {
+ p
+ ..moveTo(0, r)
+ ..quadraticBezierTo(0, 0, r, 0)
+ ..lineTo(split - 10, 0)
+ ..cubicTo(split + 2, 0, split + 4, tab, split + 18, tab)
+ ..lineTo(w - r, tab)
+ ..quadraticBezierTo(w, tab, w, tab + r);
+ } else {
+ p
+ ..moveTo(0, tab + r)
+ ..quadraticBezierTo(0, tab, r, tab)
+ ..lineTo(w - split - 18, tab)
+ ..cubicTo(w - split - 4, tab, w - split - 2, 0, w - split + 10, 0)
+ ..lineTo(w - r, 0)
+ ..quadraticBezierTo(w, 0, w, r);
+ }
+ return p
+ ..lineTo(w, h - r - 2)
+ ..quadraticBezierTo(w, h, w - r - 2, h)
+ ..lineTo(r + 2, h)
+ ..quadraticBezierTo(0, h, 0, h - r - 2)
+ ..close();
+}
+
+class _BackPainter extends CustomPainter {
+ _BackPainter(this.color);
+ final Color color;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ canvas.drawPath(_folderPath(size, tabLeft: false, tab: 10), Paint()..color = color);
+ }
+
+ @override
+ bool shouldRepaint(_BackPainter o) => o.color != color;
+}
+
+class _FrontPainter extends CustomPainter {
+ _FrontPainter({required this.top, required this.bottom, required this.edge, required this.shadow});
+ final Color top;
+ final Color bottom;
+ final Color edge;
+ final Color shadow;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final path = _folderPath(size, tabLeft: true);
+ canvas.drawShadow(path.shift(const Offset(0, -6)), shadow, 10, true);
+ canvas.drawPath(
+ path,
+ Paint()
+ ..shader = LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [top, bottom],
+ ).createShader(Offset.zero & size),
+ );
+ canvas.drawPath(
+ path,
+ Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 1
+ ..shader = LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [edge, edge.withValues(alpha: 0)],
+ stops: const [0, 0.6],
+ ).createShader(Offset.zero & size),
+ );
+ }
+
+ @override
+ bool shouldRepaint(_FrontPainter o) =>
+ o.top != top || o.bottom != bottom || o.edge != edge || o.shadow != shadow;
+}
+
+class _Fan extends StatelessWidget {
+ const _Fan({required this.children, required this.width, required this.height, this.spread = 1});
+
+ final List<Widget> children;
+ final double width;
+ final double height;
+ final double spread;
+
+ static const _turns = [-0.12, 0.09, -0.02];
+ static const _dx = [-0.2, 0.2, 0.0];
+ static const _dy = [10.0, 7.0, 0.0];
+
+ @override
+ Widget build(BuildContext context) {
+ return LayoutBuilder(
+ builder: (context, box) {
+ final n = math.min(children.length, 3);
+ final order = n == 3 ? [0, 1, 2] : n == 2 ? [0, 1] : [2];
+ return Stack(
+ clipBehavior: Clip.none,
+ children: [
+ for (var k = 0; k < n; k++)
+ Positioned(
+ left: (box.maxWidth - width) / 2 + _dx[order[k]] * spread * box.maxWidth,
+ top: _dy[order[k]],
+ width: width,
+ height: height,
+ child: Transform.rotate(angle: _turns[order[k]], child: children[k]),
+ ),
+ ],
+ );
+ },
+ );
+ }
+}
+
+class RoutinesPeek extends StatelessWidget {
+ const RoutinesPeek({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final dark = gc.bg.computeLuminance() < 0.5;
+ final hues = [for (final r in fit.routines.take(3)) folderHue(r)];
+ final colors = hues.isEmpty ? kFolderHues.take(3).toList() : hues;
+ return _Fan(
+ width: 60,
+ height: 50,
+ children: [
+ for (final c in colors.reversed)
+ _Sheet(color: Color.lerp(c, Colors.black, dark ? 0.12 : 0)!, ink: Color.lerp(c, Colors.black, 0.45)!),
+ ],
+ );
+ }
+}
+
+class _Sheet extends StatelessWidget {
+ const _Sheet({required this.color, required this.ink});
+
+ final Color color;
+ final Color ink;
+
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ padding: const EdgeInsets.fromLTRB(9, 9, 12, 0),
+ decoration: BoxDecoration(
+ color: color,
+ borderRadius: BorderRadius.circular(9),
+ boxShadow: [BoxShadow(color: Colors.black.withValues(alpha: 0.18), blurRadius: 6, offset: const Offset(0, 2))],
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ for (final f in const [1.0, 0.7, 0.45]) ...[
+ FractionallySizedBox(
+ widthFactor: f,
+ child: Container(
+ height: 3,
+ decoration: BoxDecoration(color: ink.withValues(alpha: 0.4), borderRadius: BorderRadius.circular(2)),
+ ),
+ ),
+ const SizedBox(height: 5),
+ ],
+ ],
+ ),
+ );
+ }
+}
+
+class ToolsPeek extends StatelessWidget {
+ const ToolsPeek({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final dark = gc.bg.computeLuminance() < 0.5;
+ final base = Color.lerp(gc.bgRaised2, Colors.white, dark ? 0.1 : 0)!;
+ return _Fan(
+ width: 46,
+ height: 50,
+ spread: 1.4,
+ children: [
+ for (final (icon, tint) in [
+ (PhosphorIconsBold.fire, gc.accent),
+ (PhosphorIconsBold.circlesThree, gc.brass),
+ (PhosphorIconsBold.barbell, gc.text),
+ ])
+ Container(
+ alignment: Alignment.topCenter,
+ padding: const EdgeInsets.only(top: 9),
+ decoration: BoxDecoration(
+ color: Color.lerp(base, tint, dark ? 0.16 : 0.12),
+ borderRadius: BorderRadius.circular(12),
+ border: Border.all(color: Colors.white.withValues(alpha: dark ? 0.06 : 0)),
+ boxShadow: [
+ BoxShadow(color: Colors.black.withValues(alpha: dark ? 0.35 : 0.1), blurRadius: 6, offset: const Offset(0, 2)),
+ ],
+ ),
+ child: Icon(icon, size: 19, color: tint),
+ ),
+ ],
+ );
+ }
+}
+
+class NotesPeek extends StatelessWidget {
+ const NotesPeek({super.key});
+
+ static const _paper = [Color(0xFFF2D680), Color(0xFFF3C7B1), Color(0xFFA8C99E)];
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final dark = gc.bg.computeLuminance() < 0.5;
+ return _Fan(
+ width: 48,
+ height: 48,
+ children: [
+ for (final c in _paper)
+ Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned.fill(
+ child: Container(
+ padding: const EdgeInsets.fromLTRB(8, 13, 9, 0),
+ decoration: BoxDecoration(
+ color: Color.lerp(c, Colors.black, dark ? 0.08 : 0),
+ borderRadius: const BorderRadius.only(
+ topLeft: Radius.circular(3),
+ topRight: Radius.circular(3),
+ bottomLeft: Radius.circular(3),
+ bottomRight: Radius.circular(12),
+ ),
+ boxShadow: [
+ BoxShadow(color: Colors.black.withValues(alpha: 0.2), blurRadius: 5, offset: const Offset(0, 2)),
+ ],
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ for (final f in const [1.0, 0.8, 0.5]) ...[
+ FractionallySizedBox(
+ widthFactor: f,
+ child: Container(
+ height: 2.5,
+ decoration: BoxDecoration(
+ color: Colors.black.withValues(alpha: 0.22),
+ borderRadius: BorderRadius.circular(2),
+ ),
+ ),
+ ),
+ const SizedBox(height: 5),
+ ],
+ ],
+ ),
+ ),
+ ),
+ Positioned(
+ top: -5,
+ left: 14,
+ right: 14,
+ height: 10,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ color: Colors.white.withValues(alpha: 0.45),
+ borderRadius: BorderRadius.circular(2),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ );
+ }
+}
diff --git a/lib/widgets/liquid_notch.dart b/lib/widgets/liquid_notch.dart
new file mode 100644
index 0000000..83e304d
--- /dev/null
+++ b/lib/widgets/liquid_notch.dart
@@ -0,0 +1,581 @@
+import 'dart:async';
+import 'dart:math' as math;
+import 'dart:ui' as ui;
+
+import 'package:flutter/material.dart';
+
+import '../theme/app_theme.dart';
+
+@immutable
+class LiquidNotchFrame {
+ const LiquidNotchFrame(this.width, this.height, this.y, this.neck, this.shoulder, this.opacity);
+ final double width, height, y, neck, shoulder, opacity;
+
+ static LiquidNotchFrame lerp(LiquidNotchFrame a, LiquidNotchFrame b, double t) => LiquidNotchFrame(
+ ui.lerpDouble(a.width, b.width, t)!,
+ ui.lerpDouble(a.height, b.height, t)!,
+ ui.lerpDouble(a.y, b.y, t)!,
+ ui.lerpDouble(a.neck, b.neck, t)!,
+ ui.lerpDouble(a.shoulder, b.shoulder, t)!,
+ ui.lerpDouble(a.opacity, b.opacity, t)!,
+ );
+
+ static const _enter = <(double, LiquidNotchFrame)>[
+ (0, LiquidNotchFrame(0, 0, 47, 0, 0, 0)),
+ (.08, LiquidNotchFrame(12, 10, 49, 9, 36, 0)),
+ (.16, LiquidNotchFrame(24, 19, 56, 12, 31, 0)),
+ (.24, LiquidNotchFrame(29, 27, 63, 10, 28, 0)),
+ (.32, LiquidNotchFrame(31, 36, 72, 7, 25, 0)),
+ (.40, LiquidNotchFrame(35, 44, 83, 3.5, 21, 0)),
+ (.48, LiquidNotchFrame(51, 57, 97, 1, 14, .05)),
+ (.53, LiquidNotchFrame(69, 66, 105, 0, 0, .15)),
+ (.60, LiquidNotchFrame(100, 72, 113, 0, 0, .32)),
+ (.68, LiquidNotchFrame(150, 69, 116, 0, 0, .50)),
+ (.76, LiquidNotchFrame(205, 61, 115, 0, 0, .68)),
+ (.86, LiquidNotchFrame(270, 55, 107, 0, 0, .90)),
+ (1, LiquidNotchFrame(307, 53, 102, 0, 0, 1)),
+ ];
+ static const _exit = <(double, LiquidNotchFrame)>[
+ (0, LiquidNotchFrame(307, 53, 102, 0, 0, 1)),
+ (.12, LiquidNotchFrame(285, 51, 102, 0, 0, .96)),
+ (.25, LiquidNotchFrame(244, 48, 102, 0, 0, .80)),
+ (.37, LiquidNotchFrame(191, 44, 101, 0, 0, .60)),
+ (.48, LiquidNotchFrame(137, 41, 100, 0, 0, .35)),
+ (.58, LiquidNotchFrame(84, 43, 87, 24, 45, .06)),
+ (.69, LiquidNotchFrame(58, 43, 72, 21, 42, 0)),
+ (.80, LiquidNotchFrame(36, 29, 58, 15, 36, 0)),
+ (.91, LiquidNotchFrame(17, 12, 50, 8, 29, 0)),
+ (1, LiquidNotchFrame(0, 0, 47, 0, 0, 0)),
+ ];
+
+ static LiquidNotchFrame sample(double progress, {bool exiting = false}) {
+ final keys = exiting ? _exit : _enter;
+ final p = progress.clamp(0.0, 1.0);
+ for (var i = 1; i < keys.length; i++) {
+ if (p <= keys[i].$1) {
+ final a = keys[i - 1];
+ final b = keys[i];
+ return lerp(a.$2, b.$2, (p - a.$1) / (b.$1 - a.$1));
+ }
+ }
+ return keys.last.$2;
+ }
+}
+
+class LiquidNotch extends StatefulWidget {
+ const LiquidNotch({
+ super.key,
+ required this.visible,
+ required this.child,
+ required this.sourceRect,
+ this.sourceColor = Colors.black,
+ this.pillColor = Colors.black,
+ this.enterDuration = const Duration(milliseconds: 650),
+ this.exitDuration = const Duration(milliseconds: 450),
+ this.onTap,
+ this.onDismissed,
+ this.extraHeight = 0,
+ });
+
+ final bool visible;
+ final Widget child;
+ final Rect sourceRect;
+ final double extraHeight;
+ final Color sourceColor, pillColor;
+ final Duration enterDuration, exitDuration;
+ final VoidCallback? onTap, onDismissed;
+
+ @override
+ State<LiquidNotch> createState() => _LiquidNotchState();
+}
+
+class _LiquidNotchState extends State<LiquidNotch> with SingleTickerProviderStateMixin {
+ late final AnimationController _controller = AnimationController(vsync: this)..addStatusListener(_status);
+ bool _exiting = false;
+ bool _reduced = false;
+ bool _dismissPending = false;
+ LiquidNotchFrame? _interrupted;
+
+ void _status(AnimationStatus s) {
+ if (s == AnimationStatus.completed && _exiting && _dismissPending) {
+ _dismissPending = false;
+ widget.onDismissed?.call();
+ }
+ }
+
+ LiquidNotchFrame get _frame {
+ final sampled = LiquidNotchFrame.sample(_controller.value, exiting: _exiting);
+ final previous = _interrupted;
+ if (previous == null) return sampled;
+ return LiquidNotchFrame.lerp(
+ previous, sampled, Curves.easeOut.transform((_controller.value / .4).clamp(0.0, 1.0)));
+ }
+
+ @override
+ void initState() {
+ super.initState();
+ _exiting = !widget.visible;
+ _controller.duration = widget.visible ? widget.enterDuration : widget.exitDuration;
+ _controller.value = widget.visible ? 0 : 1;
+ if (widget.visible) _controller.forward();
+ }
+
+ @override
+ void didChangeDependencies() {
+ super.didChangeDependencies();
+ _reduced = MediaQuery.disableAnimationsOf(context);
+ if (_reduced) _controller.value = 1;
+ }
+
+ @override
+ void didUpdateWidget(LiquidNotch oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ if (oldWidget.visible == widget.visible) return;
+ final prior = _controller.isAnimating ? _frame : null;
+ _exiting = !widget.visible;
+ _dismissPending = _exiting;
+ _interrupted = prior;
+ _controller.duration = _exiting ? widget.exitDuration : widget.enterDuration;
+ if (_reduced) {
+ _controller.value = 0;
+ _controller.value = 1;
+ } else {
+ _controller.forward(from: 0);
+ }
+ }
+
+ @override
+ void dispose() {
+ _controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) => LayoutBuilder(
+ builder: (context, bounds) {
+ final scale = (bounds.maxWidth / 390).clamp(.5, 1.2);
+ final source = widget.sourceRect;
+ final origin = Offset(source.center.dx, source.bottom - 49 * scale);
+ return AnimatedBuilder(
+ animation: _controller,
+ builder: (context, _) {
+ final frame = _frame;
+ final extra = widget.extraHeight * (frame.width / 307).clamp(0.0, 1.0);
+ final target = Rect.fromCenter(
+ center: Offset(origin.dx, origin.dy + (frame.y + extra / 2) * scale),
+ width: frame.width * scale,
+ height: (frame.height + extra) * scale,
+ );
+ return Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned.fill(
+ child: IgnorePointer(
+ child: CustomPaint(
+ painter: _LiquidPainter(
+ source: source,
+ target: target,
+ neck: frame.neck * scale,
+ shoulder: frame.shoulder * scale,
+ sourceColor: widget.sourceColor,
+ pillColor: widget.pillColor,
+ cap: 36 * scale,
+ ),
+ ),
+ ),
+ ),
+ if (frame.opacity > 0 && frame.width > 0)
+ Positioned.fromRect(
+ rect: target,
+ child: IgnorePointer(
+ ignoring: !widget.visible,
+ child: ExcludeSemantics(
+ excluding: !widget.visible || frame.opacity < .6,
+ child: Semantics(
+ liveRegion: true,
+ child: GestureDetector(
+ onTap: widget.onTap,
+ behavior: HitTestBehavior.opaque,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(math.min(target.height / 2, 36 * scale)),
+ child: Opacity(
+ opacity: frame.opacity,
+ child: ImageFiltered(
+ enabled: frame.opacity < 1 && !_reduced,
+ imageFilter: ui.ImageFilter.blur(
+ sigmaX: (1 - frame.opacity) * 3,
+ sigmaY: (1 - frame.opacity) * 3,
+ ),
+ child: FittedBox(
+ fit: BoxFit.contain,
+ child: SizedBox(
+ width: 307,
+ height: 53 + widget.extraHeight,
+ child: widget.child,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ },
+ );
+ },
+ );
+}
+
+class _LiquidPainter extends CustomPainter {
+ const _LiquidPainter({
+ required this.source,
+ required this.target,
+ required this.neck,
+ required this.shoulder,
+ required this.sourceColor,
+ required this.pillColor,
+ required this.cap,
+ });
+ final Rect source, target;
+ final double neck, shoulder, cap;
+ final Color sourceColor, pillColor;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final sourcePath = Path()..addRRect(RRect.fromRectAndRadius(source, Radius.circular(source.height / 2)));
+ if (target.isEmpty) {
+ canvas.drawPath(sourcePath, Paint()..color = sourceColor);
+ return;
+ }
+ final drop = Path()
+ ..addRRect(RRect.fromRectAndRadius(target, Radius.circular(math.min(target.height / 2, cap))));
+ if (neck <= 0) {
+ canvas.drawPath(sourcePath, Paint()..color = sourceColor);
+ canvas.drawPath(drop, Paint()..color = pillColor);
+ return;
+ }
+ final x = source.center.dx;
+ final y = source.bottom - 1;
+ final bottom = target.center.dy;
+ final waistY = ui.lerpDouble(y, target.top, .6)!;
+ final attach = target.width * .44;
+ final bridge = Path()
+ ..moveTo(x - shoulder, y)
+ ..cubicTo(x - shoulder * .43, y, x - neck, waistY - 4, x - neck, waistY)
+ ..cubicTo(x - neck, waistY + 6, x - attach, bottom - 8, x - attach, bottom)
+ ..lineTo(x + attach, bottom)
+ ..cubicTo(x + attach, bottom - 8, x + neck, waistY + 6, x + neck, waistY)
+ ..cubicTo(x + neck, waistY - 4, x + shoulder * .43, y, x + shoulder, y)
+ ..close();
+ final silhouette =
+ Path.combine(PathOperation.union, sourcePath, Path.combine(PathOperation.union, bridge, drop));
+ final shader = ui.Gradient.linear(
+ Offset(x, source.bottom - 2),
+ Offset(x, (target.top + target.height * .62).clamp(source.bottom + 1, double.infinity)),
+ [sourceColor, pillColor],
+ [.0, 1],
+ );
+ canvas.drawPath(silhouette, Paint()..shader = shader);
+ }
+
+ @override
+ bool shouldRepaint(_LiquidPainter old) =>
+ old.source != source ||
+ old.target != target ||
+ old.neck != neck ||
+ old.shoulder != shoulder ||
+ old.sourceColor != sourceColor ||
+ old.pillColor != pillColor ||
+ old.cap != cap;
+}
+
+final _sessions = Expando<_ToastSession>('notch toasts');
+
+Future<void> showNotchToast(
+ BuildContext context,
+ String title, {
+ String? subtitle,
+ IconData? icon,
+ Color accent = const Color(0xFF8FA377),
+ String? action,
+ VoidCallback? onTap,
+ Duration? duration,
+}) {
+ final overlay = Overlay.maybeOf(context, rootOverlay: true);
+ final words = '$title ${subtitle ?? ''}'.trim().split(RegExp(r'\s+')).length;
+ if (overlay == null || !context.mounted) return Future.value();
+ final request = _ToastRequest(
+ title: title,
+ subtitle: subtitle,
+ icon: icon,
+ accent: accent,
+ action: action,
+ onTap: onTap,
+ duration: duration ?? Duration(milliseconds: math.max(2200, 900 + words * 330)),
+ themes: InheritedTheme.capture(from: context, to: overlay.context),
+ reducedMotion: MediaQuery.maybeOf(context)?.disableAnimations ?? false,
+ );
+ final session = _sessions[overlay] ??= _ToastSession(overlay);
+ session.show(request);
+ return request.done.future;
+}
+
+class _ToastRequest {
+ _ToastRequest({
+ required this.title,
+ required this.subtitle,
+ required this.icon,
+ required this.accent,
+ required this.action,
+ required this.onTap,
+ required this.duration,
+ required this.themes,
+ required this.reducedMotion,
+ });
+ final String title;
+ final String? subtitle;
+ final IconData? icon;
+ final Color accent;
+ final String? action;
+ final VoidCallback? onTap;
+ final Duration duration;
+ final CapturedThemes themes;
+ final bool reducedMotion;
+ final done = Completer<void>();
+
+ void complete() {
+ if (!done.isCompleted) done.complete();
+ }
+}
+
+class _ToastSession {
+ _ToastSession(this.overlay);
+ final OverlayState overlay;
+ OverlayEntry? entry;
+ GlobalKey<_ToastHostState>? hostKey;
+ _ToastRequest? active, pending;
+
+ void show(_ToastRequest request) {
+ if (entry != null) {
+ pending?.complete();
+ pending = request;
+ hostKey?.currentState?.dismiss();
+ return;
+ }
+ active = request;
+ final key = GlobalKey<_ToastHostState>();
+ hostKey = key;
+ entry = OverlayEntry(builder: (_) => _ToastHost(key: key, session: this, request: request));
+ overlay.insert(entry!);
+ }
+
+ void finished(_ToastRequest request) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!identical(active, request)) return;
+ final next = pending;
+ pending = null;
+ active = null;
+ final old = entry;
+ entry = null;
+ hostKey = null;
+ old?.remove();
+ old?.dispose();
+ request.complete();
+ if (next != null) {
+ if (overlay.mounted) {
+ show(next);
+ } else {
+ next.complete();
+ }
+ }
+ });
+ WidgetsBinding.instance.ensureVisualUpdate();
+ }
+
+ void hostDisposed(_ToastRequest request) {
+ if (!identical(active, request)) return;
+ active = null;
+ pending?.complete();
+ pending = null;
+ request.complete();
+ final old = entry;
+ entry = null;
+ hostKey = null;
+ if (old != null) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ old.remove();
+ old.dispose();
+ });
+ }
+ }
+}
+
+class _ToastHost extends StatefulWidget {
+ const _ToastHost({super.key, required this.session, required this.request});
+ final _ToastSession session;
+ final _ToastRequest request;
+
+ @override
+ State<_ToastHost> createState() => _ToastHostState();
+}
+
+class _ToastHostState extends State<_ToastHost> {
+ bool _visible = true;
+ Timer? _timer;
+
+ @override
+ void initState() {
+ super.initState();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!mounted) return;
+ if (widget.session.pending != null) {
+ dismiss();
+ return;
+ }
+ final entrance = widget.request.reducedMotion ? Duration.zero : const Duration(milliseconds: 650);
+ _timer = Timer(entrance + widget.request.duration, dismiss);
+ });
+ }
+
+ void dismiss() {
+ if (!mounted || !_visible) return;
+ _timer?.cancel();
+ setState(() => _visible = false);
+ }
+
+ @override
+ void dispose() {
+ _timer?.cancel();
+ widget.session.hostDisposed(widget.request);
+ super.dispose();
+ }
+
+ static double _extraFor(_ToastRequest r) {
+ final sub = r.subtitle;
+ if (sub == null || sub.isEmpty) return 0;
+ final room = 307 - 26 - (r.icon == null ? 0 : 46) - (r.action == null ? 0 : 60);
+ final painter = TextPainter(
+ text: TextSpan(text: sub, style: _ToastContent.subStyle),
+ textDirection: TextDirection.ltr,
+ maxLines: 3,
+ )..layout(maxWidth: room.toDouble());
+ final lines = painter.computeLineMetrics().length.clamp(1, 3);
+ painter.dispose();
+ return (lines - 1) * 14.0;
+ }
+
+ static Rect sourceFor(MediaQueryData media, double width) {
+ final top = media.viewPadding.top;
+ for (final f in media.displayFeatures) {
+ final b = f.bounds;
+ if (f.type != ui.DisplayFeatureType.cutout) continue;
+ if (b.top > top || b.width > width * 0.6 || b.isEmpty) continue;
+ final side = math.max(b.height, 18.0);
+ final w = math.max(b.width, side);
+ return Rect.fromCenter(center: b.center, width: w, height: side);
+ }
+ if (top > 50) {
+ return Rect.fromLTWH((width - 126) / 2, math.max(11.0, top - 48), 126, 37);
+ }
+ const side = 20.0;
+ return Rect.fromCenter(center: Offset(width / 2, math.max(side / 2, top / 2)), width: side, height: side);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final view = View.of(context);
+ final media = MediaQueryData.fromView(view).copyWith(
+ disableAnimations: widget.request.reducedMotion,
+ textScaler: MediaQuery.textScalerOf(context),
+ );
+ return Positioned.fill(
+ child: widget.request.themes.wrap(
+ MediaQuery(
+ data: media,
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final source = sourceFor(media, constraints.maxWidth);
+ final extra = _extraFor(widget.request);
+ return Align(
+ alignment: Alignment.topCenter,
+ child: SizedBox(
+ height: source.bottom + 170 + extra,
+ child: LiquidNotch(
+ visible: _visible,
+ extraHeight: extra,
+ sourceRect: source,
+ sourceColor: Colors.black,
+ pillColor: const Color(0xFF0B0B0B),
+ onDismissed: () => widget.session.finished(widget.request),
+ onTap: () {
+ dismiss();
+ widget.request.onTap?.call();
+ },
+ child: _ToastContent(request: widget.request),
+ ),
+ ),
+ );
+ },
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _ToastContent extends StatelessWidget {
+ const _ToastContent({required this.request});
+ final _ToastRequest request;
+
+ static final subStyle = AppTheme.f(11.5,
+ weight: FontWeight.w600, color: Colors.white.withValues(alpha: 0.6), height: 1.2);
+
+ @override
+ Widget build(BuildContext context) {
+ final icon = request.icon;
+ final action = request.action;
+ return Material(
+ type: MaterialType.transparency,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(10, 9, 16, 9),
+ child: Row(
+ children: [
+ if (icon != null) ...[
+ Container(
+ width: 35,
+ height: 35,
+ decoration: BoxDecoration(color: request.accent.withValues(alpha: 0.18), shape: BoxShape.circle),
+ child: Icon(icon, size: 18, color: request.accent),
+ ),
+ const SizedBox(width: 11),
+ ],
+ Expanded(
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(request.title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(14, weight: FontWeight.w800, color: Colors.white, height: 1.1)),
+ if (request.subtitle != null && request.subtitle!.isNotEmpty) ...[
+ const SizedBox(height: 3),
+ Text(request.subtitle!, maxLines: 3, overflow: TextOverflow.ellipsis, style: subStyle),
+ ],
+ ],
+ ),
+ ),
+ if (action != null) ...[
+ const SizedBox(width: 8),
+ Text(action, style: AppTheme.f(13, weight: FontWeight.w800, color: request.accent)),
+ ],
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/medal_shelf.dart b/lib/widgets/medal_shelf.dart
index e5c153c..4a1daf1 100644
--- a/lib/widgets/medal_shelf.dart
+++ b/lib/widgets/medal_shelf.dart
@@ -5,6 +5,7 @@ import '../l10n/l10n.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import 'glass.dart';
import 'medal.dart';
import 'ui_kit.dart';
@@ -85,7 +86,7 @@ class MedalShelf extends StatelessWidget {
Future<void> showMedalSheet(BuildContext context, AwardId id) {
fit.markAwardsSeen();
- return showModalBottomSheet<void>(
+ return showAppSheet<void>(
context: context,
backgroundColor: Colors.transparent,
builder: (_) => _MedalSheet(id: id),
diff --git a/lib/widgets/muscle_radar.dart b/lib/widgets/muscle_radar.dart
new file mode 100644
index 0000000..65f2eed
--- /dev/null
+++ b/lib/widgets/muscle_radar.dart
@@ -0,0 +1,273 @@
+import 'dart:math' as math;
+
+import 'package:flutter/material.dart';
+
+import '../catalog/body_svg.dart';
+import '../l10n/l10n.dart';
+import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import 'svg_icon.dart';
+import 'ui_kit.dart';
+
+const _axes = [
+ 'chest',
+ 'shoulders',
+ 'trapezius',
+ 'back',
+ 'triceps',
+ 'biceps',
+ 'forearm',
+ 'abdomen',
+ 'quads',
+ 'calves',
+ 'hamstrings',
+ 'glutes',
+];
+
+const _backView = {'trapezius', 'back', 'triceps', 'glutes', 'hamstrings', 'calves'};
+
+class MuscleRadarCard extends StatefulWidget {
+ const MuscleRadarCard({super.key});
+
+ @override
+ State<MuscleRadarCard> createState() => _MuscleRadarCardState();
+}
+
+class _MuscleRadarCardState extends State<MuscleRadarCard> {
+ String? _picked;
+
+ Map<String, double> _month() {
+ final now = DateTime.now();
+ final raw = fit.muscleSetsBetween(DateTime(now.year, now.month), now.add(const Duration(minutes: 1)));
+ return {
+ for (final id in _axes) id: (raw[id] ?? 0) + (id == 'abdomen' ? raw['obliques'] ?? 0 : 0),
+ };
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final sets = _month();
+ final top = sets.values.fold<double>(0, math.max);
+ final picked = _picked;
+ final behind = [
+ for (final id in [..._axes]..sort((a, b) => sets[a]!.compareTo(sets[b]!)))
+ if (top > 0 && sets[id]! < top * 0.5) id,
+ ].take(3).toList();
+
+ return SoftCard(
+ radius: 20,
+ borderColor: Colors.transparent,
+ padding: const EdgeInsets.fromLTRB(18, 20, 18, 18),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(t.radarTitle, style: AppTheme.f(21, weight: FontWeight.w800, color: gc.text)),
+ const SizedBox(height: 4),
+ Text(t.radarHint, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
+ const SizedBox(height: 10),
+ AspectRatio(
+ aspectRatio: 1,
+ child: LayoutBuilder(builder: (context, c) {
+ final side = c.maxWidth;
+ final icon = side * 0.165;
+ final radius = side / 2 - _gap - icon;
+ return TweenAnimationBuilder<double>(
+ tween: Tween(begin: 0, end: 1),
+ duration: const Duration(milliseconds: 950),
+ curve: Curves.easeOutCubic,
+ builder: (context, grow, _) => Stack(
+ children: [
+ Positioned.fill(
+ child: CustomPaint(
+ painter: _RadarPainter(
+ gc: gc,
+ values: [for (final id in _axes) top <= 0 ? 0 : sets[id]! / top * grow],
+ radius: radius,
+ picked: picked == null ? -1 : _axes.indexOf(picked),
+ ),
+ ),
+ ),
+ for (var i = 0; i < _axes.length; i++)
+ _figure(gc, i, side, radius, icon, sets),
+ ],
+ ),
+ );
+ }),
+ ),
+ const SizedBox(height: 6),
+ AnimatedSwitcher(
+ duration: const Duration(milliseconds: 220),
+ child: Text(
+ key: ValueKey(picked ?? behind.join()),
+ picked != null
+ ? '${t.muscle(picked)} · ${t.setCount(sets[picked]!.round())}'
+ : top <= 0
+ ? t.radarEmpty
+ : behind.isEmpty
+ ? t.radarBalanced
+ : t.radarFocus(behind.map(t.muscle).join(', ')),
+ textAlign: TextAlign.center,
+ style: AppTheme.f(13, weight: FontWeight.w600, color: picked != null ? gc.text : gc.textSecondary),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ static const _gap = 6.0;
+
+ Widget _figure(GymColors gc, int i, double side, double radius, double size, Map<String, double> sets) {
+ final a = -math.pi / 2 + i * 2 * math.pi / _axes.length;
+ final id = _axes[i];
+ final on = _picked == id;
+ final crop = MuscleFigurePainter.crop(id);
+ final body = MuscleFigurePainter.content(id);
+ final k = size / crop.width;
+ final reach = radius + _gap + (math.cos(a).abs() * body.width + math.sin(a).abs() * body.height) * k / 2;
+ return Positioned(
+ left: side / 2 + math.cos(a) * reach - (body.center.dx - crop.left) * k,
+ top: side / 2 + math.sin(a) * reach - (body.center.dy - crop.top) * k,
+ width: size,
+ height: size,
+ child: Semantics(
+ button: true,
+ label: '${t.muscle(id)} · ${t.setCount(sets[id]!.round())}',
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => setState(() => _picked = on ? null : id),
+ child: AnimatedScale(
+ scale: on ? 1.14 : 1,
+ duration: const Duration(milliseconds: 220),
+ curve: Curves.easeOutBack,
+ child: CustomPaint(painter: MuscleFigurePainter(gc: gc, muscle: id)),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _RadarPainter extends CustomPainter {
+ _RadarPainter({required this.gc, required this.values, required this.radius, required this.picked});
+
+ final GymColors gc;
+ final List<double> values;
+ final double radius;
+ final int picked;
+
+ Offset _at(Offset c, int i, double r) {
+ final a = -math.pi / 2 + i * 2 * math.pi / values.length;
+ return c + Offset(math.cos(a) * r, math.sin(a) * r);
+ }
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final c = size.center(Offset.zero);
+ final n = values.length;
+ final grid = Paint()
+ ..color = gc.border
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 1;
+ for (var ring = 1; ring <= 4; ring++) {
+ final r = radius * ring / 4;
+ canvas.drawPath(Path()..addPolygon([for (var i = 0; i < n; i++) _at(c, i, r)], true), grid);
+ }
+ for (var i = 0; i < n; i++) {
+ canvas.drawLine(c, _at(c, i, radius), grid);
+ }
+
+ final pts = [for (var i = 0; i < n; i++) _at(c, i, radius * values[i].clamp(0.0, 1.0))];
+ final shape = Path()..addPolygon(pts, true);
+ canvas.drawPath(shape, Paint()..color = gc.accent.withValues(alpha: 0.22));
+ canvas.drawPath(
+ shape,
+ Paint()
+ ..color = gc.accent
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 2
+ ..strokeJoin = StrokeJoin.round,
+ );
+ for (var i = 0; i < n; i++) {
+ canvas.drawCircle(pts[i], i == picked ? 5 : 3, Paint()..color = i == picked ? gc.text : gc.accent);
+ }
+ }
+
+ @override
+ bool shouldRepaint(_RadarPainter old) =>
+ old.gc != gc || old.radius != radius || old.picked != picked || !_same(old.values, values);
+
+ static bool _same(List<double> a, List<double> b) {
+ for (var i = 0; i < a.length; i++) {
+ if (a[i] != b[i]) return false;
+ }
+ return a.length == b.length;
+ }
+}
+
+class MuscleFigurePainter extends CustomPainter {
+ MuscleFigurePainter({required this.gc, required this.muscle});
+
+ final GymColors gc;
+ final String muscle;
+
+ static Rect _half(String id) =>
+ _backView.contains(id) ? const Rect.fromLTRB(270, 0, 540, 462) : const Rect.fromLTRB(0, 0, 262, 462);
+
+ static Rect crop(String id) {
+ final cx = _backView.contains(id) ? 411.0 : 115.0;
+ if (id == 'calves') return Rect.fromCenter(center: Offset(cx, 362), width: 200, height: 200);
+ final top = id == 'quads' || id == 'hamstrings' || id == 'glutes' ? 160.0 : -4.0;
+ return Rect.fromLTWH(cx - 135, top, 270, 270);
+ }
+
+ static final _content = <String, Rect>{};
+
+ static Rect content(String id) => _content.putIfAbsent(id, () {
+ final box = crop(id).intersect(_half(id));
+ var l = double.infinity, t = double.infinity, r = -double.infinity, b = -double.infinity;
+ for (final d in [...bodyBaseMain, ...bodyBaseLite]) {
+ for (final m in svgPath(d).computeMetrics()) {
+ for (var at = 0.0; at < m.length; at += 2) {
+ final p = m.getTangentForOffset(at)?.position;
+ if (p == null || !box.contains(p)) continue;
+ l = math.min(l, p.dx);
+ t = math.min(t, p.dy);
+ r = math.max(r, p.dx);
+ b = math.max(b, p.dy);
+ }
+ }
+ }
+ return l.isFinite ? Rect.fromLTRB(l, t, r, b) : box;
+ });
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final crop = MuscleFigurePainter.crop(muscle);
+ final dark = gc.bg.computeLuminance() < 0.5;
+ final skin = dark ? const Color(0xFFE4E1DC) : const Color(0xFFB9B1A8);
+ final rest = Color.lerp(skin, gc.bgRaised, 0.22)!;
+ final lit = {muscle, if (muscle == 'abdomen') 'obliques'};
+
+ canvas.clipRect(Offset.zero & size);
+ final k = size.width / crop.width;
+ canvas.scale(k);
+ canvas.translate(-crop.left, -crop.top);
+ canvas.clipRect(_half(muscle));
+ final paint = Paint()..isAntiAlias = true;
+ for (final d in [...bodyBaseMain, ...bodyBaseLite]) {
+ canvas.drawPath(svgPath(d), paint..color = skin);
+ }
+ for (final e in muscleFills.entries) {
+ paint.color = lit.contains(e.key) ? gc.accent : rest;
+ for (final d in e.value) {
+ canvas.drawPath(svgPath(d), paint);
+ }
+ }
+ }
+
+ @override
+ bool shouldRepaint(MuscleFigurePainter old) => old.gc != gc || old.muscle != muscle;
+}
diff --git a/lib/widgets/note_kit.dart b/lib/widgets/note_kit.dart
index 701adc9..4b8834d 100644
--- a/lib/widgets/note_kit.dart
+++ b/lib/widgets/note_kit.dart
@@ -1,5 +1,6 @@
import 'dart:io';
+import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import 'package:video_player/video_player.dart';
@@ -10,6 +11,7 @@ import '../services/media_store.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import 'glass.dart';
import 'ui_kit.dart';
Color noteKindColor(GymColors gc, NoteKind k) => switch (k) {
@@ -187,7 +189,7 @@ class NoteCalendar extends StatelessWidget {
Future<void> showNoteDaySheet(BuildContext context, DateTime day) async {
final gc = context.gc;
- final kind = await showModalBottomSheet<NoteKind>(
+ final kind = await showAppSheet<NoteKind>(
context: context,
backgroundColor: Colors.transparent,
builder: (sheet) => Container(
@@ -198,40 +200,20 @@ Future<void> showNoteDaySheet(BuildContext context, DateTime day) async {
),
child: Column(
mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(noteDayLabel(day).toUpperCase(),
- style: AppTheme.f(13, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),
- const SizedBox(height: 3),
- Text(t.fullDate(day), style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textTertiary)),
- const SizedBox(height: 18),
- for (final k in NoteKind.values) ...[
- if (k != NoteKind.values.first) const SizedBox(height: 8),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => Navigator.of(sheet).pop(k),
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
- decoration: BoxDecoration(
- color: gc.bgRaised2,
- borderRadius: BorderRadius.circular(16),
- ),
- child: Row(
- children: [
- Icon(noteKindIcon(k), size: 18, color: noteKindColor(gc, k)),
- const SizedBox(width: 14),
- Expanded(
- child: Text(noteKindLabel(k),
- style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),
- ),
- Icon(PhosphorIconsRegular.caretRight, size: 14, color: gc.textTertiary),
- ],
- ),
+ const SizedBox(height: 16),
+ SheetTitle(noteDayLabel(day), subtitle: t.fullDate(day)),
+ const SizedBox(height: 14),
+ OptionGroup([
+ for (final k in NoteKind.values)
+ OptionItem(
+ noteKindLabel(k),
+ leading: Icon(noteKindIcon(k), size: 19, color: noteKindColor(gc, k)),
+ onTap: () => Navigator.of(sheet).pop(k),
),
- ),
- ],
+ ]),
],
),
),
@@ -293,13 +275,9 @@ class NoteKindPicker extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: selected == kind
- ? noteKindColor(gc, kind).withValues(alpha: 0.14)
+ ? noteKindColor(gc, kind).withValues(alpha: 0.16)
: gc.bgRaised,
borderRadius: BorderRadius.circular(18),
- border: Border.all(
- color: selected == kind ? noteKindColor(gc, kind) : gc.border,
- width: selected == kind ? 1.4 : 1,
- ),
),
child: Column(
children: [
@@ -466,7 +444,7 @@ class NoteCard extends StatelessWidget {
],
if (note.media.isNotEmpty) ...[
const SizedBox(height: 12),
- NoteMediaStrip(media: note.media),
+ NoteMediaStrip(media: note.media, scope: note.id),
],
],
),
@@ -511,11 +489,12 @@ class _NoteRail extends CustomPainter {
}
class NoteMediaStrip extends StatelessWidget {
- const NoteMediaStrip({super.key, required this.media, this.size = 64, this.max = 4});
+ const NoteMediaStrip({super.key, required this.media, this.size = 64, this.max = 4, this.scope});
final List<String> media;
final double size;
final int max;
+ final String? scope;
@override
Widget build(BuildContext context) {
@@ -528,10 +507,11 @@ class NoteMediaStrip extends StatelessWidget {
for (int i = 0; i < shown.length; i++) ...[
if (i > 0) const SizedBox(width: 8),
GestureDetector(
- onTap: () => showNoteMedia(context, media, i),
+ onTap: () => showNoteMedia(context, media, i, scope: scope),
child: NoteThumb(
name: shown[i],
size: size,
+ scope: scope,
badge: i == shown.length - 1 && extra > 0 ? '+$extra' : null,
),
),
@@ -542,24 +522,48 @@ class NoteMediaStrip extends StatelessWidget {
}
}
+String noteHeroTag(String scope, String name) => 'nm:$scope:$name';
+
class NoteThumb extends StatelessWidget {
- const NoteThumb({super.key, required this.name, this.size = 64, this.badge, this.onRemove});
+ const NoteThumb({
+ super.key,
+ required this.name,
+ this.size = 64,
+ this.badge,
+ this.onRemove,
+ this.natural = false,
+ this.scope,
+ });
final String name;
final double size;
final String? badge;
final VoidCallback? onRemove;
+ final bool natural;
+ final String? scope;
@override
Widget build(BuildContext context) {
final gc = context.gc;
final path = MediaStore.pathFor(name);
+ final photo = path != null && !MediaStore.isVideo(name);
+ final fallback = Icon(PhosphorIconsRegular.imageSquare, size: size * 0.34, color: gc.textTertiary);
Widget inner;
if (path == null) {
- inner = Icon(PhosphorIconsRegular.imageSquare, size: size * 0.34, color: gc.textTertiary);
- } else if (MediaStore.isVideo(name)) {
+ inner = fallback;
+ } else if (!photo) {
inner = Icon(PhosphorIconsFill.playCircle, size: size * 0.38, color: gc.textSecondary);
+ } else if (natural) {
+ inner = Image.file(
+ File(path),
+ height: size,
+ fit: BoxFit.contain,
+ gaplessPlayback: true,
+ frameBuilder: (_, child, frame, sync) =>
+ frame == null && !sync ? SizedBox(width: size, height: size) : child,
+ errorBuilder: (_, _, _) => SizedBox(width: size, height: size, child: fallback),
+ );
} else {
inner = Image.file(
File(path),
@@ -567,27 +571,28 @@ class NoteThumb extends StatelessWidget {
height: size,
fit: BoxFit.cover,
gaplessPlayback: true,
- errorBuilder: (_, _, _) =>
- Icon(PhosphorIconsRegular.imageSquare, size: size * 0.34, color: gc.textTertiary),
+ errorBuilder: (_, _, _) => fallback,
);
}
+ final tag = scope;
+ if (photo && tag != null) inner = Hero(tag: noteHeroTag(tag, name), child: inner);
+
+ final tile = natural && photo
+ ? ClipRRect(borderRadius: BorderRadius.circular(16), child: inner)
+ : Container(
+ width: size,
+ height: size,
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(16)),
+ clipBehavior: Clip.antiAlias,
+ child: Center(child: inner),
+ );
return SizedBox(
- width: size,
height: size,
child: Stack(
clipBehavior: Clip.none,
children: [
- Positioned.fill(
- child: Container(
- decoration: BoxDecoration(
- color: gc.bgRaised2,
- borderRadius: BorderRadius.circular(16),
- ),
- clipBehavior: Clip.antiAlias,
- child: Center(child: inner),
- ),
- ),
+ tile,
if (badge != null)
Positioned.fill(
child: Container(
@@ -627,17 +632,25 @@ class NoteThumb extends StatelessWidget {
}
}
-Future<void> showNoteMedia(BuildContext context, List<String> media, int index) => showDialog(
- context: context,
+Future<void> showNoteMedia(BuildContext context, List<String> media, int index, {String? scope}) =>
+ Navigator.of(context).push(PageRouteBuilder<void>(
+ opaque: false,
+ barrierDismissible: true,
barrierColor: const Color(0xF2000000),
- builder: (_) => _MediaViewer(media: media, start: index),
- );
+ barrierLabel: t.cancel,
+ transitionDuration: const Duration(milliseconds: 360),
+ reverseTransitionDuration: const Duration(milliseconds: 300),
+ pageBuilder: (_, _, _) => _MediaViewer(media: media, start: index, scope: scope),
+ transitionsBuilder: (_, animation, _, child) =>
+ FadeTransition(opacity: CurvedAnimation(parent: animation, curve: Curves.easeOut), child: child),
+ ));
class _MediaViewer extends StatefulWidget {
- const _MediaViewer({required this.media, required this.start});
+ const _MediaViewer({required this.media, required this.start, this.scope});
final List<String> media;
final int start;
+ final String? scope;
@override
State<_MediaViewer> createState() => _MediaViewerState();
@@ -655,8 +668,9 @@ class _MediaViewerState extends State<_MediaViewer> {
@override
Widget build(BuildContext context) {
- return Dialog.fullscreen(
- backgroundColor: Colors.transparent,
+ final scope = widget.scope;
+ return Material(
+ type: MaterialType.transparency,
child: Stack(
children: [
PageView.builder(
@@ -670,9 +684,12 @@ class _MediaViewerState extends State<_MediaViewer> {
if (MediaStore.isVideo(name)) {
return _FullVideo(key: ValueKey(path), path: path);
}
+ final image = Image.file(File(path), fit: BoxFit.contain);
return InteractiveViewer(
maxScale: 5,
- child: Center(child: Image.file(File(path), fit: BoxFit.contain)),
+ child: Center(
+ child: scope == null ? image : Hero(tag: noteHeroTag(scope, name), child: image),
+ ),
);
},
),
@@ -762,7 +779,7 @@ class _FullVideoState extends State<_FullVideo> {
}
if (c == null) {
return const Center(
- child: SizedBox(width: 26, height: 26, child: CircularProgressIndicator(strokeWidth: 2)),
+ child: CupertinoActivityIndicator(radius: 13, color: Colors.white70),
);
}
return GestureDetector(
diff --git a/lib/widgets/photo_source_sheet.dart b/lib/widgets/photo_source_sheet.dart
index 55df606..c033747 100644
--- a/lib/widgets/photo_source_sheet.dart
+++ b/lib/widgets/photo_source_sheet.dart
@@ -4,10 +4,10 @@ import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../l10n/l10n.dart';
import '../theme/app_colors.dart';
-import '../theme/app_theme.dart';
+import 'glass.dart';
import 'ui_kit.dart';
-Future<ImageSource?> pickPhotoSource(BuildContext context) => showModalBottomSheet<ImageSource>(
+Future<ImageSource?> pickPhotoSource(BuildContext context) => showAppSheet<ImageSource>(
context: context,
backgroundColor: Colors.transparent,
builder: (_) => const PhotoSourceSheet(),
@@ -23,36 +23,22 @@ class PhotoSourceSheet extends StatelessWidget {
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,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
const SizedBox(height: 18),
- _option(context, PhosphorIconsRegular.camera, t.takePhoto, ImageSource.camera),
- const SizedBox(height: 10),
- _option(context, PhosphorIconsRegular.image, t.chooseGallery, ImageSource.gallery),
+ OptionGroup([
+ OptionItem(t.takePhoto,
+ icon: PhosphorIconsRegular.camera, onTap: () => Navigator.of(context).pop(ImageSource.camera)),
+ OptionItem(t.chooseGallery,
+ icon: PhosphorIconsRegular.image, onTap: () => Navigator.of(context).pop(ImageSource.gallery)),
+ ]),
],
),
);
}
-
- Widget _option(BuildContext context, IconData icon, String label, ImageSource source) {
- final gc = context.gc;
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => Navigator.of(context).pop(source),
- child: SoftCard(
- radius: 16,
- padding: const EdgeInsets.all(16),
- child: Row(children: [
- Icon(icon, size: 20, color: gc.textSecondary),
- const SizedBox(width: 14),
- Expanded(child: Text(label, style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text))),
- ]),
- ),
- );
- }
}
diff --git a/lib/widgets/rolling_text.dart b/lib/widgets/rolling_text.dart
new file mode 100644
index 0000000..329b0d4
--- /dev/null
+++ b/lib/widgets/rolling_text.dart
@@ -0,0 +1,172 @@
+import 'package:flutter/material.dart';
+
+final _digitCells = <(TextStyle, double), double>{};
+
+double digitCell(TextStyle style, TextScaler scaler) {
+ if (_digitCells.length > 48) _digitCells.clear();
+ return _digitCells.putIfAbsent((style, scaler.scale(100)), () {
+ var widest = 0.0;
+ for (var d = 0; d < 10; d++) {
+ final p = TextPainter(
+ text: TextSpan(text: '$d', style: style),
+ textDirection: TextDirection.ltr,
+ textScaler: scaler,
+ )..layout();
+ if (p.width > widest) widest = p.width;
+ p.dispose();
+ }
+ return widest.ceilToDouble();
+ });
+}
+
+class RollingText extends StatefulWidget {
+ const RollingText(
+ this.text, {
+ super.key,
+ required this.style,
+ this.duration = const Duration(milliseconds: 420),
+ this.countsDown,
+ this.textAlign = TextAlign.left,
+ });
+
+ final String text;
+ final TextStyle style;
+ final Duration duration;
+ final bool? countsDown;
+ final TextAlign textAlign;
+
+ @override
+ State<RollingText> createState() => _RollingTextState();
+}
+
+class _RollingTextState extends State<RollingText> {
+ static const _burst = Duration(milliseconds: 180);
+
+ bool _up = true;
+ bool _rapid = false;
+ DateTime? _changedAt;
+
+ static double? _numeric(String s) {
+ final digits = s.replaceAll(RegExp(r'[^0-9.]'), '');
+ return digits.isEmpty ? null : double.tryParse(digits);
+ }
+
+ @override
+ void didUpdateWidget(RollingText old) {
+ super.didUpdateWidget(old);
+ if (old.text == widget.text) return;
+ final now = DateTime.now();
+ _rapid = _changedAt != null && now.difference(_changedAt!) < _burst;
+ _changedAt = now;
+ final forced = widget.countsDown;
+ if (forced != null) {
+ _up = !forced;
+ return;
+ }
+ final a = _numeric(old.text), b = _numeric(widget.text);
+ if (a != null && b != null && a != b) _up = b > a;
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final chars = widget.text.characters.toList();
+ final n = chars.length;
+ final reduce = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
+ final line = (widget.style.fontSize ?? 14) * (widget.style.height ?? 1.2);
+ final digit = digitCell(widget.style, MediaQuery.textScalerOf(context));
+ final row = Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ for (var i = 0; i < n; i++)
+ _RollingChar(
+ key: ValueKey(n - i),
+ char: chars[i],
+ style: widget.style,
+ up: _up,
+ duration: reduce || _rapid ? Duration.zero : widget.duration,
+ solo: _rapid,
+ line: line,
+ width: _isDigit(chars[i]) ? digit : null,
+ ),
+ ],
+ );
+ return Semantics(
+ label: widget.text,
+ excludeSemantics: true,
+ child: AnimatedSize(
+ duration: reduce || _rapid ? Duration.zero : const Duration(milliseconds: 240),
+ curve: Curves.easeOutCubic,
+ alignment: switch (widget.textAlign) {
+ TextAlign.right || TextAlign.end => Alignment.centerRight,
+ TextAlign.center => Alignment.center,
+ _ => Alignment.centerLeft,
+ },
+ child: row,
+ ),
+ );
+ }
+
+ static bool _isDigit(String c) => c.length == 1 && c.codeUnitAt(0) >= 48 && c.codeUnitAt(0) <= 57;
+}
+
+class _RollingChar extends StatelessWidget {
+ const _RollingChar({
+ super.key,
+ required this.char,
+ required this.style,
+ required this.up,
+ required this.duration,
+ required this.line,
+ this.solo = false,
+ this.width,
+ });
+
+ final String char;
+ final TextStyle style;
+ final bool up;
+ final Duration duration;
+ final double line;
+ final bool solo;
+ final double? width;
+
+ @override
+ Widget build(BuildContext context) {
+ return ClipRect(
+ child: SizedBox(
+ height: line,
+ width: width,
+ child: AnimatedSwitcher(
+ duration: duration,
+ switchInCurve: Curves.easeOutCubic,
+ switchOutCurve: Curves.easeInCubic,
+ layoutBuilder: (current, previous) => Stack(
+ alignment: Alignment.center,
+ clipBehavior: Clip.none,
+ children: [if (!solo) ...previous, ?current],
+ ),
+ transitionBuilder: (child, animation) {
+ final incoming = (child.key as ValueKey?)?.value == char;
+ final from = incoming ? (up ? 0.72 : -0.72) : (up ? -0.72 : 0.72);
+ return AnimatedBuilder(
+ animation: animation,
+ child: child,
+ builder: (_, kid) {
+ final t = animation.value;
+ return Opacity(
+ opacity: t.clamp(0.0, 1.0),
+ child: Transform.translate(offset: Offset(0, from * line * (1 - t)), child: kid),
+ );
+ },
+ );
+ },
+ child: Text(char, key: ValueKey(char), style: style, textHeightBehavior: _tight),
+ ),
+ ),
+ );
+ }
+
+ static const _tight = TextHeightBehavior(
+ applyHeightToFirstAscent: false,
+ applyHeightToLastDescent: false,
+ );
+}
diff --git a/lib/widgets/routine_folder.dart b/lib/widgets/routine_folder.dart
new file mode 100644
index 0000000..9913cca
--- /dev/null
+++ b/lib/widgets/routine_folder.dart
@@ -0,0 +1,201 @@
+import 'package:flutter/material.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+
+import '../l10n/l10n.dart';
+import '../models/workout.dart';
+import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import 'ui_kit.dart';
+
+const kFolderHues = [
+ Color(0xFFF3C7B1),
+ Color(0xFFA78BDA),
+ Color(0xFFA8C99E),
+ Color(0xFF9CC2E8),
+ Color(0xFFE8CF98),
+ Color(0xFFE6A4B9),
+];
+
+Color folderHue(Routine r) =>
+ kFolderHues[(r.color >= 0 ? r.color : r.id.codeUnits.fold<int>(0, (a, c) => a + c)) % kFolderHues.length];
+
+class RoutineFolder extends StatelessWidget {
+ const RoutineFolder({super.key, required this.routine, required this.onMenu});
+
+ final Routine routine;
+ final VoidCallback onMenu;
+
+ static const _tab = 16.0;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final r = routine;
+ final n = r.exerciseIds.length;
+ final hue = folderHue(r);
+ final dark = gc.bg.computeLuminance() < 0.5;
+ final back = Color.lerp(hue, Colors.black, dark ? 0.42 : 0.18)!;
+ final front = Color.lerp(gc.bgRaised2, hue, dark ? 0.14 : 0.3)!;
+ final ink = Color.lerp(hue, Colors.black, 0.35)!;
+
+ return Pressable(
+ onTap: () => fit.openRoutine(r.id),
+ scale: 0.975,
+ child: SizedBox(
+ height: 196,
+ child: Stack(
+ children: [
+ Positioned(
+ left: 0,
+ top: 0,
+ width: 74,
+ height: _tab + 24,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(14)),
+ ),
+ ),
+ ),
+ Positioned.fill(
+ top: _tab,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: const BorderRadius.only(
+ topRight: Radius.circular(20),
+ bottomLeft: Radius.circular(22),
+ bottomRight: Radius.circular(22),
+ ),
+ ),
+ ),
+ ),
+ Positioned(
+ left: 12,
+ right: 12,
+ top: _tab + 8,
+ height: 64,
+ child: Transform.rotate(
+ angle: -0.018,
+ child: DecoratedBox(
+ decoration: BoxDecoration(color: back, borderRadius: BorderRadius.circular(12)),
+ ),
+ ),
+ ),
+ Positioned(
+ left: 8,
+ right: 8,
+ top: _tab + 16,
+ height: 64,
+ child: Container(
+ padding: const EdgeInsets.fromLTRB(14, 12, 40, 0),
+ decoration: BoxDecoration(color: hue, borderRadius: BorderRadius.circular(12)),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _line(ink.withValues(alpha: 0.45), 1),
+ const SizedBox(height: 5),
+ _line(ink.withValues(alpha: 0.2), 0.55),
+ ],
+ ),
+ ),
+ ),
+ Positioned(
+ left: 6,
+ right: 6,
+ top: _tab + 50,
+ bottom: 46,
+ child: Container(
+ padding: const EdgeInsets.fromLTRB(14, 12, 8, 10),
+ decoration: BoxDecoration(
+ color: front,
+ borderRadius: BorderRadius.circular(18),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withValues(alpha: dark ? 0.35 : 0.1),
+ blurRadius: 14,
+ offset: const Offset(0, -3),
+ ),
+ ],
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: Text.rich(
+ TextSpan(children: [
+ TextSpan(text: fit.routineTitle(r)),
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: Padding(
+ padding: const EdgeInsets.only(left: 4),
+ child: Icon(PhosphorIconsBold.caretRight, size: 13, color: gc.textSecondary),
+ ),
+ ),
+ ]),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(16, weight: FontWeight.w800, color: gc.text, height: 1.15),
+ ),
+ ),
+ Semantics(
+ button: true,
+ label: t.moreOptions,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onMenu,
+ child: Container(
+ width: 30,
+ height: 30,
+ decoration: BoxDecoration(color: gc.text.withValues(alpha: 0.1), shape: BoxShape.circle),
+ child: Icon(PhosphorIconsBold.dotsThreeVertical, size: 16, color: gc.text),
+ ),
+ ),
+ ),
+ ],
+ ),
+ const Spacer(),
+ Text(
+ [if (r.group.isNotEmpty) r.group, t.exerciseCount(n)].join(' · '),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textSecondary),
+ ),
+ ],
+ ),
+ ),
+ ),
+ Positioned(
+ left: 0,
+ right: 0,
+ bottom: 0,
+ height: 46,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: n > 0 ? () => fit.startRoutine(r) : () => fit.openRoutine(r.id),
+ child: Center(
+ child: Row(mainAxisSize: MainAxisSize.min, children: [
+ Icon(n > 0 ? PhosphorIconsFill.play : PhosphorIconsBold.plus, size: 12, color: gc.textSecondary),
+ const SizedBox(width: 7),
+ Text(n > 0 ? titleCase(t.startWorkout) : t.addExercises,
+ style: AppTheme.f(13.5, weight: FontWeight.w700, color: gc.textSecondary)),
+ ]),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _line(Color c, double width) => FractionallySizedBox(
+ alignment: Alignment.centerLeft,
+ widthFactor: width,
+ child: Container(height: 2.5, decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(2))),
+ );
+}
diff --git a/lib/widgets/shimmer.dart b/lib/widgets/shimmer.dart
new file mode 100644
index 0000000..c5a71b7
--- /dev/null
+++ b/lib/widgets/shimmer.dart
@@ -0,0 +1,48 @@
+import 'package:flutter/material.dart';
+
+import '../theme/app_colors.dart';
+
+class Shimmer extends StatefulWidget {
+ const Shimmer({super.key, this.radius = 16});
+
+ final double radius;
+
+ @override
+ State<Shimmer> createState() => _ShimmerState();
+}
+
+class _ShimmerState extends State<Shimmer> with SingleTickerProviderStateMixin {
+ late final AnimationController _c =
+ AnimationController(vsync: this, duration: const Duration(milliseconds: 1300))..repeat(count: 1);
+
+ @override
+ void dispose() {
+ _c.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final base = gc.bgRaised2;
+ final shine = Color.lerp(gc.bgRaised2, gc.text, 0.07)!;
+ return AnimatedBuilder(
+ animation: _c,
+ builder: (context, _) {
+ final x = -1.6 + 3.2 * Curves.easeInOutSine.transform(_c.value);
+ return DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(widget.radius),
+ gradient: LinearGradient(
+ begin: Alignment(x - 0.8, -0.3),
+ end: Alignment(x + 0.8, 0.3),
+ colors: [base, shine, base],
+ stops: const [0.2, 0.5, 0.8],
+ ),
+ ),
+ child: const SizedBox.expand(),
+ );
+ },
+ );
+ }
+}
diff --git a/lib/widgets/svg_icon.dart b/lib/widgets/svg_icon.dart
index b95e88c..217588f 100644
--- a/lib/widgets/svg_icon.dart
+++ b/lib/widgets/svg_icon.dart
@@ -71,7 +71,7 @@ class _IconPainter extends CustomPainter {
class Ic {
Ic._();
static const flame = [IconPath('M12 2c1 4-3 5-3 9a3 3 0 0 0 6 0c0-1.5-.5-2-1-3 2 1 3 3 3 5a5 5 0 0 1-10 0c0-5 4-6 5-11z', fill: true)];
- static const play = [IconPath('M8 5v14l11-7z', fill: true)];
+ static const play = [IconPath('M8.2 6.1v11.8a1.4 1.4 0 0 0 2.1 1.2l9.2-5.9a1.4 1.4 0 0 0 0-2.4l-9.2-5.9a1.4 1.4 0 0 0-2.1 1.2z', fill: true)];
static const barbell = [IconPath('M6 4v16M18 4v16M2 9h4M18 9h4M2 15h4M18 15h4M6 12h12', strokeWidth: 2)];
static const barbellThin = [IconPath('M6 7v10M18 7v10M2 12h4M18 12h4M9 9v6M15 9v6', strokeWidth: 1.8)];
static const wrench = [IconPath('M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.77z', strokeWidth: 2)];
diff --git a/lib/widgets/ui_kit.dart b/lib/widgets/ui_kit.dart
index cd8434b..10ca29e 100644
--- a/lib/widgets/ui_kit.dart
+++ b/lib/widgets/ui_kit.dart
@@ -1,9 +1,11 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import 'rolling_text.dart';
import 'svg_icon.dart';
class SoftCard extends StatelessWidget {
@@ -148,6 +150,44 @@ class TinySwitch extends StatelessWidget {
}
}
+class Pressable extends StatefulWidget {
+ const Pressable({super.key, required this.child, required this.onTap, this.scale = 0.965, this.onLongPress});
+
+ final Widget child;
+ final VoidCallback? onTap;
+ final VoidCallback? onLongPress;
+ final double scale;
+
+ @override
+ State<Pressable> createState() => _PressableState();
+}
+
+class _PressableState extends State<Pressable> {
+ bool _down = false;
+
+ void _set(bool v) {
+ if (_down != v && mounted) setState(() => _down = v);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: widget.onTap,
+ onLongPress: widget.onLongPress,
+ onTapDown: widget.onTap == null ? null : (_) => _set(true),
+ onTapUp: (_) => _set(false),
+ onTapCancel: () => _set(false),
+ child: AnimatedScale(
+ scale: _down ? widget.scale : 1,
+ duration: Duration(milliseconds: _down ? 90 : 260),
+ curve: _down ? Curves.easeOut : Curves.easeOutBack,
+ child: widget.child,
+ ),
+ );
+ }
+}
+
class GhostButton extends StatelessWidget {
const GhostButton({super.key, required this.label, required this.icon, required this.onTap});
@@ -158,8 +198,7 @@ class GhostButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final gc = context.gc;
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
+ return Pressable(
onTap: onTap,
child: Container(
height: 46,
@@ -203,6 +242,139 @@ class SheetHandle extends StatelessWidget {
);
}
+class SheetTitle extends StatelessWidget {
+ const SheetTitle(this.text, {super.key, this.subtitle});
+
+ final String text;
+ final String? subtitle;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(text, textAlign: TextAlign.center, style: AppTheme.f(17, weight: FontWeight.w700, color: gc.text)),
+ if (subtitle != null) ...[
+ const SizedBox(height: 4),
+ Text(subtitle!,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.35)),
+ ],
+ ],
+ );
+ }
+}
+
+class OptionItem {
+ const OptionItem(
+ this.label, {
+ required this.onTap,
+ this.icon,
+ this.leading,
+ this.detail,
+ this.selected = false,
+ this.danger = false,
+ });
+
+ final String label;
+ final VoidCallback onTap;
+ final IconData? icon;
+ final Widget? leading;
+ final String? detail;
+ final bool selected;
+ final bool danger;
+}
+
+class OptionGroup extends StatelessWidget {
+ const OptionGroup(this.items, {super.key, this.scroll = false});
+
+ final List<OptionItem> items;
+ final bool scroll;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final divider = Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border);
+ final Widget body = scroll
+ ? ListView.separated(
+ shrinkWrap: true,
+ padding: EdgeInsets.zero,
+ itemCount: items.length,
+ separatorBuilder: (_, _) => divider,
+ itemBuilder: (_, i) => _OptionRow(items[i]),
+ )
+ : Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ for (var i = 0; i < items.length; i++) ...[
+ if (i > 0) divider,
+ _OptionRow(items[i]),
+ ],
+ ],
+ );
+ return ClipRRect(
+ borderRadius: BorderRadius.circular(18),
+ child: ColoredBox(color: gc.bgRaised2, child: body),
+ );
+ }
+}
+
+class _OptionRow extends StatelessWidget {
+ const _OptionRow(this.o);
+
+ final OptionItem o;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final tone = o.danger ? gc.danger : (o.selected ? gc.ember : gc.text);
+ return Semantics(
+ button: true,
+ selected: o.selected,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: o.onTap,
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 50),
+ child: Padding(
+ padding: EdgeInsets.symmetric(horizontal: 16, vertical: o.detail == null ? 0 : 11),
+ child: Row(children: [
+ if (o.leading != null) ...[
+ o.leading!,
+ const SizedBox(width: 12),
+ ] else if (o.icon != null) ...[
+ Icon(o.icon, size: 19, color: o.danger ? gc.danger : (o.selected ? gc.ember : gc.textSecondary)),
+ const SizedBox(width: 14),
+ ],
+ Expanded(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(o.label,
+ style: AppTheme.f(14.5,
+ weight: o.selected ? FontWeight.w800 : FontWeight.w600, color: tone)),
+ if (o.detail != null) ...[
+ const SizedBox(height: 2),
+ Text(o.detail!,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),
+ ],
+ ],
+ ),
+ ),
+ if (o.selected) ...[
+ const SizedBox(width: 10),
+ Icon(PhosphorIconsFill.checkCircle, size: 18, color: gc.ember),
+ ],
+ ]),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
class RoundAction extends StatelessWidget {
const RoundAction({
super.key,
@@ -222,9 +394,9 @@ class RoundAction extends StatelessWidget {
@override
Widget build(BuildContext context) {
final gc = context.gc;
- final button = GestureDetector(
- behavior: HitTestBehavior.opaque,
+ final button = Pressable(
onTap: onTap,
+ scale: 0.9,
child: Container(
width: size,
height: size,
@@ -298,6 +470,11 @@ class ScreenHeader extends StatelessWidget {
}
}
+String sentenceCase(String s) {
+ if (s.isEmpty || s != s.toUpperCase() || s == s.toLowerCase()) return s;
+ return s[0] + s.substring(1).toLowerCase();
+}
+
String titleCase(String s) {
if (s.isEmpty || s != s.toUpperCase()) return s;
if (s.length <= 4 && !s.contains(' ')) return s;
@@ -369,7 +546,7 @@ class StepperControl extends StatelessWidget {
Widget label = Container(
constraints: BoxConstraints(minWidth: minWidth),
alignment: Alignment.center,
- child: Text(value, style: AppTheme.f(fontSize, weight: FontWeight.w700, color: gc.text)),
+ child: RollingText(value, style: AppTheme.f(fontSize, weight: FontWeight.w700, color: gc.text)),
);
if (onEdit != null) {
label = GestureDetector(behavior: HitTestBehavior.opaque, onTap: onEdit, child: label);
@@ -393,16 +570,51 @@ class ToolRow extends StatelessWidget {
final Widget control;
@override
Widget build(BuildContext context) {
- final gc = context.gc;
return SoftCard(
- radius: 14,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Flexible(child: Text(label, style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary))),
- control,
- ],
+ radius: 20,
+ borderColor: Colors.transparent,
+ padding: EdgeInsets.zero,
+ child: _line(context),
+ );
+ }
+
+ Widget _line(BuildContext context) {
+ final gc = context.gc;
+ return ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 56),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Flexible(child: Text(sentenceCase(label), style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text))),
+ const SizedBox(width: 12),
+ control,
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class ToolGroup extends StatelessWidget {
+ const ToolGroup(this.rows, {super.key});
+
+ final List<ToolRow> rows;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return ClipRRect(
+ borderRadius: BorderRadius.circular(20),
+ child: ColoredBox(
+ color: gc.bgRaised,
+ child: Column(children: [
+ for (var i = 0; i < rows.length; i++) ...[
+ if (i > 0) Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border),
+ rows[i]._line(context),
+ ],
+ ]),
),
);
}
@@ -516,8 +728,9 @@ class Pill extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return GestureDetector(
+ return Pressable(
onTap: onTap,
+ scale: 0.94,
child: Container(
padding: EdgeInsets.symmetric(horizontal: hPad, vertical: vPad),
decoration: BoxDecoration(color: bg, borderRadius: BorderRadius.circular(100)),
@@ -549,7 +762,7 @@ class PrimaryButton extends StatelessWidget {
Widget build(BuildContext context) {
final gc = context.gc;
final f = fg ?? gc.onEmber;
- return GestureDetector(
+ return Pressable(
onTap: onTap,
child: Container(
width: double.infinity,
@@ -559,7 +772,10 @@ class PrimaryButton extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- if (icon != null) ...[SvgPathIcon(icon!, size: 18, color: f), const SizedBox(width: 10)],
+ if (icon != null) ...[
+ SvgPathIcon(icon!, size: 15, color: f),
+ const SizedBox(width: 9),
+ ],
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
diff --git a/test/flow_test.dart b/test/flow_test.dart
index 6877fb0..00aedb7 100644
--- a/test/flow_test.dart
+++ b/test/flow_test.dart
@@ -60,4 +60,26 @@ void main() {
expect(fit.trainStep, 'review');
expect(fit.sessionPicks, isNotEmpty);
});
+
+ test('toggleResetPicks clears picks when non-empty, and restores defaults when empty', () {
+ fit.sessions.clear();
+ fit.selectedMuscles.clear();
+ fit.startFocusWorkout();
+ fit.trainContinue();
+
+ expect(fit.sessionPicks, isNotEmpty);
+ final defaultCount = fit.sessionPicks.length;
+
+ fit.toggleResetPicks();
+ expect(fit.sessionPicks, isEmpty);
+
+ fit.toggleResetPicks();
+ expect(fit.sessionPicks.length, defaultCount);
+
+ fit.clearPicks();
+ expect(fit.sessionPicks, isEmpty);
+
+ fit.resetDefaultPicks();
+ expect(fit.sessionPicks.length, defaultCount);
+ });
}
diff --git a/test/shell_transition_test.dart b/test/shell_transition_test.dart
index d481632..893f599 100644
--- a/test/shell_transition_test.dart
+++ b/test/shell_transition_test.dart
@@ -28,12 +28,10 @@ void main() {
});
double homeOpacity(WidgetTester tester) {
- final fade = tester.widget<FadeTransition>(
- find
- .ancestor(of: find.byType(HomeScreen), matching: find.byType(FadeTransition))
- .first,
+ final fade = tester.widget<Opacity>(
+ find.ancestor(of: find.byType(HomeScreen), matching: find.byType(Opacity)).first,
);
- return fade.opacity.value;
+ return fade.opacity;
}
testWidgets('the screen being left is gone before the new one shows up', (tester) async {
@@ -64,6 +62,9 @@ void main() {
reason: 'no da tiempo a ver la app antes de la medalla');
await tester.pump(const Duration(seconds: 2));
+ expect(find.byType(AwardCelebration), findsNothing);
+
+ await tester.pump(const Duration(milliseconds: 1500));
expect(find.byType(AwardCelebration), findsOneWidget);
await tester.pump(const Duration(seconds: 2));
@@ -80,21 +81,40 @@ void main() {
fit.refreshAwards();
expect(fit.pendingAwards.length, greaterThan(1));
- await tester.pump(const Duration(seconds: 3));
+ await tester.pump(const Duration(milliseconds: 4500));
expect(find.byType(AwardCelebration), findsOneWidget);
await tester.tap(find.text(t.awardNice));
await tester.pump();
expect(find.byType(AwardCelebration), findsNothing);
- await tester.pump(const Duration(seconds: 2));
+ await tester.pump(const Duration(seconds: 4));
expect(find.byType(AwardCelebration), findsNothing,
reason: 'la segunda medalla salía pegada a la primera');
- await tester.pump(const Duration(seconds: 2));
+ await tester.pump(const Duration(milliseconds: 2500));
expect(find.byType(AwardCelebration), findsOneWidget);
await tester.pump(const Duration(seconds: 2));
fit.persistNow();
});
+
+ testWidgets('holding a tab lets the pill slide to another one', (tester) async {
+ await tester.pumpWidget(const GymManeApp());
+ await tester.pump();
+
+ final home = tester.getCenter(find.text(t.home));
+ final profile = tester.getCenter(find.text(t.profile));
+ final gesture = await tester.startGesture(home);
+ await tester.pump(const Duration(milliseconds: 700));
+ for (var i = 1; i <= 10; i++) {
+ await gesture.moveTo(Offset.lerp(home, profile, i / 10)!);
+ await tester.pump(const Duration(milliseconds: 16));
+ }
+ expect(fit.route, 'home');
+ await gesture.up();
+ await tester.pump();
+ expect(fit.route, 'settings');
+ await tester.pump(const Duration(seconds: 1));
+ });
}
diff --git a/test/train_step2_test.dart b/test/train_step2_test.dart
new file mode 100644
index 0000000..d33309e
--- /dev/null
+++ b/test/train_step2_test.dart
@@ -0,0 +1,40 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/app/gymmane_app.dart';
+import 'package:gymmane/state/fit_state.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+
+void main() {
+ testWidgets('TrainScreen step 2 displays reset picks button and toggles selection', (tester) async {
+ fit.onboarded = true;
+ fit.selectedMuscles.clear();
+ fit.selectedMuscles.addAll(['chest', 'triceps']);
+ fit.trainContinue();
+ fit.route = 'train';
+
+ await tester.pumpWidget(const GymManeApp());
+ await tester.pumpAndSettle();
+
+ final iconFinder = find.byIcon(PhosphorIconsRegular.arrowCounterClockwise);
+ expect(iconFinder, findsOneWidget);
+ final initialIcon = tester.widget<Icon>(iconFinder);
+
+ expect(find.byIcon(PhosphorIconsRegular.plus), findsOneWidget);
+
+ expect(fit.sessionPicks.isNotEmpty, true);
+
+ await tester.tap(iconFinder);
+ await tester.pumpAndSettle();
+ expect(fit.sessionPicks.isEmpty, true);
+ final clearedIcon = tester.widget<Icon>(iconFinder);
+ expect(clearedIcon.color != initialIcon.color, true);
+
+ await tester.tap(iconFinder);
+ await tester.pumpAndSettle();
+ expect(fit.sessionPicks.isNotEmpty, true);
+ final restoredIcon = tester.widget<Icon>(iconFinder);
+ expect(restoredIcon.color == initialIcon.color, true);
+
+ fit.route = 'home';
+ });
+}