Skip to content

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

Desktop layout for the web version

InlitX7474c36e4280
diff --git a/lib/app/app_shell.dart b/lib/app/app_shell.dart
index fb54d6a..47b330d 100644
--- a/lib/app/app_shell.dart
+++ b/lib/app/app_shell.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:math' as math;
import 'dart:ui' as ui;
+import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show RenderRepaintBoundary;
import 'package:flutter/services.dart';
@@ -41,6 +42,9 @@ import '../services/device_kind.dart';
import '../services/health_steps.dart';
import '../services/incoming_share.dart';
import '../services/nutrition_widgets.dart';
+import '../services/local_store.dart';
+import '../services/server/server_link.dart';
+import '../services/supplement_reminder.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
@@ -53,6 +57,7 @@ import '../widgets/health_cards.dart';
import '../widgets/liquid_notch.dart';
import '../widgets/start_countdown.dart';
import '../widgets/ui_kit.dart';
+import 'desktop.dart';
class AppShell extends StatefulWidget {
const AppShell({super.key});
@@ -114,6 +119,12 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
_queueCelebration();
IncomingShare.listen(_receive);
NutritionWidgets.listenOpen(_openFromWidget);
+ SupplementReminder.instance.onOpen = _openSupplements;
+ SupplementReminder.instance.listenTaken(fit.takeSupplementsOn);
+ if (kIsWeb) {
+ ServerLink.instance.onRemote = _remoteChanged;
+ ServerLink.instance.start();
+ }
HealthSteps.listen(_showStepsInfo);
fit.refreshSteps();
fit.refreshHealth();
@@ -123,6 +134,9 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
await NutritionWidgets.takePending();
final open = await NutritionWidgets.takeOpen();
if (open != null) _openFromWidget(open);
+ final launched = await SupplementReminder.instance.launchIds();
+ if (launched != null) _openSupplements(launched);
+ await SupplementReminder.instance.takePending();
if (await HealthSteps.takeUsage()) _showStepsInfo();
await fit.readDisplay();
await _offerLiteMode();
@@ -138,6 +152,19 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
}
}
+ void _remoteChanged(String text, {required bool conflict, required bool fromPhone}) {
+ final data = Store.decodeState(text);
+ if (data.isEmpty || fit.isSessionActive) return;
+ fit.applyBackup(data);
+ if (!mounted) return;
+ showNotchToast(context, fromPhone ? t.webSyncedPhone : t.webSynced, icon: PhosphorIconsFill.arrowsClockwise, accent: context.gc.sage);
+ }
+
+ void _openSupplements(List<String> ids) {
+ if (!mounted || !fit.onboarded || fit.isSessionActive) return;
+ fit.openSupplements(ids);
+ }
+
void _showStepsInfo() {
if (!mounted || !fit.onboarded) return;
showStepsSheet(context);
@@ -337,6 +364,7 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
if (state == AppLifecycleState.resumed) {
fit.rollNutritionDay();
NutritionWidgets.takePending();
+ SupplementReminder.instance.takePending();
fit.refreshAlarmPermission();
fit.syncRest();
fit.refreshWidgets();
@@ -350,8 +378,11 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
return AnimatedBuilder(
animation: fit,
builder: (context, _) {
- if (!fit.onboarded) return const OnboardingScreen();
- final parked = fit.sessionParked && fit.showNav;
+ if (!fit.onboarded) {
+ return const OnboardingScreen();
+ }
+ final wide = DesktopScope.wideFor(MediaQuery.sizeOf(context).width);
+ final parked = fit.sessionParked && fit.showNav && !wide;
return PopScope(
canPop: false,
@@ -399,29 +430,41 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
Scaffold(
backgroundColor: Colors.transparent,
body: Padding(
- padding: EdgeInsets.only(
+ padding: EdgeInsetsDirectional.only(
+ start: wide ? DesktopScope.sidebarWidth : 0,
bottom: (MediaQuery.viewInsetsOf(context).bottom > 0
? 0
: MediaQuery.viewPaddingOf(context).bottom) +
(parked ? _pillSpace : 0)),
- child: NotificationListener<ScrollNotification>(
- onNotification: _onScroll,
- child: RepaintBoundary(child: _animatedScreen()),
+ child: DesktopScope(
+ wide: wide,
+ child: NotificationListener<ScrollNotification>(
+ onNotification: _onScroll,
+ child: RepaintBoundary(child: _animatedScreen()),
+ ),
),
),
),
]),
),
),
- Positioned(
- left: 0,
- right: 0,
+ if (wide)
+ const PositionedDirectional(
+ start: 16,
+ top: 16,
+ bottom: 16,
+ width: DesktopScope.sidebarWidth - 32,
+ child: Material(type: MaterialType.transparency, child: _Sidebar()),
+ ),
+ PositionedDirectional(
+ start: wide ? DesktopScope.sidebarWidth : 0,
+ end: 0,
top: 0,
child: _blurTop.contains(fit.route)
? _CollapsedBar(progress: _collapse, title: _compactTitle())
: const SizedBox.shrink(),
),
- if (fit.showNav)
+ if (fit.showNav && !wide)
Positioned(
left: 0,
right: 0,
@@ -429,7 +472,7 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
child: EdgeBlur(
top: false, height: 128 + MediaQuery.viewPaddingOf(context).bottom + (parked ? _pillSpace : 0)),
),
- if (fit.showNav && MediaQuery.viewInsetsOf(context).bottom < 60) ...[
+ if (fit.showNav && !wide && MediaQuery.viewInsetsOf(context).bottom < 60) ...[
Positioned(
left: 24,
right: 24,
@@ -575,7 +618,7 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Single
if (currentChild != null) Positioned.fill(key: currentChild.key, child: currentChild),
],
),
- child: KeyedSubtree(key: ValueKey(fit.route), child: _screen()),
+ child: KeyedSubtree(key: ValueKey(fit.route), child: _DesktopPage(route: fit.route, child: _screen())),
);
}
@@ -1188,3 +1231,306 @@ class _SoftCopy extends CustomPainter {
@override
bool shouldRepaint(_SoftCopy old) => old.image != image || old.amount != amount;
}
+
+class _Sidebar extends StatelessWidget {
+ const _Sidebar();
+
+ static const _main = [
+ ('home', PhosphorIconsRegular.house, PhosphorIconsFill.house),
+ ('progress', PhosphorIconsRegular.chartLineUp, PhosphorIconsFill.chartLineUp),
+ ('exercises', PhosphorIconsRegular.barbell, PhosphorIconsFill.barbell),
+ ('settings', PhosphorIconsRegular.userCircle, PhosphorIconsFill.userCircle),
+ ];
+
+ String _label(String id) => switch (id) {
+ 'home' => titleCase(t.home),
+ 'progress' => titleCase(t.progress),
+ 'exercises' => titleCase(t.exercises),
+ 'settings' => sentenceCase(t.profile),
+ 'routines' => titleCase(t.routines),
+ 'notes' => titleCase(t.journal),
+ 'tools' => titleCase(t.tools),
+ 'nutrition' => sentenceCase(t.nutrition),
+ _ => titleCase(t.settings),
+ };
+
+ void _go(String id) {
+ switch (id) {
+ case 'home':
+ fit.goHome();
+ case 'progress':
+ fit.goProgress();
+ case 'exercises':
+ fit.goExercises();
+ case 'settings':
+ fit.goSettings();
+ case 'routines':
+ fit.goHome();
+ fit.goRoutines();
+ case 'notes':
+ fit.goHome();
+ fit.goNotes(all: true);
+ case 'tools':
+ fit.goHome();
+ fit.goTools();
+ case 'nutrition':
+ fit.goHome();
+ fit.goNutrition();
+ default:
+ fit.goSettings();
+ fit.goPreferences();
+ }
+ }
+
+ String get _active {
+ final r = fit.route;
+ if (r.startsWith('preferences')) return 'preferences';
+ if (r == 'routine-edit' || r == 'ai-plan') return 'routines';
+ if (r == 'note-edit') return 'notes';
+ if (r == 'tools-detail') return 'tools';
+ if (r == 'exercise-detail') return 'exercises';
+ if (const ['history', 'measures', 'timeline', 'compare', 'health'].contains(r)) return 'progress';
+ if (const ['awards', 'moments', 'passes', 'about', 'places'].contains(r)) return 'settings';
+ return r;
+ }
+
+ @override
+ Widget build(BuildContext context) => ListenableBuilder(listenable: fit, builder: (context, _) => _panel(context));
+
+ Widget _panel(BuildContext context) {
+ final gc = context.gc;
+ final active = _active;
+ final live = fit.isSessionActive;
+ return Container(
+ padding: const EdgeInsets.fromLTRB(14, 20, 14, 16),
+ decoration: BoxDecoration(
+ color: gc.bgRaised.withValues(alpha: 0.72),
+ borderRadius: BorderRadius.circular(28),
+ ),
+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ Padding(
+ padding: const EdgeInsetsDirectional.only(start: 6),
+ child: Row(children: [
+ ClipRRect(
+ borderRadius: BorderRadius.circular(10),
+ child: Image.asset('assets/img/app_icon.png', width: 34, height: 34, filterQuality: FilterQuality.medium),
+ ),
+ const SizedBox(width: 11),
+ Expanded(
+ child: Text('GymMane',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.4)),
+ ),
+ ]),
+ ),
+ const SizedBox(height: 24),
+ _StartButton(live: live),
+ const SizedBox(height: 22),
+ for (final (id, icon, fill) in _main) ...[
+ _SideItem(
+ label: _label(id),
+ icon: icon,
+ iconFill: fill,
+ selected: active == id,
+ onTap: () => _go(id),
+ ),
+ const SizedBox(height: 4),
+ ],
+ const SizedBox(height: 18),
+ for (final (id, icon, fill) in [
+ ('routines', PhosphorIconsRegular.listChecks, PhosphorIconsFill.listChecks),
+ ('notes', PhosphorIconsRegular.notebook, PhosphorIconsFill.notebook),
+ ('tools', PhosphorIconsRegular.calculator, PhosphorIconsFill.calculator),
+ if (fit.nutritionBeta) ('nutrition', PhosphorIconsRegular.forkKnife, PhosphorIconsFill.forkKnife),
+ ]) ...[
+ _SideItem(
+ label: _label(id),
+ icon: icon,
+ iconFill: fill,
+ selected: active == id,
+ small: true,
+ onTap: () => _go(id),
+ ),
+ const SizedBox(height: 2),
+ ],
+ const Spacer(),
+ _SideItem(
+ label: _label('preferences'),
+ icon: PhosphorIconsRegular.gearSix,
+ iconFill: PhosphorIconsFill.gearSix,
+ selected: active == 'preferences',
+ small: true,
+ onTap: () => _go('preferences'),
+ ),
+ const SizedBox(height: 10),
+ const _ServerStatus(),
+ ]),
+ );
+ }
+}
+
+class _StartButton extends StatelessWidget {
+ const _StartButton({required this.live});
+
+ final bool live;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return Pressable(
+ onTap: () => live ? fit.stepBackIntoSession() : playWorkout(context),
+ scale: 0.97,
+ child: Semantics(
+ button: true,
+ child: Container(
+ height: 48,
+ decoration: BoxDecoration(color: gc.ember, borderRadius: BorderRadius.circular(100)),
+ padding: const EdgeInsets.symmetric(horizontal: 18),
+ child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
+ Icon(PhosphorIconsFill.play, size: 15, color: gc.onEmber),
+ const SizedBox(width: 9),
+ Flexible(
+ child: FitText(live ? t.keepTraining : sentenceCase(t.startWorkout),
+ style: AppTheme.f(14.5, weight: FontWeight.w800, color: gc.onEmber)),
+ ),
+ ]),
+ ),
+ ),
+ );
+ }
+}
+
+class _SideItem extends StatefulWidget {
+ const _SideItem({
+ required this.label,
+ required this.icon,
+ required this.iconFill,
+ required this.selected,
+ required this.onTap,
+ this.small = false,
+ });
+
+ final String label;
+ final IconData icon;
+ final IconData iconFill;
+ final bool selected;
+ final bool small;
+ final VoidCallback onTap;
+
+ @override
+ State<_SideItem> createState() => _SideItemState();
+}
+
+class _SideItemState extends State<_SideItem> {
+ bool _hover = false;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final on = widget.selected;
+ final h = widget.small ? 40.0 : 46.0;
+ return MouseRegion(
+ cursor: SystemMouseCursors.click,
+ onEnter: (_) => setState(() => _hover = true),
+ onExit: (_) => setState(() => _hover = false),
+ child: Semantics(
+ button: true,
+ selected: on,
+ label: widget.label,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: widget.onTap,
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 180),
+ curve: Curves.easeOutCubic,
+ height: h,
+ padding: const EdgeInsetsDirectional.only(start: 14, end: 10),
+ decoration: BoxDecoration(
+ color: on ? gc.bgRaised2 : (_hover ? gc.bgRaised2.withValues(alpha: 0.5) : Colors.transparent),
+ borderRadius: BorderRadius.circular(16),
+ ),
+ child: Row(children: [
+ Icon(on ? widget.iconFill : widget.icon,
+ size: widget.small ? 17 : 19, color: on ? gc.text : gc.textSecondary),
+ const SizedBox(width: 13),
+ Expanded(
+ child: Text(widget.label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(widget.small ? 13.5 : 14.5,
+ weight: on ? FontWeight.w800 : FontWeight.w600, color: on ? gc.text : gc.textSecondary)),
+ ),
+ ]),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _ServerStatus extends StatelessWidget {
+ const _ServerStatus();
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return ListenableBuilder(
+ listenable: ServerLink.instance,
+ builder: (context, _) {
+ final link = ServerLink.instance;
+ final ok = !link.available || link.online;
+ final text = !link.available ? t.webServerLocal : (link.online ? t.webServerSaved : t.webServerOffline);
+ return Padding(
+ padding: const EdgeInsetsDirectional.only(start: 14, end: 8),
+ child: Row(children: [
+ Container(
+ width: 7,
+ height: 7,
+ decoration: BoxDecoration(color: ok ? gc.sage : gc.warn, shape: BoxShape.circle),
+ ),
+ const SizedBox(width: 9),
+ Expanded(
+ child: Text(text,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textTertiary)),
+ ),
+ ]),
+ );
+ },
+ );
+ }
+}
+
+class _DesktopPage extends StatelessWidget {
+ const _DesktopPage({required this.route, required this.child});
+
+ final String route;
+ final Widget child;
+
+ static const _sheets = {'history', 'awards'};
+
+ static const _flow = {'home', 'progress', 'settings', 'tools', 'nutrition', 'preferences', 'notes', 'routines', 'exercises', 'history', 'awards', 'exercise-detail'};
+
+ @override
+ Widget build(BuildContext context) {
+ if (!DesktopScope.of(context)) return child;
+ final max = _flow.contains(route) ? DesktopScope.flowWidth : DesktopScope.readingWidth;
+ return LayoutBuilder(builder: (context, box) {
+ final inset = _sheets.contains(route) ? 24.0 : 0.0;
+ final width = (box.maxWidth - inset * 2) < max ? box.maxWidth - inset * 2 : max;
+ final media = MediaQuery.of(context);
+ return Center(
+ child: SizedBox(
+ width: width,
+ height: box.maxHeight,
+ child: MediaQuery(
+ data: media.copyWith(size: Size(width, media.size.height)),
+ child: child,
+ ),
+ ),
+ );
+ });
+ }
+}
diff --git a/lib/app/desktop.dart b/lib/app/desktop.dart
new file mode 100644
index 0000000..1781515
--- /dev/null
+++ b/lib/app/desktop.dart
@@ -0,0 +1,228 @@
+import 'dart:math' as math;
+
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+
+class DesktopScope extends InheritedWidget {
+ const DesktopScope({super.key, required this.wide, required super.child});
+
+ final bool wide;
+
+ static const minWidth = 1000.0;
+ static const sidebarWidth = 252.0;
+ static const readingWidth = 760.0;
+ static const flowWidth = 1600.0;
+
+ static bool wideFor(double width) => kIsWeb && width >= minWidth;
+
+ static bool of(BuildContext context) =>
+ context.dependOnInheritedWidgetOfExactType<DesktopScope>()?.wide ?? false;
+
+ @override
+ bool updateShouldNotify(DesktopScope oldWidget) => oldWidget.wide != wide;
+}
+
+class FlowWide extends ParentDataWidget<CardFlowData> {
+ const FlowWide({super.key, required super.child});
+
+ @override
+ void applyParentData(RenderObject renderObject) {
+ final data = renderObject.parentData as CardFlowData;
+ if (data.wide) return;
+ data.wide = true;
+ renderObject.parent?.markNeedsLayout();
+ }
+
+ @override
+ Type get debugTypicalAncestorWidgetClass => CardFlow;
+}
+
+class FlowSlot extends ParentDataWidget<CardFlowData> {
+ const FlowSlot({super.key, this.column, this.lift = 0, this.span = 1, this.stretch = false, required super.child});
+
+ final int? column;
+ final double lift;
+ final int span;
+ final bool stretch;
+
+ @override
+ void applyParentData(RenderObject renderObject) {
+ final data = renderObject.parentData as CardFlowData;
+ if (data.lift == lift && data.column == column && data.span == span && data.stretch == stretch) return;
+ data.stretch = stretch;
+ data.lift = lift;
+ data.column = column;
+ data.span = span;
+ renderObject.parent?.markNeedsLayout();
+ }
+
+ @override
+ Type get debugTypicalAncestorWidgetClass => CardFlow;
+}
+
+class CardFlow extends MultiChildRenderObjectWidget {
+ const CardFlow({super.key, required super.children, this.minColumn = 360, this.maxColumns = 3, this.gap = 22});
+
+ final double minColumn;
+ final int maxColumns;
+ final double gap;
+
+ static int columnsFor(double width, {double minColumn = 360, int maxColumns = 3, double gap = 22}) =>
+ math.max(1, math.min(maxColumns, ((width + gap) / (minColumn + gap)).floor()));
+
+ @override
+ RenderObject createRenderObject(BuildContext context) => RenderCardFlow(
+ minColumn: minColumn, maxColumns: maxColumns, gap: gap, rtl: Directionality.of(context) == TextDirection.rtl);
+
+ @override
+ void updateRenderObject(BuildContext context, RenderCardFlow renderObject) {
+ renderObject
+ ..minColumn = minColumn
+ ..maxColumns = maxColumns
+ ..gap = gap
+ ..rtl = Directionality.of(context) == TextDirection.rtl;
+ }
+}
+
+class CardFlowData extends ContainerBoxParentData<RenderBox> {
+ bool wide = false;
+ double lift = 0;
+ int? column;
+ int span = 1;
+ bool stretch = false;
+}
+
+class RenderCardFlow extends RenderBox
+ with ContainerRenderObjectMixin<RenderBox, CardFlowData>, RenderBoxContainerDefaultsMixin<RenderBox, CardFlowData> {
+ RenderCardFlow({required double minColumn, required int maxColumns, required double gap, required bool rtl})
+ : _minColumn = minColumn,
+ _maxColumns = maxColumns,
+ _gap = gap,
+ _rtl = rtl;
+
+ bool _rtl;
+
+ set rtl(bool v) {
+ if (v == _rtl) return;
+ _rtl = v;
+ markNeedsLayout();
+ }
+
+ double _minColumn;
+ int _maxColumns;
+ double _gap;
+
+ set minColumn(double v) {
+ if (v == _minColumn) return;
+ _minColumn = v;
+ markNeedsLayout();
+ }
+
+ set maxColumns(int v) {
+ if (v == _maxColumns) return;
+ _maxColumns = v;
+ markNeedsLayout();
+ }
+
+ set gap(double v) {
+ if (v == _gap) return;
+ _gap = v;
+ markNeedsLayout();
+ }
+
+ @override
+ void setupParentData(RenderBox child) {
+ if (child.parentData is! CardFlowData) child.parentData = CardFlowData();
+ }
+
+ int _columnsFor(double width) =>
+ CardFlow.columnsFor(width, minColumn: _minColumn, maxColumns: _maxColumns, gap: _gap);
+
+ @override
+ void performLayout() {
+ final width = constraints.maxWidth;
+ final n = _columnsFor(width);
+ final colW = (width - _gap * (n - 1)) / n;
+ final heights = List<double>.filled(n, 0);
+ final order = <RenderBox>[];
+ final spans = <RenderBox>[];
+ final wides = <RenderBox>[];
+ for (var c = firstChild; c != null; c = (c.parentData as CardFlowData).nextSibling) {
+ final d = c.parentData as CardFlowData;
+ if (n == 1) {
+ order.add(c);
+ } else if (d.wide || d.span >= n) {
+ wides.add(c);
+ } else if (d.span > 1) {
+ spans.add(c);
+ } else {
+ order.add(c);
+ }
+ }
+ order
+ ..addAll(spans)
+ ..addAll(wides);
+ final last = List<RenderBox?>.filled(n, null);
+ var evened = false;
+ void even() {
+ if (evened || n == 1) return;
+ evened = true;
+ final target = heights.reduce(math.max);
+ for (var i = 0; i < n; i++) {
+ final c = last[i];
+ if (c == null) continue;
+ final d = c.parentData as CardFlowData;
+ final extra = target - heights[i];
+ if (!d.stretch || extra < 0.5) continue;
+ c.layout(BoxConstraints.tightFor(width: c.size.width, height: c.size.height + extra), parentUsesSize: true);
+ heights[i] = target;
+ }
+ }
+ for (final child in order) {
+ final data = child.parentData as CardFlowData;
+ if (data.wide || data.span > 1) even();
+ if (n > 1 && data.span > 1 && data.span < n && !data.wide) {
+ final k = data.span;
+ final top = heights.sublist(0, k).reduce(math.max);
+ final w = colW * k + _gap * (k - 1);
+ child.layout(BoxConstraints.tightFor(width: w), parentUsesSize: true);
+ data.offset = Offset(_rtl ? width - w : 0, top);
+ for (var i = 0; i < k; i++) {
+ heights[i] = top + child.size.height + (child.size.height > 0 ? _gap : 0);
+ }
+ } else if (data.wide || data.span >= n || n == 1) {
+ final top = heights.reduce(math.max);
+ child.layout(BoxConstraints.tightFor(width: width), parentUsesSize: true);
+ data.offset = Offset(0, top);
+ final next = top + child.size.height + (child.size.height > 0 ? _gap : 0);
+ for (var i = 0; i < n; i++) {
+ heights[i] = next;
+ }
+ } else {
+ var col = 0;
+ for (var i = 1; i < n; i++) {
+ if (heights[i] < heights[col] - 0.5) col = i;
+ }
+ final want = data.column;
+ if (n >= 3 && want != null && want < n) col = want;
+ child.layout(BoxConstraints.tightFor(width: colW), parentUsesSize: true);
+ final x = _rtl ? width - colW - col * (colW + _gap) : col * (colW + _gap);
+ final up = heights[col] == 0 && n > 1 ? data.lift : 0.0;
+ data.offset = Offset(x, heights[col] - up);
+ if (child.size.height > 0) heights[col] += child.size.height - up + _gap;
+ last[col] = child;
+ }
+ }
+ even();
+ final tallest = heights.reduce(math.max);
+ size = constraints.constrain(Size(width, math.max(0, tallest - _gap)));
+ }
+
+ @override
+ void paint(PaintingContext context, Offset offset) => defaultPaint(context, offset);
+
+ @override
+ bool hitTestChildren(BoxHitTestResult result, {required Offset position}) =>
+ defaultHitTestChildren(result, position: position);
+}
diff --git a/lib/app/gymmane_app.dart b/lib/app/gymmane_app.dart
index ef3cf84..7ca0ed6 100644
--- a/lib/app/gymmane_app.dart
+++ b/lib/app/gymmane_app.dart
@@ -1,3 +1,5 @@
+import 'package:flutter/foundation.dart';
+import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
@@ -6,6 +8,7 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import 'app_shell.dart';
+import 'desktop.dart';
class GymManeApp extends StatefulWidget {
const GymManeApp({super.key});
@@ -41,6 +44,7 @@ class _GymManeAppState extends State<GymManeApp> {
return MaterialApp(
title: 'GymMane',
debugShowCheckedModeBanner: false,
+ scrollBehavior: kIsWeb ? const _WebScroll() : null,
theme: AppTheme.light,
darkTheme: _look.$3 ? AppTheme.amoled : AppTheme.dark,
themeMode: _look.$1,
@@ -60,7 +64,7 @@ class _GymManeAppState extends State<GymManeApp> {
textScaler: TextScaler.linear(system * fit.textFactor),
disableAnimations: media.disableAnimations || fit.calmMotion,
),
- child: _ButtonNavScrim(child: child!),
+ child: kIsWeb ? _WebFrame(child: child!) : _ButtonNavScrim(child: child!),
);
},
home: const AppShell(),
@@ -92,3 +96,42 @@ class _ButtonNavScrim extends StatelessWidget {
);
}
}
+
+class _WebScroll extends MaterialScrollBehavior {
+ const _WebScroll();
+
+ @override
+ Set<PointerDeviceKind> get dragDevices => {
+ PointerDeviceKind.touch,
+ PointerDeviceKind.mouse,
+ PointerDeviceKind.trackpad,
+ PointerDeviceKind.stylus,
+ };
+}
+
+class _WebFrame extends StatelessWidget {
+ const _WebFrame({required this.child});
+
+ final Widget child;
+
+ static const _column = 640.0;
+
+ @override
+ Widget build(BuildContext context) {
+ final media = MediaQuery.of(context);
+ final size = media.size;
+ if (size.width <= _column + 40 || DesktopScope.wideFor(size.width)) return child;
+ return ColoredBox(
+ color: context.gc.bg,
+ child: Center(
+ child: SizedBox(
+ width: _column,
+ child: MediaQuery(
+ data: media.copyWith(size: Size(_column, size.height)),
+ child: child,
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/main.dart b/lib/main.dart
index 046920b..8747538 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -11,10 +11,12 @@ import 'services/nutrition_widgets.dart';
import 'services/live_workout.dart';
import 'services/local_store.dart';
import 'services/media_store.dart';
+import 'services/graphics_mode.dart';
import 'services/rest_alarm.dart';
import 'services/screen_awake.dart';
import 'state/fit_state.dart';
import 'wear/wear_app.dart';
+import 'wear/wear_surfaces.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
@@ -32,6 +34,7 @@ Future<void> main() async {
await MediaStore.init();
await AlarmStore.init();
await RestAlarm.instance.init();
+ GraphicsMode.load();
fit.loadFromStore();
fit.syncPhotoReminder();
fit.syncMeasureReminder();
@@ -43,6 +46,7 @@ Future<void> main() async {
_sessionSideEffects();
if (watch) {
+ WearSurfaces.watch();
runApp(const WearApp());
return;
}