Skip to content

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

Add shareable exercise notes to routines

Alexander Petrov5137e1ef63a6
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index 4c8fa75..69c0723 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -1828,6 +1828,9 @@
"byZone": "By area",
"importAlreadyHave": "You already have these routines. You can add them again as a copy.",
"importAsCopy": "Add as a copy",
+ "routineExerciseNote": "Routine note",
+ "importRoutineNotes": "Add missing routine notes",
+ "routineNotesAdded": "Routine notes added",
"importOwned": "Already yours",
"setDuplicated": "Set duplicated",
"setTypeCluster": "Cluster",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index 18acdd5..b4673af 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -9512,6 +9512,24 @@ abstract class AppLocalizations {
/// **'Add as a copy'**
String get importAsCopy;
+ /// No description provided for @routineExerciseNote.
+ ///
+ /// In en, this message translates to:
+ /// **'Routine note'**
+ String get routineExerciseNote;
+
+ /// No description provided for @importRoutineNotes.
+ ///
+ /// In en, this message translates to:
+ /// **'Add missing routine notes'**
+ String get importRoutineNotes;
+
+ /// No description provided for @routineNotesAdded.
+ ///
+ /// In en, this message translates to:
+ /// **'Routine notes added'**
+ String get routineNotesAdded;
+
/// No description provided for @importOwned.
///
/// In en, this message translates to:
diff --git a/lib/l10n/app_localizations_ar.dart b/lib/l10n/app_localizations_ar.dart
index 605a9e3..defcb5d 100644
--- a/lib/l10n/app_localizations_ar.dart
+++ b/lib/l10n/app_localizations_ar.dart
@@ -5390,6 +5390,15 @@ class AppLocalizationsAr extends AppLocalizations {
@override
String get importAsCopy => 'أضف كنسخة';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'لديك';
diff --git a/lib/l10n/app_localizations_bn.dart b/lib/l10n/app_localizations_bn.dart
index 4e631d6..7deaa17 100644
--- a/lib/l10n/app_localizations_bn.dart
+++ b/lib/l10n/app_localizations_bn.dart
@@ -5361,6 +5361,15 @@ class AppLocalizationsBn extends AppLocalizations {
@override
String get importAsCopy => 'কপি হিসেবে যোগ করো';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'আগেই তোমার';
diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart
index 068b773..06c8add 100644
--- a/lib/l10n/app_localizations_de.dart
+++ b/lib/l10n/app_localizations_de.dart
@@ -5390,6 +5390,15 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get importAsCopy => 'Als Kopie hinzufügen';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Schon da';
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 11f6ca6..8bcf143 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -5335,6 +5335,15 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get importAsCopy => 'Add as a copy';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Already yours';
diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart
index 95317b5..11d199d 100644
--- a/lib/l10n/app_localizations_es.dart
+++ b/lib/l10n/app_localizations_es.dart
@@ -5376,6 +5376,15 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get importAsCopy => 'Añadir como copia';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Ya la tienes';
diff --git a/lib/l10n/app_localizations_fa.dart b/lib/l10n/app_localizations_fa.dart
index 5902f54..2d2e062 100644
--- a/lib/l10n/app_localizations_fa.dart
+++ b/lib/l10n/app_localizations_fa.dart
@@ -5313,6 +5313,15 @@ class AppLocalizationsFa extends AppLocalizations {
@override
String get importAsCopy => 'افزودن به‌عنوان کپی';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'دارید';
diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart
index 8539a07..aff4cf2 100644
--- a/lib/l10n/app_localizations_fr.dart
+++ b/lib/l10n/app_localizations_fr.dart
@@ -5393,6 +5393,15 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get importAsCopy => 'Ajouter en copie';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Déjà là';
diff --git a/lib/l10n/app_localizations_hi.dart b/lib/l10n/app_localizations_hi.dart
index 12078f1..0ca4a16 100644
--- a/lib/l10n/app_localizations_hi.dart
+++ b/lib/l10n/app_localizations_hi.dart
@@ -5347,6 +5347,15 @@ class AppLocalizationsHi extends AppLocalizations {
@override
String get importAsCopy => 'कॉपी के रूप में जोड़ें';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'पहले से तुम्हारा';
diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart
index bba23e1..44a24d1 100644
--- a/lib/l10n/app_localizations_id.dart
+++ b/lib/l10n/app_localizations_id.dart
@@ -5250,6 +5250,15 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get importAsCopy => 'Tambah sebagai salinan';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Sudah milikmu';
diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart
index a8ef046..6507a6b 100644
--- a/lib/l10n/app_localizations_it.dart
+++ b/lib/l10n/app_localizations_it.dart
@@ -5376,6 +5376,15 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get importAsCopy => 'Aggiungi come copia';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Già tua';
diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart
index 71d8fcd..35b6487 100644
--- a/lib/l10n/app_localizations_ja.dart
+++ b/lib/l10n/app_localizations_ja.dart
@@ -5201,6 +5201,15 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get importAsCopy => 'コピーとして追加';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => '追加済み';
diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart
index 7c6cb8c..3553ca4 100644
--- a/lib/l10n/app_localizations_ko.dart
+++ b/lib/l10n/app_localizations_ko.dart
@@ -5212,6 +5212,15 @@ class AppLocalizationsKo extends AppLocalizations {
@override
String get importAsCopy => '사본으로 추가';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => '이미 있음';
diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart
index 974abda..41cf983 100644
--- a/lib/l10n/app_localizations_nl.dart
+++ b/lib/l10n/app_localizations_nl.dart
@@ -5378,6 +5378,15 @@ class AppLocalizationsNl extends AppLocalizations {
@override
String get importAsCopy => 'Als kopie toevoegen';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Heb je al';
diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart
index b86aee6..e3baaac 100644
--- a/lib/l10n/app_localizations_pl.dart
+++ b/lib/l10n/app_localizations_pl.dart
@@ -5441,6 +5441,15 @@ class AppLocalizationsPl extends AppLocalizations {
@override
String get importAsCopy => 'Dodaj jako kopię';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Już masz';
diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart
index 94a824f..179e133 100644
--- a/lib/l10n/app_localizations_pt.dart
+++ b/lib/l10n/app_localizations_pt.dart
@@ -5369,6 +5369,15 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get importAsCopy => 'Adicionar como cópia';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Você já tem';
diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart
index c285761..5e5aaf8 100644
--- a/lib/l10n/app_localizations_ru.dart
+++ b/lib/l10n/app_localizations_ru.dart
@@ -5539,6 +5539,15 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get importAsCopy => 'Добавить копию';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Уже есть';
diff --git a/lib/l10n/app_localizations_tr.dart b/lib/l10n/app_localizations_tr.dart
index 7619229..565f221 100644
--- a/lib/l10n/app_localizations_tr.dart
+++ b/lib/l10n/app_localizations_tr.dart
@@ -5367,6 +5367,15 @@ class AppLocalizationsTr extends AppLocalizations {
@override
String get importAsCopy => 'Kopya olarak ekle';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Zaten var';
diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart
index 2b29566..7a9db11 100644
--- a/lib/l10n/app_localizations_uk.dart
+++ b/lib/l10n/app_localizations_uk.dart
@@ -5431,6 +5431,15 @@ class AppLocalizationsUk extends AppLocalizations {
@override
String get importAsCopy => 'Додати копію';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Уже є';
diff --git a/lib/l10n/app_localizations_ur.dart b/lib/l10n/app_localizations_ur.dart
index bcb43bf..903a3f0 100644
--- a/lib/l10n/app_localizations_ur.dart
+++ b/lib/l10n/app_localizations_ur.dart
@@ -5323,6 +5323,15 @@ class AppLocalizationsUr extends AppLocalizations {
@override
String get importAsCopy => 'نقل کے طور پر شامل کرو';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'پہلے سے تمہاری';
diff --git a/lib/l10n/app_localizations_vi.dart b/lib/l10n/app_localizations_vi.dart
index 5afd8b4..be4d4bf 100644
--- a/lib/l10n/app_localizations_vi.dart
+++ b/lib/l10n/app_localizations_vi.dart
@@ -5255,6 +5255,15 @@ class AppLocalizationsVi extends AppLocalizations {
@override
String get importAsCopy => 'Thêm dưới dạng bản sao';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => 'Đã có';
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index 608eb57..5f0ed15 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -5149,6 +5149,15 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get importAsCopy => '添加为副本';
+ @override
+ String get routineExerciseNote => 'Routine note';
+
+ @override
+ String get importRoutineNotes => 'Add missing routine notes';
+
+ @override
+ String get routineNotesAdded => 'Routine notes added';
+
@override
String get importOwned => '已拥有';
diff --git a/lib/models/workout.dart b/lib/models/workout.dart
index fd86c95..0a0bfa4 100644
--- a/lib/models/workout.dart
+++ b/lib/models/workout.dart
@@ -270,6 +270,7 @@ class Routine {
Map<String, int>? rest,
List<List<String>>? ladders,
Map<String, List<String>>? alts,
+ Map<String, String>? exerciseNotes,
this.group = '',
this.color = -1,
this.archived = false})
@@ -278,7 +279,8 @@ class Routine {
plan = plan ?? {},
rest = rest ?? {},
ladders = ladders ?? [],
- alts = alts ?? {};
+ alts = alts ?? {},
+ exerciseNotes = exerciseNotes ?? {};
final String id;
String name;
String group;
@@ -291,6 +293,7 @@ class Routine {
final Map<String, int> rest;
final List<List<String>> ladders;
final Map<String, List<String>> alts;
+ final Map<String, String> exerciseNotes;
Map<String, dynamic> toJson() => {
'id': id,
@@ -298,6 +301,7 @@ class Routine {
if (ladders.isNotEmpty) 'lad': ladders,
if (alts.isNotEmpty) 'alt': alts,
'ex': exerciseIds,
+ if (exerciseNotes.isNotEmpty) 'notes': exerciseNotes,
if (rest.isNotEmpty) 'r': rest,
if (sets.isNotEmpty) 's': sets,
if (chained.isNotEmpty) 'c': chained.toList(),
@@ -328,6 +332,11 @@ class Routine {
for (final e in ((j['alt'] as Map?) ?? const {}).entries)
if (e.value is List && (e.value as List).isNotEmpty) e.key as String: (e.value as List).cast<String>().toList(),
},
+ exerciseNotes: {
+ for (final e in ((j['notes'] as Map?) ?? const {}).entries)
+ if (e.key is String && e.value is String && (e.value as String).trim().isNotEmpty)
+ e.key as String: (e.value as String).trim(),
+ },
group: (j['g'] as String?) ?? '',
color: (j['k'] as num?)?.toInt() ?? -1,
archived: j['a'] == true,
diff --git a/lib/screens/ai_plan_screen.dart b/lib/screens/ai_plan_screen.dart
index b89d459..e29590b 100644
--- a/lib/screens/ai_plan_screen.dart
+++ b/lib/screens/ai_plan_screen.dart
@@ -25,6 +25,7 @@ class _AiPlanScreenState extends State<AiPlanScreen> {
List<String> _missed = const [];
int _added = 0;
int _routines = 0;
+ int _notesAdded = 0;
bool _unreadable = false;
bool _format = false;
@@ -127,7 +128,7 @@ class _AiPlanScreenState extends State<AiPlanScreen> {
fg: _answer.text.trim().isEmpty ? gc.textTertiary : gc.onEmber,
onTap: _import,
),
- if (_unreadable || _added > 0 || _missed.isNotEmpty) ...[
+ if (_unreadable || _added > 0 || _notesAdded > 0 || _missed.isNotEmpty) ...[
const SizedBox(height: 18),
_result(gc),
],
@@ -172,7 +173,7 @@ class _AiPlanScreenState extends State<AiPlanScreen> {
}
Widget _result(GymColors gc) {
- final good = _added > 0;
+ final good = _added > 0 || _notesAdded > 0;
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
@@ -186,8 +187,10 @@ class _AiPlanScreenState extends State<AiPlanScreen> {
Text(
_unreadable
? t.planFailed
- : good
+ : _added > 0
? '${t.routinesAdded(_routines)} · ${t.exerciseCount(_added)}'
+ : _notesAdded > 0
+ ? '${t.routineNotesAdded} · ${t.noteCount(_notesAdded)}'
: t.planNothing,
style: AppTheme.f(13.5, weight: FontWeight.w600, color: good ? gc.sage : gc.text),
),
@@ -249,6 +252,7 @@ class _AiPlanScreenState extends State<AiPlanScreen> {
_unreadable = true;
_added = 0;
_routines = 0;
+ _notesAdded = 0;
_missed = const [];
});
return;
@@ -258,6 +262,7 @@ class _AiPlanScreenState extends State<AiPlanScreen> {
_unreadable = false;
_added = outcome.added;
_routines = outcome.routines;
+ _notesAdded = outcome.notesAdded;
_missed = outcome.missed;
});
}
diff --git a/lib/screens/plan_import_sheet.dart b/lib/screens/plan_import_sheet.dart
index c5eaf29..3e733cd 100644
--- a/lib/screens/plan_import_sheet.dart
+++ b/lib/screens/plan_import_sheet.dart
@@ -106,12 +106,21 @@ class _PlanImportSheetState extends State<_PlanImportSheet> {
void _apply({bool copies = false}) {
final result = fit.applyPlan(_plans, schedule: _schedule, copies: copies);
final gc = context.gc;
+ final changed = result.routines > 0 || result.notesAdded > 0;
showNotchToast(
context,
- result.routines > 0 ? t.routinesAdded(result.routines) : t.nothingToImport,
- subtitle: result.routines > 0 ? t.exerciseCount(result.added) : null,
- icon: result.routines > 0 ? PhosphorIconsFill.checkCircle : PhosphorIconsFill.warningCircle,
- accent: result.routines > 0 ? gc.sage : gc.warn,
+ result.routines > 0
+ ? t.routinesAdded(result.routines)
+ : result.notesAdded > 0
+ ? t.routineNotesAdded
+ : t.nothingToImport,
+ subtitle: result.routines > 0
+ ? t.exerciseCount(result.added)
+ : result.notesAdded > 0
+ ? t.noteCount(result.notesAdded)
+ : null,
+ icon: changed ? PhosphorIconsFill.checkCircle : PhosphorIconsFill.warningCircle,
+ accent: changed ? gc.sage : gc.warn,
);
Navigator.of(context).pop();
}
@@ -124,6 +133,7 @@ class _PlanImportSheetState extends State<_PlanImportSheet> {
final preview = _plans.isEmpty ? null : fit.previewPlan(_plans);
final hasDays = _plans.any((p) => p.days.isNotEmpty);
final allOwned = preview != null && preview.routines > 0 && preview.owned == preview.routines;
+ final notesOnly = allOwned && preview.hasNewNotes;
return Container(
padding: sheetPad(context).add(EdgeInsets.only(bottom: MediaQuery.viewInsetsOf(context).bottom)),
constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(context).height * 0.9),
@@ -205,7 +215,7 @@ class _PlanImportSheetState extends State<_PlanImportSheet> {
),
),
],
- if (allOwned) ...[
+ if (allOwned && !notesOnly) ...[
const SizedBox(height: 12),
Row(children: [
Icon(PhosphorIconsRegular.checkCircle, size: 16, color: gc.sage),
@@ -217,7 +227,9 @@ class _PlanImportSheetState extends State<_PlanImportSheet> {
]),
],
const SizedBox(height: 16),
- if (allOwned)
+ if (notesOnly)
+ PrimaryButton(label: t.importRoutineNotes, onTap: _apply)
+ else if (allOwned)
GhostButton(
label: t.importAsCopy,
icon: PhosphorIconsRegular.copy,
diff --git a/lib/screens/routine_edit_screen.dart b/lib/screens/routine_edit_screen.dart
index 5e95b18..c22c781 100644
--- a/lib/screens/routine_edit_screen.dart
+++ b/lib/screens/routine_edit_screen.dart
@@ -855,6 +855,31 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
},
style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),
const SizedBox(height: 16),
+ GhostButton(
+ label: t.routineExerciseNote,
+ icon: PhosphorIconsRegular.pushPin,
+ onTap: () async {
+ final text = await askText(
+ sheet,
+ title: t.routineExerciseNote,
+ initial: routine.exerciseNotes[ex.id] ?? '',
+ hint: t.notePlaceholder,
+ allowEmpty: true,
+ maxLines: 3,
+ );
+ if (text != null) fit.setRoutineExerciseNote(_id, ex.id, text);
+ },
+ ),
+ if (routine.exerciseNotes[ex.id] case final note?) ...[
+ const SizedBox(height: 6),
+ Text(
+ note,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(12.5, color: gc.textSecondary, height: 1.4),
+ ),
+ ],
+ const SizedBox(height: 16),
_planHeader(gc, mode, repsOnly),
const SizedBox(height: 8),
for (var i = 0; i < plan.length; i++)
diff --git a/lib/services/plan_share.dart b/lib/services/plan_share.dart
index 72d9983..a1fedd1 100644
--- a/lib/services/plan_share.dart
+++ b/lib/services/plan_share.dart
@@ -28,6 +28,7 @@ class PlanItem {
this.mode = '',
this.secondary = const [],
this.ladder = const [],
+ this.loggingNote = '',
this.sec,
this.km,
});
@@ -47,6 +48,7 @@ class PlanItem {
final List<String> steps;
final String mode;
final List<String> ladder;
+ final String loggingNote;
final int? sec;
final double? km;
}
@@ -338,6 +340,10 @@ List<PlanItem> _items(Object? raw, bool lb) {
final List list => [for (final s in list.whereType<String>()) if (s.trim().isNotEmpty) s.trim()],
_ => const [],
},
+ loggingNote: switch (_value(entry, ['loggingnote'])) {
+ final String note => note.trim(),
+ _ => '',
+ },
sec: _seconds(_value(entry, _timeKeys)),
km: _double(_value(entry, _distanceKeys)),
));
@@ -398,6 +404,7 @@ List<PlanItem> _mergeRepeats(List<PlanItem> items) {
mode: first.mode,
secondary: first.secondary,
ladder: first.ladder,
+ loggingNote: first.loggingNote.isEmpty ? item.loggingNote : first.loggingNote,
sec: first.sec ?? item.sec,
km: first.km ?? item.km,
);
diff --git a/lib/state/fit_state.dart b/lib/state/fit_state.dart
index a8be58d..b5a1635 100644
--- a/lib/state/fit_state.dart
+++ b/lib/state/fit_state.dart
@@ -1062,7 +1062,8 @@ class FitState extends FitCore
' "plan": [{"type": "warmup", "reps": 10, "weight": 30}]},\n'
' {"name": "Barbell Bent Over Row", "reps": 8, "superset": true,\n'
' "plan": [{"reps": 8, "weight": 50}, {"reps": 8, "weight": 50}, {"reps": 6, "weight": 45}]},\n'
- ' {"name": "Dumbbell Biceps Curl", "sets": 3, "reps": 12}\n'
+ ' {"name": "Dumbbell Biceps Curl", "sets": 3, "reps": 12,\n'
+ ' "logging_note": "Log reps per arm and weight per dumbbell."}\n'
' ]\n'
' },\n'
' {\n'
@@ -1138,8 +1139,11 @@ class FitState extends FitCore
return exerciseById(id);
}
- ({int routines, int added, List<String> missed, int owned}) previewPlan(List<PlanRoutine> plans) {
+ ({int routines, int added, List<String> missed, int owned, bool hasNewNotes}) previewPlan(
+ List<PlanRoutine> plans,
+ ) {
var made = 0, added = 0, owned = 0;
+ var hasNewNotes = false;
final missed = <String>[];
for (final plan in plans) {
var found = 0;
@@ -1151,11 +1155,20 @@ class FitState extends FitCore
missed.add(item.name);
}
}
- if (found > 0) made++;
- if (found > 0 && ownsPlan(plan)) owned++;
+ if (found == 0) continue;
+ made++;
added += found;
+ final existing = _matchingRoutine(plan);
+ if (existing == null) continue;
+ owned++;
+ hasNewNotes =
+ hasNewNotes ||
+ plan.items.any((item) {
+ final ex = _planExercise(item);
+ return ex != null && item.loggingNote.isNotEmpty && !existing.exerciseNotes.containsKey(ex.id);
+ });
}
- return (routines: made, added: added, missed: missed, owned: owned);
+ return (routines: made, added: added, missed: missed, owned: owned, hasNewNotes: hasNewNotes);
}
Routine? _ownedRoutine(PlanRoutine plan, List<String> ids) {
@@ -1163,17 +1176,19 @@ class FitState extends FitCore
return routines.where((r) => _sameRoutine(r, name, ids) && r.group == plan.group).firstOrNull;
}
- bool ownsPlan(PlanRoutine plan) {
+ bool ownsPlan(PlanRoutine plan) => _matchingRoutine(plan) != null;
+
+ Routine? _matchingRoutine(PlanRoutine plan) {
final ids = <String>[];
for (final item in plan.items) {
final ex = _planExercise(item);
if (ex == null) {
- if ((item.muscle ?? '').isNotEmpty) return false;
+ if ((item.muscle ?? '').isNotEmpty) return null;
continue;
}
if (!ids.contains(ex.id)) ids.add(ex.id);
}
- return ids.isNotEmpty && _ownedRoutine(plan, ids) != null;
+ return ids.isEmpty ? null : _ownedRoutine(plan, ids);
}
bool _sameRoutine(Routine r, String name, List<String> ids) =>
@@ -1181,18 +1196,20 @@ class FitState extends FitCore
r.exerciseIds.length == ids.length &&
[for (var i = 0; i < ids.length; i++) r.exerciseIds[i] == ids[i]].every((x) => x);
- ({int routines, int added, List<String> missed}) applyPlan(List<PlanRoutine> plans,
+ ({int routines, int added, List<String> missed, int notesAdded}) applyPlan(List<PlanRoutine> plans,
{bool schedule = false, bool copies = false}) {
- var made = 0, added = 0;
+ var made = 0, added = 0, notesAdded = 0;
final missed = <String>[];
for (final plan in plans) {
final picked = <(Exercise, PlanItem)>[];
+ final incomingNotes = <String, String>{};
for (final item in plan.items) {
final ex = _planExercise(item, create: true);
if (ex == null) {
if (!missed.contains(item.name)) missed.add(item.name);
continue;
}
+ if (item.loggingNote.isNotEmpty) incomingNotes.putIfAbsent(ex.id, () => item.loggingNote);
if (picked.any((p) => p.$1.id == ex.id)) continue;
picked.add((ex, item));
}
@@ -1223,18 +1240,24 @@ class FitState extends FitCore
made++;
added += picked.length;
}
+ final notes = routineById(id)!.exerciseNotes;
+ for (final entry in incomingNotes.entries) {
+ if (notes.containsKey(entry.key)) continue;
+ notes[entry.key] = entry.value;
+ notesAdded++;
+ }
if (schedule) {
for (final d in plan.days) {
weeklyPlan[d] = id;
}
}
}
- if (added > 0 || schedule) {
+ if (added > 0 || notesAdded > 0 || schedule) {
persistNow();
syncTrainReminder();
notifyListeners();
}
- return (routines: made, added: added, missed: missed);
+ return (routines: made, added: added, missed: missed, notesAdded: notesAdded);
}
List<PlannedSet> _plannedFrom(PlanItem item) {
@@ -1281,6 +1304,7 @@ class FitState extends FitCore
'id': id,
'name': ex.name,
'sets': routineSets(r, id),
+ 'logging_note': ?r.exerciseNotes[id],
if (hasPlan(r, id))
'plan': [
for (final p in plannedSets(r, id))
diff --git a/lib/state/library_state.dart b/lib/state/library_state.dart
index 01a37fb..7ff8384 100644
--- a/lib/state/library_state.dart
+++ b/lib/state/library_state.dart
@@ -339,6 +339,7 @@ mixin LibraryState on FitCore {
modeOverride.remove(id);
for (final r in routines) {
r.exerciseIds.remove(id);
+ r.exerciseNotes.remove(id);
}
favorites.remove(id);
_persist();
diff --git a/lib/state/routines_state.dart b/lib/state/routines_state.dart
index c9da293..c132c30 100644
--- a/lib/state/routines_state.dart
+++ b/lib/state/routines_state.dart
@@ -575,6 +575,7 @@ mixin RoutinesState on FitCore, LibraryState {
made.plan.addAll({for (final e in source.plan.entries) e.key: [...e.value]});
made.rest.addAll(source.rest);
made.alts.addAll({for (final e in source.alts.entries) e.key: [...e.value]});
+ made.exerciseNotes.addAll(source.exerciseNotes);
made.group = source.group;
made.color = source.color;
_persist();
@@ -648,6 +649,7 @@ mixin RoutinesState on FitCore, LibraryState {
r.rest.remove(exId);
r.chained.remove(exId);
r.alts.remove(exId);
+ r.exerciseNotes.remove(exId);
} else {
r.exerciseIds.add(exId);
}
@@ -704,6 +706,7 @@ mixin RoutinesState on FitCore, LibraryState {
if (plan != null) r.plan[to] = [for (final p in plan) PlannedSet(kind: p.kind)];
final rest = r.rest.remove(from);
if (rest != null) r.rest[to] = rest;
+ r.exerciseNotes.remove(from);
if (r.chained.remove(from)) r.chained.add(to);
final alts = r.alts.remove(from);
if (alts != null) {
@@ -745,6 +748,7 @@ mixin RoutinesState on FitCore, LibraryState {
final rest = r.rest[exId];
final chained = r.chained.contains(exId);
final alts = r.alts[exId];
+ final note = r.exerciseNotes[exId];
toggleRoutineExercise(routineId, exId);
return () {
final back = _routine(routineId);
@@ -755,6 +759,7 @@ mixin RoutinesState on FitCore, LibraryState {
if (rest != null) back.rest[exId] = rest;
if (chained) back.chained.add(exId);
if (alts != null) back.alts[exId] = alts;
+ if (note != null) back.exerciseNotes[exId] = note;
_persist();
notifyListeners();
};
@@ -774,6 +779,22 @@ mixin RoutinesState on FitCore, LibraryState {
int? routineRest(String? routineId, String exId) =>
routineId == null ? null : _routine(routineId)?.rest[exId];
+ String? routineExerciseNote(String? routineId, String exId) =>
+ routineId == null ? null : _routine(routineId)?.exerciseNotes[exId];
+
+ void setRoutineExerciseNote(String routineId, String exId, String text) {
+ final r = _routine(routineId);
+ if (r == null || !r.exerciseIds.contains(exId)) return;
+ final note = text.trim();
+ if (note.isEmpty) {
+ r.exerciseNotes.remove(exId);
+ } else {
+ r.exerciseNotes[exId] = note;
+ }
+ _persist();
+ notifyListeners();
+ }
+
void setRoutineRest(String routineId, String exId, int? seconds) {
final r = _routine(routineId);
if (r == null || !r.exerciseIds.contains(exId)) return;
diff --git a/lib/widgets/dialogs.dart b/lib/widgets/dialogs.dart
index 54decd0..abb5986 100644
--- a/lib/widgets/dialogs.dart
+++ b/lib/widgets/dialogs.dart
@@ -72,6 +72,8 @@ Future<String?> askText(
required String title,
String initial = '',
String hint = '',
+ bool allowEmpty = false,
+ int maxLines = 1,
}) async {
final gc = context.gc;
final controller = TextEditingController(text: initial)
@@ -84,6 +86,7 @@ Future<String?> askText(
content: TextField(
controller: controller,
autofocus: true,
+ maxLines: maxLines,
textCapitalization: TextCapitalization.sentences,
style: AppTheme.s(15, color: gc.text),
cursorColor: gc.accent,
@@ -102,8 +105,8 @@ Future<String?> askText(
),
);
Future<void>.delayed(const Duration(milliseconds: 600), controller.dispose);
- final text = raw?.trim() ?? '';
- return text.isEmpty ? null : text;
+ final text = raw?.trim();
+ return text == '' && !allowEmpty ? null : text;
}
Future<double?> askNumber(
diff --git a/lib/widgets/workout_notes.dart b/lib/widgets/workout_notes.dart
index 3ede90b..56ba61b 100644
--- a/lib/widgets/workout_notes.dart
+++ b/lib/widgets/workout_notes.dart
@@ -17,15 +17,20 @@ class WorkoutNoteStrip extends StatelessWidget {
final String exerciseId;
final bool onDark;
+ static String? _routineNote(String exerciseId) =>
+ fit.routineExerciseNote(fit.session?.routineId, exerciseId);
+
static bool offers(String exerciseId) =>
+ _routineNote(exerciseId) != null ||
fit.workoutNotesFor(exerciseId).isNotEmpty ||
(exerciseId.isNotEmpty && fit.notesFor(exerciseId).isEmpty && fit.exerciseHistory(exerciseId).length < 3);
@override
Widget build(BuildContext context) {
final notes = fit.workoutNotesFor(exerciseId);
+ final routineNote = _routineNote(exerciseId);
final gc = context.gc;
- if (notes.isEmpty) {
+ if (notes.isEmpty && routineNote == null) {
if (!offers(exerciseId)) return const SizedBox.shrink();
return Semantics(
button: true,
@@ -69,21 +74,10 @@ class WorkoutNoteStrip extends StatelessWidget {
borderRadius: BorderRadius.circular(12),
),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ if (routineNote != null) _noteLine(gc, routineNote, PhosphorIconsFill.pushPin),
for (var i = 0; i < notes.length; i++) ...[
- if (i > 0) const SizedBox(height: 6),
- Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
- Padding(
- padding: const EdgeInsets.only(top: 1.5),
- child: Icon(_iconOf(notes[i]), size: 13, color: gc.accent),
- ),
- const SizedBox(width: 8),
- Expanded(
- child: Text(notes[i].text.trim().replaceAll(RegExp(r'\s*\n\s*'), ' · '),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: AppTheme.f(12.5, weight: FontWeight.w600, color: gc.textSecondary, height: 1.3)),
- ),
- ]),
+ if (i > 0 || routineNote != null) const SizedBox(height: 6),
+ _noteLine(gc, notes[i].text, _iconOf(notes[i])),
],
]),
),
@@ -92,6 +86,25 @@ class WorkoutNoteStrip extends StatelessWidget {
}
}
+Widget _noteLine(GymColors gc, String text, IconData icon) => Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(top: 1.5),
+ child: Icon(icon, size: 13, color: gc.accent),
+ ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(
+ text.trim().replaceAll(RegExp(r'\s*\n\s*'), ' · '),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(12.5, weight: FontWeight.w600, color: gc.textSecondary, height: 1.3),
+ ),
+ ),
+ ],
+);
+
IconData _iconOf(GymNote n) => n.pinned ? PhosphorIconsFill.pushPin : PhosphorIconsFill.arrowBendDownRight;
Widget _sheetBox(BuildContext context, List<Widget> children) {
@@ -127,9 +140,16 @@ Future<void> showWorkoutNotesSheet(BuildContext context, String exerciseId) => s
builder: (sheet, _) {
final gc = sheet.gc;
final notes = fit.workoutNotesFor(exerciseId);
+ final routineNote = WorkoutNoteStrip._routineNote(exerciseId);
return _sheetBox(sheet, [
SheetTitle(t.workoutNotesTitle, subtitle: _exerciseTitle(exerciseId)),
const SizedBox(height: 16),
+ if (routineNote != null) ...[
+ Text(t.routineExerciseNote, style: AppTheme.f(11, weight: FontWeight.w700, color: gc.accent)),
+ const SizedBox(height: 6),
+ Text(routineNote, style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text, height: 1.4)),
+ const SizedBox(height: 16),
+ ],
for (final n in notes) ...[
Container(
padding: const EdgeInsets.fromLTRB(14, 12, 8, 12),
diff --git a/test/pending_translation_keys.txt b/test/pending_translation_keys.txt
index abfdb29..0b261e0 100644
--- a/test/pending_translation_keys.txt
+++ b/test/pending_translation_keys.txt
@@ -12,3 +12,6 @@ sidesReps
progSchemeTitle
groupMoveUp
groupMoveDown
+routineExerciseNote
+importRoutineNotes
+routineNotesAdded
diff --git a/test/plan_import_export_test.dart b/test/plan_import_export_test.dart
index e9a1fa6..d9034c0 100644
--- a/test/plan_import_export_test.dart
+++ b/test/plan_import_export_test.dart
@@ -1,6 +1,7 @@
import 'dart:convert';
import 'package:flutter_test/flutter_test.dart';
import 'package:gymmane/l10n/l10n.dart';
+import 'package:gymmane/models/note.dart';
import 'package:gymmane/models/workout.dart';
import 'package:gymmane/services/local_store.dart';
import 'package:gymmane/services/plan_pdf.dart';
@@ -115,6 +116,68 @@ void main() {
expect(text, contains('"weeks"'));
expect(text, contains('Barbell Bench Press'));
});
+
+ test('a routine cue survives storage and sharing without exporting Journal notes', () {
+ const cue = 'Enter the weight of one dumbbell and reps per arm.';
+ final ex = idOf('Dumbbell Hammer Curl');
+ final r = routineWith([ex], name: 'Arms');
+ fit.setRoutineExerciseNote(r.id, ex, ' $cue ');
+ fit.saveNote(
+ exerciseId: ex,
+ date: DateTime.now(),
+ kind: NoteKind.note,
+ text: 'Private Journal note',
+ pinned: true,
+ );
+
+ expect(Routine.fromJson(r.toJson()).exerciseNotes, {ex: cue});
+ final shared = fit.exportPlanJson([r]);
+ expect(shared, isNot(contains('Private Journal note')));
+ fit.resetAllData();
+
+ expect(fit.applyPlan(parsePlan(shared)).notesAdded, 1);
+ final imported = fit.routines.single;
+ expect(imported.exerciseIds, [ex]);
+ expect(imported.exerciseNotes, {ex: cue});
+ expect(fit.customExercises, isEmpty);
+ expect(fit.notes, isEmpty);
+ final copy = fit.routineById(fit.duplicateRoutine(imported.id))!;
+ expect(copy.exerciseNotes, {ex: cue});
+ final undo = fit.removeRoutineExercise(imported.id, ex)!;
+ expect(imported.exerciseNotes, isEmpty);
+ undo();
+ expect(imported.exerciseNotes, {ex: cue});
+ fit.setRoutineExerciseNote(imported.id, ex, ' ');
+ expect(imported.exerciseNotes, isEmpty);
+ expect(copy.exerciseNotes, {ex: cue});
+ });
+
+ test('re-import fills missing cues without replacing notes or planned sets', () {
+ final curl = idOf('Dumbbell Hammer Curl');
+ final press = idOf('Barbell Bench Press');
+ final r = routineWith([curl, press]);
+ fit.setPlannedSets(r.id, curl, const [PlannedSet(reps: 12, weightKg: 10)]);
+ fit.setRoutineExerciseNote(r.id, press, 'My seat setting');
+ final plans = parsePlan('''
+ {"name":"Push","exercises":[
+ {"name":"Dumbbell Hammer Curl","sets":1,"reps":20},
+ {"name":"Dumbbell Hammer Curl","sets":1,"logging_note":" Reps per arm "},
+ {"name":"Barbell Bench Press","logging_note":"Different seat setting"}
+ ]}
+ ''');
+
+ expect(fit.previewPlan(plans).hasNewNotes, isTrue);
+ final result = fit.applyPlan(plans);
+ expect(result.routines, 0);
+ expect(result.notesAdded, 1);
+ expect(fit.routines.single.id, r.id);
+ expect(r.exerciseNotes, {curl: 'Reps per arm', press: 'My seat setting'});
+ expect(fit.plannedSets(r, curl).single.reps, 12);
+ expect(fit.plannedSets(r, curl).single.weightKg, 10);
+ expect(fit.customExercises, isEmpty);
+ expect(fit.previewPlan(plans).hasNewNotes, isFalse);
+ expect(fit.applyPlan(plans).notesAdded, 0);
+ });
});
group('plan en PDF', () {
diff --git a/test/routine_note_widget_test.dart b/test/routine_note_widget_test.dart
new file mode 100644
index 0000000..c2d0abf
--- /dev/null
+++ b/test/routine_note_widget_test.dart
@@ -0,0 +1,94 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/l10n/l10n.dart';
+import 'package:gymmane/screens/plan_import_sheet.dart';
+import 'package:gymmane/screens/routine_edit_screen.dart';
+import 'package:gymmane/services/local_store.dart';
+import 'package:gymmane/state/fit_state.dart';
+import 'package:gymmane/theme/app_theme.dart';
+import 'package:gymmane/widgets/workout_notes.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ group('routine notes in the UI', () {
+ setUp(() async {
+ SharedPreferences.setMockInitialValues({});
+ await Store.instance.init();
+ fit.resetAllData();
+ fit.onboarded = true;
+ setAppLanguage('en');
+ });
+
+ testWidgets('create a note in the routine and see it only in that workout', (tester) async {
+ final ex = fit.matchExerciseByName('Dumbbell Hammer Curl')!;
+ final id = fit.createRoutine('Arms');
+ fit.toggleRoutineExercise(id, ex.id);
+ fit.openRoutine(id);
+ await tester.binding.setSurfaceSize(const Size(400, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ await tester.pumpWidget(MaterialApp(
+ theme: AppTheme.dark,
+ home: AnimatedBuilder(
+ animation: fit,
+ builder: (_, _) => const Scaffold(body: RoutineEditScreen()),
+ ),
+ ));
+ await tester.pumpAndSettle();
+ await tester.tap(find.text(ex.name).first);
+ await tester.pumpAndSettle();
+ await tester.tap(find.text(t.routineExerciseNote));
+ await tester.pumpAndSettle();
+ const cue = 'Log reps per arm.';
+ await tester.enterText(find.byType(TextField).last, cue);
+ await tester.tap(find.widgetWithText(TextButton, t.save));
+ await tester.pumpAndSettle();
+ expect(find.text(cue), findsOneWidget);
+
+ Widget strip() => MaterialApp(
+ theme: AppTheme.dark,
+ home: Scaffold(body: WorkoutNoteStrip(exerciseId: ex.id)),
+ );
+ await tester.pumpWidget(const SizedBox.shrink());
+ await tester.pumpAndSettle();
+ fit.startRoutine(fit.routineById(id)!);
+ await tester.pumpWidget(strip());
+ expect(find.text(cue), findsOneWidget);
+ fit.resetAllData();
+ final other = fit.createRoutine('Other');
+ fit.toggleRoutineExercise(other, ex.id);
+ fit.startRoutine(fit.routineById(other)!);
+ await tester.pumpWidget(strip());
+ expect(find.text(cue), findsNothing);
+ fit.resetAllData();
+ await tester.pumpAndSettle();
+ });
+
+ testWidgets('an owned routine offers to import missing notes without a copy', (tester) async {
+ final ex = fit.matchExerciseByName('Dumbbell Hammer Curl')!;
+ final id = fit.createRoutine('Arms');
+ fit.toggleRoutineExercise(id, ex.id);
+ late BuildContext context;
+ await tester.pumpWidget(MaterialApp(
+ theme: AppTheme.dark,
+ home: Scaffold(body: Builder(builder: (ctx) {
+ context = ctx;
+ return const SizedBox();
+ })),
+ ));
+ showPlanImportSheet(context, text: '''
+ {"name":"Arms","exercises":[
+ {"name":"Dumbbell Hammer Curl","logging_note":"Log reps per arm."}
+ ]}
+ ''');
+ await tester.pumpAndSettle();
+ await tester.tap(find.text(t.importRoutineNotes));
+ await tester.pumpAndSettle();
+ expect(fit.routines.single.id, id);
+ expect(fit.routineExerciseNote(id, ex.id), 'Log reps per arm.');
+ await tester.pumpWidget(const SizedBox.shrink());
+ await tester.pump(const Duration(seconds: 3));
+ });
+ });
+}