Skip to content

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

New Settings home with search and row descriptions

InlitX0512c005382a
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 0964e14..211da34 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -1,9 +1,12 @@
+import 'dart:async';
import 'dart:convert';
import 'dart:io';
-import 'dart:typed_data';
+import 'dart:math' as math;
+import 'dart:ui' as ui;
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:home_widget/home_widget.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart';
@@ -32,12 +35,15 @@ import '../widgets/file_thumb.dart';
import '../widgets/glass.dart';
import '../widgets/liquid_notch.dart';
import '../widgets/photo_source_sheet.dart';
+import '../widgets/sheet_page.dart';
import '../widgets/profile_avatar.dart';
import '../widgets/ruler_picker.dart';
import '../widgets/timer_panel.dart';
import 'profile_screen.dart';
import 'strava_sheet.dart';
+import '../widgets/health_cards.dart';
import '../widgets/steps_card.dart';
+import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
const _kRepoUrl = 'https://github.com/InlitX/GymMane';
@@ -46,383 +52,494 @@ const _kFeatureUrl = '$_kRepoUrl/issues/new?labels=enhancement';
const _kKofiUrl = 'https://ko-fi.com/inlitx';
class SettingsScreen extends StatelessWidget {
- const SettingsScreen({super.key});
+ const SettingsScreen({super.key, this.section});
+
+ final String? section;
@override
Widget build(BuildContext context) {
final gc = context.gc;
+ final id = section;
+ if (id == null) return _SettingsHome(screen: this);
return RiseScope(
- id: 'settings',
+ id: 'settings-$id',
once: false,
- child: SafeArea(
- bottom: false,
- child: SingleChildScrollView(
- clipBehavior: Clip.none,
- padding: const EdgeInsets.fromLTRB(20, 12, 20, 32),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: riseAll([
- ScreenHeader(title: t.settings, onBack: fit.backFromPreferences),
- const SizedBox(height: 20),
- _group(gc, t.sectionGeneral, [
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.moon,
- t.theme,
- [
- ('system', t.themeAuto, PhosphorIconsRegular.circleHalf),
- ('dark', t.darkTheme, PhosphorIconsRegular.moon),
- ('amoled', t.amoledTheme, PhosphorIconsRegular.moonStars),
- ('light', t.lightTheme, PhosphorIconsRegular.sun),
- ],
- () => fit.themePref,
- fit.setThemePref,
- hint: t.themeAutoHint,
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => _editLanguage(context),
- child: _prefRow(
- gc,
- PhosphorIconsRegular.translate,
- t.languageLabel,
- Row(mainAxisSize: MainAxisSize.min, children: [
- Text(
- languageNameOf(fit.language),
- style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),
+ child: SheetPage(
+ title: titleCase(_sectionTitle(id)),
+ eyebrow: t.settings,
+ onBack: fit.popRoute,
+ children: riseAll(_sectionBody(context, gc, id)),
+ ),
+ );
+ }
+
+ List<Widget> _sectionBody(BuildContext context, GymColors gc, String id) {
+ switch (id) {
+ case 'general':
+ return [
+ _card(gc, [
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.moon,
+ t.theme,
+ [
+ ('system', t.themeAuto, PhosphorIconsRegular.circleHalf),
+ ('dark', t.darkTheme, PhosphorIconsRegular.moon),
+ ('amoled', t.amoledTheme, PhosphorIconsRegular.moonStars),
+ ('light', t.lightTheme, PhosphorIconsRegular.sun),
+ ],
+ () => fit.themePref,
+ fit.setThemePref,
+ hint: t.themeAutoHint,
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _editLanguage(context),
+ child: _prefRow(
+ gc,
+ PhosphorIconsRegular.translate,
+ t.languageLabel,
+ Row(mainAxisSize: MainAxisSize.min, children: [
+ Text(
+ languageNameOf(fit.language),
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),
+ ),
+ const SizedBox(width: 6),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ]),
),
- const SizedBox(width: 6),
- Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
- ]),
- ),
- ),
- _prefRow(gc, PhosphorIconsRegular.scales, t.unitsLabel, SegToggle([
- SegOption('kg', fit.units == 'kg', () => fit.setUnits('kg')),
- SegOption('lb', fit.units == 'lb', () => fit.setUnits('lb')),
- ])),
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.calendarBlank,
- t.weekStartSetting,
- [for (final d in SettingsState.weekStarts) ('$d', t.weekday(d), PhosphorIconsRegular.calendarBlank)],
- () => '${fit.weekStartDay}',
- (v) => fit.setWeekStart(int.parse(v)),
- ),
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.calendarDots,
- t.heatRangeSetting,
- [
- ('weeks', t.heatRangeWeeks, PhosphorIconsRegular.squaresFour),
- ('year', t.heatRangeYear, PhosphorIconsRegular.calendarDots),
- ],
- () => fit.heatmapRange,
- fit.setHeatmapRange,
- hint: t.heatRangeHint,
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleHeatmapLabels,
- child: _prefRow(gc, PhosphorIconsRegular.gridNine, t.heatmapLabelsSetting,
- TinySwitch(on: fit.heatmapLabels)),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => _editBackground(context),
- child: _prefRow(
- gc,
- PhosphorIconsRegular.image,
- t.background,
- Row(mainAxisSize: MainAxisSize.min, children: [
- Text(_bgName(fit.bgPattern),
- style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary)),
- const SizedBox(width: 6),
- Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
- ]),
- ),
- ),
- ]),
- const SizedBox(height: 18),
- _group(gc, t.sectionTraining, [
- _prefRow(
- gc,
- PhosphorIconsRegular.timer,
- t.restTimer,
- StepperControl(
- value: fit.restSeconds == 0 ? t.restOff : clockLabel(fit.restSeconds),
- minWidth: 48,
- btnSize: 28,
- gap: 10,
- fontSize: 14,
- onDec: () => fit.setRestSeconds(fit.restSeconds - 15),
- onInc: () => fit.setRestSeconds(fit.restSeconds + 15),
- onEdit: () async {
- final v = await askRuler(context,
- title: t.restTimer,
- value: fit.restSeconds.toDouble(),
- min: 0,
- max: 600,
- step: 5,
- majorEvery: 6,
- format: (v) => clockLabel(v.round()),
- tickLabel: (v) => clockLabel(v.round()));
- if (v != null) fit.setRestSeconds(v.round());
- },
- ),
- hint: t.restRowHint,
- ),
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.gauge,
- t.effortSetting,
- [
- ('', t.restOff, PhosphorIconsRegular.prohibit),
- ('rpe', 'RPE', PhosphorIconsRegular.gauge),
- ('rir', 'RIR', PhosphorIconsRegular.arrowCounterClockwise),
- ],
- () => fit.effortMode,
- fit.setEffortMode,
- hint: t.effortHint,
- rowHint: t.effortRowHint,
- ),
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.barbell,
- t.weightStepSetting,
- [for (final s in fit.weightSteps) ('$s', '${fmt(s)} ${fit.units}', PhosphorIconsRegular.barbell)],
- () => '${fit.weightStep}',
- (v) => fit.setWeightStep(double.parse(v)),
- rowHint: t.weightStepHint,
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleAutoAdvance,
- child: _prefRow(gc, PhosphorIconsRegular.skipForward, t.autoAdvance,
- TinySwitch(on: fit.autoAdvance), hint: t.autoAdvanceHint),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleStartCountdown,
- child: _prefRow(gc, PhosphorIconsRegular.timer, t.countdownSetting,
- TinySwitch(on: fit.startCountdown), hint: t.countdownHint),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleKeepScreenOn,
- child: _prefRow(gc, PhosphorIconsRegular.sun, t.keepScreenOn,
- TinySwitch(on: fit.keepScreenOn), hint: t.keepScreenOnHint),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleMultiPlan,
- child: _prefRow(gc, PhosphorIconsRegular.stack, t.multiPlanSetting,
- TinySwitch(on: fit.multiPlan), hint: t.multiPlanSettingHint),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleLevelHints,
- child: _prefRow(gc, PhosphorIconsRegular.stairs, t.levelHintsSetting,
- TinySwitch(on: fit.levelHints), hint: t.levelHintsHint),
- ),
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.rows,
- t.layoutSetting,
- [
- ('cards', t.layoutCards, PhosphorIconsRegular.cards),
- ('list', t.layoutList, PhosphorIconsRegular.listBullets),
- ],
- () => fit.sessionLayout,
- fit.setSessionLayout,
- hint: t.layoutHint,
- rowHint: t.layoutRowHint,
- ),
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.filmStrip,
- t.demoSizeTitle,
- [
- ('large', t.demoLarge, PhosphorIconsRegular.rectangle),
- ('small', t.demoSmall, PhosphorIconsRegular.square),
- ('off', t.demoOff, PhosphorIconsRegular.eyeSlash),
- ],
- () => fit.demoSize,
- fit.setDemoSize,
- rowHint: t.demoSizeRowHint,
- ),
- if (fit.demoSize != 'off')
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.repeat,
- t.demoLoopTitle,
- [
- ('always', t.demoLoopAlways, PhosphorIconsRegular.repeat),
- ('short', t.demoLoopShort, PhosphorIconsRegular.timer),
- ],
- () => fit.demoLoop,
- fit.setDemoLoop,
- hint: t.demoLoopHint,
- rowHint: t.demoLoopRowHint,
- ),
- ]),
- const SizedBox(height: 18),
- _linkGroup(gc, [
+ ),
+ _prefRow(gc, PhosphorIconsRegular.scales, t.unitsLabel, SegToggle([
+ SegOption('kg', fit.units == 'kg', () => fit.setUnits('kg')),
+ SegOption('lb', fit.units == 'lb', () => fit.setUnits('lb')),
+ ])),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.calendarBlank,
+ t.weekStartSetting,
+ [for (final d in SettingsState.weekStarts) ('$d', t.weekday(d), PhosphorIconsRegular.calendarBlank)],
+ () => '${fit.weekStartDay}',
+ (v) => fit.setWeekStart(int.parse(v)),
+ ),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.calendarDots,
+ t.heatRangeSetting,
+ [
+ ('weeks', t.heatRangeWeeks, PhosphorIconsRegular.squaresFour),
+ ('year', t.heatRangeYear, PhosphorIconsRegular.calendarDots),
+ ],
+ () => fit.heatmapRange,
+ fit.setHeatmapRange,
+ hint: t.heatRangeHint,
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleHeatmapLabels,
+ child: _prefRow(gc, PhosphorIconsRegular.gridNine, t.heatmapLabelsSetting,
+ TinySwitch(on: fit.heatmapLabels)),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _editBackground(context),
+ child: _prefRow(
+ gc,
+ PhosphorIconsRegular.image,
+ t.background,
+ Row(mainAxisSize: MainAxisSize.min, children: [
+ Text(_bgName(fit.bgPattern),
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary)),
+ const SizedBox(width: 6),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ]),
+ ),
+ ),
+
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.setBlur(!fit.blurOn),
+ child: _prefRow(gc, PhosphorIconsRegular.drop, t.blurSetting, TinySwitch(on: fit.blurOn),
+ hint: t.blurSettingHint),
+ ),
+ ]),
+ ];
+ case 'training':
+ return [
+ _card(gc, [
+ _prefRow(
+ gc,
+ PhosphorIconsRegular.timer,
+ t.restTimer,
+ StepperControl(
+ value: fit.restSeconds == 0 ? t.restOff : clockLabel(fit.restSeconds),
+ minWidth: 48,
+ btnSize: 28,
+ gap: 10,
+ fontSize: 14,
+ onDec: () => fit.setRestSeconds(fit.restSeconds - 15),
+ onInc: () => fit.setRestSeconds(fit.restSeconds + 15),
+ onEdit: () async {
+ final v = await askRuler(context,
+ title: t.restTimer,
+ value: fit.restSeconds.toDouble(),
+ min: 0,
+ max: 600,
+ step: 5,
+ majorEvery: 6,
+ format: (v) => clockLabel(v.round()),
+ tickLabel: (v) => clockLabel(v.round()));
+ if (v != null) fit.setRestSeconds(v.round());
+ },
+ ),
+ hint: t.restRowHint,
+ ),
+ _prefRow(
+ gc,
+ PhosphorIconsRegular.timer,
+ t.miniRest,
+ StepperControl(
+ value: fit.miniRestSeconds == 0 ? t.restOff : clockLabel(fit.miniRestSeconds),
+ minWidth: 48,
+ btnSize: 28,
+ gap: 10,
+ fontSize: 14,
+ onDec: () => fit.setMiniRest(fit.miniRestSeconds - 5),
+ onInc: () => fit.setMiniRest(fit.miniRestSeconds + 5),
+ onEdit: () async {
+ final v = await askRuler(context,
+ title: t.miniRest,
+ value: fit.miniRestSeconds.toDouble(),
+ min: 0,
+ max: 180,
+ step: 5,
+ majorEvery: 6,
+ format: (v) => clockLabel(v.round()),
+ tickLabel: (v) => clockLabel(v.round()));
+ if (v != null) fit.setMiniRest(v.round());
+ },
+ ),
+ hint: t.miniRestHint,
+ ),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.gauge,
+ t.effortSetting,
+ [
+ ('', t.restOff, PhosphorIconsRegular.prohibit),
+ ('rpe', 'RPE', PhosphorIconsRegular.gauge),
+ ('rir', 'RIR', PhosphorIconsRegular.arrowCounterClockwise),
+ ],
+ () => fit.effortMode,
+ fit.setEffortMode,
+ hint: t.effortHint,
+ rowHint: t.effortRowHint,
+ ),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.barbell,
+ t.weightStepSetting,
+ [for (final s in fit.weightSteps) ('$s', '${fmt(s)} ${fit.units}', PhosphorIconsRegular.barbell)],
+ () => '${fit.weightStep}',
+ (v) => fit.setWeightStep(double.parse(v)),
+ rowHint: t.weightStepHint,
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleAutoAdvance,
+ child: _prefRow(gc, PhosphorIconsRegular.skipForward, t.autoAdvance,
+ TinySwitch(on: fit.autoAdvance), hint: t.autoAdvanceHint),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleStartCountdown,
+ child: _prefRow(gc, PhosphorIconsRegular.timer, t.countdownSetting,
+ TinySwitch(on: fit.startCountdown), hint: t.countdownHint),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleKeepScreenOn,
+ child: _prefRow(gc, PhosphorIconsRegular.sun, t.keepScreenOn,
+ TinySwitch(on: fit.keepScreenOn), hint: t.keepScreenOnHint),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleMultiPlan,
+ child: _prefRow(gc, PhosphorIconsRegular.stack, t.multiPlanSetting,
+ TinySwitch(on: fit.multiPlan), hint: t.multiPlanSettingHint),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleLevelHints,
+ child: _prefRow(gc, PhosphorIconsRegular.stairs, t.levelHintsSetting,
+ TinySwitch(on: fit.levelHints), hint: t.levelHintsHint),
+ ),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.rows,
+ t.layoutSetting,
+ [
+ ('cards', t.layoutCards, PhosphorIconsRegular.cards),
+ ('list', t.layoutList, PhosphorIconsRegular.listBullets),
+ ],
+ () => fit.sessionLayout,
+ fit.setSessionLayout,
+ hint: t.layoutHint,
+ rowHint: t.layoutRowHint,
+ ),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.filmStrip,
+ t.demoSizeTitle,
+ [
+ ('large', t.demoLarge, PhosphorIconsRegular.rectangle),
+ ('small', t.demoSmall, PhosphorIconsRegular.square),
+ ('off', t.demoOff, PhosphorIconsRegular.eyeSlash),
+ ],
+ () => fit.demoSize,
+ fit.setDemoSize,
+ rowHint: t.demoSizeRowHint,
+ ),
+ if (fit.demoSize != 'off')
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.repeat,
+ t.demoLoopTitle,
+ [
+ ('always', t.demoLoopAlways, PhosphorIconsRegular.repeat),
+ ('short', t.demoLoopShort, PhosphorIconsRegular.timer),
+ ],
+ () => fit.demoLoop,
+ fit.setDemoLoop,
+ hint: t.demoLoopHint,
+ rowHint: t.demoLoopRowHint,
+ ),
+
+ ]),
+ const SizedBox(height: 18),
+ _linkGroup(gc, [
(PhosphorIconsRegular.mapPin, t.placesLabel, fit.goPlaces),
- ]),
- const SizedBox(height: 18),
- _group(gc, t.sectionAlerts, [
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => _editTrainReminder(context),
- child: _prefRow(
- gc,
- PhosphorIconsRegular.bellSimple,
- t.trainReminder,
- Row(mainAxisSize: MainAxisSize.min, children: [
- Flexible(
- child: Text(
- _reminderValue(context),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.right,
- style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),
- ),
+ ]),
+ ];
+ case 'alerts':
+ return [
+ _card(gc, [
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _editTrainReminder(context),
+ child: _prefRow(
+ gc,
+ PhosphorIconsRegular.bellSimple,
+ t.trainReminder,
+ Row(mainAxisSize: MainAxisSize.min, children: [
+ Flexible(
+ child: Text(
+ _reminderValue(context),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.right,
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),
+ ),
+ ),
+ const SizedBox(width: 6),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ]),
+ hint: t.trainReminderRowHint,
),
- const SizedBox(width: 6),
- Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
- ]),
- hint: t.trainReminderRowHint,
- ),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => _editAlarmSound(context),
- child: _prefRow(
- gc,
- PhosphorIconsRegular.speakerHigh,
- t.alarmSound,
- Row(mainAxisSize: MainAxisSize.min, children: [
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 128),
- child: Text(
- fit.alarmSoundName ?? t.alarmDefaultName,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.right,
- style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),
- ),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => _editAlarmSound(context),
+ child: _prefRow(
+ gc,
+ PhosphorIconsRegular.speakerHigh,
+ t.alarmSound,
+ Row(mainAxisSize: MainAxisSize.min, children: [
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 128),
+ child: Text(
+ fit.alarmSoundName ?? t.alarmDefaultName,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.right,
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary),
+ ),
+ ),
+ const SizedBox(width: 6),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
+ ]),
+ hint: t.alarmSoundRowHint,
+ ),
+ ),
+ _choiceRow(
+ context,
+ gc,
+ PhosphorIconsRegular.vibrate,
+ t.alarmStyleTitle,
+ [
+ ('loud', t.alarmStyleLoud, PhosphorIconsRegular.bellRinging),
+ ('quiet', t.alarmStyleQuiet, PhosphorIconsRegular.bellSimpleSlash),
+ ('vibrate', t.alarmStyleVibrate, PhosphorIconsRegular.vibrate),
+ ],
+ () => fit.alarmStyle,
+ fit.setAlarmStyle,
+ hint: t.alarmStyleHint,
+ rowHint: t.alarmStyleRowHint,
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleToastSound,
+ child: _prefRow(gc, PhosphorIconsRegular.bellSimple, t.toastSoundSetting,
+ TinySwitch(on: fit.toastSound), hint: t.toastSoundHint),
+ ),
+ if (!fit.alarmAllowed) ...[
+ const SizedBox(height: 14),
+ _alarmWarning(context, gc),
+ const SizedBox(height: 14),
+ ],
+
+ ]),
+ ];
+ case 'home':
+ return [
+ _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,
+ onTap: () => showHealthPicker(context),
+ child: _prefRow(
+ gc,
+ PhosphorIconsRegular.heartbeat,
+ t.healthSetting,
+ Row(mainAxisSize: MainAxisSize.min, children: [
+ if (fit.healthShown.isNotEmpty)
+ Text('${fit.healthShown.length}',
+ style: AppTheme.f(13.5, weight: FontWeight.w700, color: gc.textSecondary)),
+ const SizedBox(width: 6),
+ Icon(PhosphorIconsBold.caretRight, size: 14, color: gc.textTertiary),
+ ]),
+ hint: t.healthSettingHint),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.toggleGamification,
+ child: _prefRow(gc, PhosphorIconsRegular.medal, t.gamificationSetting,
+ TinySwitch(on: fit.gamification), hint: t.gamificationHint),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: fit.togglePass,
+ child: _prefRow(gc, PhosphorIconsRegular.qrCode, t.gymPass,
+ TinySwitch(on: fit.passOn), hint: t.gymPassSettingHint),
+ ),
+
+ ]),
+ ];
+ case 'beta':
+ return [
+ _card(gc, [
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.setNutritionBeta(!fit.nutritionBeta),
+ child: _prefRow(gc, PhosphorIconsRegular.forkKnife, t.nutritionBeta,
+ TinySwitch(on: fit.nutritionBeta),
+ hint: t.nutritionBetaHint,
+ badge: BetaTag(t.sectionBeta, small: true)),
+ ),
+
+ ]),
+ const SizedBox(height: 28),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(4, 0, 0, 12),
+ child: Text(t.nutritionAboutTitle.toUpperCase(),
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4)),
+ ),
+ Container(
+ padding: const EdgeInsets.fromLTRB(16, 4, 16, 18),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(26)),
+ child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
+ for (final (icon, title, body) in [
+ (PhosphorIconsRegular.barbell, t.nutritionAboutWhatTitle, t.nutritionAboutWhat),
+ (PhosphorIconsRegular.shieldCheck, t.nutritionAboutScanTitle, t.nutritionAboutScan),
+ (PhosphorIconsRegular.deviceMobile, t.nutritionAboutLocalTitle, t.nutritionAboutLocal),
+ (PhosphorIconsRegular.flask, t.nutritionAboutBetaTitle, t.nutritionAboutBeta),
+ ])
+ Padding(
+ padding: const EdgeInsets.only(top: 14),
+ child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ _rowIcon(gc, icon),
+ Expanded(
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ const SizedBox(height: 2),
+ Text(title, style: AppTheme.f(14.5, weight: FontWeight.w700, color: gc.text)),
+ const SizedBox(height: 3),
+ Text(body,
+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary, height: 1.45)),
+ ]),
),
- const SizedBox(width: 6),
- Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
]),
- hint: t.alarmSoundRowHint,
),
- ),
- _choiceRow(
- context,
- gc,
- PhosphorIconsRegular.vibrate,
- t.alarmStyleTitle,
- [
- ('loud', t.alarmStyleLoud, PhosphorIconsRegular.bellRinging),
- ('quiet', t.alarmStyleQuiet, PhosphorIconsRegular.bellSimpleSlash),
- ('vibrate', t.alarmStyleVibrate, PhosphorIconsRegular.vibrate),
- ],
- () => fit.alarmStyle,
- fit.setAlarmStyle,
- hint: t.alarmStyleHint,
- rowHint: t.alarmStyleRowHint,
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleToastSound,
- child: _prefRow(gc, PhosphorIconsRegular.bellSimple, t.toastSoundSetting,
- TinySwitch(on: fit.toastSound), hint: t.toastSoundHint),
- ),
- if (!fit.alarmAllowed) ...[
- const SizedBox(height: 14),
- _alarmWarning(context, gc),
- const SizedBox(height: 14),
- ],
]),
- const SizedBox(height: 18),
- _group(gc, t.sectionHome, [
- 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),
- ),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: fit.toggleGamification,
- child: _prefRow(gc, PhosphorIconsRegular.medal, t.gamificationSetting,
- TinySwitch(on: fit.gamification), hint: t.gamificationHint),
- ),
- ]),
- const SizedBox(height: 18),
- _group(gc, t.sectionBeta, [
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => fit.setNutritionBeta(!fit.nutritionBeta),
- child: _prefRow(gc, PhosphorIconsRegular.forkKnife, t.nutritionBeta,
- TinySwitch(on: fit.nutritionBeta),
- hint: t.nutritionBetaHint,
- badge: BetaTag(t.sectionBeta, small: true)),
- ),
- ]),
- const SizedBox(height: 18),
- if (Platform.isAndroid || Platform.isIOS) ...[
- _sectionLabel(gc, t.sectionWidgets),
- const SizedBox(height: 8),
- _linkGroup(gc, [
- (PhosphorIconsRegular.squaresFour, t.addActivityWidget, () => _addWidget(context, 'HeatmapWidgetProvider')),
- (PhosphorIconsRegular.chartBar, t.addStatsWidget, () => _addWidget(context, 'StatsWidgetProvider')),
- (PhosphorIconsRegular.person, t.addBodyWidget, () => _addWidget(context, 'BodyWidgetProvider')),
- (PhosphorIconsRegular.checkCircle, t.addTodayWidget, () => _addWidget(context, 'TodayWidgetProvider')),
- (PhosphorIconsRegular.calendarCheck, t.addWeekWidget, () => _addWidget(context, 'WeekWidgetProvider')),
- ]),
- const SizedBox(height: 18),
- ],
- _sectionLabel(gc, t.sectionData),
- const SizedBox(height: 8),
- _linkGroup(gc, [
+ ),
+ const SizedBox(height: 12),
+ _linkGroup(gc, [
+ (PhosphorIconsRegular.githubLogo, t.nutritionAboutSuggest, () => _open(context, '$_kRepoUrl/issues')),
+ ]),
+ ];
+ case 'widgets':
+ return [
+ _linkGroup(gc, [
+ (PhosphorIconsRegular.squaresFour, t.addActivityWidget, () => _addWidget(context, 'HeatmapWidgetProvider')),
+ (PhosphorIconsRegular.chartBar, t.addStatsWidget, () => _addWidget(context, 'StatsWidgetProvider')),
+ (PhosphorIconsRegular.person, t.addBodyWidget, () => _addWidget(context, 'BodyWidgetProvider')),
+ (PhosphorIconsRegular.checkCircle, t.addTodayWidget, () => _addWidget(context, 'TodayWidgetProvider')),
+ (PhosphorIconsRegular.calendarCheck, t.addWeekWidget, () => _addWidget(context, 'WeekWidgetProvider')),
+ ], hints: [t.widgetHintActivity, t.widgetHintStats, t.widgetHintBody, t.widgetHintToday, t.widgetHintWeek]),
+ ];
+ case 'data':
+ return [
+ _linkGroup(gc, [
(PhosphorIconsRegular.fileCsv, t.exportCsv, () => _exportCsv(context)),
(PhosphorIconsRegular.fileZip, t.exportBackup, () => _exportBackup(context)),
(PhosphorIconsRegular.downloadSimple, t.importBackup, () => _importBackup(context)),
@@ -431,48 +548,118 @@ class SettingsScreen extends StatelessWidget {
(PhosphorIconsRegular.arrowSquareIn, t.importFromApp, () => _openImportApps(context)),
(PhosphorIconsRegular.export, t.stravaRow, () => showStravaSheet(context)),
(PhosphorIconsRegular.trash, t.resetData, () => _resetAll(context)),
- ], danger: AutoBackup.instance.supported ? 6 : 5),
- const SizedBox(height: 18),
- _sectionLabel(gc, t.support),
- const SizedBox(height: 8),
- _linkGroup(gc, [
+ ], danger: AutoBackup.instance.supported ? 6 : 5),
+ ];
+ default:
+ return [
+ _linkGroup(gc, [
(PhosphorIconsRegular.bug, t.reportBug, () => _open(context, _kBugUrl)),
(PhosphorIconsRegular.lightbulb, t.requestFeature, () => _open(context, _kFeatureUrl)),
(PhosphorIconsRegular.githubLogo, t.starOnGithub, () => _open(context, _kRepoUrl)),
(PhosphorIconsRegular.coffee, t.buyCoffee, () => _open(context, _kKofiUrl)),
- ]),
- const SizedBox(height: 22),
- _linkGroup(gc, [
- (PhosphorIconsRegular.info, t.aboutGymmane, fit.goAbout),
- ]),
- ]),
- ),
- ),
- ),
- );
+ ], hints: [t.supportHintBug, t.supportHintFeature, t.supportHintStar, t.supportHintCoffee]),
+ ];
+ }
}
- Widget _group(GymColors gc, String label, List<Widget> rows) => Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- _sectionLabel(gc, label),
- const SizedBox(height: 8),
- SoftCard(
- radius: 20,
- borderColor: Colors.transparent,
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Column(children: rows),
- ),
- ],
+ 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)),
+ child: Column(children: rows),
);
- Widget _sectionLabel(GymColors gc, String t) =>
- Text(t.toUpperCase(),
- style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3));
+ static String _sectionTitle(String id) => switch (id) {
+ 'general' => t.sectionGeneral,
+ 'training' => t.sectionTraining,
+ 'alerts' => t.sectionAlerts,
+ 'home' => t.sectionHome,
+ 'widgets' => t.sectionWidgets,
+ 'beta' => t.sectionBeta,
+ 'data' => t.sectionData,
+ _ => titleCase(t.support),
+ };
+
+ static String sectionTitleOf(String id) => _sectionTitle(id);
+
+ List<_Category> _categories() {
+ const r = PhosphorIconsRegular.gearSix;
+ return [
+ _Category('general', PhosphorIconsRegular.slidersHorizontal, _sectionTitle('general'), [
+ (t.theme, PhosphorIconsRegular.moon),
+ (t.languageLabel, PhosphorIconsRegular.translate),
+ (t.unitsLabel, PhosphorIconsRegular.scales),
+ (t.weekStartSetting, PhosphorIconsRegular.calendarBlank),
+ (t.heatRangeSetting, PhosphorIconsRegular.calendarDots),
+ (t.heatmapLabelsSetting, PhosphorIconsRegular.gridNine),
+ (t.background, PhosphorIconsRegular.image),
+ (t.blurSetting, PhosphorIconsRegular.drop),
+ ]),
+ _Category('training', PhosphorIconsRegular.barbell, _sectionTitle('training'), [
+ (t.restTimer, PhosphorIconsRegular.timer),
+ (t.miniRest, PhosphorIconsRegular.timer),
+ (t.effortSetting, PhosphorIconsRegular.gauge),
+ (t.weightStepSetting, PhosphorIconsRegular.barbell),
+ (t.autoAdvance, PhosphorIconsRegular.skipForward),
+ (t.countdownSetting, PhosphorIconsRegular.timer),
+ (t.keepScreenOn, PhosphorIconsRegular.sun),
+ (t.multiPlanSetting, PhosphorIconsRegular.stack),
+ (t.levelHintsSetting, PhosphorIconsRegular.stairs),
+ (t.layoutSetting, PhosphorIconsRegular.rows),
+ (t.demoSizeTitle, PhosphorIconsRegular.filmStrip),
+ (t.demoLoopTitle, PhosphorIconsRegular.repeat),
+ (t.placesLabel, PhosphorIconsRegular.mapPin),
+ ]),
+ _Category('alerts', PhosphorIconsRegular.bellSimple, _sectionTitle('alerts'), [
+ (t.trainReminder, PhosphorIconsRegular.bellSimple),
+ (t.alarmSound, PhosphorIconsRegular.speakerHigh),
+ (t.alarmStyleTitle, PhosphorIconsRegular.vibrate),
+ (t.toastSoundSetting, PhosphorIconsRegular.bellSimple),
+ ]),
+ _Category('home', PhosphorIconsRegular.house, _sectionTitle('home'), [
+ (t.focusCard, PhosphorIconsRegular.target),
+ (t.homeRecommended, PhosphorIconsRegular.sparkle),
+ (t.homeRoutines, PhosphorIconsRegular.folders),
+ (t.homeWeekStats, PhosphorIconsRegular.chartBar),
+ (t.stepsSetting, PhosphorIconsRegular.footprints),
+ (t.healthSetting, PhosphorIconsRegular.heartbeat),
+ (t.gamificationSetting, PhosphorIconsRegular.medal),
+ (t.gymPass, PhosphorIconsRegular.qrCode),
+ ]),
+ if (Platform.isAndroid || Platform.isIOS)
+ _Category('widgets', PhosphorIconsRegular.squaresFour, _sectionTitle('widgets'), [
+ (t.addActivityWidget, PhosphorIconsRegular.squaresFour),
+ (t.addStatsWidget, PhosphorIconsRegular.chartBar),
+ (t.addBodyWidget, PhosphorIconsRegular.person),
+ (t.addTodayWidget, PhosphorIconsRegular.checkCircle),
+ (t.addWeekWidget, PhosphorIconsRegular.calendarCheck),
+ ]),
+ _Category('beta', PhosphorIconsRegular.flask, _sectionTitle('beta'), [
+ (t.nutritionBeta, PhosphorIconsRegular.forkKnife),
+ ]),
+ _Category('data', PhosphorIconsRegular.database, _sectionTitle('data'), [
+ (t.exportCsv, PhosphorIconsRegular.fileCsv),
+ (t.exportBackup, PhosphorIconsRegular.fileZip),
+ (t.importBackup, PhosphorIconsRegular.downloadSimple),
+ (t.autoBackup, PhosphorIconsRegular.clockCounterClockwise),
+ (t.importFromApp, PhosphorIconsRegular.arrowSquareIn),
+ (t.stravaRow, PhosphorIconsRegular.export),
+ (t.resetData, PhosphorIconsRegular.trash),
+ ]),
+ _Category('support', PhosphorIconsRegular.heart, _sectionTitle('support'), [
+ (t.reportBug, PhosphorIconsRegular.bug),
+ (t.requestFeature, PhosphorIconsRegular.lightbulb),
+ (t.starOnGithub, PhosphorIconsRegular.githubLogo),
+ (t.buyCoffee, PhosphorIconsRegular.coffee),
+ ]),
+ _Category('about', PhosphorIconsRegular.info, t.aboutGymmane, [(t.aboutGymmane, r)]),
+ ];
+ }
+
+ static void _openCategory(String id) => id == 'about' ? fit.goAbout() : fit.pushRoute('preferences/$id');
Widget _prefRow(GymColors gc, IconData icon, String label, Widget control, {String? hint, Widget? badge}) {
if (hint == null) {
- return SizedBox(
+ return _Flash(label: label, child: SizedBox(
height: 52,
child: Row(
children: [
@@ -482,9 +669,9 @@ class SettingsScreen extends StatelessWidget {
control,
],
),
- );
+ ));
}
- return ConstrainedBox(
+ return _Flash(label: label, child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 52),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
@@ -514,7 +701,7 @@ class SettingsScreen extends StatelessWidget {
],
),
),
- );
+ ));
}
Widget _choiceRow(
@@ -617,28 +804,33 @@ class SettingsScreen extends StatelessWidget {
Widget _rowIcon(GymColors gc, IconData icon, {Color? color}) => Padding(
padding: const EdgeInsets.only(right: 14),
- child: SizedBox(
- width: 22,
- child: Icon(icon, size: 19, color: color ?? gc.textSecondary),
+ child: Container(
+ width: 34,
+ height: 34,
+ decoration: BoxDecoration(
+ color: (color ?? gc.text).withValues(alpha: 0.09),
+ shape: BoxShape.circle,
+ ),
+ child: Icon(icon, size: 17, color: color ?? gc.text),
),
);
- Widget _linkGroup(GymColors gc, List<(IconData, String, VoidCallback)> items, {int? danger}) {
+ Widget _linkGroup(GymColors gc, List<(IconData, String, VoidCallback)> items, {int? danger, List<String>? hints}) {
return Container(
decoration: BoxDecoration(
color: gc.bgRaised,
- borderRadius: BorderRadius.circular(20),
+ borderRadius: BorderRadius.circular(26),
),
clipBehavior: Clip.antiAlias,
child: Column(
children: [
for (int i = 0; i < items.length; i++)
- GestureDetector(
+ _Flash(label: items[i].$2, child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: items[i].$3,
child: Container(
- height: 52,
- padding: const EdgeInsets.symmetric(horizontal: 16),
+ constraints: const BoxConstraints(minHeight: 52),
+ padding: EdgeInsets.symmetric(horizontal: 16, vertical: hints == null ? 0 : 13),
decoration: BoxDecoration(
border: i < items.length - 1
? Border(bottom: BorderSide(color: gc.border.withValues(alpha: 0.6)))
@@ -648,14 +840,25 @@ class SettingsScreen extends StatelessWidget {
children: [
_rowIcon(gc, items[i].$1, color: i == danger ? gc.danger : null),
Expanded(
- child: Text(items[i].$2,
- style: AppTheme.f(14.5,
- weight: FontWeight.w500, color: i == danger ? gc.danger : gc.text))),
+ 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)),
+ if (hints != null && i < hints.length) ...[
+ const SizedBox(height: 2),
+ Text(hints[i],
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary, height: 1.3)),
+ ],
+ ],
+ ),
+ ),
Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
],
),
),
- ),
+ )),
],
),
);
@@ -1464,11 +1667,12 @@ 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;
return Container(
padding: EdgeInsets.fromLTRB(20, 12, 20, 20 + MediaQuery.of(context).viewInsets.bottom + MediaQuery.paddingOf(context).bottom),
decoration: BoxDecoration(
- color: gc.bgRaised,
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ color: sheet,
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(32)),
),
child: SingleChildScrollView(
child: Column(
@@ -1476,86 +1680,71 @@ class _ProfileSheetState extends State<_ProfileSheet> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.yourProfile,
- textAlign: TextAlign.center,
- style: AppTheme.f(17, weight: FontWeight.w700, color: gc.text)),
- const SizedBox(height: 4),
- Text(t.autofills, textAlign: TextAlign.center, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
const SizedBox(height: 20),
- Center(child: _photoPicker(gc)),
+ Text(sentenceCase(t.yourProfile), style: AppTheme.f(24, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.4)),
+ const SizedBox(height: 3),
+ Text(t.autofills, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
const SizedBox(height: 18),
- _coverPicker(gc),
- const SizedBox(height: 20),
- _label(gc, t.nameLabel),
- const SizedBox(height: 8),
- TextField(
- controller: _name,
- style: AppTheme.f(15, weight: FontWeight.w600, color: gc.text),
- cursorColor: gc.accent,
- textCapitalization: TextCapitalization.words,
- onChanged: (v) => fit.updateProfile(name: v),
- decoration: InputDecoration(
- hintText: kDefaultName,
- hintStyle: AppTheme.f(15, weight: FontWeight.w600, color: gc.textTertiary),
- filled: true,
- fillColor: gc.bgRaised2,
- contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
- border: OutlineInputBorder(borderRadius: BorderRadius.circular(14), borderSide: BorderSide.none),
- ),
- ),
+ _top(gc, sheet),
const SizedBox(height: 16),
- _label(gc, t.handleLabel),
- const SizedBox(height: 8),
- TextField(
- controller: _handle,
- style: AppTheme.f(15, weight: FontWeight.w600, color: gc.text),
- cursorColor: gc.accent,
- onChanged: fit.setProfileHandle,
- decoration: InputDecoration(
- filled: true,
- fillColor: gc.bgRaised2,
- hintText: fit.profileHandle,
- hintStyle: AppTheme.f(15, weight: FontWeight.w600, color: gc.textTertiary),
- prefixIcon: Padding(
- padding: const EdgeInsets.only(left: 16, right: 6),
- child: Text('@',
- style: AppTheme.f(15, weight: FontWeight.w700, color: gc.textSecondary)),
+ _group(gc, [
+ _field(gc, t.nameLabel, TextField(
+ controller: _name,
+ style: AppTheme.f(15.5, weight: FontWeight.w600, color: gc.text),
+ cursorColor: gc.accent,
+ textCapitalization: TextCapitalization.words,
+ onChanged: (v) => fit.updateProfile(name: v),
+ decoration: InputDecoration(
+ isCollapsed: true,
+ border: InputBorder.none,
+ hintText: kDefaultName,
+ hintStyle: AppTheme.f(15.5, weight: FontWeight.w600, color: gc.textTertiary),
),
- prefixIconConstraints: const BoxConstraints(minWidth: 0, minHeight: 0),
- contentPadding: const EdgeInsets.symmetric(horizontal: 4, vertical: 14),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(14), borderSide: BorderSide.none),
- ),
- ),
- const SizedBox(height: 16),
- _row(gc, t.pickBadge, _badgeDots(gc)),
- const SizedBox(height: 12),
- _row(gc, t.sexLabel, SegToggle([
- SegOption(t.male, p.sex == 'male', () => _up(() => fit.updateProfile(sex: 'male'))),
- SegOption(t.female, p.sex == 'female', () => _up(() => fit.updateProfile(sex: 'female'))),
- ])),
- const SizedBox(height: 12),
- _stepRow(gc, t.ageLabel, '${p.age}', () => _up(() => fit.updateProfile(ageDelta: -1)), () => _up(() => fit.updateProfile(ageDelta: 1)), edit: editAge),
- const SizedBox(height: 12),
- _stepRow(gc, t.heightLabel, fit.heightLabel(p.heightCm), () => _up(() => fit.updateProfile(heightDelta: -fit.heightStep)), () => _up(() => fit.updateProfile(heightDelta: fit.heightStep)), edit: editHeight),
- const SizedBox(height: 12),
- _stepRow(gc, t.weightLabel, fit.weightLabel(p.weightKg),
- () => _up(() => fit.updateProfile(weightDelta: -fit.fromDisplayWeight(fit.isLb ? 1 : 0.5))),
- () => _up(() => fit.updateProfile(weightDelta: fit.fromDisplayWeight(fit.isLb ? 1 : 0.5))),
- edit: editBodyWeight),
- const SizedBox(height: 12),
- _stepRow(gc, t.weeklyGoal, '${p.weeklyGoal}×', () => _up(() => fit.updateProfile(weeklyGoalDelta: -1)), () => _up(() => fit.updateProfile(weeklyGoalDelta: 1))),
+ )),
+ _field(gc, t.handleLabel, Row(children: [
+ Text('@', style: AppTheme.f(15.5, weight: FontWeight.w700, color: gc.textTertiary)),
+ const SizedBox(width: 3),
+ Expanded(
+ child: TextField(
+ controller: _handle,
+ style: AppTheme.f(15.5, weight: FontWeight.w600, color: gc.text),
+ cursorColor: gc.accent,
+ onChanged: fit.setProfileHandle,
+ decoration: InputDecoration(
+ isCollapsed: true,
+ border: InputBorder.none,
+ hintText: fit.profileHandle,
+ hintStyle: AppTheme.f(15.5, weight: FontWeight.w600, color: gc.textTertiary),
+ ),
+ ),
+ ),
+ ])),
+ _row(gc, t.pickBadge, _badgeDots(gc)),
+ ]),
const SizedBox(height: 12),
- _label(gc, t.activityLabel),
- const SizedBox(height: 8),
+ _group(gc, [
+ _row(gc, t.sexLabel, SegToggle([
+ SegOption(t.male, p.sex == 'male', () => _up(() => fit.updateProfile(sex: 'male'))),
+ SegOption(t.female, p.sex == 'female', () => _up(() => fit.updateProfile(sex: 'female'))),
+ ])),
+ _stepRow(gc, t.ageLabel, '${p.age}', () => _up(() => fit.updateProfile(ageDelta: -1)), () => _up(() => fit.updateProfile(ageDelta: 1)), edit: editAge),
+ _stepRow(gc, t.heightLabel, fit.heightLabel(p.heightCm), () => _up(() => fit.updateProfile(heightDelta: -fit.heightStep)), () => _up(() => fit.updateProfile(heightDelta: fit.heightStep)), edit: editHeight),
+ _stepRow(gc, t.weightLabel, fit.weightLabel(p.weightKg),
+ () => _up(() => fit.updateProfile(weightDelta: -fit.fromDisplayWeight(fit.isLb ? 1 : 0.5))),
+ () => _up(() => fit.updateProfile(weightDelta: fit.fromDisplayWeight(fit.isLb ? 1 : 0.5))),
+ edit: editBodyWeight),
+ _stepRow(gc, t.weeklyGoal, '${p.weeklyGoal}×', () => _up(() => fit.updateProfile(weeklyGoalDelta: -1)), () => _up(() => fit.updateProfile(weeklyGoalDelta: 1))),
+ ]),
+ const SizedBox(height: 18),
+ Padding(padding: const EdgeInsets.only(left: 4), child: _label(gc, t.activityLabel)),
+ const SizedBox(height: 10),
Wrap(spacing: 8, runSpacing: 8, children: [
_act(gc, t.activityName('Sedentary'), 1.2),
_act(gc, t.activityName('Light'), 1.375),
_act(gc, t.activityName('Moderate'), 1.55),
_act(gc, t.activityName('Active'), 1.725),
]),
- const SizedBox(height: 22),
+ const SizedBox(height: 24),
PrimaryButton(label: t.done, onTap: () => Navigator.of(context).pop()),
],
),
@@ -1568,72 +1757,108 @@ class _ProfileSheetState extends State<_ProfileSheet> {
setState(() {});
}
- Widget _photoPicker(GymColors gc) {
- final has = fit.profilePhoto != null;
- return Column(
- children: [
- GestureDetector(
- onTap: _pickPhoto,
- child: Stack(
- alignment: Alignment.bottomRight,
- children: [
- ProfileAvatar(size: 96),
- Container(
- padding: const EdgeInsets.all(7),
+ Widget _top(GymColors gc, Color sheet) {
+ final banner = fit.profileBanner;
+ final photo = fit.profilePhoto != null;
+ Widget chip(IconData icon) => Container(
+ width: 30,
+ height: 30,
+ decoration: BoxDecoration(
+ color: Colors.black.withValues(alpha: 0.5),
+ shape: BoxShape.circle,
+ border: Border.all(color: Colors.white.withValues(alpha: 0.18)),
+ ),
+ child: Icon(icon, size: 14, color: Colors.white),
+ );
+ Widget remove(String label, VoidCallback onTap) => GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 6),
+ child: Text(label, style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary)),
+ ),
+ );
+ return SizedBox(
+ height: 168,
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned(
+ left: 0,
+ right: 0,
+ top: 0,
+ height: 120,
+ child: GestureDetector(
+ onTap: _pickBanner,
+ child: Container(
decoration: BoxDecoration(
- color: gc.ember,
- shape: BoxShape.circle,
- border: Border.all(color: gc.bgRaised, width: 2),
+ color: gc.bgRaised2,
+ borderRadius: BorderRadius.circular(24),
+ image: DecorationImage(
+ image: banner == null ? kDefaultBanner : MemoryImage(banner),
+ fit: BoxFit.cover,
+ ),
),
- child: Icon(PhosphorIconsFill.camera, size: 14, color: gc.onEmber),
+ alignment: Alignment.topRight,
+ padding: const EdgeInsets.all(10),
+ child: chip(PhosphorIconsRegular.image),
),
- ],
- ),
- ),
- const SizedBox(height: 8),
- GestureDetector(
- onTap: has ? () => _up(fit.clearProfilePhoto) : _pickPhoto,
- child: Text(
- has ? t.removePhoto : t.addPhoto,
- style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary),
+ ),
),
- ),
- ],
- );
- }
-
- Widget _coverPicker(GymColors gc) {
- final bytes = fit.profileBanner;
- return Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- _label(gc, t.coverLabel),
- const SizedBox(height: 8),
- GestureDetector(
- onTap: _pickBanner,
- child: Container(
- height: 96,
- decoration: BoxDecoration(
- color: gc.bgRaised2,
- borderRadius: BorderRadius.circular(14),
- image: DecorationImage(
- image: bytes == null ? kDefaultBanner : MemoryImage(bytes),
- fit: BoxFit.cover,
+ Positioned(
+ left: 14,
+ top: 74,
+ child: GestureDetector(
+ onTap: _pickPhoto,
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Container(
+ padding: const EdgeInsets.all(4),
+ decoration: BoxDecoration(color: sheet, shape: BoxShape.circle),
+ child: ProfileAvatar(size: 82),
+ ),
+ Positioned(right: 0, bottom: 2, child: chip(PhosphorIconsRegular.camera)),
+ ],
),
),
),
- ),
- const SizedBox(height: 8),
- Center(
- child: GestureDetector(
- onTap: bytes == null ? _pickBanner : () => _up(fit.clearProfileBanner),
- child: Text(
- bytes == null ? t.addCover : t.removeCover,
- style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary),
- ),
+ Positioned(
+ left: 118,
+ right: 0,
+ top: 128,
+ child: Row(children: [
+ if (photo) remove(t.removePhoto, () => _up(fit.clearProfilePhoto)),
+ if (photo && banner != null) Text(' · ', style: AppTheme.f(12, color: gc.textTertiary)),
+ if (banner != null) remove(t.removeCover, () => _up(fit.clearProfileBanner)),
+ ]),
),
- ),
- ],
+ ],
+ ),
+ );
+ }
+
+ Widget _group(GymColors gc, List<Widget> rows) {
+ return Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),
+ child: Column(children: [
+ for (var i = 0; i < rows.length; i++) ...[
+ if (i > 0) Container(height: 1, color: gc.text.withValues(alpha: 0.06)),
+ rows[i],
+ ],
+ ]),
+ );
+ }
+
+ Widget _field(GymColors gc, String label, Widget input) {
+ return Padding(
+ padding: const EdgeInsets.symmetric(vertical: 12),
+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ _label(gc, label),
+ const SizedBox(height: 6),
+ input,
+ ]),
);
}
@@ -1703,13 +1928,11 @@ class _ProfileSheetState extends State<_ProfileSheet> {
style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3));
Widget _row(GymColors gc, String label, Widget control) {
- return SoftCard(
- radius: 14,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
+ return ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 56),
child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text(label, style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary)),
+ Expanded(child: Text(sentenceCase(label), style: AppTheme.f(14.5, weight: FontWeight.w600, color: gc.text))),
control,
],
),
@@ -1737,8 +1960,8 @@ class _ProfileSheetState extends State<_ProfileSheet> {
final active = fit.profile.activity == v;
return Pill(
label: label,
- bg: active ? gc.ember : gc.bgRaised2,
- fg: active ? gc.onEmber : gc.textSecondary,
+ bg: active ? gc.text : gc.bgRaised,
+ fg: active ? gc.bg : gc.textSecondary,
onTap: () => _up(() => fit.updateProfile(activity: v)),
hPad: 12,
vPad: 8,
@@ -1746,3 +1969,447 @@ class _ProfileSheetState extends State<_ProfileSheet> {
);
}
}
+
+class _Category {
+ const _Category(this.id, this.icon, this.title, this.rows);
+
+ final String id;
+ final IconData icon;
+ final String title;
+ final List<(String, IconData)> rows;
+}
+
+String? _flashPending;
+
+class _Flash extends StatefulWidget {
+ const _Flash({required this.label, required this.child});
+
+ final String label;
+ final Widget child;
+
+ @override
+ State<_Flash> createState() => _FlashState();
+}
+
+class _FlashState extends State<_Flash> with SingleTickerProviderStateMixin {
+ late final _glow = AnimationController(
+ vsync: this, duration: const Duration(milliseconds: 220), reverseDuration: const Duration(milliseconds: 900));
+ Timer? _off;
+
+ @override
+ void initState() {
+ super.initState();
+ if (_flashPending != widget.label) return;
+ _flashPending = null;
+ _off = Timer(const Duration(milliseconds: 320), () async {
+ if (!mounted) return;
+ await Scrollable.ensureVisible(context,
+ alignment: 0.4, duration: const Duration(milliseconds: 480), curve: Curves.easeOutCubic);
+ if (!mounted) return;
+ await _glow.forward();
+ if (mounted) _glow.reverse();
+ });
+ }
+
+ @override
+ void dispose() {
+ _off?.cancel();
+ _glow.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return AnimatedBuilder(
+ animation: _glow,
+ child: widget.child,
+ builder: (context, child) {
+ final v = _glow.value;
+ if (v <= 0) return child!;
+ return Stack(
+ children: [
+ Positioned(
+ left: -8,
+ right: -8,
+ top: 4,
+ bottom: 4,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ color: gc.text.withValues(alpha: 0.05 * v),
+ borderRadius: BorderRadius.circular(14),
+ border: Border.all(color: gc.text.withValues(alpha: 0.7 * v), width: 1.5),
+ ),
+ ),
+ ),
+ child!,
+ ],
+ );
+ },
+ );
+ }
+}
+
+class _SettingsHome extends StatefulWidget {
+ const _SettingsHome({required this.screen});
+
+ final SettingsScreen screen;
+
+ @override
+ State<_SettingsHome> createState() => _SettingsHomeState();
+}
+
+class _SettingsHomeState extends State<_SettingsHome> {
+ final _query = TextEditingController();
+ final _focus = FocusNode();
+ final _scroll = ScrollController();
+ static const _span = 96.0;
+ static const _back = 36.0;
+ static const _pill = 52.0;
+ static const _titleSize = 32.0;
+ static const _small = 0.56;
+
+ @override
+ void initState() {
+ super.initState();
+ _focus.addListener(() => setState(() {}));
+ }
+
+ double get _folded {
+ if (!_scroll.hasClients) return 0;
+ final v = (_scroll.offset / _span).clamp(0.0, 1.0);
+ return Curves.easeInOut.transform(v);
+ }
+
+ Future<void> _openSearch() async {
+ HapticFeedback.selectionClick();
+ if (_scroll.hasClients && _scroll.offset > 0) {
+ await _scroll.animateTo(0, duration: const Duration(milliseconds: 420), curve: Curves.easeOutCubic);
+ }
+ if (mounted) _focus.requestFocus();
+ }
+
+ @override
+ void dispose() {
+ _query.dispose();
+ _focus.dispose();
+ _scroll.dispose();
+ super.dispose();
+ }
+
+ static String _plain(String s) => s
+ .toLowerCase()
+ .replaceAll(RegExp('[áàä]'), 'a')
+ .replaceAll(RegExp('[éèë]'), 'e')
+ .replaceAll(RegExp('[íìï]'), 'i')
+ .replaceAll(RegExp('[óòö]'), 'o')
+ .replaceAll(RegExp('[úùü]'), 'u');
+
+ void _go(_Category c, String? row) {
+ _focus.unfocus();
+ _flashPending = row;
+ SettingsScreen._openCategory(c.id);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final cats = widget.screen._categories();
+ final q = _plain(_query.text.trim());
+ final searching = q.isNotEmpty || _focus.hasFocus;
+ final hits = <(_Category, String, IconData)>[
+ if (q.isNotEmpty)
+ for (final c in cats)
+ for (final r in c.rows)
+ if (_plain(r.$1).contains(q) || _plain(c.title).contains(q)) (c, r.$1, r.$2),
+ ];
+
+ final pad = MediaQuery.paddingOf(context).top;
+ final titleTop = pad + 12 + _back + 18;
+ final pillTop = titleTop + _titleSize * 1.05 + 18;
+
+ return RiseScope(
+ id: 'settings',
+ once: false,
+ child: GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onTap: _focus.unfocus,
+ child: Stack(
+ children: [
+ SingleChildScrollView(
+ key: const PageStorageKey('settings-home'),
+ controller: _scroll,
+ clipBehavior: Clip.none,
+ padding: EdgeInsets.fromLTRB(20, pillTop + _pill + 18, 20, 40),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: riseAll([
+ AnimatedSwitcher(
+ duration: const Duration(milliseconds: 200),
+ switchInCurve: Curves.easeOutCubic,
+ switchOutCurve: Curves.easeInCubic,
+ transitionBuilder: (child, a) => FadeTransition(
+ opacity: a,
+ child: SlideTransition(
+ position: Tween(begin: const Offset(0, 0.02), end: Offset.zero).animate(a),
+ child: child,
+ ),
+ ),
+ child: searching
+ ? _results(gc, hits, q.isEmpty)
+ : Column(
+ key: const ValueKey('cats'),
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ for (final (g, label) in [
+ (const {'general', 'training', 'alerts'}, t.settingsGroupApp),
+ (const {'home', 'widgets', 'beta'}, t.settingsGroupHome),
+ (const {'data', 'support', 'about'}, t.settingsGroupData),
+ ]) ...[
+ Padding(
+ padding: const EdgeInsets.fromLTRB(4, 6, 0, 10),
+ child: Text(label.toUpperCase(),
+ style: AppTheme.f(10.5,
+ weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.4)),
+ ),
+ for (final c in cats.where((c) => g.contains(c.id))) ...[
+ Rise(index: cats.indexOf(c) + 2, child: _bubble(gc, c)),
+ const SizedBox(height: 10),
+ ],
+ const SizedBox(height: 12),
+ ],
+ ],
+ ),
+ ),
+ ]),
+ ),
+ ),
+ Positioned.fill(child: IgnorePointer(child: _bar(pad))),
+ _header(gc, pad, titleTop, pillTop),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _bar(double pad) {
+ final blur = EdgeBlur(height: pad + 64, sigma: 14);
+ return AnimatedBuilder(
+ animation: _scroll,
+ builder: (context, _) {
+ final p = _folded;
+ if (p <= 0.001) return const SizedBox.shrink();
+ return Align(alignment: Alignment.topCenter, child: Opacity(opacity: p, child: blur));
+ },
+ );
+ }
+
+ Widget _header(GymColors gc, double pad, double titleTop, double pillTop) {
+ return Positioned.fill(
+ child: LayoutBuilder(builder: (context, box) {
+ final w = box.maxWidth;
+ return AnimatedBuilder(
+ animation: _scroll,
+ builder: (context, _) {
+ final p = _folded;
+ final blur = math.sin(p * math.pi) * 5;
+ final scale = 1 - (1 - _small) * p;
+ final titleH = _titleSize * 1.05;
+ final small = pad + 12 + _back / 2 - titleH * _small / 2;
+ final pillX = 20 + (w - 20 - _back - 20) * p;
+ final pillY = pillTop + (pad + 12 - pillTop) * p;
+ final pillW = (w - 40) + (_back - (w - 40)) * p;
+ final pillH = _pill + (_back - _pill) * p;
+ return Stack(
+ children: [
+ Positioned(
+ left: 20,
+ top: pad + 12,
+ child: RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromPreferences),
+ ),
+ Positioned(
+ left: 20 + (_back + 12) * p,
+ top: titleTop + (small - titleTop) * p,
+ child: IgnorePointer(
+ child: Transform.scale(
+ scale: scale,
+ alignment: Alignment.topLeft,
+ child: ImageFiltered(
+ enabled: blur > 0.3,
+ imageFilter: ui.ImageFilter.blur(sigmaX: blur, sigmaY: blur),
+ child: Text(titleCase(t.settings),
+ style: AppTheme.f(_titleSize,
+ weight: FontWeight.w800, color: gc.text, letterSpacing: -0.9, height: 1.05)),
+ ),
+ ),
+ ),
+ ),
+ Positioned(
+ left: pillX,
+ top: pillY,
+ width: pillW,
+ height: pillH,
+ child: AnimatedContainer(
+ duration: const Duration(milliseconds: 220),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ borderRadius: BorderRadius.circular(pillH / 2),
+ border: Border.all(color: gc.text.withValues(alpha: _focus.hasFocus ? 0.16 : 0)),
+ ),
+ clipBehavior: Clip.antiAlias,
+ child: Stack(
+ children: [
+ IgnorePointer(
+ ignoring: p > 0.5,
+ child: Opacity(
+ opacity: (1 - p / 0.6).clamp(0.0, 1.0),
+ child: OverflowBox(
+ alignment: Alignment.centerLeft,
+ minWidth: w - 40,
+ maxWidth: w - 40,
+ child: _search(gc),
+ ),
+ ),
+ ),
+ if (p > 0.45)
+ Positioned.fill(
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: _openSearch,
+ child: Opacity(
+ opacity: ((p - 0.45) / 0.55).clamp(0.0, 1.0),
+ child: Icon(PhosphorIconsRegular.magnifyingGlass, size: 16, color: gc.text),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ },
+ );
+ }),
+ );
+ }
+
+ Widget _circle(GymColors gc, IconData icon, {double size = 40}) => Container(
+ width: size,
+ height: size,
+ decoration: BoxDecoration(color: gc.text.withValues(alpha: 0.09), shape: BoxShape.circle),
+ child: Icon(icon, size: size * 0.48, color: gc.text),
+ );
+
+ Widget _search(GymColors gc) {
+ final on = _focus.hasFocus;
+ return Container(
+ height: 52,
+ padding: const EdgeInsets.symmetric(horizontal: 18),
+ child: Row(
+ children: [
+ Icon(PhosphorIconsRegular.magnifyingGlass, size: 18, color: on ? gc.text : gc.textTertiary),
+ const SizedBox(width: 12),
+ Expanded(
+ child: TextField(
+ controller: _query,
+ focusNode: _focus,
+ onChanged: (_) => setState(() {}),
+ textInputAction: TextInputAction.search,
+ style: AppTheme.f(16, weight: FontWeight.w500, color: gc.text),
+ cursorColor: gc.text,
+ decoration: InputDecoration(
+ isCollapsed: true,
+ border: InputBorder.none,
+ hintText: t.settingsSearch,
+ hintStyle: AppTheme.f(16, weight: FontWeight.w500, color: gc.textTertiary),
+ ),
+ ),
+ ),
+ AnimatedScale(
+ scale: _query.text.isEmpty ? 0 : 1,
+ duration: const Duration(milliseconds: 220),
+ curve: Curves.easeOutBack,
+ child: GestureDetector(
+ onTap: () => setState(_query.clear),
+ child: Icon(PhosphorIconsRegular.xCircle, size: 20, color: gc.textSecondary),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _bubble(GymColors gc, _Category c) {
+ return Pressable(
+ onTap: () => _go(c, null),
+ scale: 0.975,
+ child: Container(
+ height: 64,
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(22)),
+ child: Row(
+ children: [
+ _circle(gc, c.icon),
+ const SizedBox(width: 14),
+ Expanded(
+ child: Text(c.title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(16, weight: FontWeight.w600, color: gc.text)),
+ ),
+ Icon(PhosphorIconsRegular.caretRight, size: 16, color: gc.textTertiary),
+ const SizedBox(width: 6),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _results(GymColors gc, List<(_Category, String, IconData)> hits, bool empty) {
+ if (empty) return const SizedBox(key: ValueKey('blank'), height: 200);
+ if (hits.isEmpty) {
+ return Padding(
+ key: const ValueKey('none'),
+ padding: const EdgeInsets.fromLTRB(4, 12, 4, 12),
+ child: Text(t.settingsNoResults, style: AppTheme.f(15, weight: FontWeight.w500, color: gc.textSecondary)),
+ );
+ }
+ return Column(
+ key: ValueKey('hits${hits.length}'),
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ for (var i = 0; i < hits.length; i++) ...[
+ if (i > 0) const SizedBox(height: 10),
+ Pressable(
+ onTap: () => _go(hits[i].$1, hits[i].$2),
+ scale: 0.975,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(20)),
+ child: Row(
+ children: [
+ _circle(gc, hits[i].$3, size: 38),
+ const SizedBox(width: 11),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(hits[i].$2,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(16, weight: FontWeight.w600, color: gc.text)),
+ Text(hits[i].$1.title,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary)),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ],
+ );
+ }
+}