Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Add ready-made plans, routine groups and the start sheet, with filters in the editor (#11, #14, #30, #32)
InlitX75c3de8c5786
diff --git a/lib/catalog/program_templates.dart b/lib/catalog/program_templates.dartnew file mode 100644index 0000000..4c34d6c--- /dev/null+++ b/lib/catalog/program_templates.dart@@ -0,0 +1,137 @@+class ProgramDay {+ const ProgramDay(this.name, this.exercises, {this.weekday});++ final String name;+ final List<(String, int)> exercises;+ final int? weekday;+}++class ProgramTemplate {+ const ProgramTemplate(this.id, this.name, this.days);++ final String id;+ final String name;+ final List<ProgramDay> days;+}++const List<ProgramTemplate> kProgramTemplates = [+ ProgramTemplate('fullbody', 'Full Body', [+ ProgramDay('Full Body', [+ ('Barbell Squat', 3),+ ('Barbell Bench Press', 3),+ ('Barbell Row', 3),+ ('Overhead Press', 3),+ ('Romanian Deadlift', 3),+ ('Plank', 3),+ ], weekday: 1),+ ProgramDay('Full Body', [+ ('Barbell Squat', 3),+ ('Barbell Bench Press', 3),+ ('Barbell Row', 3),+ ('Overhead Press', 3),+ ('Romanian Deadlift', 3),+ ('Plank', 3),+ ], weekday: 3),+ ProgramDay('Full Body', [+ ('Barbell Squat', 3),+ ('Barbell Bench Press', 3),+ ('Barbell Row', 3),+ ('Overhead Press', 3),+ ('Romanian Deadlift', 3),+ ('Plank', 3),+ ], weekday: 5),+ ]),+ ProgramTemplate('ppl', 'Push Pull Legs', [+ ProgramDay('Push', [+ ('Barbell Bench Press', 4),+ ('Incline Dumbbell Press', 3),+ ('Overhead Press', 3),+ ('Lateral Raise', 3),+ ('Triceps Pushdown', 3),+ ], weekday: 1),+ ProgramDay('Pull', [+ ('Pull Up', 4),+ ('Barbell Row', 4),+ ('Lat Pulldown', 3),+ ('Face Pull', 3),+ ('Barbell Curl', 3),+ ], weekday: 3),+ ProgramDay('Legs', [+ ('Barbell Squat', 4),+ ('Romanian Deadlift', 3),+ ('Leg Press', 3),+ ('Leg Curl', 3),+ ('Standing Calf Raise', 4),+ ], weekday: 5),+ ]),+ ProgramTemplate('upperlower', 'Upper Lower', [+ ProgramDay('Upper', [+ ('Barbell Bench Press', 4),+ ('Barbell Row', 4),+ ('Overhead Press', 3),+ ('Lat Pulldown', 3),+ ('Barbell Curl', 3),+ ('Triceps Pushdown', 3),+ ], weekday: 1),+ ProgramDay('Lower', [+ ('Barbell Squat', 4),+ ('Romanian Deadlift', 3),+ ('Leg Press', 3),+ ('Leg Curl', 3),+ ('Standing Calf Raise', 4),+ ], weekday: 2),+ ProgramDay('Upper', [+ ('Incline Dumbbell Press', 4),+ ('Pull Up', 4),+ ('Dumbbell Standing Overhead Press', 3),+ ('Seated Cable Row', 3),+ ('Hammer Curl', 3),+ ('Triceps Dip', 3),+ ], weekday: 4),+ ProgramDay('Lower', [+ ('Deadlift', 3),+ ('Front Squat', 3),+ ('Leg Extension', 3),+ ('Leg Curl', 3),+ ('Standing Calf Raise', 4),+ ], weekday: 5),+ ]),+ ProgramTemplate('stronglifts', 'StrongLifts 5×5', [+ ProgramDay('Workout A', [+ ('Barbell Squat', 5),+ ('Barbell Bench Press', 5),+ ('Barbell Row', 5),+ ], weekday: 1),+ ProgramDay('Workout B', [+ ('Barbell Squat', 5),+ ('Overhead Press', 5),+ ('Deadlift', 1),+ ], weekday: 3),+ ]),+ ProgramTemplate('startingstrength', 'Starting Strength', [+ ProgramDay('Workout A', [+ ('Barbell Squat', 3),+ ('Barbell Bench Press', 3),+ ('Deadlift', 1),+ ], weekday: 1),+ ProgramDay('Workout B', [+ ('Barbell Squat', 3),+ ('Overhead Press', 3),+ ('Barbell Row', 3),+ ], weekday: 3),+ ]),+ ProgramTemplate('home', 'No Kit', [+ ProgramDay('Home A', [+ ('Push Up', 3),+ ('Pull Up', 3),+ ('Bodyweight Squat', 3),+ ('Plank', 3),+ ], weekday: 2),+ ProgramDay('Home B', [+ ('Triceps Dip', 3),+ ('Chin Up', 3),+ ('Lunge', 3),+ ('Hanging Leg Raise', 3),+ ], weekday: 5),+ ]),+];diff --git a/lib/screens/routine_edit_screen.dart b/lib/screens/routine_edit_screen.dartindex a4b025a..85e9287 100644--- a/lib/screens/routine_edit_screen.dart+++ b/lib/screens/routine_edit_screen.dart@@ -1,16 +1,18 @@import 'package:flutter/material.dart';-import 'package:phosphor_flutter/phosphor_flutter.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';import '../catalog/exercise_catalog.dart';import '../l10n/l10n.dart';import '../models/exercise.dart';-import '../services/exercise_match.dart';+import '../models/workout.dart';import '../state/fit_state.dart';import '../theme/app_colors.dart';import '../theme/app_theme.dart';+import '../widgets/dialogs.dart';import '../widgets/exercise_media.dart';import '../widgets/svg_icon.dart';import '../widgets/ui_kit.dart';+import 'exercises_screen.dart';class RoutineEditScreen extends StatefulWidget {const RoutineEditScreen({super.key});@@ -33,9 +35,11 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {super.dispose();}- List<Exercise> get _filtered {- if (_q.trim().isEmpty) return kExercises;- return kExercises.where(exerciseSearch(_q)).toList();+ List<Exercise> get _filtered => fit.exercisesMatching(_q);++ void _clearSearch() {+ _search.clear();+ setState(() => _q = '');}@override@@ -53,9 +57,10 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {Expanded(child: ListView.builder(padding: const EdgeInsets.fromLTRB(20, 12, 20, 20),- itemCount: list.length + 1,+ itemCount: (list.isEmpty ? 1 : list.length) + 1,itemBuilder: (context, i) {if (i == 0) return _header(gc, routine.exerciseIds.length);+ if (list.isEmpty) return _noMatches(gc);return _pickRow(gc, list[i - 1]);},),@@ -86,7 +91,7 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {child: TextField(controller: _name,autofocus: fit.activeRoutine?.name.isEmpty ?? false,- style: AppTheme.d(22, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.5),+ style: AppTheme.f(22, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.5),cursorColor: gc.accent,textCapitalization: TextCapitalization.words,onChanged: (v) => fit.renameRoutine(_id, v),@@ -94,10 +99,22 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {isCollapsed: true,border: InputBorder.none,hintText: t.routineName,- hintStyle: AppTheme.d(22, weight: FontWeight.w700, color: gc.textTertiary),+ hintStyle: AppTheme.f(22, weight: FontWeight.w700, color: gc.textTertiary),+ ),+ ),+ ),+ Semantics(+ button: true,+ label: t.duplicateRoutine,+ child: GestureDetector(+ onTap: () => fit.openRoutine(fit.duplicateRoutine(_id)),+ child: Padding(+ padding: const EdgeInsets.all(6),+ child: Icon(PhosphorIconsRegular.copySimple, size: 19, color: gc.textTertiary),),),),+ const SizedBox(width: 4),GestureDetector(onTap: _confirmDelete,child: Padding(@@ -107,23 +124,55 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {),]),const SizedBox(height: 20),- Text(t.schedule, style: AppTheme.d(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 3)),+ Text(t.schedule, style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1.5)),const SizedBox(height: 10),Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [for (int i = 0; i < 7; i++) _dayToggle(gc, i)],),+ const SizedBox(height: 18),+ GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => _pickGroup(routine),+ child: Container(+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),+ decoration: BoxDecoration(+ color: gc.bgRaised,+ borderRadius: BorderRadius.circular(14),+ ),+ child: Row(+ children: [+ Icon(PhosphorIconsRegular.folderSimple, size: 17, color: gc.textSecondary),+ const SizedBox(width: 12),+ Expanded(+ child: Text(t.routineGroup,+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.text)),+ ),+ Text(routine.group.isEmpty ? t.noGroup : routine.group,+ style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary)),+ const SizedBox(width: 6),+ Icon(PhosphorIconsRegular.caretRight, size: 14, color: gc.textTertiary),+ ],+ ),+ ),+ ),const SizedBox(height: 24),- Text(t.exercisesWithCount(count), style: AppTheme.d(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 3)),+ Text(t.exercisesWithCount(count), style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1.5)),const SizedBox(height: 10),if (routine.exerciseIds.isEmpty)Padding(padding: const EdgeInsets.only(bottom: 6),- child: Text(t.addFromList, style: AppTheme.s(13, color: gc.textTertiary)),+ child: Text(t.addFromList, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textTertiary)),)else ...[+ Text(t.setsPlannedHint, style: AppTheme.f(11, weight: FontWeight.w500, color: gc.textTertiary)),+ const SizedBox(height: 6),+ if (routine.exerciseIds.length > 1) ...[+ Text(t.supersetHint, style: AppTheme.f(11, weight: FontWeight.w500, color: gc.textTertiary)),+ const SizedBox(height: 6),+ ],if (routine.exerciseIds.length > 1) ...[- Text(t.dragToReorder, style: AppTheme.s(11, color: gc.textTertiary)),+ Text(t.dragToReorder, style: AppTheme.f(11, weight: FontWeight.w500, color: gc.textTertiary)),const SizedBox(height: 8),],ReorderableListView(@@ -133,7 +182,7 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {onReorder: (from, to) => fit.reorderRoutineExercise(routine.id, from, to),children: [for (int i = 0; i < fit.routineExercises(routine).length; i++)- _chosenRow(gc, fit.routineExercises(routine)[i], i),+ _chosenRow(gc, routine, fit.routineExercises(routine)[i], i),],),],@@ -143,11 +192,78 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {hint: t.addExercises,onChanged: (v) => setState(() => _q = v),),+ const SizedBox(height: 10),+ _filterChips(gc),const SizedBox(height: 12),],);}+ Widget _filterChips(GymColors gc) {+ Widget chip(String label, bool active, VoidCallback onTap) => Padding(+ padding: const EdgeInsets.only(right: 8),+ child: Pill(+ label: label,+ bg: active ? gc.ember : gc.bgRaised2,+ fg: active ? gc.onEmber : gc.textSecondary,+ onTap: onTap,+ hPad: 12,+ vPad: 6,+ fontSize: 12,+ ),+ );+ final picked = (fit.exMuscleFilter == null ? 0 : 1) ++ (fit.exEquipmentFilter == null ? 0 : 1) ++ (fit.exDifficultyFilter == null ? 0 : 1);+ return SingleChildScrollView(+ scrollDirection: Axis.horizontal,+ child: Row(children: [+ chip(picked > 0 ? '${t.filters} · $picked' : t.filters, picked > 0,+ () => showExerciseFilters(context, onClear: _clearSearch)),+ chip(t.favouritesOnly, fit.exFavouritesOnly, fit.toggleFavouritesFilter),+ chip(t.noGearOnly, fit.exNoGearOnly, fit.toggleNoGearFilter),+ for (final id in kFilterMuscles)+ chip(muscleLabel(id), fit.exMuscleFilter == id, () => fit.setMuscleFilter(id)),+ ]),+ );+ }++ Widget _noMatches(GymColors gc) {+ return Padding(+ padding: const EdgeInsets.symmetric(vertical: 28),+ child: Column(+ children: [+ Text(t.noExercisesFound, style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),+ const SizedBox(height: 12),+ Row(+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ Pill(+ label: t.clearFilters,+ bg: gc.bgRaised2,+ fg: gc.accent,+ onTap: () {+ _clearSearch();+ fit.clearExFilters();+ },+ ),+ const SizedBox(width: 10),+ Pill(+ label: t.newExercise,+ bg: gc.bgRaised2,+ fg: gc.textSecondary,+ onTap: () => showCreateExerciseSheet(+ context,+ onCreated: (id) => fit.toggleRoutineExercise(_id, id),+ ),+ ),+ ],+ ),+ ],+ ),+ );+ }+Widget _dayToggle(GymColors gc, int i) {final weekday = i + 1;final on = fit.weeklyPlan[weekday] == _id;@@ -162,19 +278,18 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {),alignment: Alignment.center,child: Text(t.weekdayInitial(i + 1),- style: AppTheme.d(14, weight: FontWeight.w700, color: on ? gc.onEmber : gc.textSecondary)),+ style: AppTheme.f(14, weight: FontWeight.w700, color: on ? gc.onEmber : gc.textSecondary)),),);}- Widget _chosenRow(GymColors gc, Exercise ex, int index) {+ Widget _chosenRow(GymColors gc, Routine routine, Exercise ex, int index) {return Container(key: ValueKey(ex.id),margin: const EdgeInsets.only(bottom: 8),padding: const EdgeInsets.all(8),decoration: BoxDecoration(color: gc.bgRaised,- border: Border.all(color: gc.border),borderRadius: BorderRadius.circular(14),),child: Row(children: [@@ -192,8 +307,50 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {SizedBox(width: 44, child: ExerciseMedia(ex: ex, height: 44, radius: 10)),const SizedBox(width: 12),Expanded(- child: Text(exerciseName(ex), style: AppTheme.s(14, weight: FontWeight.w600, color: gc.text)),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(exerciseName(ex),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),+ const SizedBox(height: 2),+ StepperControl(+ value: t.setCount(fit.routineSets(routine, ex.id)),+ minWidth: 62,+ btnSize: 24,+ gap: 8,+ fontSize: 12,+ btnRadius: 7,+ onDec: () => fit.bumpRoutineSets(_id, ex.id, -1),+ onInc: () => fit.bumpRoutineSets(_id, ex.id, 1),+ ),+ ],+ ),),+ if (index < routine.exerciseIds.length - 1)+ Semantics(+ button: true,+ toggled: routine.chained.contains(ex.id),+ label: t.supersetLink,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => fit.toggleChain(_id, ex.id),+ child: SizedBox(+ width: 38,+ height: 44,+ child: Center(+ child: Icon(+ routine.chained.contains(ex.id)+ ? PhosphorIconsFill.link+ : PhosphorIconsRegular.link,+ size: 17,+ color: routine.chained.contains(ex.id) ? gc.ember : gc.textTertiary,+ ),+ ),+ ),+ ),+ ),Semantics(button: true,label: t.removeFromRoutine,@@ -238,9 +395,9 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [- Text(exerciseName(ex), style: AppTheme.s(14, weight: FontWeight.w600, color: gc.text)),+ Text(exerciseName(ex), style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),const SizedBox(height: 2),- Text('${muscleLabel(ex.primary)} · ${t.equipment(ex.equipment)}', style: AppTheme.s(12, color: gc.textSecondary)),+ Text('${muscleLabel(ex.primary)} · ${t.equipment(ex.equipment)}', style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),],),),@@ -261,6 +418,111 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {);}+ void _pickGroup(Routine routine) {+ final gc = context.gc;+ showModalBottomSheet<void>(+ context: context,+ backgroundColor: Colors.transparent,+ builder: (sheet) => Container(+ padding: sheetPad(sheet),+ decoration: BoxDecoration(+ color: gc.bgRaised,+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),+ ),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ const SheetHandle(),+ const SizedBox(height: 18),+ Text(t.routineGroup,+ textAlign: TextAlign.center,+ style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),+ const SizedBox(height: 16),+ _groupOption(gc, t.noGroup, routine.group.isEmpty, () {+ fit.setRoutineGroup(_id, '');+ Navigator.pop(sheet);+ }),+ for (final group in fit.routineGroups)+ _groupOption(gc, group, routine.group == group, () {+ fit.setRoutineGroup(_id, group);+ Navigator.pop(sheet);+ }),+ const SizedBox(height: 6),+ GhostButton(+ label: t.newGroup,+ icon: PhosphorIconsRegular.plus,+ onTap: () {+ Navigator.pop(sheet);+ _newGroup();+ },+ ),+ ],+ ),+ ),+ );+ }++ Widget _groupOption(GymColors gc, String label, bool selected, VoidCallback onTap) {+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap,+ child: Container(+ margin: const EdgeInsets.only(bottom: 8),+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),+ decoration: BoxDecoration(+ color: selected ? gc.emberSoft : gc.bgRaised2,+ borderRadius: BorderRadius.circular(14),+ border: Border.all(color: selected ? gc.ember : Colors.transparent),+ ),+ child: Row(+ children: [+ Expanded(+ child: Text(label,+ style: AppTheme.f(14, weight: FontWeight.w600, color: selected ? gc.ember : gc.text)),+ ),+ if (selected) SvgPathIcon(Ic.checkBold, size: 16, color: gc.ember),+ ],+ ),+ ),+ );+ }++ Future<void> _newGroup() async {+ final gc = context.gc;+ final controller = TextEditingController();+ final name = await showDialog<String>(+ context: context,+ builder: (dctx) => appDialog(+ gc,+ title: Text(t.newGroup, style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text)),+ content: TextField(+ controller: controller,+ autofocus: true,+ textCapitalization: TextCapitalization.words,+ style: AppTheme.f(15, weight: FontWeight.w500, color: gc.text),+ cursorColor: gc.accent,+ decoration: InputDecoration(+ hintText: t.groupNameHint,+ hintStyle: AppTheme.f(15, weight: FontWeight.w500, color: gc.textTertiary),+ filled: true,+ fillColor: gc.bgRaised2,+ contentPadding: const EdgeInsets.symmetric(horizontal: 18, vertical: 16),+ border: OutlineInputBorder(+ borderRadius: BorderRadius.circular(18), borderSide: BorderSide.none),+ ),+ onSubmitted: (v) => Navigator.of(dctx).pop(v),+ ),+ actions: [+ dialogAction(t.cancel, gc.textSecondary, () => Navigator.of(dctx).pop(), strong: false),+ dialogAction(t.save, gc.accent, () => Navigator.of(dctx).pop(controller.text)),+ ],+ ),+ );+ controller.dispose();+ if (name != null && name.trim().isNotEmpty) fit.setRoutineGroup(_id, name);+ }+void _confirmDelete() {final gc = context.gc;showModalBottomSheet<void>(@@ -274,7 +536,7 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.stretch,children: [- Text(t.deleteRoutine, style: AppTheme.s(15, weight: FontWeight.w600, color: gc.text)),+ Text(t.deleteRoutine, style: AppTheme.f(15, weight: FontWeight.w600, color: gc.text)),const SizedBox(height: 18),PrimaryButton(label: t.deleteCaps,@@ -292,7 +554,7 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {height: 48,alignment: Alignment.center,child: Text(t.cancelCaps,- style: AppTheme.d(14, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1)),+ style: AppTheme.f(14, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1)),),),],diff --git a/lib/screens/routines_screen.dart b/lib/screens/routines_screen.dartindex e48f49c..f2b1b7a 100644--- a/lib/screens/routines_screen.dart+++ b/lib/screens/routines_screen.dart@@ -1,6 +1,7 @@import 'package:flutter/material.dart';-import 'package:phosphor_flutter/phosphor_flutter.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';+import '../catalog/program_templates.dart';import '../l10n/l10n.dart';import '../models/workout.dart';import '../state/fit_state.dart';@@ -24,7 +25,7 @@ class RoutinesScreen extends StatelessWidget {children: [ScreenHeader(title: t.routines, onBack: fit.backFromRoutines, titleSize: 22),const SizedBox(height: 22),- Text(t.weeklyPlan, style: AppTheme.d(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 3)),+ Text(t.weeklyPlan, style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1.5)),const SizedBox(height: 10),SoftCard(radius: 18,@@ -32,21 +33,127 @@ class RoutinesScreen extends StatelessWidget {child: Column(children: [for (int i = 0; i < 7; i++) _dayRow(context, gc, i)]),),const SizedBox(height: 26),- Text(t.yourRoutines, style: AppTheme.d(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 3)),+ Text(t.yourRoutines, style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1.5)),const SizedBox(height: 10),if (fit.routines.isEmpty)Padding(padding: const EdgeInsets.symmetric(vertical: 26),child: Text(t.noRoutines,- textAlign: TextAlign.center, style: AppTheme.s(13, color: gc.textSecondary)),+ textAlign: TextAlign.center, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),)- else- for (final r in fit.routines) _routineCard(gc, r),+ else ...[+ for (final group in fit.routineGroups) ...[+ _groupHeader(gc, group, fit.routinesInGroup(group).length),+ for (final r in fit.routinesInGroup(group)) _routineCard(gc, r),+ const SizedBox(height: 8),+ ],+ for (final r in fit.routinesInGroup('')) _routineCard(gc, r),+ ],const SizedBox(height: 16),PrimaryButton(label: t.newRoutine,onTap: () => fit.openRoutine(fit.createRoutine()),),+ const SizedBox(height: 10),+ GhostButton(+ label: t.templates,+ icon: PhosphorIconsRegular.stack,+ onTap: () => _openTemplates(context),+ ),+ const SizedBox(height: 10),+ GhostButton(+ label: t.aiRoutine,+ icon: PhosphorIconsRegular.sparkle,+ onTap: fit.goAiPlan,+ ),+ ],+ ),+ ),+ );+ }++ void _openTemplates(BuildContext context) {+ final gc = context.gc;+ showModalBottomSheet<void>(+ context: context,+ backgroundColor: Colors.transparent,+ isScrollControlled: true,+ builder: (sheet) => Container(+ padding: sheetPad(sheet),+ constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.85),+ decoration: BoxDecoration(+ color: gc.bgRaised,+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),+ ),+ child: SingleChildScrollView(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ const SheetHandle(),+ const SizedBox(height: 18),+ Text(t.templates,+ textAlign: TextAlign.center,+ style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),+ const SizedBox(height: 6),+ Text(t.templatesHint,+ textAlign: TextAlign.center,+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),+ const SizedBox(height: 18),+ for (final template in kProgramTemplates)+ _templateCard(context, gc, sheet, template),+ ],+ ),+ ),+ ),+ );+ }++ Widget _templateCard(+ BuildContext context, GymColors gc, BuildContext sheet, ProgramTemplate template) {+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () {+ final made = fit.applyTemplate(template);+ Navigator.pop(sheet);+ if (made == 0 || !context.mounted) return;+ ScaffoldMessenger.of(context).showSnackBar(+ SnackBar(content: Text(t.templateAdded(made)), behavior: SnackBarBehavior.floating),+ );+ },+ child: Container(+ margin: const EdgeInsets.only(bottom: 10),+ padding: const EdgeInsets.all(14),+ decoration: BoxDecoration(+ color: gc.bgRaised2,+ borderRadius: BorderRadius.circular(16),+ ),+ child: Row(+ children: [+ Container(+ width: 42,+ height: 42,+ decoration: BoxDecoration(color: gc.emberSoft, borderRadius: BorderRadius.circular(12)),+ child: Icon(PhosphorIconsRegular.stack, size: 20, color: gc.ember),+ ),+ const SizedBox(width: 14),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(template.name,+ style: AppTheme.f(15, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.5)),+ const SizedBox(height: 2),+ Text(t.templateBlurb(template.id),+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.35)),+ const SizedBox(height: 4),+ Text(t.dayCount(template.days.length),+ style: AppTheme.f(11, weight: FontWeight.w500, color: gc.textTertiary)),+ ],+ ),+ ),+ const SizedBox(width: 8),+ Icon(PhosphorIconsRegular.plus, size: 16, color: gc.textSecondary),],),),@@ -65,15 +172,17 @@ class RoutinesScreen extends StatelessWidget {padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),child: Row(children: [- SizedBox(- width: 92,- child: Text(t.weekday(i + 1),- style: AppTheme.s(14, weight: FontWeight.w600, color: isToday ? gc.ember : gc.text)),- ),+ Text(t.weekdayShort(weekday),+ maxLines: 1,+ softWrap: false,+ style: AppTheme.f(14, weight: FontWeight.w600, color: isToday ? gc.ember : gc.text)),+ const SizedBox(width: 14),Expanded(child: Text(assigned == null ? t.restDayShort : fit.routineTitle(assigned),textAlign: TextAlign.right,- style: AppTheme.s(14, color: assigned != null ? gc.text : gc.textTertiary)),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(14, weight: FontWeight.w500, color: assigned != null ? gc.text : gc.textTertiary)),),const SizedBox(width: 8),SvgPathIcon(Ic.chevronRight, size: 14, color: gc.textTertiary),@@ -83,6 +192,25 @@ class RoutinesScreen extends StatelessWidget {);}+ Widget _groupHeader(GymColors gc, String name, int count) {+ return Padding(+ padding: const EdgeInsets.only(bottom: 8, left: 4),+ child: Row(+ children: [+ Icon(PhosphorIconsRegular.folderSimple, size: 15, color: gc.brass),+ const SizedBox(width: 8),+ Expanded(+ child: Text(name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(13, weight: FontWeight.w700, color: gc.text, letterSpacing: 1)),+ ),+ Text('$count', style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary)),+ ],+ ),+ );+ }+Widget _routineCard(GymColors gc, Routine r) {final n = r.exerciseIds.length;return GestureDetector(@@ -93,7 +221,6 @@ class RoutinesScreen extends StatelessWidget {padding: const EdgeInsets.all(14),decoration: BoxDecoration(color: gc.bgRaised,- border: Border.all(color: gc.border),borderRadius: BorderRadius.circular(18),),child: Row(@@ -109,9 +236,9 @@ class RoutinesScreen extends StatelessWidget {child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [- Text(fit.routineTitle(r), style: AppTheme.s(15, weight: FontWeight.w600, color: gc.text)),+ Text(fit.routineTitle(r), style: AppTheme.f(15, weight: FontWeight.w600, color: gc.text)),const SizedBox(height: 2),- Text(t.exerciseCount(n), style: AppTheme.s(12, color: gc.textSecondary)),+ Text(t.exerciseCount(n), style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),],),),@@ -145,14 +272,21 @@ class RoutinesScreen extends StatelessWidget {crossAxisAlignment: CrossAxisAlignment.stretch,children: [Text(t.setDay(t.weekday(weekday).toUpperCase()),- style: AppTheme.d(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 2)),+ style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 0.4)),const SizedBox(height: 14),_sheetItem(context, gc, t.restDayShort, fit.weeklyPlan[weekday] == null, () {fit.assignRoutineToDay(weekday, null);Navigator.pop(context);}),- for (final r in fit.routines)- _sheetItem(context, gc, fit.routineTitle(r), fit.weeklyPlan[weekday] == r.id, () {+ for (final r in [+ for (final group in fit.routineGroups) ...fit.routinesInGroup(group),+ ...fit.routinesInGroup(''),+ ])+ _sheetItem(+ context,+ gc,+ r.group.isEmpty ? fit.routineTitle(r) : '${r.group} · ${fit.routineTitle(r)}',+ fit.weeklyPlan[weekday] == r.id, () {fit.assignRoutineToDay(weekday, r.id);Navigator.pop(context);}),@@ -179,7 +313,7 @@ class RoutinesScreen extends StatelessWidget {children: [Expanded(child: Text(label,- style: AppTheme.s(14, weight: FontWeight.w600, color: selected ? gc.ember : gc.text)),+ style: AppTheme.f(14, weight: FontWeight.w600, color: selected ? gc.ember : gc.text)),),if (selected) SvgPathIcon(Ic.checkBold, size: 16, color: gc.ember),],diff --git a/lib/screens/start_sheet.dart b/lib/screens/start_sheet.dartnew file mode 100644index 0000000..ae0bd6d--- /dev/null+++ b/lib/screens/start_sheet.dart@@ -0,0 +1,186 @@+import 'package:flutter/material.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';++import '../l10n/l10n.dart';+import '../models/workout.dart';+import '../state/fit_state.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import '../widgets/ui_kit.dart';++void showStartSheet(BuildContext context, {DateTime? day}) {+ showModalBottomSheet<void>(+ context: context,+ backgroundColor: Colors.transparent,+ isScrollControlled: true,+ builder: (_) => StartSheet(day: day),+ );+}++class StartSheet extends StatelessWidget {+ const StartSheet({super.key, this.day});++ final DateTime? day;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final planned = day == null ? fit.todayRoutine : fit.routineOn(day!);+ final others = [+ for (final group in fit.routineGroups) ...fit.routinesInGroup(group),+ ...fit.routinesInGroup(''),+ ].where((r) => r.id != planned?.id && r.exerciseIds.isNotEmpty).toList();+ return Container(+ constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(context).height * 0.82),+ padding: sheetPad(context),+ decoration: BoxDecoration(+ color: gc.bgRaised,+ border: Border.all(color: gc.border),+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),+ ),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ const SheetHandle(),+ const SizedBox(height: 16),+ Text(day == null ? t.startTitle : t.logTitle,+ style: AppTheme.f(21, weight: FontWeight.w700, color: gc.text)),+ const SizedBox(height: 4),+ Text(t.longDate(day ?? DateTime.now()),+ style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary)),+ if (day != null) ...[+ const SizedBox(height: 12),+ Text(t.logHint, style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textTertiary)),+ ],+ const SizedBox(height: 18),+ Flexible(+ child: SingleChildScrollView(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ if (planned != null && planned.exerciseIds.isNotEmpty) ...[+ _plannedCard(context, gc, planned),+ const SizedBox(height: 10),+ ],+ if (others.isNotEmpty) ...[+ _label(gc, t.yourRoutines),+ for (final r in others) ...[+ _routineRow(context, gc, r),+ const SizedBox(height: 8),+ ],+ const SizedBox(height: 6),+ ],+ _label(gc, t.orStartFrom),+ _option(context, gc, PhosphorIconsRegular.listPlus, t.pickExercisesOption,+ () => fit.startPicking(on: day)),+ const SizedBox(height: 8),+ _option(context, gc, PhosphorIconsRegular.person, t.chooseFocusOption,+ () => fit.startWorkout(null, day)),+ ],+ ),+ ),+ ),+ ],+ ),+ );+ }++ Widget _label(GymColors gc, String text) => Padding(+ padding: const EdgeInsets.only(left: 4, bottom: 8),+ child: Text(text.toUpperCase(),+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.2)),+ );++ Widget _plannedCard(BuildContext context, GymColors gc, Routine r) {+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => _go(context, () => fit.startRoutine(r, on: day)),+ child: Container(+ padding: const EdgeInsets.all(16),+ decoration: BoxDecoration(+ color: gc.emberSoft,+ border: Border.all(color: gc.ember.withValues(alpha: 0.4)),+ borderRadius: BorderRadius.circular(20),+ ),+ child: Row(children: [+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(day == null ? t.todaysRoutine : t.plannedRoutine,+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.brass, letterSpacing: 1.2)),+ const SizedBox(height: 6),+ Text(fit.routineTitle(r),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(18, weight: FontWeight.w700, color: gc.text)),+ const SizedBox(height: 2),+ Text(t.exerciseCount(r.exerciseIds.length),+ style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary)),+ ],+ ),+ ),+ const SizedBox(width: 12),+ Container(+ width: 46,+ height: 46,+ decoration: BoxDecoration(color: gc.ember, shape: BoxShape.circle),+ child: Icon(PhosphorIconsFill.play, size: 18, color: gc.onEmber),+ ),+ ]),+ ),+ );+ }++ Widget _routineRow(BuildContext context, GymColors gc, Routine r) {+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => _go(context, () => fit.startRoutine(r, on: day)),+ child: SoftCard(+ radius: 16,+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 13),+ child: Row(children: [+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(r.group.isEmpty ? fit.routineTitle(r) : '${r.group} · ${fit.routineTitle(r)}',+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(14.5, weight: FontWeight.w600, color: gc.text)),+ const SizedBox(height: 2),+ Text(t.exerciseCount(r.exerciseIds.length),+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),+ ],+ ),+ ),+ const SizedBox(width: 10),+ Icon(PhosphorIconsFill.play, size: 14, color: gc.textSecondary),+ ]),+ ),+ );+ }++ Widget _option(+ BuildContext context, GymColors gc, IconData icon, String label, VoidCallback action) {+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => _go(context, action),+ child: SoftCard(+ radius: 16,+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14),+ child: Row(children: [+ Icon(icon, size: 19, color: gc.textSecondary),+ const SizedBox(width: 13),+ Expanded(child: Text(label, style: AppTheme.f(14.5, weight: FontWeight.w600, color: gc.text))),+ ]),+ ),+ );+ }++ void _go(BuildContext context, VoidCallback action) {+ Navigator.of(context).pop();+ action();+ }+}diff --git a/lib/state/routines_state.dart b/lib/state/routines_state.dartindex f6c3c4a..d76243f 100644--- a/lib/state/routines_state.dart+++ b/lib/state/routines_state.dart@@ -1,10 +1,17 @@part of 'fit_state.dart';+const int kDefaultRoutineSets = 3;+mixin RoutinesState on FitCore, LibraryState {String? activeRoutineId;+ int _routineSeq = 0;void goRoutines() => pushRoute('routines');+ void goAiPlan() => pushRoute('ai-plan');++ void backFromAiPlan() => popRoute(fallback: 'routines');+void backFromRoutines() => popRoute();Routine? _routine(String id) {@@ -25,14 +32,17 @@ mixin RoutinesState on FitCore, LibraryState {return out;}- Routine? get todayRoutine {- final id = weeklyPlan[DateTime.now().weekday];+ Routine? get todayRoutine => routineOn(DateTime.now());++ Routine? routineOn(DateTime day) {+ final id = weeklyPlan[day.weekday];return id == null ? null : _routine(id);}String createRoutine([String name = '']) {- final id = 'r${DateTime.now().microsecondsSinceEpoch}';+ final id = 'r${DateTime.now().microsecondsSinceEpoch}-${_routineSeq++}';routines.add(Routine(id, name.trim(), []));+ refreshAwards();_persist();notifyListeners();return id;@@ -46,6 +56,38 @@ mixin RoutinesState on FitCore, LibraryState {notifyListeners();}+ List<String> get routineGroups {+ final out = <String>[];+ for (final r in routines) {+ if (r.group.isNotEmpty && !out.contains(r.group)) out.add(r.group);+ }+ return out;+ }++ List<Routine> routinesInGroup(String group) =>+ routines.where((r) => r.group == group).toList();++ void setRoutineGroup(String id, String group) {+ final r = _routine(id);+ if (r == null) return;+ r.group = group.trim();+ _persist();+ notifyListeners();+ }++ String duplicateRoutine(String id) {+ final source = _routine(id);+ if (source == null) return '';+ final copy = createRoutine(t.copySuffix(routineTitle(source)));+ final made = _routine(copy)!;+ made.exerciseIds.addAll(source.exerciseIds);+ made.sets.addAll(source.sets);+ made.group = source.group;+ _persist();+ notifyListeners();+ return copy;+ }+void deleteRoutine(String id) {routines.removeWhere((r) => r.id == id);weeklyPlan.removeWhere((_, v) => v == id);@@ -57,7 +99,34 @@ mixin RoutinesState on FitCore, LibraryState {void toggleRoutineExercise(String routineId, String exId) {final r = _routine(routineId);if (r == null) return;- if (!r.exerciseIds.remove(exId)) r.exerciseIds.add(exId);+ if (r.exerciseIds.remove(exId)) {+ r.sets.remove(exId);+ } else {+ r.exerciseIds.add(exId);+ }+ _persist();+ notifyListeners();+ }++ int routineSets(Routine r, String exId) => r.sets[exId] ?? kDefaultRoutineSets;++ bool chainsToNext(Routine r, String exId) {+ final i = r.exerciseIds.indexOf(exId);+ return i >= 0 && i < r.exerciseIds.length - 1 && r.chained.contains(exId);+ }++ void toggleChain(String routineId, String exId) {+ final r = _routine(routineId);+ if (r == null) return;+ if (!r.chained.remove(exId)) r.chained.add(exId);+ _persist();+ notifyListeners();+ }++ void bumpRoutineSets(String routineId, String exId, int delta) {+ final r = _routine(routineId);+ if (r == null || !r.exerciseIds.contains(exId)) return;+ r.sets[exId] = (routineSets(r, exId) + delta).clamp(1, 12);_persist();notifyListeners();}@@ -80,6 +149,7 @@ mixin RoutinesState on FitCore, LibraryState {weeklyPlan[weekday] = routineId;}_persist();+ syncTrainReminder();notifyListeners();}