Skip to content

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

Home cards that stack and live samples in settings

InlitX96bfe3c2524d
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index 6aa0df5..19543a4 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
+import '../widgets/body_map.dart';
import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../l10n/l10n.dart';
@@ -12,6 +13,7 @@ import '../widgets/exercise_media.dart';
import '../widgets/glass.dart';
import '../widgets/home_folder.dart';
import '../widgets/routine_folder.dart';
+import '../widgets/scroll_away.dart';
import '../widgets/steps_card.dart';
import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
@@ -42,31 +44,27 @@ class HomeScreen extends StatelessWidget {
_topBar(gc),
const SizedBox(height: 20),
if (fit.showFocus || fit.todayRoutine?.exerciseIds.isNotEmpty == true) ...[
- _hero(context, gc),
+ ScrollAway(radius: 26, child: _hero(context, gc)),
const SizedBox(height: 14),
],
- _weekCard(context, gc),
+ _away(_weekCard(context, gc)),
if (fit.stepsOn && fit.stepsAvailable) ...[
const SizedBox(height: 14),
- StepsCard(),
+ _away(StepsCard()),
],
if (fit.photoDue) ...[
const SizedBox(height: 14),
- _photoNudge(gc),
+ _away(_photoNudge(gc)),
],
if (fit.showWeekStats) ...[
const SizedBox(height: 30),
- _heading(gc, t.thisWeek),
- const SizedBox(height: 14),
- _weekStats(context, gc),
+ _section(gc, t.thisWeek, null, _weekStats(context, gc)),
],
if (fit.showRoutineRow && routines.isNotEmpty) ...[
const SizedBox(height: 30),
- _heading(gc, t.routines, onMore: fit.goRoutines),
- const SizedBox(height: 14),
- LayoutBuilder(
+ _section(gc, t.routines, fit.goRoutines, LayoutBuilder(
builder: (context, box) => SizedBox(
- height: 196,
+ height: routineFolderHeight(context),
child: ListView.separated(
scrollDirection: Axis.horizontal,
clipBehavior: Clip.none,
@@ -82,12 +80,10 @@ class HomeScreen extends StatelessWidget {
),
),
),
- ),
+ )),
],
const SizedBox(height: 30),
- _heading(gc, t.activityLabel, onMore: fit.goProgress),
- const SizedBox(height: 14),
- SoftCard(
+ _section(gc, t.activityLabel, fit.goProgress, SoftCard(
radius: 22,
borderColor: Colors.transparent,
padding: const EdgeInsets.fromLTRB(18, 18, 18, 16),
@@ -104,12 +100,10 @@ class HomeScreen extends StatelessWidget {
labels: fit.heatmapLabels,
onTapDay: (i) => showDaySheet(context, fit.heatmapWeekDate(i)),
),
- ),
+ )),
if (fit.showRecommended && recommended.isNotEmpty) ...[
const SizedBox(height: 30),
- _heading(gc, t.recommended, onMore: fit.goExercises),
- const SizedBox(height: 14),
- SizedBox(
+ _section(gc, t.recommended, fit.goExercises, SizedBox(
height: 158,
child: ListView.separated(
scrollDirection: Axis.horizontal,
@@ -117,10 +111,10 @@ class HomeScreen extends StatelessWidget {
separatorBuilder: (_, _) => const SizedBox(width: 12),
itemBuilder: (_, i) => _recCard(gc, recommended[i]),
),
- ),
+ )),
],
const SizedBox(height: 30),
- Row(
+ _away(Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
@@ -150,7 +144,7 @@ class HomeScreen extends StatelessWidget {
),
),
],
- ),
+ ), dim: 0),
if (fit.nutritionBeta) ...[
const SizedBox(height: 12),
HomeFolder(
@@ -168,6 +162,20 @@ class HomeScreen extends StatelessWidget {
);
}
+ Widget _away(Widget child, {double dim = 0.45}) => ScrollAway(radius: 22, dim: dim, child: child);
+
+ Widget _section(GymColors gc, String title, VoidCallback? onMore, Widget child) => _away(
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ _heading(gc, title, onMore: onMore),
+ const SizedBox(height: 14),
+ child,
+ ],
+ ),
+ dim: 0,
+ );
+
Widget _topBar(GymColors gc) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
@@ -356,11 +364,19 @@ class HomeScreen extends StatelessWidget {
weight: FontWeight.w800, color: gc.text, height: 1.1)),
),
const SizedBox(height: 7),
- Text(subtitle,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
- const SizedBox(height: 20),
+ Row(children: [
+ if (isRoutine && rest == null && fit.showMiniBody) ...[
+ MiniBody(sets: fit.routineMuscleSets(routine), height: 38),
+ const SizedBox(width: 10),
+ ],
+ Flexible(
+ child: Text(subtitle,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
+ ),
+ ]),
+ const SizedBox(height: 18),
Row(children: [
Expanded(
child: PrimaryButton(
@@ -592,10 +608,7 @@ void showWeeklyGoalSheet(BuildContext context) {
builder: (sheet) => StatefulBuilder(
builder: (sheet, setSheet) => Container(
padding: sheetPad(sheet),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
+ decoration: sheetDecoration(gc),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -630,3 +643,4 @@ void showWeeklyGoalSheet(BuildContext context) {
),
);
}
+
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 211da34..4d87dd4 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -35,8 +35,12 @@ import '../widgets/file_thumb.dart';
import '../widgets/glass.dart';
import '../widgets/liquid_notch.dart';
import '../widgets/photo_source_sheet.dart';
+import '../widgets/widget_showcase.dart';
+import '../widgets/home_cards_panel.dart';
+import '../widgets/settings_showcase.dart';
import '../widgets/sheet_page.dart';
import '../widgets/profile_avatar.dart';
+import '../widgets/report_sheet.dart';
import '../widgets/ruler_picker.dart';
import '../widgets/timer_panel.dart';
import 'profile_screen.dart';
@@ -44,6 +48,7 @@ import 'strava_sheet.dart';
import '../widgets/health_cards.dart';
import '../widgets/steps_card.dart';
import '../widgets/svg_icon.dart';
+import '../widgets/import_card.dart';
import '../widgets/ui_kit.dart';
const _kRepoUrl = 'https://github.com/InlitX/GymMane';
@@ -60,6 +65,7 @@ class SettingsScreen extends StatelessWidget {
Widget build(BuildContext context) {
final gc = context.gc;
final id = section;
+ WidgetShowcase.warm(context);
if (id == null) return _SettingsHome(screen: this);
return RiseScope(
id: 'settings-$id',
@@ -164,10 +170,33 @@ class SettingsScreen extends StatelessWidget {
child: _prefRow(gc, PhosphorIconsRegular.drop, t.blurSetting, TinySwitch(on: fit.blurOn),
hint: t.blurSettingHint),
),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.textAa,
+ t.textSizeSetting,
+ [
+ ('small', t.textSizeSmall, PhosphorIconsRegular.textAa),
+ ('normal', t.textSizeNormal, PhosphorIconsRegular.textAa),
+ ('large', t.textSizeLarge, PhosphorIconsRegular.textAa),
+ ],
+ () => fit.textSize,
+ fit.setTextSize,
+ hint: t.textSizeHint,
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.setCalmMotion(!fit.calmMotion),
+ child: _prefRow(gc, PhosphorIconsRegular.waveSine, t.calmMotionSetting, TinySwitch(on: fit.calmMotion),
+ hint: t.calmMotionHint),
+ ),
]),
+ const SizedBox(height: 22),
+ const LookShowcase(),
];
case 'training':
return [
+ _subhead(gc, t.settingsRests, top: 6),
_card(gc, [
_prefRow(
gc,
@@ -223,6 +252,9 @@ class SettingsScreen extends StatelessWidget {
),
hint: t.miniRestHint,
),
+ ]),
+ _subhead(gc, t.settingsDuring),
+ _card(gc, [
_choiceRow(
context,
gc,
@@ -266,6 +298,21 @@ class SettingsScreen extends StatelessWidget {
child: _prefRow(gc, PhosphorIconsRegular.sun, t.keepScreenOn,
TinySwitch(on: fit.keepScreenOn), hint: t.keepScreenOnHint),
),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleAskCheckIn,
+ child: _prefRow(gc, PhosphorIconsRegular.moon, t.checkInSetting,
+ TinySwitch(on: fit.askCheckIn), hint: t.checkInSettingHint),
+ ),
+ ]),
+ _subhead(gc, t.routines),
+ _card(gc, [
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleMiniBody,
+ child: _prefRow(gc, PhosphorIconsRegular.person, t.miniBodySetting,
+ TinySwitch(on: fit.showMiniBody), hint: t.miniBodySettingHint),
+ ),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: fit.toggleMultiPlan,
@@ -278,6 +325,9 @@ class SettingsScreen extends StatelessWidget {
child: _prefRow(gc, PhosphorIconsRegular.stairs, t.levelHintsSetting,
TinySwitch(on: fit.levelHints), hint: t.levelHintsHint),
),
+ ]),
+ _subhead(gc, t.settingsLook),
+ _card(gc, [
_choiceRow(
context,
gc,
@@ -406,44 +456,17 @@ class SettingsScreen extends StatelessWidget {
],
]),
+ const SizedBox(height: 22),
+ const AlertsShowcase(),
];
case 'home':
return [
+ HomeCardsPanel(onSteps: () async {
+ if (await fit.setStepsOn(!fit.stepsOn) || !context.mounted) return;
+ showStepsSheet(context);
+ }),
+ const SizedBox(height: 22),
_card(gc, [
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleFocusCard,
- child: _prefRow(gc, PhosphorIconsRegular.target, t.focusCard,
- TinySwitch(on: fit.showFocus), hint: t.focusCardHint),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleRecommended,
- child: _prefRow(gc, PhosphorIconsRegular.sparkle, t.homeRecommended,
- TinySwitch(on: fit.showRecommended), hint: t.recommendedRowHint),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleRoutineRow,
- child: _prefRow(gc, PhosphorIconsRegular.folders, t.homeRoutines,
- TinySwitch(on: fit.showRoutineRow), hint: t.homeRoutinesHint),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleWeekStats,
- child: _prefRow(gc, PhosphorIconsRegular.chartBar, t.homeWeekStats,
- TinySwitch(on: fit.showWeekStats), hint: t.homeWeekStatsHint),
- ),
- if (fit.stepsAvailable)
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () async {
- if (await fit.setStepsOn(!fit.stepsOn) || !context.mounted) return;
- showStepsSheet(context);
- },
- child: _prefRow(gc, PhosphorIconsRegular.footprints, t.stepsSetting,
- TinySwitch(on: fit.stepsOn), hint: t.stepsSettingHint),
- ),
if (fit.stepsAvailable)
GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -475,6 +498,8 @@ class SettingsScreen extends StatelessWidget {
),
]),
+ const SizedBox(height: 22),
+ const HomeExtrasShowcase(),
];
case 'beta':
return [
@@ -536,17 +561,22 @@ class SettingsScreen extends StatelessWidget {
(PhosphorIconsRegular.checkCircle, t.addTodayWidget, () => _addWidget(context, 'TodayWidgetProvider')),
(PhosphorIconsRegular.calendarCheck, t.addWeekWidget, () => _addWidget(context, 'WeekWidgetProvider')),
], hints: [t.widgetHintActivity, t.widgetHintStats, t.widgetHintBody, t.widgetHintToday, t.widgetHintWeek]),
+ const SizedBox(height: 22),
+ const WidgetShowcase(),
];
case 'data':
return [
+ ImportCard(onTap: () => _openImportApps(context)),
+ const SizedBox(height: 12),
_linkGroup(gc, [
(PhosphorIconsRegular.fileCsv, t.exportCsv, () => _exportCsv(context)),
+ (PhosphorIconsRegular.fileText, t.reportTitle, () => showReportSheet(context)),
(PhosphorIconsRegular.fileZip, t.exportBackup, () => _exportBackup(context)),
(PhosphorIconsRegular.downloadSimple, t.importBackup, () => _importBackup(context)),
if (AutoBackup.instance.supported)
(PhosphorIconsRegular.clockCounterClockwise, t.autoBackup, () => showAutoBackupSheet(context)),
- (PhosphorIconsRegular.arrowSquareIn, t.importFromApp, () => _openImportApps(context)),
(PhosphorIconsRegular.export, t.stravaRow, () => showStravaSheet(context)),
+ (PhosphorIconsRegular.barbell, t.clearWorkouts, () => _clearWorkouts(context)),
(PhosphorIconsRegular.trash, t.resetData, () => _resetAll(context)),
], danger: AutoBackup.instance.supported ? 6 : 5),
];
@@ -558,10 +588,38 @@ class SettingsScreen extends StatelessWidget {
(PhosphorIconsRegular.githubLogo, t.starOnGithub, () => _open(context, _kRepoUrl)),
(PhosphorIconsRegular.coffee, t.buyCoffee, () => _open(context, _kKofiUrl)),
], hints: [t.supportHintBug, t.supportHintFeature, t.supportHintStar, t.supportHintCoffee]),
+ const SizedBox(height: 28),
+ Center(
+ child: ExcludeSemantics(
+ child: Image.asset(
+ 'assets/img/support-cat.png',
+ width: 300,
+ filterQuality: FilterQuality.medium,
+ ),
+ ),
+ ),
+ const SizedBox(height: 22),
+ Text(t.supportThanksTitle,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(22, weight: FontWeight.w800, color: gc.text, height: 1.2)),
+ const SizedBox(height: 8),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: Text(t.supportThanksBody,
+ textAlign: TextAlign.center,
+ style: AppTheme.f(14, weight: FontWeight.w500, color: gc.textSecondary, height: 1.45)),
+ ),
+ const SizedBox(height: 22),
];
}
}
+ Widget _subhead(GymColors gc, String label, {double top = 18}) => Padding(
+ padding: EdgeInsets.fromLTRB(6, top, 0, 10),
+ child: Text(label.toUpperCase(),
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4)),
+ );
+
Widget _card(GymColors gc, List<Widget> rows) => Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(26)),
@@ -593,6 +651,8 @@ class SettingsScreen extends StatelessWidget {
(t.heatmapLabelsSetting, PhosphorIconsRegular.gridNine),
(t.background, PhosphorIconsRegular.image),
(t.blurSetting, PhosphorIconsRegular.drop),
+ (t.textSizeSetting, PhosphorIconsRegular.textAa),
+ (t.calmMotionSetting, PhosphorIconsRegular.waveSine),
]),
_Category('training', PhosphorIconsRegular.barbell, _sectionTitle('training'), [
(t.restTimer, PhosphorIconsRegular.timer),
@@ -602,6 +662,8 @@ class SettingsScreen extends StatelessWidget {
(t.autoAdvance, PhosphorIconsRegular.skipForward),
(t.countdownSetting, PhosphorIconsRegular.timer),
(t.keepScreenOn, PhosphorIconsRegular.sun),
+ (t.checkInSetting, PhosphorIconsRegular.moon),
+ (t.miniBodySetting, PhosphorIconsRegular.person),
(t.multiPlanSetting, PhosphorIconsRegular.stack),
(t.levelHintsSetting, PhosphorIconsRegular.stairs),
(t.layoutSetting, PhosphorIconsRegular.rows),
@@ -638,11 +700,13 @@ class SettingsScreen extends StatelessWidget {
]),
_Category('data', PhosphorIconsRegular.database, _sectionTitle('data'), [
(t.exportCsv, PhosphorIconsRegular.fileCsv),
+ (t.reportTitle, PhosphorIconsRegular.fileText),
(t.exportBackup, PhosphorIconsRegular.fileZip),
(t.importBackup, PhosphorIconsRegular.downloadSimple),
(t.autoBackup, PhosphorIconsRegular.clockCounterClockwise),
(t.importFromApp, PhosphorIconsRegular.arrowSquareIn),
(t.stravaRow, PhosphorIconsRegular.export),
+ (t.clearWorkouts, PhosphorIconsRegular.barbell),
(t.resetData, PhosphorIconsRegular.trash),
]),
_Category('support', PhosphorIconsRegular.heart, _sectionTitle('support'), [
@@ -762,10 +826,7 @@ class SettingsScreen extends StatelessWidget {
final now = current();
return Container(
padding: sheetPad(sheet),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
+ decoration: sheetDecoration(gc),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -838,14 +899,14 @@ class SettingsScreen extends StatelessWidget {
),
child: Row(
children: [
- _rowIcon(gc, items[i].$1, color: i == danger ? gc.danger : null),
+ _rowIcon(gc, items[i].$1, color: danger != null && i >= danger ? gc.danger : null),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(items[i].$2,
style: AppTheme.f(14.5,
- weight: FontWeight.w500, color: i == danger ? gc.danger : gc.text)),
+ weight: FontWeight.w500, color: danger != null && i >= danger ? gc.danger : gc.text)),
if (hints != null && i < hints.length) ...[
const SizedBox(height: 2),
Text(hints[i],
@@ -879,6 +940,22 @@ class SettingsScreen extends StatelessWidget {
);
}
+ Future<void> _clearWorkouts(BuildContext context) async {
+ if (fit.sessions.isEmpty) {
+ _snack(context, t.clearWorkoutsNone);
+ return;
+ }
+ final ok = await askConfirm(
+ context,
+ title: t.clearWorkoutsTitle(fit.sessions.length),
+ body: t.clearWorkoutsBody,
+ confirmLabel: t.clearWorkoutsConfirm,
+ );
+ if (!ok) return;
+ fit.clearWorkouts();
+ if (context.mounted) _snack(context, t.clearWorkoutsDone);
+ }
+
Future<void> _resetAll(BuildContext context) async {
final ok = await askConfirm(
context,
@@ -979,10 +1056,7 @@ class SettingsScreen extends StatelessWidget {
isScrollControlled: true,
builder: (sheet) => Container(
padding: sheetPad(sheet),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
+ decoration: sheetDecoration(gc),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -1217,10 +1291,7 @@ class SettingsScreen extends StatelessWidget {
builder: (sheet) => StatefulBuilder(
builder: (sheet, setSheet) => Container(
padding: sheetPad(sheet),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
+ decoration: sheetDecoration(gc),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -1377,10 +1448,7 @@ class SettingsScreen extends StatelessWidget {
final photo = fit.bgPhotoPath;
return Container(
padding: sheetPad(sheet),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
+ decoration: sheetDecoration(gc),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -1567,10 +1635,7 @@ class _LanguageSheet extends StatelessWidget {
return Container(
constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(context).height * 0.66),
padding: sheetPad(context),
- decoration: BoxDecoration(
- color: context.gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
+ decoration: sheetDecoration(context.gc),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -1613,10 +1678,7 @@ class _AlarmSoundSheet extends StatelessWidget {
final current = fit.alarmSoundName ?? t.alarmDefaultName;
return Container(
padding: sheetPad(context),
- decoration: BoxDecoration(
- color: context.gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
+ decoration: sheetDecoration(context.gc),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -1667,13 +1729,10 @@ class _ProfileSheetState extends State<_ProfileSheet> {
Widget build(BuildContext context) {
final gc = context.gc;
final p = fit.profile;
- final sheet = fit.dark ? Color.lerp(gc.bg, gc.bgRaised, 0.55)! : gc.bg;
+ final sheet = gc.bgRaised;
return Container(
padding: EdgeInsets.fromLTRB(20, 12, 20, 20 + MediaQuery.of(context).viewInsets.bottom + MediaQuery.paddingOf(context).bottom),
- decoration: BoxDecoration(
- color: sheet,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(32)),
- ),
+ decoration: sheetDecoration(gc),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -1925,7 +1984,7 @@ class _ProfileSheetState extends State<_ProfileSheet> {
Widget _label(GymColors gc, String t) =>
Text(t.toUpperCase(),
- style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3));
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4));
Widget _row(GymColors gc, String label, Widget control) {
return ConstrainedBox(
diff --git a/lib/widgets/home_cards_panel.dart b/lib/widgets/home_cards_panel.dart
new file mode 100644
index 0000000..58dd0fa
--- /dev/null
+++ b/lib/widgets/home_cards_panel.dart
@@ -0,0 +1,247 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+import '../l10n/l10n.dart';
+import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import 'ui_kit.dart';
+
+class HomeCardsPanel extends StatelessWidget {
+ const HomeCardsPanel({super.key, required this.onSteps});
+
+ final VoidCallback onSteps;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final rows = <(String, bool, VoidCallback)>[
+ (t.homeCardFocus, fit.showFocus, fit.toggleFocusCard),
+ if (fit.stepsAvailable) (t.homeCardSteps, fit.stepsOn, onSteps),
+ (t.homeCardWeek, fit.showWeekStats, fit.toggleWeekStats),
+ (t.homeCardRoutines, fit.showRoutineRow, fit.toggleRoutineRow),
+ (t.homeCardRecommended, fit.showRecommended, fit.toggleRecommended),
+ ];
+ return Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ Container(
+ padding: const EdgeInsets.fromLTRB(18, 18, 14, 14),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(28)),
+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ Padding(
+ padding: const EdgeInsets.only(left: 2),
+ child: Text(t.homeCardsTitle,
+ style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.3)),
+ ),
+ const SizedBox(height: 14),
+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Expanded(
+ flex: 11,
+ child: Column(children: [
+ for (final (i, (label, on, tap)) in rows.indexed) ...[
+ if (i > 0) const SizedBox(height: 8),
+ Pressable(
+ scale: 0.97,
+ onTap: () {
+ HapticFeedback.selectionClick();
+ tap();
+ },
+ child: Container(
+ constraints: const BoxConstraints(minHeight: 46),
+ padding: const EdgeInsets.fromLTRB(14, 8, 8, 8),
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(16)),
+ child: Row(children: [
+ Expanded(
+ child: Text(label,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(13.5, weight: FontWeight.w700, color: on ? gc.text : gc.textSecondary)),
+ ),
+ const SizedBox(width: 6),
+ TinySwitch(on: on),
+ ]),
+ ),
+ ),
+ ],
+ ]),
+ ),
+ const SizedBox(width: 12),
+ Expanded(flex: 8, child: SizedBox(height: rows.length * 54.0 - 8, child: _HomeSketch(gc: gc))),
+ ]),
+ ]),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(6, 10, 6, 0),
+ child: Text(t.homeCardsHint, style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textTertiary)),
+ ),
+ ]);
+ }
+}
+
+class _HomeSketch extends StatelessWidget {
+ const _HomeSketch({required this.gc});
+
+ final GymColors gc;
+
+ Widget _bar(double w, double h, Color color) => Container(
+ width: w,
+ height: h,
+ decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(h)),
+ );
+
+ Widget _box(double h, {Widget? child, Color? color, EdgeInsets? pad}) => Container(
+ height: h,
+ padding: pad ?? const EdgeInsets.symmetric(horizontal: 8),
+ decoration: BoxDecoration(color: color ?? gc.bgRaised, borderRadius: BorderRadius.circular(10)),
+ child: child,
+ );
+
+ @override
+ Widget build(BuildContext context) {
+ final soft = gc.text.withValues(alpha: 0.22);
+ final blocks = <(bool, Widget)>[
+ (
+ fit.showFocus,
+ _box(58,
+ color: gc.bgRaised2.withValues(alpha: 1),
+ pad: const EdgeInsets.fromLTRB(9, 10, 9, 9),
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ _bar(46, 6, gc.text.withValues(alpha: 0.7)),
+ const SizedBox(height: 5),
+ _bar(30, 4, soft),
+ const Spacer(),
+ _bar(double.infinity, 11, gc.text),
+ ])),
+ ),
+ (
+ true,
+ _box(26,
+ child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
+ for (var i = 0; i < 7; i++)
+ Container(
+ width: 9,
+ height: 9,
+ decoration: BoxDecoration(shape: BoxShape.circle, color: i > 2 && i < 6 ? gc.text : gc.bgRaised2),
+ ),
+ ])),
+ ),
+ (
+ fit.stepsOn && fit.stepsAvailable,
+ _box(18,
+ child: Center(
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(3),
+ child: SizedBox(
+ height: 4,
+ child: Row(children: [
+ Expanded(flex: 6, child: ColoredBox(color: gc.sage)),
+ Expanded(flex: 4, child: ColoredBox(color: gc.bgRaised2)),
+ ]),
+ ),
+ ),
+ )),
+ ),
+ (
+ fit.showWeekStats,
+ _box(28,
+ child: Row(children: [
+ for (final w in [18.0, 12.0, 10.0]) ...[_bar(w, 6, gc.text.withValues(alpha: 0.6)), const SizedBox(width: 7)],
+ const Spacer(),
+ Container(
+ width: 12,
+ height: 12,
+ decoration: BoxDecoration(shape: BoxShape.circle, border: Border.all(color: gc.accent, width: 2)),
+ ),
+ ])),
+ ),
+ (
+ fit.showRoutineRow,
+ Row(children: [
+ for (final c in const [Color(0xFF8FB4DE), Color(0xFFDE9FB4)]) ...[
+ if (c == const Color(0xFFDE9FB4)) const SizedBox(width: 6),
+ Expanded(
+ child: _box(34,
+ pad: const EdgeInsets.fromLTRB(5, 5, 5, 0),
+ child: Align(
+ alignment: Alignment.topCenter,
+ child: _bar(double.infinity, 7, c.withValues(alpha: 0.75)),
+ )),
+ ),
+ ],
+ ]),
+ ),
+ (
+ true,
+ _box(40,
+ child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
+ for (var r = 0; r < 3; r++)
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 1.5),
+ child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
+ for (var c = 0; c < 9; c++)
+ Container(
+ width: 7,
+ height: 6,
+ decoration: BoxDecoration(
+ color: (r + c) % 3 == 0 ? gc.accent.withValues(alpha: 0.4 + c * 0.06) : gc.bgRaised2,
+ borderRadius: BorderRadius.circular(1.5),
+ ),
+ ),
+ ]),
+ ),
+ ])),
+ ),
+ (
+ fit.showRecommended,
+ Row(children: [
+ for (var i = 0; i < 3; i++) ...[
+ if (i > 0) const SizedBox(width: 5),
+ Expanded(child: _box(30)),
+ ],
+ ]),
+ ),
+ ];
+ return ExcludeSemantics(
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(20),
+ child: Container(
+ color: gc.bg,
+ padding: const EdgeInsets.fromLTRB(9, 12, 9, 0),
+ child: Stack(children: [
+ OverflowBox(
+ alignment: Alignment.topCenter,
+ maxHeight: double.infinity,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ Align(alignment: Alignment.centerLeft, child: _bar(40, 5, soft)),
+ const SizedBox(height: 9),
+ for (final (on, child) in blocks)
+ AnimatedSize(
+ duration: const Duration(milliseconds: 320),
+ curve: Curves.easeOutCubic,
+ alignment: Alignment.topCenter,
+ child: on
+ ? Padding(padding: const EdgeInsets.only(bottom: 6), child: child)
+ : const SizedBox(width: double.infinity),
+ ),
+ ]),
+ ),
+ Positioned(
+ left: 0,
+ right: 0,
+ bottom: 0,
+ height: 36,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [gc.bg.withValues(alpha: 0), gc.bg],
+ ),
+ ),
+ ),
+ ),
+ ]),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/widgets/home_widget_views.dart b/lib/widgets/home_widget_views.dart
index 58bce8c..882978e 100644
--- a/lib/widgets/home_widget_views.dart
+++ b/lib/widgets/home_widget_views.dart
@@ -213,8 +213,8 @@ class StatsWidgetView extends StatelessWidget {
Widget _chip(GymColors gc, String value, String label) {
return Expanded(
child: Container(
- height: 44,
- padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 9),
+ constraints: const BoxConstraints(minHeight: 44),
+ padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 9),
decoration: BoxDecoration(
color: gc.bgRaised2,
borderRadius: BorderRadius.circular(12),
diff --git a/lib/widgets/settings_showcase.dart b/lib/widgets/settings_showcase.dart
new file mode 100644
index 0000000..dc22922
--- /dev/null
+++ b/lib/widgets/settings_showcase.dart
@@ -0,0 +1,856 @@
+import 'dart:ui' as ui;
+
+import 'package:flutter/material.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+
+import '../l10n/l10n.dart';
+import '../models/gym_pass.dart';
+import '../state/fit_state.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+import 'charts.dart';
+import 'gym_pass_card.dart';
+import 'medal.dart';
+
+class _Collage extends StatelessWidget {
+ const _Collage({required this.columns, this.offset = Offset.zero});
+
+ final List<Widget> columns;
+ static const height = 380.0;
+ final Offset offset;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return ShowcaseDefer(
+ height: height,
+ child: ExcludeSemantics(
+ child: IgnorePointer(
+ child: SizedBox(
+ height: height,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(28),
+ child: ColoredBox(
+ color: gc.bgRaised,
+ child: OverflowBox(
+ maxWidth: 1000,
+ maxHeight: 1000,
+ child: Transform.translate(
+ offset: offset,
+ child: Transform.rotate(
+ angle: -0.16,
+ child: Transform.scale(
+ scale: 0.66,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ for (var i = 0; i < columns.length; i++) ...[
+ if (i > 0) const SizedBox(width: 10),
+ columns[i],
+ ],
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class ShowcaseDefer extends StatelessWidget {
+ const ShowcaseDefer({super.key, required this.height, required this.child});
+
+ final double height;
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) =>
+ RepaintBoundary(child: SizedBox(height: height, child: child));
+}
+
+Widget _lift(Widget child, {double radius = 24}) => DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(radius),
+ boxShadow: [BoxShadow(color: Colors.black.withValues(alpha: 0.3), blurRadius: 10, offset: const Offset(0, 6))],
+ ),
+ child: child,
+ );
+
+Widget _stack(double top, List<Widget> items) => Padding(
+ padding: EdgeInsets.only(top: top),
+ child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [
+ for (var i = 0; i < items.length; i++) ...[
+ if (i > 0) const SizedBox(height: 10),
+ items[i],
+ ],
+ ]),
+ );
+
+class _Tile extends StatelessWidget {
+ const _Tile({required this.w, required this.h, required this.child, this.pad = 16});
+
+ final double w;
+ final double h;
+ final Widget child;
+ final double pad;
+
+ @override
+ Widget build(BuildContext context) => _lift(Container(
+ width: w,
+ height: h,
+ padding: EdgeInsets.all(pad),
+ decoration: BoxDecoration(color: context.gc.bgRaised2, borderRadius: BorderRadius.circular(24)),
+ child: child,
+ ));
+}
+
+Widget _kicker(GymColors gc, String text) => Text(text.toUpperCase(),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3));
+
+Widget _big(GymColors gc, String text, {double size = 30, Color? color}) =>
+ Text(text, maxLines: 1, style: AppTheme.f(size, weight: FontWeight.w800, color: color ?? gc.text, height: 1.05));
+
+Widget _iconTile(GymColors gc, IconData icon, String value, String label, Color tone, {double h = 120}) => _Tile(
+ w: 150,
+ h: h,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Icon(icon, size: 24, color: tone),
+ const Spacer(),
+ _big(gc, value, size: 24),
+ if (label.isNotEmpty) _kicker(gc, label),
+ ]),
+ );
+
+const _sample = 'Aa';
+
+String _letter(int weekday) => t.weekdayShort(weekday).characters.first.toUpperCase();
+
+class _Ring extends StatelessWidget {
+ const _Ring({required this.value, required this.color, required this.child, this.size = 110});
+
+ final double value;
+ final Color color;
+ final Widget child;
+ final double size;
+
+ @override
+ Widget build(BuildContext context) => SizedBox(
+ width: size,
+ height: size,
+ child: Stack(alignment: Alignment.center, children: [
+ SizedBox.expand(
+ child: CircularProgressIndicator(
+ value: value,
+ strokeWidth: 9,
+ strokeCap: StrokeCap.round,
+ color: color,
+ backgroundColor: context.gc.bgRaised,
+ ),
+ ),
+ child,
+ ]),
+ );
+}
+
+class AlertsShowcase extends StatelessWidget {
+ const AlertsShowcase({super.key});
+
+ Widget _note(GymColors gc,
+ {required IconData icon,
+ required Color tone,
+ required String title,
+ required String body,
+ String when = '',
+ Widget? extra}) =>
+ _lift(Container(
+ width: 330,
+ padding: const EdgeInsets.fromLTRB(16, 14, 16, 16),
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(24)),
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Row(children: [
+ Container(
+ width: 22,
+ height: 22,
+ decoration: BoxDecoration(color: tone.withValues(alpha: 0.18), shape: BoxShape.circle),
+ child: Icon(icon, size: 12, color: tone),
+ ),
+ const SizedBox(width: 8),
+ Text('GymMane', style: AppTheme.f(12, weight: FontWeight.w700, color: gc.textSecondary)),
+ if (when.isNotEmpty)
+ Flexible(
+ child: Text(' · $when',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary)),
+ ),
+ ]),
+ const SizedBox(height: 10),
+ Text(title,
+ maxLines: 1, overflow: TextOverflow.ellipsis, style: AppTheme.f(16, weight: FontWeight.w800, color: gc.text)),
+ const SizedBox(height: 3),
+ Text(body,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(13.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),
+ ?extra,
+ ]),
+ ));
+
+ Widget _pill(GymColors gc, String label, {bool strong = false}) => Container(
+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
+ decoration: BoxDecoration(color: strong ? gc.text : gc.bgRaised, borderRadius: BorderRadius.circular(100)),
+ child: Text(label, style: AppTheme.f(12.5, weight: FontWeight.w800, color: strong ? gc.bg : gc.text)),
+ );
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final bell = _Tile(
+ w: 150,
+ h: 170,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Icon(PhosphorIconsRegular.bellRinging, size: 44, color: gc.sage),
+ const Spacer(),
+ _big(gc, '18:30'),
+ const SizedBox(height: 4),
+ _kicker(gc, '${_letter(1)} · ${_letter(3)} · ${_letter(5)}'),
+ ]),
+ );
+ final sound = _Tile(
+ w: 150,
+ h: 130,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Icon(PhosphorIconsRegular.speakerHigh, size: 30, color: gc.text),
+ const Spacer(),
+ Row(crossAxisAlignment: CrossAxisAlignment.end, children: [
+ for (final (i, v) in const [0.3, 0.6, 1.0, 0.7, 0.45, 0.85, 0.5, 0.3, 0.65, 0.4].indexed) ...[
+ if (i > 0) const SizedBox(width: 5),
+ Container(
+ width: 6,
+ height: 36 * v,
+ decoration: BoxDecoration(color: i < 6 ? gc.accent : gc.bgRaised, borderRadius: BorderRadius.circular(3)),
+ ),
+ ],
+ ]),
+ ]),
+ );
+ final vibrate = _Tile(
+ w: 150,
+ h: 110,
+ child: Center(child: Icon(PhosphorIconsRegular.vibrate, size: 48, color: gc.textSecondary)),
+ );
+ final live = _note(
+ gc,
+ icon: PhosphorIconsFill.barbell,
+ tone: gc.accent,
+ title: t.catalogName('EIeI8Vf', 'Barbell Bench Press'),
+ body: '${t.liveSet(3, 4)} · 80 kg × 8',
+ when: t.liveChannel,
+ extra: Padding(
+ padding: const EdgeInsets.only(top: 12),
+ child: Row(children: [
+ _pill(gc, t.liveDoneSet, strong: true),
+ const SizedBox(width: 8),
+ _pill(gc, t.liveSkipRest),
+ ]),
+ ),
+ );
+ final restNote = _note(gc,
+ icon: PhosphorIconsFill.timer, tone: gc.accent, title: t.restOverTitle, body: t.restOverBody, when: t.noteToday);
+ final island = _lift(
+ Container(
+ width: 330,
+ height: 64,
+ padding: const EdgeInsets.symmetric(horizontal: 10),
+ decoration: BoxDecoration(color: Colors.black, borderRadius: BorderRadius.circular(100)),
+ child: Row(children: [
+ Container(
+ width: 44,
+ height: 44,
+ decoration: BoxDecoration(color: gc.sage.withValues(alpha: 0.2), shape: BoxShape.circle),
+ child: Icon(PhosphorIconsFill.checkCircle, size: 22, color: gc.sage),
+ ),
+ const SizedBox(width: 12),
+ Expanded(
+ child: Text(t.notifTrainBody,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(14.5, weight: FontWeight.w700, color: Colors.white)),
+ ),
+ ]),
+ ),
+ radius: 100,
+ );
+ final timer = _Tile(
+ w: 150,
+ h: 190,
+ child: Center(
+ child: _Ring(
+ value: 0.62,
+ color: gc.accent,
+ size: 112,
+ child: Column(mainAxisSize: MainAxisSize.min, children: [
+ _big(gc, '1:24', size: 28),
+ const SizedBox(height: 2),
+ Text(t.liveResting, style: AppTheme.f(11, weight: FontWeight.w600, color: gc.accent)),
+ ]),
+ ),
+ ),
+ );
+ final supp = _Tile(
+ w: 150,
+ h: 140,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Row(children: [
+ Icon(PhosphorIconsRegular.pill, size: 26, color: gc.brass),
+ const Spacer(),
+ Text('10:00', style: AppTheme.f(13, weight: FontWeight.w700, color: gc.textSecondary)),
+ ]),
+ const Spacer(),
+ Text(t.suppCreatine, maxLines: 1, style: AppTheme.f(16, weight: FontWeight.w800, color: gc.text)),
+ Text('5 g', style: AppTheme.f(12.5, weight: FontWeight.w600, color: gc.textTertiary)),
+ ]),
+ );
+ final fast = _Tile(
+ w: 150,
+ h: 110,
+ child: Row(children: [
+ Icon(PhosphorIconsRegular.hourglassMedium, size: 30, color: gc.sage),
+ const SizedBox(width: 10),
+ _big(gc, '16 h', size: 26),
+ ]),
+ );
+ return _Collage(
+ offset: const Offset(22, -8),
+ columns: [
+ _stack(20, [bell, sound, vibrate, _iconTile(gc, PhosphorIconsRegular.bellSlash, '22:00', '', gc.textSecondary),
+ _iconTile(gc, PhosphorIconsRegular.alarm, '7:00', '', gc.accent)]),
+ _stack(0, [
+ restNote,
+ live,
+ island,
+ _note(gc,
+ icon: PhosphorIconsFill.camera,
+ tone: gc.info,
+ title: t.notifPhotoTitle,
+ body: t.notifPhotoBody(14),
+ when: '9:00'),
+ _Tile(
+ w: 330,
+ h: 100,
+ child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
+ for (final (icon, on) in [
+ (PhosphorIconsRegular.speakerSlash, false),
+ (PhosphorIconsRegular.vibrate, true),
+ (PhosphorIconsRegular.speakerHigh, false),
+ ])
+ Container(
+ width: 82,
+ height: 56,
+ decoration: BoxDecoration(color: on ? gc.text : gc.bgRaised, borderRadius: BorderRadius.circular(100)),
+ child: Icon(icon, size: 24, color: on ? gc.bg : gc.textSecondary),
+ ),
+ ]),
+ ),
+ _Tile(
+ w: 330,
+ h: 104,
+ child: Row(children: [
+ Icon(PhosphorIconsRegular.bellSimpleRinging, size: 26, color: gc.sage),
+ const SizedBox(width: 14),
+ Expanded(
+ child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
+ for (var d = 1; d <= 7; d++)
+ Container(
+ width: 30,
+ height: 30,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: const {1, 3, 5}.contains(d) ? gc.sage.withValues(alpha: 0.22) : gc.bgRaised,
+ ),
+ child: Text(_letter(d),
+ style: AppTheme.f(11.5,
+ weight: FontWeight.w800, color: const {1, 3, 5}.contains(d) ? gc.sage : gc.textTertiary)),
+ ),
+ ]),
+ ),
+ ]),
+ ),
+ ]),
+ _stack(40, [timer, supp, fast, _iconTile(gc, PhosphorIconsRegular.ruler, '14', t.notifMeasureTitle, gc.warn),
+ _iconTile(gc, PhosphorIconsRegular.drop, '1,5 L', '', gc.info)]),
+ ],
+ );
+ }
+}
+
+class HomeExtrasShowcase extends StatelessWidget {
+ const HomeExtrasShowcase({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ const pass = GymPass(id: 'demo', name: 'GymMane Fit', code: 'GYMMANE-2026-0042', hue: 0);
+ final steps = _Tile(
+ w: 150,
+ h: 170,
+ child: Center(
+ child: _Ring(
+ value: 0.78,
+ color: gc.sage,
+ size: 112,
+ child: Column(mainAxisSize: MainAxisSize.min, children: [
+ Icon(PhosphorIconsRegular.footprints, size: 18, color: gc.sage),
+ _big(gc, '6 240', size: 22),
+ Text(t.homeCardSteps, style: AppTheme.f(11, weight: FontWeight.w600, color: gc.textTertiary)),
+ ]),
+ ),
+ ),
+ );
+ final level = _Tile(
+ w: 150,
+ h: 130,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Row(children: [
+ Icon(PhosphorIconsRegular.medal, size: 22, color: gc.accent),
+ const Spacer(),
+ _big(gc, '7'),
+ ]),
+ const Spacer(),
+ ClipRRect(
+ borderRadius: BorderRadius.circular(4),
+ child: SizedBox(
+ height: 7,
+ child: Row(children: [
+ Expanded(
+ flex: 64,
+ child: DecoratedBox(decoration: BoxDecoration(gradient: LinearGradient(colors: [gc.accent, gc.brass]))),
+ ),
+ Expanded(flex: 36, child: ColoredBox(color: gc.bgRaised)),
+ ]),
+ ),
+ ),
+ ]),
+ );
+ final medal = _Tile(w: 150, h: 150, child: Center(child: Medal(id: AwardId.values[1], size: 96)));
+ final medalLocked = _Tile(w: 150, h: 150, child: Center(child: Medal(id: AwardId.values[6], size: 96, locked: true)));
+ final passCard = SizedBox(width: 330, child: _lift(const GymPassCard(pass: pass, hero: false), radius: 22));
+ final heart = _Tile(
+ w: 330,
+ h: 130,
+ pad: 0,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(24),
+ child: Stack(children: [
+ Positioned.fill(
+ top: 34,
+ child: CustomPaint(
+ painter: _Pulse(
+ const [64, 62, 63, 60, 61, 59, 60, 57, 58, 56, 58],
+ line: gc.accent,
+ grid: gc.text.withValues(alpha: 0.06),
+ dotRing: gc.bgRaised2,
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 14, 16, 0),
+ child: Row(children: [
+ Icon(PhosphorIconsFill.heart, size: 16, color: gc.accent),
+ const SizedBox(width: 6),
+ Expanded(child: _kicker(gc, t.healthRestingHr)),
+ Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [
+ _big(gc, '56', size: 26),
+ const SizedBox(width: 3),
+ Text(t.healthBpm, style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textSecondary)),
+ ]),
+ ]),
+ ),
+ ]),
+ ),
+ );
+ final week = _Tile(
+ w: 330,
+ h: 96,
+ child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
+ for (var d = 1; d <= 7; d++)
+ Column(mainAxisAlignment: MainAxisAlignment.center, children: [
+ Text(_letter(d), style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary)),
+ const SizedBox(height: 6),
+ Container(
+ width: 30,
+ height: 30,
+ decoration:
+ BoxDecoration(shape: BoxShape.circle, color: const {1, 3, 4, 6}.contains(d) ? gc.text : gc.bgRaised),
+ child: const {1, 3, 4, 6}.contains(d) ? Icon(PhosphorIconsBold.check, size: 14, color: gc.bg) : null,
+ ),
+ ]),
+ ]),
+ );
+ final streak = _Tile(
+ w: 150,
+ h: 130,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Icon(PhosphorIconsFill.flame, size: 24, color: gc.accent),
+ const Spacer(),
+ _big(gc, '12'),
+ _kicker(gc, t.streakCaps),
+ ]),
+ );
+ final sleep = _Tile(
+ w: 150,
+ h: 130,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Icon(PhosphorIconsRegular.moonStars, size: 24, color: gc.warn),
+ const Spacer(),
+ _big(gc, '7:42'),
+ _kicker(gc, t.unitHours),
+ ]),
+ );
+ return _Collage(
+ offset: const Offset(22, -8),
+ columns: [
+ _stack(20, [steps, level, medal, _iconTile(gc, PhosphorIconsRegular.fire, '520', 'kcal', gc.accent),
+ _iconTile(gc, PhosphorIconsRegular.scales, '78,4', 'kg', gc.textSecondary)]),
+ _stack(0, [
+ passCard,
+ heart,
+ week,
+ _Tile(
+ w: 330,
+ h: 120,
+ child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
+ for (final i in [2, 3, 4, 5]) Medal(id: AwardId.values[i], size: 70, locked: i == 5),
+ ]),
+ ),
+ _Tile(
+ w: 330,
+ h: 120,
+ child: Row(crossAxisAlignment: CrossAxisAlignment.end, children: [
+ for (final (i, v) in const [0.45, 0.8, 0.3, 1.0, 0.0, 0.65, 0.0].indexed) ...[
+ if (i > 0) const SizedBox(width: 10),
+ Expanded(
+ child: Column(mainAxisAlignment: MainAxisAlignment.end, children: [
+ Container(
+ height: 8 + 62 * v,
+ decoration: BoxDecoration(
+ color: v == 0 ? gc.bgRaised : (i == 3 ? gc.accent : gc.text.withValues(alpha: 0.55)),
+ borderRadius: BorderRadius.circular(6),
+ ),
+ ),
+ const SizedBox(height: 6),
+ Text(_letter(i + 1), style: AppTheme.f(10, weight: FontWeight.w700, color: gc.textTertiary)),
+ ]),
+ ),
+ ],
+ ]),
+ ),
+ ]),
+ _stack(40, [streak, sleep, medalLocked, _iconTile(gc, PhosphorIconsRegular.path, '4,2', 'km', gc.sage),
+ _iconTile(gc, PhosphorIconsRegular.trophy, '3', '', gc.brass)]),
+ ],
+ );
+ }
+}
+
+class LookShowcase extends StatelessWidget {
+ const LookShowcase({super.key});
+
+ static final _levels = [
+ for (var i = 0; i < 7 * 16; i++) const [0, 2, 0, 3, 1, 4, 0, 0, 2, 3, 0, 1, 4, 2][(i * 5 + i ~/ 7) % 14],
+ ];
+
+ static Widget _blob(Color c, double size) =>
+ Container(width: size, height: size, decoration: BoxDecoration(color: c, shape: BoxShape.circle));
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final now = DateTime.now();
+ final first = DateTime(now.year, now.month, now.day - now.weekday + 1 - 7 * 15);
+ Widget swatch(GymColors c) => Container(
+ width: 34,
+ height: 60,
+ padding: const EdgeInsets.all(5),
+ decoration: BoxDecoration(
+ color: c.bg,
+ borderRadius: BorderRadius.circular(12),
+ border: Border.all(color: gc.border),
+ ),
+ child: Column(children: [
+ Container(height: 14, decoration: BoxDecoration(color: c.bgRaised, borderRadius: BorderRadius.circular(4))),
+ const Spacer(),
+ Container(height: 8, decoration: BoxDecoration(color: c.accent, borderRadius: BorderRadius.circular(4))),
+ ]),
+ );
+ final themes = _Tile(
+ w: 150,
+ h: 130,
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
+ swatch(GymColors.dark),
+ swatch(GymColors.amoled),
+ swatch(GymColors.light),
+ ]),
+ const Spacer(),
+ _kicker(gc, t.theme),
+ ]),
+ );
+ final units = _Tile(
+ w: 150,
+ h: 110,
+ child: Center(
+ child: Container(
+ padding: const EdgeInsets.all(4),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(100)),
+ child: Row(mainAxisSize: MainAxisSize.min, children: [
+ Container(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
+ decoration: BoxDecoration(color: gc.text, borderRadius: BorderRadius.circular(100)),
+ child: Text('kg', style: AppTheme.f(16, weight: FontWeight.w800, color: gc.bg)),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: Text('lb', style: AppTheme.f(16, weight: FontWeight.w700, color: gc.textSecondary)),
+ ),
+ ]),
+ ),
+ ),
+ );
+ final text = _Tile(
+ w: 150,
+ h: 130,
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
+ children: [
+ for (final (size, tone) in [(17.0, gc.textTertiary), (26.0, gc.textSecondary), (37.0, gc.text)])
+ Text(_sample, style: AppTheme.f(size, weight: FontWeight.w800, color: tone, height: 1)),
+ ],
+ ),
+ );
+ final heat = _lift(Container(
+ width: 330,
+ padding: const EdgeInsets.fromLTRB(18, 16, 18, 16),
+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(24)),
+ child: Heatmap(levels: _levels, firstDay: first, labels: true),
+ ));
+ final languages = _Tile(
+ w: 330,
+ h: 104,
+ child: Wrap(spacing: 8, runSpacing: 8, children: [
+ for (final w in const ['Hola', 'Hello', 'Bonjour', 'Hallo', 'Ciao', 'Olá', 'Привет', '你好', 'مرحبا'])
+ Container(
+ padding: const EdgeInsets.symmetric(horizontal: 11, vertical: 6),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(100)),
+ child: Text(w,
+ style: AppTheme.f(13, weight: FontWeight.w700, color: w == 'Hola' ? gc.accent : gc.textSecondary)),
+ ),
+ ]),
+ );
+ final weekStart = _Tile(
+ w: 330,
+ h: 84,
+ child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
+ for (var d = 1; d <= 7; d++)
+ Container(
+ width: 34,
+ height: 34,
+ alignment: Alignment.center,
+ decoration: BoxDecoration(shape: BoxShape.circle, color: d == 1 ? gc.accent : gc.bgRaised),
+ child: Text(_letter(d),
+ style: AppTheme.f(12.5, weight: FontWeight.w800, color: d == 1 ? gc.onEmber : gc.textSecondary)),
+ ),
+ ]),
+ );
+ final dots = _Tile(
+ w: 150,
+ h: 150,
+ pad: 0,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(24),
+ child: CustomPaint(painter: _Dots(gc.text.withValues(alpha: 0.18)), child: const SizedBox.expand()),
+ ),
+ );
+ final blur = _Tile(
+ w: 150,
+ h: 130,
+ pad: 0,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(24),
+ child: Stack(children: [
+ Positioned.fill(
+ child: ImageFiltered(
+ imageFilter: ui.ImageFilter.blur(sigmaX: 14, sigmaY: 14),
+ child: Stack(children: [
+ Positioned(left: 20, top: 18, child: _blob(gc.accent, 70)),
+ Positioned(right: 16, bottom: 10, child: _blob(gc.info, 60)),
+ ]),
+ ),
+ ),
+ Positioned(
+ left: 14,
+ right: 14,
+ bottom: 14,
+ child: Container(
+ height: 26,
+ decoration:
+ BoxDecoration(color: gc.text.withValues(alpha: 0.12), borderRadius: BorderRadius.circular(100)),
+ ),
+ ),
+ ]),
+ ),
+ );
+ final motion = _Tile(
+ w: 150,
+ h: 110,
+ child: Center(child: Icon(PhosphorIconsRegular.waveSine, size: 48, color: gc.textSecondary)),
+ );
+ return _Collage(
+ offset: const Offset(22, -8),
+ columns: [
+ _stack(20, [themes, units, text, _iconTile(gc, PhosphorIconsRegular.translate, 'A文', '', gc.accent),
+ _iconTile(gc, PhosphorIconsRegular.clock, '18:30', '24 h', gc.textSecondary)]),
+ _stack(0, [
+ heat,
+ languages,
+ weekStart,
+ _Tile(
+ w: 330,
+ h: 110,
+ child: Row(children: [
+ Icon(PhosphorIconsRegular.calendarDots, size: 26, color: gc.textSecondary),
+ const SizedBox(width: 14),
+ _big(gc, '12', size: 28),
+ const SizedBox(width: 6),
+ Expanded(child: _kicker(gc, t.heatRangeSetting)),
+ ]),
+ ),
+ _Tile(
+ w: 330,
+ h: 120,
+ child: Row(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ Expanded(
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(16),
+ child: ColoredBox(
+ color: gc.bg,
+ child: CustomPaint(painter: _Dots(gc.text.withValues(alpha: 0.25)), child: const SizedBox.expand()),
+ ),
+ ),
+ ),
+ const SizedBox(width: 10),
+ Expanded(
+ child: Container(decoration: BoxDecoration(color: gc.bg, borderRadius: BorderRadius.circular(16))),
+ ),
+ const SizedBox(width: 10),
+ Expanded(
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(16),
+ gradient: LinearGradient(
+ begin: Alignment.topLeft,
+ end: Alignment.bottomRight,
+ colors: [gc.accent.withValues(alpha: 0.7), gc.info.withValues(alpha: 0.5), gc.bg],
+ ),
+ ),
+ child: Icon(PhosphorIconsRegular.image, size: 22, color: Colors.white.withValues(alpha: 0.8)),
+ ),
+ ),
+ ]),
+ ),
+ ]),
+ _stack(40, [dots, blur, motion, _iconTile(gc, PhosphorIconsRegular.sunHorizon, '', t.lightTheme, gc.warn),
+ _iconTile(gc, PhosphorIconsRegular.moon, '', t.darkTheme, gc.textSecondary)]),
+ ],
+ );
+ }
+}
+
+class _Dots extends CustomPainter {
+ _Dots(this.color);
+
+ final Color color;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final paint = Paint()..color = color;
+ for (var y = 12.0; y < size.height; y += 18) {
+ for (var x = 12.0; x < size.width; x += 18) {
+ canvas.drawCircle(Offset(x, y), 1.8, paint);
+ }
+ }
+ }
+
+ @override
+ bool shouldRepaint(_Dots old) => old.color != color;
+}
+
+class _Pulse extends CustomPainter {
+ _Pulse(this.values, {required this.line, required this.grid, required this.dotRing});
+
+ final List<double> values;
+ final Color line;
+ final Color grid;
+ final Color dotRing;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final lo = values.reduce((a, b) => a < b ? a : b) - 2;
+ final hi = values.reduce((a, b) => a > b ? a : b) + 2;
+ const left = 16.0, right = 24.0, top = 8.0, bottom = 14.0;
+ final w = size.width - left - right, h = size.height - top - bottom;
+ Offset at(int i) => Offset(left + w * i / (values.length - 1), top + h * (1 - (values[i] - lo) / (hi - lo)));
+ final gridPaint = Paint()
+ ..color = grid
+ ..strokeWidth = 1;
+ for (var k = 0; k < 3; k++) {
+ final y = top + h * k / 2;
+ canvas.drawLine(Offset(left, y), Offset(size.width - right, y), gridPaint);
+ }
+ final path = Path()..moveTo(at(0).dx, at(0).dy);
+ for (var i = 1; i < values.length; i++) {
+ final p = at(i - 1), q = at(i);
+ final mx = (p.dx + q.dx) / 2;
+ path.cubicTo(mx, p.dy, mx, q.dy, q.dx, q.dy);
+ }
+ final area = Path.from(path)
+ ..lineTo(at(values.length - 1).dx, size.height)
+ ..lineTo(at(0).dx, size.height)
+ ..close();
+ canvas.drawPath(
+ area,
+ Paint()
+ ..shader = LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [line.withValues(alpha: 0.32), line.withValues(alpha: 0)],
+ ).createShader(Offset.zero & size),
+ );
+ canvas.drawPath(
+ path,
+ Paint()
+ ..color = line
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 3
+ ..strokeCap = StrokeCap.round,
+ );
+ final end = at(values.length - 1);
+ canvas.drawCircle(end, 9, Paint()..color = line.withValues(alpha: 0.22));
+ canvas.drawCircle(end, 5.5, Paint()..color = line);
+ canvas.drawCircle(end, 2.5, Paint()..color = dotRing);
+ }
+
+ @override
+ bool shouldRepaint(_Pulse old) => old.line != line || old.grid != grid;
+}
diff --git a/lib/widgets/widget_showcase.dart b/lib/widgets/widget_showcase.dart
new file mode 100644
index 0000000..cca8fa0
--- /dev/null
+++ b/lib/widgets/widget_showcase.dart
@@ -0,0 +1,250 @@
+import 'package:flutter/material.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
+
+import '../l10n/l10n.dart';
+import '../theme/app_colors.dart';
+import 'home_widget_views.dart';
+import 'nutrition_art.dart';
+import 'settings_showcase.dart' show ShowcaseDefer;
+
+class WidgetShowcase extends StatelessWidget {
+ const WidgetShowcase({super.key, this.height = 380});
+
+ static bool _warm = false;
+
+ static void warm(BuildContext context) {
+ if (_warm) return;
+ _warm = true;
+ final h = (VesselWidgetGeometry.vesselHeight * MediaQuery.devicePixelRatioOf(context)).round();
+ for (final a in const [
+ 'assets/img/vessel-water.webp',
+ 'assets/img/vessel-water-mask.webp',
+ 'assets/img/vessel-shake.webp',
+ 'assets/img/vessel-shake-mask.webp',
+ ]) {
+ precacheImage(ResizeImage(AssetImage(a), height: h, policy: ResizeImagePolicy.fit), context);
+ }
+ precacheImage(const AssetImage('assets/img/shake-texture.webp'), context);
+ }
+
+ final double height;
+
+ static const _gap = 10.0;
+
+ static final _levels = [
+ for (var i = 0; i < 7 * 40; i++) const [0, 2, 0, 3, 1, 4, 0, 0, 2, 3, 0, 1, 4, 2][(i * 7 + i ~/ 9) % 14],
+ ];
+
+ static const _body = {
+ 'chest': 0.9,
+ 'shoulders': 0.6,
+ 'triceps': 0.7,
+ 'back': 0.8,
+ 'biceps': 0.5,
+ 'quads': 0.75,
+ 'glutes': 0.55,
+ 'hamstrings': 0.4,
+ 'abdomen': 0.3,
+ };
+
+ Widget _vessel(
+ GymColors gc, {
+ required String title,
+ required IconData icon,
+ required Color tone,
+ required Color liquid,
+ required String asset,
+ required double top,
+ required double bottom,
+ required double curve,
+ String? texture,
+ required String value,
+ required String goal,
+ required String pill,
+ required double level,
+ }) {
+ const g = VesselWidgetGeometry.size;
+ const column = VesselWidgetGeometry.columnRight - VesselWidgetGeometry.columnLeft;
+ return SizedBox(
+ width: g.width,
+ height: g.height,
+ child: Stack(children: [
+ VesselWidgetView(gc: gc, title: title, icon: icon, tone: tone, goal: goal, pill: pill),
+ Positioned(
+ left: VesselWidgetGeometry.vesselLeft,
+ top: VesselWidgetGeometry.vesselTop,
+ height: VesselWidgetGeometry.vesselHeight,
+ width: 56,
+ child: PhotoVessel(
+ asset: asset,
+ level: level,
+ height: VesselWidgetGeometry.vesselHeight,
+ top: top,
+ bottom: bottom,
+ curve: curve,
+ liquid: liquid,
+ texture: texture,
+ animate: false,
+ ),
+ ),
+ Positioned(
+ left: VesselWidgetGeometry.columnLeft,
+ top: VesselWidgetGeometry.valueBaseline - VesselWidgetGeometry.valueSize - 2,
+ child: Text(value,
+ style: TextStyle(
+ fontFamily: 'Nunito',
+ fontSize: VesselWidgetGeometry.valueSize,
+ height: 1.1,
+ fontWeight: FontWeight.w800,
+ color: gc.text)),
+ ),
+ Positioned(
+ left: VesselWidgetGeometry.columnLeft,
+ top: VesselWidgetGeometry.barTop,
+ width: column * level,
+ height: VesselWidgetGeometry.barHeight,
+ child: DecoratedBox(
+ decoration: BoxDecoration(color: tone, borderRadius: BorderRadius.circular(VesselWidgetGeometry.barHeight)),
+ ),
+ ),
+ ]),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ Widget lift(Widget child) => DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(24),
+ boxShadow: [BoxShadow(color: Colors.black.withValues(alpha: 0.3), blurRadius: 10, offset: const Offset(0, 6))],
+ ),
+ child: child,
+ );
+ Widget col(double top, List<Widget> items) => Padding(
+ padding: EdgeInsets.only(top: top),
+ child: Column(mainAxisSize: MainAxisSize.min, children: [
+ for (var i = 0; i < items.length; i++) ...[
+ if (i > 0) const SizedBox(height: _gap),
+ items[i] is Row || items[i] is Align ? items[i] : lift(items[i]),
+ ],
+ ]),
+ );
+
+ final small = col(0, [
+ Align(
+ alignment: Alignment.centerRight,
+ child: Transform.translate(
+ offset: const Offset(6, 0),
+ child: lift(TodayWidgetView(gc: gc, done: true, planned: true, streak: 12, size: const Size(112, 112))),
+ ),
+ ),
+ _vessel(gc,
+ title: t.waterLabel,
+ icon: PhosphorIconsFill.drop,
+ tone: gc.water,
+ liquid: const Color(0xFF4FB4F2),
+ asset: 'assets/img/vessel-water.webp',
+ top: 0.269,
+ bottom: 0.989,
+ curve: 0.08,
+ value: '1.5',
+ goal: '/ 2.5 L',
+ pill: '+ 250 ml',
+ level: 0.6),
+ _vessel(gc,
+ title: t.macroProtein,
+ icon: PhosphorIconsFill.lightning,
+ tone: gc.protein,
+ liquid: const Color(0xFFB98F72),
+ asset: 'assets/img/vessel-shake.webp',
+ top: 0.407,
+ bottom: 0.975,
+ curve: 0.066,
+ texture: 'assets/img/shake-texture.webp',
+ value: '96',
+ goal: '/ 150 g',
+ pill: '+ 24 g',
+ level: 0.64),
+ TodayWidgetView(gc: gc, done: false, planned: true, streak: 12, size: const Size(155, 155)),
+ ]);
+ final wide = col(40, [
+ HeatmapWidgetView(gc: gc, levels: _levels, streak: 12),
+ KcalWidgetView(
+ gc: gc,
+ kcal: 1640,
+ goal: 2400,
+ protein: 96,
+ carbs: 180,
+ fat: 52,
+ goals: (150, 260, 70),
+ unit: 'kcal',
+ ),
+ BodyWidgetView(gc: gc, intensity: _body, days: 7, size: const Size(320, 220)),
+ Align(
+ alignment: Alignment.centerRight,
+ child: lift(TodayWidgetView(gc: gc, done: false, planned: false, rest: true, streak: 12, size: const Size(130, 130))),
+ ),
+ ]);
+ final mixed = Padding(
+ padding: const EdgeInsets.only(top: 72),
+ child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [
+ lift(StatsWidgetView(gc: gc, streak: 12, sessionsThisWeek: 3, goalPct: 75, size: const Size(155, 172))),
+ const SizedBox(height: _gap),
+ lift(RotatedBox(
+ quarterTurns: 1,
+ child: WeekWidgetView(gc: gc, done: const [true, false, true, true, false, true, false], goal: 4, size: const Size(348, 155)),
+ )),
+ ]),
+ );
+
+ return ShowcaseDefer(
+ height: height,
+ child: ExcludeSemantics(
+ child: IgnorePointer(
+ child: SizedBox(
+ height: height,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(28),
+ child: ColoredBox(
+ color: gc.bgRaised,
+ child: OverflowBox(
+ maxWidth: 1000,
+ maxHeight: 1000,
+ child: Transform.translate(
+ offset: const Offset(16, -26),
+ child: Transform.rotate(
+ angle: -0.16,
+ child: Transform.scale(
+ scale: 0.66,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ width: 155,
+ height: 602,
+ child: OverflowBox(alignment: Alignment.topCenter, maxHeight: double.infinity, child: small),
+ ),
+ const SizedBox(width: _gap),
+ SizedBox(
+ width: 320,
+ height: 602,
+ child: OverflowBox(alignment: Alignment.topCenter, maxHeight: double.infinity, child: wide),
+ ),
+ const SizedBox(width: _gap),
+ mixed,
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/test/home_test.dart b/test/home_test.dart
index aba74e6..f2cf75c 100644
--- a/test/home_test.dart
+++ b/test/home_test.dart
@@ -6,6 +6,7 @@ import 'package:gymmane/services/local_store.dart';
import 'package:gymmane/state/fit_state.dart';
import 'package:gymmane/theme/app_colors.dart';
import 'package:gymmane/widgets/home_widget_views.dart';
+import 'package:gymmane/widgets/scroll_away.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
@@ -309,4 +310,99 @@ void main() {
});
});
});
+
+ group('tarjeta que se aleja', () {
+ Future<ScrollController> pump(WidgetTester tester) async {
+ final ctrl = ScrollController();
+ await tester.pumpWidget(MaterialApp(
+ home: Scaffold(
+ body: SingleChildScrollView(
+ controller: ctrl,
+ child: Column(children: [
+ const SizedBox(height: 80),
+ const ScrollAway(child: SizedBox(key: Key('card'), height: 200)),
+ const SizedBox(height: 2000),
+ ]),
+ ),
+ ),
+ ));
+ await tester.pump();
+ return ctrl;
+ }
+
+ double progress(WidgetTester tester) =>
+ tester.state<ScrollAwayState>(find.byType(ScrollAway)).progress.value;
+
+ double opacity(WidgetTester tester) => tester
+ .widget<Opacity>(find.descendant(of: find.byType(ScrollAway), matching: find.byType(Opacity)))
+ .opacity;
+
+ testWidgets('quieta arriba, a medias al bajar y del todo cuando sale', (tester) async {
+ final ctrl = await pump(tester);
+ expect(progress(tester), 0);
+ expect(opacity(tester), 1);
+
+ ctrl.jumpTo(10);
+ await tester.pump();
+ expect(progress(tester), 0);
+
+ ctrl.jumpTo(148);
+ await tester.pump();
+ expect(progress(tester), closeTo(0.5, 0.001));
+ expect(opacity(tester), inExclusiveRange(0, 1));
+
+ ctrl.jumpTo(600);
+ await tester.pump();
+ expect(progress(tester), 1);
+ expect(opacity(tester), 0);
+
+ ctrl.jumpTo(0);
+ await tester.pump();
+ expect(progress(tester), 0);
+ expect(opacity(tester), 1);
+ });
+
+ testWidgets('en cascada: cada tarjeta espera a llegar arriba para irse', (tester) async {
+ final ctrl = ScrollController();
+ await tester.pumpWidget(MaterialApp(
+ home: Scaffold(
+ body: SingleChildScrollView(
+ controller: ctrl,
+ child: const Column(children: [
+ ScrollAway(key: Key('a'), child: SizedBox(height: 200)),
+ ScrollAway(key: Key('b'), child: SizedBox(height: 200)),
+ SizedBox(height: 2000),
+ ]),
+ ),
+ ),
+ ));
+ await tester.pump();
+ double of(String k) => tester.state<ScrollAwayState>(find.byKey(Key(k))).progress.value;
+
+ ctrl.jumpTo(100);
+ await tester.pump();
+ expect(of('a'), closeTo(0.5, 0.001));
+ expect(of('b'), 0);
+
+ ctrl.jumpTo(130);
+ await tester.pump();
+ expect(of('b'), 0);
+
+ ctrl.jumpTo(300);
+ await tester.pump();
+ expect(of('a'), 1);
+ expect(of('b'), inExclusiveRange(0, 1));
+ });
+
+ testWidgets('sin animaciones del sistema no se mueve', (tester) async {
+ await tester.pumpWidget(const MediaQuery(
+ data: MediaQueryData(disableAnimations: true),
+ child: Directionality(
+ textDirection: TextDirection.ltr,
+ child: SingleChildScrollView(child: ScrollAway(child: SizedBox(height: 200))),
+ ),
+ ));
+ expect(find.byType(Transform), findsNothing);
+ });
+ });
}