Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Edit progression and favourite from the routine editor
InlitX5d31d27207a3
diff --git a/lib/screens/exercise_detail_screen.dart b/lib/screens/exercise_detail_screen.dartindex cbdf27b..6254d64 100644--- a/lib/screens/exercise_detail_screen.dart+++ b/lib/screens/exercise_detail_screen.dart@@ -6,7 +6,6 @@ import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';import '../l10n/l10n.dart';import '../models/exercise.dart';-import '../models/progression.dart';import '../models/workout.dart';import '../services/exercise_match.dart';import '../state/fit_state.dart';@@ -20,6 +19,7 @@ import '../widgets/exercise_preview.dart';import '../widgets/ruler_picker.dart';import '../widgets/glass.dart';import '../widgets/liquid_notch.dart';+import '../widgets/progression_sheet.dart';import '../widgets/stopwatch_card.dart';import '../widgets/svg_icon.dart';import '../widgets/timer_panel.dart';@@ -915,17 +915,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {);}- Widget _star(GymColors gc, bool fav) {- return SizedBox(- width: 18,- height: 18,- child: Stack(children: [- if (fav)- SvgPathIcon(const [IconPath('M12 2l3.09 6.26L22 9.27l-5 4.87L18.18 21 12 17.77 5.82 21 7 14.14l-5-4.87 6.91-1.01z', fill: true)], size: 18, color: gc.accent),- SvgPathIcon(Ic.star, size: 18, color: fav ? gc.accent : gc.textSecondary),- ]),- );- }+ Widget _star(GymColors gc, bool fav) => FavoriteStar(on: fav);Widget _stackRow(BuildContext context, GymColors gc, String id) {final stack = fit.ownStackFor(id);@@ -1346,28 +1336,12 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {);}- String _kindName(ProgressKind k) => switch (k) {- ProgressKind.manual => t.progManual,- ProgressKind.linear => t.progLinear,- ProgressKind.double => t.progDouble,- ProgressKind.volume => t.progVolume,- ProgressKind.amrap => t.progAmrap,- };-- String _kindHint(ProgressKind k) => switch (k) {- ProgressKind.manual => t.progManualHint,- ProgressKind.linear => t.progLinearHint,- ProgressKind.double => t.progDoubleHint,- ProgressKind.volume => t.progVolumeHint,- ProgressKind.amrap => t.progAmrapHint,- };-Widget _progressRow(BuildContext context, GymColors gc, String id) {final kind = fit.progressRule(id).kind;final on = fit.hasProgress(id);return GestureDetector(behavior: HitTestBehavior.opaque,- onTap: () => _pickProgression(context, id),+ onTap: () => showProgressionSheet(context, id),child: Padding(padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),child: Row(@@ -1383,7 +1357,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {child: Text(t.progression, style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text)),),const SizedBox(width: 12),- Text(_kindName(kind), style: AppTheme.f(13, weight: FontWeight.w600, color: on ? gc.accent : gc.textSecondary)),+ Text(progressKindName(kind), style: AppTheme.f(13, weight: FontWeight.w600, color: on ? gc.accent : gc.textSecondary)),const SizedBox(width: 6),Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),],@@ -1392,152 +1366,6 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {);}- void _pickProgression(BuildContext context, String id) {- showAppSheet<void>(- context: context,- backgroundColor: Colors.transparent,- isScrollControlled: true,- builder: (sheet) => AnimatedBuilder(- animation: fit,- builder: (sheet, _) {- final gc = sheet.gc;- final rule = fit.progressRule(id);- final on = fit.hasProgress(id);- void set(ProgressRule r) => fit.setProgressRule(id, r);- Widget stepper(String value, VoidCallback dec, VoidCallback inc, {bool tight = false}) => StepperControl(- value: value,- minWidth: tight ? 28 : 44,- btnSize: tight ? 28 : 30,- gap: tight ? 2 : 4,- fontSize: 14,- btnRadius: 10,- onDec: dec,- onInc: inc,- );- Widget line(String label, List<Widget> controls) => Padding(- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),- child: Row(children: [- Expanded(child: FitText(label, style: AppTheme.f(13.5, weight: FontWeight.w500, color: gc.text))),- const SizedBox(width: 10),- for (var i = 0; i < controls.length; i++) ...[- if (i > 0)- Padding(- padding: const EdgeInsets.symmetric(horizontal: 4),- child: Text('–', style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textTertiary)),- ),- controls[i],- ],- ]),- );- final params = <Widget>[- Semantics(- button: true,- toggled: on,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () => fit.toggleProgress(id),- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),- child: Row(children: [- Expanded(- child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [- Text(t.progApply, style: AppTheme.f(14, weight: FontWeight.w500, color: gc.text)),- if (!on) ...[- const SizedBox(height: 3),- Text(t.progApplyHint,- style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),- ],- ]),- ),- const SizedBox(width: 12),- TinySwitch(on: on),- ]),- ),- ),- ),- if (on)- line(t.progStep, [- stepper(fit.weightLabel(fit.progressFor(id) ?? 0), () => fit.bumpProgressStep(id, -1),- () => fit.bumpProgressStep(id, 1)),- ]),- if (rule.usesRange)- line(t.progRange, [- stepper('${rule.low}', () => set(rule.copyWith(low: rule.low - 1)),- () => set(rule.copyWith(low: rule.low + 1, high: math.max(rule.high, rule.low + 2))), tight: true),- stepper('${rule.high}', () => set(rule.copyWith(high: rule.high - 1)),- () => set(rule.copyWith(high: rule.high + 1)), tight: true),- ]),- if (rule.kind == ProgressKind.volume)- line(t.progSets, [- stepper('${rule.sets}', () => set(rule.copyWith(sets: rule.sets - 1)),- () => set(rule.copyWith(sets: rule.sets + 1, maxSets: math.max(rule.maxSets, rule.sets + 2))), tight: true),- stepper('${rule.maxSets}', () => set(rule.copyWith(maxSets: rule.maxSets - 1)),- () => set(rule.copyWith(maxSets: rule.maxSets + 1)), tight: true),- ]),- if (on) ...[- line(t.progDeload, [- stepper(t.progFails(rule.fails), () => set(rule.copyWith(fails: rule.fails - 1)),- () => set(rule.copyWith(fails: rule.fails + 1))),- ]),- line(t.progDeloadPct, [- stepper('${rule.deloadPct} %', () => set(rule.copyWith(deloadPct: rule.deloadPct - 5)),- () => set(rule.copyWith(deloadPct: rule.deloadPct + 5))),- ]),- ],- ];- return ConstrainedBox(- constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.9),- child: Container(- decoration: sheetDecoration(gc),- child: SingleChildScrollView(- padding: sheetPad(sheet),- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- const SheetHandle(),- const SizedBox(height: 16),- SheetTitle(t.progression),- const SizedBox(height: 14),- OptionGroup([- for (final k in ProgressKind.values)- OptionItem(- _kindName(k),- detail: k == rule.kind ? _kindHint(k) : null,- selected: k == rule.kind,- onTap: () => set(rule.copyWith(kind: k)),- ),- ]),- AnimatedSize(- duration: const Duration(milliseconds: 240),- curve: Curves.easeOutCubic,- alignment: Alignment.topCenter,- child: rule.kind == ProgressKind.manual- ? const SizedBox(width: double.infinity)- : Container(- margin: const EdgeInsets.only(top: 12),- decoration: BoxDecoration(- border: Border.all(color: gc.border),- borderRadius: BorderRadius.circular(20),- ),- child: Column(children: [- for (var i = 0; i < params.length; i++) ...[- if (i > 0) Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border),- params[i],- ],- ]),- ),- ),- ],- ),- ),- ),- );- },- ),- );- }-Widget _repsOnlyRow(GymColors gc, String id, bool on) {return Semantics(button: true,diff --git a/lib/screens/routine_edit_screen.dart b/lib/screens/routine_edit_screen.dartindex e56ae13..73c5227 100644--- a/lib/screens/routine_edit_screen.dart+++ b/lib/screens/routine_edit_screen.dart@@ -16,6 +16,7 @@ import '../widgets/ruler_picker.dart';import '../widgets/glass.dart';import '../widgets/routine_folder.dart';import '../widgets/liquid_notch.dart';+import '../widgets/progression_sheet.dart';import '../widgets/set_kind.dart';import '../widgets/svg_icon.dart';import '../widgets/timer_panel.dart';@@ -831,7 +832,17 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {children: [const SheetHandle(),const SizedBox(height: 18),- Text(exerciseName(ex), style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text)),+ Row(children: [+ Expanded(+ child: Text(exerciseName(ex), style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text)),+ ),+ const SizedBox(width: 12),+ RoundAction(+ label: t.favouritesOnly,+ onTap: () => fit.toggleFavorite(ex.id),+ child: FavoriteStar(on: fit.favorites[ex.id] ?? false),+ ),+ ]),const SizedBox(height: 4),Text(switch (mode) {@@ -883,6 +894,10 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {),const SizedBox(height: 10),_restRow(sheet, gc, routine, ex),+ if (mode.isEmpty) ...[+ const SizedBox(height: 8),+ _progressRow(sheet, gc, ex),+ ],const SizedBox(height: 8),_altsRow(sheet, gc, routine, ex),if (fit.modeOf(ex.id).isEmpty) ...[@@ -900,6 +915,31 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {);}+ Widget _progressRow(BuildContext sheet, GymColors gc, Exercise ex) {+ final kind = fit.progressRule(ex.id).kind;+ final on = fit.hasProgress(ex.id);+ return Pressable(+ scale: 0.98,+ onTap: () => showProgressionSheet(sheet, ex.id),+ child: Container(+ padding: const EdgeInsets.fromLTRB(16, 12, 12, 12),+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(18)),+ child: Row(children: [+ SvgPathIcon(Ic.trendUp, size: 19, color: on ? gc.text : gc.textSecondary),+ const SizedBox(width: 12),+ Expanded(+ child: Text(t.progSchemeTitle, style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),+ ),+ const SizedBox(width: 8),+ Text(progressKindName(kind),+ style: AppTheme.f(13, weight: FontWeight.w600, color: on ? gc.accent : gc.textSecondary)),+ const SizedBox(width: 6),+ Icon(PhosphorIconsBold.caretRight, size: 13, color: gc.textTertiary),+ ]),+ ),+ );+ }+Widget _altsRow(BuildContext sheet, GymColors gc, Routine routine, Exercise ex) {final alts = [for (final id in fit.routineAlts(routine.id, ex.id)) ?fit.exerciseById(id)];return Pressable(diff --git a/lib/widgets/progression_sheet.dart b/lib/widgets/progression_sheet.dartnew file mode 100644index 0000000..8e80517--- /dev/null+++ b/lib/widgets/progression_sheet.dart@@ -0,0 +1,173 @@+import 'dart:math' as math;++import 'package:flutter/material.dart';++import '../l10n/l10n.dart';+import '../models/progression.dart';+import '../state/fit_state.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import 'glass.dart';+import 'ui_kit.dart';++String progressKindName(ProgressKind k) => switch (k) {+ ProgressKind.manual => t.progManual,+ ProgressKind.linear => t.progLinear,+ ProgressKind.double => t.progDouble,+ ProgressKind.volume => t.progVolume,+ ProgressKind.amrap => t.progAmrap,+ };++String progressKindHint(ProgressKind k) => switch (k) {+ ProgressKind.manual => t.progManualHint,+ ProgressKind.linear => t.progLinearHint,+ ProgressKind.double => t.progDoubleHint,+ ProgressKind.volume => t.progVolumeHint,+ ProgressKind.amrap => t.progAmrapHint,+ };++void showProgressionSheet(BuildContext context, String id) {+ showAppSheet<void>(+ context: context,+ backgroundColor: Colors.transparent,+ isScrollControlled: true,+ builder: (sheet) => AnimatedBuilder(+ animation: fit,+ builder: (sheet, _) {+ final gc = sheet.gc;+ final rule = fit.progressRule(id);+ final on = fit.hasProgress(id);+ void set(ProgressRule r) => fit.setProgressRule(id, r);+ Widget stepper(String value, VoidCallback dec, VoidCallback inc, {bool tight = false}) => StepperControl(+ value: value,+ minWidth: tight ? 28 : 44,+ btnSize: tight ? 28 : 30,+ gap: tight ? 2 : 4,+ fontSize: 14,+ btnRadius: 10,+ onDec: dec,+ onInc: inc,+ );+ Widget line(String label, List<Widget> controls) => Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),+ child: Row(children: [+ Expanded(child: FitText(label, style: AppTheme.f(13.5, weight: FontWeight.w500, color: gc.text))),+ const SizedBox(width: 10),+ for (var i = 0; i < controls.length; i++) ...[+ if (i > 0)+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 4),+ child: Text('–', style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textTertiary)),+ ),+ controls[i],+ ],+ ]),+ );+ final params = <Widget>[+ Semantics(+ button: true,+ toggled: on,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => fit.toggleProgress(id),+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),+ child: Row(children: [+ Expanded(+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Text(t.progApply, style: AppTheme.f(14, weight: FontWeight.w500, color: gc.text)),+ if (!on) ...[+ const SizedBox(height: 3),+ Text(t.progApplyHint,+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),+ ],+ ]),+ ),+ const SizedBox(width: 12),+ TinySwitch(on: on),+ ]),+ ),+ ),+ ),+ if (on)+ line(t.progStep, [+ stepper(fit.weightLabel(fit.progressFor(id) ?? 0), () => fit.bumpProgressStep(id, -1),+ () => fit.bumpProgressStep(id, 1)),+ ]),+ if (rule.usesRange)+ line(t.progRange, [+ stepper('${rule.low}', () => set(rule.copyWith(low: rule.low - 1)),+ () => set(rule.copyWith(low: rule.low + 1, high: math.max(rule.high, rule.low + 2))), tight: true),+ stepper('${rule.high}', () => set(rule.copyWith(high: rule.high - 1)),+ () => set(rule.copyWith(high: rule.high + 1)), tight: true),+ ]),+ if (rule.kind == ProgressKind.volume)+ line(t.progSets, [+ stepper('${rule.sets}', () => set(rule.copyWith(sets: rule.sets - 1)),+ () => set(rule.copyWith(sets: rule.sets + 1, maxSets: math.max(rule.maxSets, rule.sets + 2))), tight: true),+ stepper('${rule.maxSets}', () => set(rule.copyWith(maxSets: rule.maxSets - 1)),+ () => set(rule.copyWith(maxSets: rule.maxSets + 1)), tight: true),+ ]),+ if (on) ...[+ line(t.progDeload, [+ stepper(t.progFails(rule.fails), () => set(rule.copyWith(fails: rule.fails - 1)),+ () => set(rule.copyWith(fails: rule.fails + 1))),+ ]),+ line(t.progDeloadPct, [+ stepper('${rule.deloadPct} %', () => set(rule.copyWith(deloadPct: rule.deloadPct - 5)),+ () => set(rule.copyWith(deloadPct: rule.deloadPct + 5))),+ ]),+ ],+ ];+ return ConstrainedBox(+ constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.9),+ child: Container(+ decoration: sheetDecoration(gc),+ child: SingleChildScrollView(+ padding: sheetPad(sheet),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ const SheetHandle(),+ const SizedBox(height: 16),+ SheetTitle(t.progression),+ const SizedBox(height: 14),+ OptionGroup([+ for (final k in ProgressKind.values)+ OptionItem(+ progressKindName(k),+ detail: k == rule.kind ? progressKindHint(k) : null,+ selected: k == rule.kind,+ onTap: () => set(rule.copyWith(kind: k)),+ ),+ ]),+ AnimatedSize(+ duration: const Duration(milliseconds: 240),+ curve: Curves.easeOutCubic,+ alignment: Alignment.topCenter,+ child: rule.kind == ProgressKind.manual+ ? const SizedBox(width: double.infinity)+ : Container(+ margin: const EdgeInsets.only(top: 12),+ decoration: BoxDecoration(+ border: Border.all(color: gc.border),+ borderRadius: BorderRadius.circular(20),+ ),+ child: Column(children: [+ for (var i = 0; i < params.length; i++) ...[+ if (i > 0) Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border),+ params[i],+ ],+ ]),+ ),+ ),+ ],+ ),+ ),+ ),+ );+ },+ ),+ );+}diff --git a/lib/widgets/ui_kit.dart b/lib/widgets/ui_kit.dartindex a455858..dc62805 100644--- a/lib/widgets/ui_kit.dart+++ b/lib/widgets/ui_kit.dart@@ -1108,3 +1108,23 @@ class PrimaryButton extends StatelessWidget {);}}++class FavoriteStar extends StatelessWidget {+ const FavoriteStar({super.key, required this.on});++ final bool on;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ return SizedBox(+ width: 18,+ height: 18,+ child: Stack(children: [+ if (on)+ SvgPathIcon(const [IconPath('M12 2l3.09 6.26L22 9.27l-5 4.87L18.18 21 12 17.77 5.82 21 7 14.14l-5-4.87 6.91-1.01z', fill: true)], size: 18, color: gc.accent),+ SvgPathIcon(Ic.star, size: 18, color: on ? gc.accent : gc.textSecondary),+ ]),+ );+ }+}