Skip to content

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

Step out of a workout, keep the button bar solid and fit text at large sizes

InlitXae167dc4224a
diff --git a/lib/app/app_shell.dart b/lib/app/app_shell.dart
index cfef376..f1eba93 100644
--- a/lib/app/app_shell.dart
+++ b/lib/app/app_shell.dart
@@ -41,6 +41,7 @@ import '../widgets/dialogs.dart';
import '../widgets/glass.dart';
import '../widgets/liquid_notch.dart';
import '../widgets/start_countdown.dart';
+import '../widgets/ui_kit.dart';
class AppShell extends StatefulWidget {
const AppShell({super.key});
@@ -65,6 +66,7 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
'tools-detail',
};
+ static const _pillSpace = 68.0;
static const _firstAwardWait = Duration(milliseconds: 4000);
static const _nextAwardWait = Duration(milliseconds: 6000);
@@ -186,6 +188,7 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
animation: fit,
builder: (context, _) {
if (!fit.onboarded) return const OnboardingScreen();
+ final parked = fit.sessionParked && fit.showNav;
return PopScope(
canPop: false,
@@ -221,7 +224,8 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
Scaffold(
backgroundColor: Colors.transparent,
body: Padding(
- padding: EdgeInsets.only(bottom: MediaQuery.viewPaddingOf(context).bottom),
+ padding: EdgeInsets.only(
+ bottom: MediaQuery.viewPaddingOf(context).bottom + (parked ? _pillSpace : 0)),
child: NotificationListener<ScrollNotification>(
onNotification: _onScroll,
child: _animatedScreen(),
@@ -243,15 +247,35 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
left: 0,
right: 0,
bottom: 0,
- child: EdgeBlur(top: false, height: 128 + MediaQuery.viewPaddingOf(context).bottom),
+ child: EdgeBlur(
+ top: false, height: 128 + MediaQuery.viewPaddingOf(context).bottom + (parked ? _pillSpace : 0)),
),
- if (fit.showNav && MediaQuery.viewInsetsOf(context).bottom < 60)
+ if (fit.showNav && MediaQuery.viewInsetsOf(context).bottom < 60) ...[
Positioned(
left: 18,
right: 18,
bottom: 18 + MediaQuery.viewPaddingOf(context).bottom,
child: Directionality(textDirection: TextDirection.ltr, child: _NavBar()),
),
+ Positioned(
+ left: 18,
+ right: 18,
+ bottom: 18 + _NavBarState.height + 10 + MediaQuery.viewPaddingOf(context).bottom,
+ child: AnimatedSwitcher(
+ duration: const Duration(milliseconds: 320),
+ switchInCurve: Curves.easeOutCubic,
+ switchOutCurve: Curves.easeInCubic,
+ transitionBuilder: (child, a) => FadeTransition(
+ opacity: a,
+ child: SlideTransition(
+ position: Tween(begin: const Offset(0, 0.4), end: Offset.zero).animate(a),
+ child: child,
+ ),
+ ),
+ child: parked ? const _ParkedPill() : const SizedBox(width: double.infinity),
+ ),
+ ),
+ ],
if (fit.countdownUntil != null && fit.session != null)
Positioned.fill(
child: StartCountdown(key: ValueKey(fit.countdownUntil), until: fit.countdownUntil!),
@@ -406,6 +430,65 @@ final _overlayLight = _overlayBase.copyWith(
systemNavigationBarIconBrightness: Brightness.dark,
);
+class _ParkedPill extends StatelessWidget {
+ const _ParkedPill();
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final ex = fit.currentExercise;
+ return Pressable(
+ onTap: fit.stepBackIntoSession,
+ scale: 0.97,
+ child: Semantics(
+ button: true,
+ label: t.resumeWorkout,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(22),
+ boxShadow: const [BoxShadow(color: Color(0x40000000), blurRadius: 24, offset: Offset(0, 10))],
+ ),
+ child: GlassSurface(
+ radius: 22,
+ blur: 16,
+ padding: const EdgeInsets.fromLTRB(16, 8, 8, 8),
+ child: Material(
+ type: MaterialType.transparency,
+ child: Row(children: [
+ Expanded(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.paused,
+ style: AppTheme.f(10.5,
+ weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.2)),
+ const SizedBox(height: 2),
+ Text(ex == null ? '' : t.catalogName(ex.id, ex.name),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(14.5, weight: FontWeight.w700, color: gc.text)),
+ ],
+ ),
+ ),
+ const SizedBox(width: 12),
+ Text(fit.elapsedLabel, style: AppTheme.f(14, weight: FontWeight.w700, color: gc.textSecondary)),
+ const SizedBox(width: 12),
+ Container(
+ width: 40,
+ height: 40,
+ decoration: BoxDecoration(color: gc.ember, shape: BoxShape.circle),
+ child: Icon(PhosphorIconsFill.play, size: 16, color: gc.onEmber),
+ ),
+ ]),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
class _NavBar extends StatefulWidget {
const _NavBar();
@@ -414,6 +497,7 @@ class _NavBar extends StatefulWidget {
}
class _NavBarState extends State<_NavBar> {
+ static const height = 74.0;
static const _iw = 58.0;
static const _fabW = 54.0;
static const _routes = ['home', 'progress', 'exercises', 'settings'];
@@ -469,7 +553,7 @@ class _NavBarState extends State<_NavBar> {
final gc = context.gc;
return SizedBox(
- height: 74,
+ height: height,
child: LayoutBuilder(
builder: (context, c) {
_slotW = c.maxWidth - 16;
@@ -605,6 +689,10 @@ class _NavBarState extends State<_NavBar> {
}
void _play(BuildContext context) {
+ if (fit.sessionParked) {
+ fit.stepBackIntoSession();
+ return;
+ }
final planned = fit.todayRoutine;
if (planned != null && planned.exerciseIds.isNotEmpty) {
fit.startRoutine(planned);
diff --git a/lib/app/gymmane_app.dart b/lib/app/gymmane_app.dart
index 62f23be..0002583 100644
--- a/lib/app/gymmane_app.dart
+++ b/lib/app/gymmane_app.dart
@@ -3,12 +3,15 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import '../l10n/l10n.dart';
import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import 'app_shell.dart';
class GymManeApp extends StatelessWidget {
const GymManeApp({super.key});
+ static const maxTextScale = 1.15;
+
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
@@ -27,8 +30,37 @@ class GymManeApp extends StatelessWidget {
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
+ builder: (context, child) => MediaQuery.withClampedTextScaling(
+ maxScaleFactor: maxTextScale,
+ child: _ButtonNavScrim(child: child!),
+ ),
home: const AppShell(),
),
);
}
}
+
+class _ButtonNavScrim extends StatelessWidget {
+ const _ButtonNavScrim({required this.child});
+
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) {
+ final bar = MediaQuery.viewPaddingOf(context).bottom;
+ final buttons = MediaQuery.systemGestureInsetsOf(context).left == 0;
+ return Stack(
+ children: [
+ child,
+ if (buttons && bar > 0)
+ Positioned(
+ left: 0,
+ right: 0,
+ bottom: 0,
+ height: bar,
+ child: IgnorePointer(child: ColoredBox(color: context.gc.bg)),
+ ),
+ ],
+ );
+ }
+}
diff --git a/lib/screens/tools_screen.dart b/lib/screens/tools_screen.dart
index 1b1994f..34675e0 100644
--- a/lib/screens/tools_screen.dart
+++ b/lib/screens/tools_screen.dart
@@ -24,6 +24,7 @@ class ToolsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final gc = context.gc;
+ final scale = MediaQuery.textScalerOf(context).scale(1);
return SafeArea(
bottom: false,
child: SingleChildScrollView(
@@ -45,8 +46,8 @@ class ToolsScreen extends StatelessWidget {
physics: const NeverScrollableScrollPhysics(),
mainAxisSpacing: 12,
crossAxisSpacing: 12,
- childAspectRatio: 1.12,
- children: [for (final tool in kToolMeta) _card(gc, tool)],
+ childAspectRatio: 1.12 / scale,
+ children: [for (final tool in kToolMeta) _card(gc, tool, scale)],
),
],
),
@@ -54,7 +55,7 @@ class ToolsScreen extends StatelessWidget {
);
}
- Widget _card(GymColors gc, ToolMeta tool) {
+ Widget _card(GymColors gc, ToolMeta tool, double scale) {
return GestureDetector(
onTap: () => fit.openTool(tool.id),
child: Container(
@@ -81,7 +82,7 @@ class ToolsScreen extends StatelessWidget {
style: AppTheme.f(14.5, weight: FontWeight.w700, color: gc.text)),
const SizedBox(height: 2),
SizedBox(
- height: 31,
+ height: 31 * scale,
child: Text(t.toolDesc(tool.id),
maxLines: 2,
overflow: TextOverflow.ellipsis,
diff --git a/lib/widgets/entrance.dart b/lib/widgets/entrance.dart
index b1803c7..9ea1019 100644
--- a/lib/widgets/entrance.dart
+++ b/lib/widgets/entrance.dart
@@ -168,8 +168,9 @@ class _RollInState extends State<RollIn> with SingleTickerProviderStateMixin {
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));
+ final scaler = MediaQuery.textScalerOf(context);
+ final line = scaler.scale(widget.style.fontSize ?? 14) * (widget.style.height ?? 1.2);
+ final cell = digitCell(widget.style, scaler);
return Semantics(
label: widget.text,
excludeSemantics: true,
diff --git a/lib/widgets/rolling_text.dart b/lib/widgets/rolling_text.dart
index 329b0d4..b7530eb 100644
--- a/lib/widgets/rolling_text.dart
+++ b/lib/widgets/rolling_text.dart
@@ -72,8 +72,9 @@ class _RollingTextState extends State<RollingText> {
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 scaler = MediaQuery.textScalerOf(context);
+ final line = scaler.scale(widget.style.fontSize ?? 14) * (widget.style.height ?? 1.2);
+ final digit = digitCell(widget.style, scaler);
final row = Row(
mainAxisSize: MainAxisSize.min,
children: [
diff --git a/lib/widgets/ui_kit.dart b/lib/widgets/ui_kit.dart
index 10ca29e..43c8777 100644
--- a/lib/widgets/ui_kit.dart
+++ b/lib/widgets/ui_kit.dart
@@ -475,6 +475,20 @@ String sentenceCase(String s) {
return s[0] + s.substring(1).toLowerCase();
}
+class FitText extends StatelessWidget {
+ const FitText(this.text, {super.key, required this.style});
+
+ final String text;
+ final TextStyle style;
+
+ @override
+ Widget build(BuildContext context) => FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: AlignmentDirectional.centerStart,
+ child: Text(text, maxLines: 1, style: style),
+ );
+}
+
String titleCase(String s) {
if (s.isEmpty || s != s.toUpperCase()) return s;
if (s.length <= 4 && !s.contains(' ')) return s;