Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Add note folders and notes pinned to an exercise (#308)
InlitX46f83650f95f
diff --git a/lib/models/note.dart b/lib/models/note.dartindex 2500bb8..8d21da1 100644--- a/lib/models/note.dart+++ b/lib/models/note.dart@@ -10,6 +10,7 @@ class GymNote {this.media = const [],required this.createdAt,this.pinned = false,+ this.folder = '',});final String id;@@ -20,6 +21,7 @@ class GymNote {final List<String> media;final DateTime createdAt;final bool pinned;+ final String folder;bool get isGeneral => exerciseId.isEmpty;@@ -37,6 +39,7 @@ class GymNote {String? text,List<String>? media,bool? pinned,+ String? folder,}) =>GymNote(id: id,@@ -47,6 +50,7 @@ class GymNote {media: media ?? this.media,createdAt: createdAt,pinned: pinned ?? this.pinned,+ folder: folder ?? this.folder,);Map<String, dynamic> toJson() => {@@ -58,6 +62,7 @@ class GymNote {if (media.isNotEmpty) 'm': media,'c': createdAt.toIso8601String(),if (pinned) 'p': true,+ if (folder.isNotEmpty) 'f': folder,};factory GymNote.fromJson(Map<String, dynamic> j) {@@ -71,6 +76,23 @@ class GymNote {media: ((j['m'] as List?) ?? const []).cast<String>(),createdAt: created,pinned: j['p'] == true,+ folder: (j['f'] ?? '') as String,);}}++class NoteFolder {+ NoteFolder({required this.id, required this.name, this.color = 0});++ final String id;+ String name;+ int color;++ Map<String, dynamic> toJson() => {'id': id, 'n': name, 'k': color};++ factory NoteFolder.fromJson(Map<String, dynamic> j) => NoteFolder(+ id: (j['id'] ?? '') as String,+ name: (j['n'] ?? '') as String,+ color: ((j['k'] ?? 0) as num).toInt(),+ );+}diff --git a/lib/screens/note_edit_screen.dart b/lib/screens/note_edit_screen.dartindex 4fc033c..c0d8c19 100644--- a/lib/screens/note_edit_screen.dart+++ b/lib/screens/note_edit_screen.dart@@ -12,6 +12,7 @@ import '../theme/app_colors.dart';import '../theme/app_theme.dart';import '../widgets/dialogs.dart';import '../widgets/glass.dart';+import '../widgets/note_folder.dart';import '../widgets/note_kit.dart';import '../widgets/ui_kit.dart';@@ -32,6 +33,7 @@ class _NoteEditScreenState extends State<NoteEditScreen> {late String _exerciseId = _note?.exerciseId ?? fit.noteDraftExercise;late final List<String> _media = [...?_note?.media];late bool _pinned = _note?.pinned ?? false;+ late String _folder = _note?.folder ?? fit.noteDraftFolder;final List<String> _added = [];bool _saved = false;@@ -57,6 +59,7 @@ class _NoteEditScreenState extends State<NoteEditScreen> {text: _text.text,media: _media,pinned: _pinned,+ folder: _folder,);fit.closeNoteEditor();}@@ -104,6 +107,7 @@ class _NoteEditScreenState extends State<NoteEditScreen> {Widget build(BuildContext context) {final gc = context.gc;final exercise = _exerciseId.isEmpty ? null : fit.exerciseById(_exerciseId);+ final folder = fit.noteFolderById(_folder);return SafeArea(bottom: false,@@ -170,6 +174,7 @@ class _NoteEditScreenState extends State<NoteEditScreen> {icon: PhosphorIconsRegular.calendarBlank,label: t.noteDateLabel,value: t.shortDateYear(_date),+ shrink: true,onTap: _pickDate,),Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border),@@ -194,6 +199,15 @@ class _NoteEditScreenState extends State<NoteEditScreen> {),onTap: _pickExercise,),+ Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border),+ _row(+ gc,+ icon: PhosphorIconsRegular.folder,+ label: t.noteFolderLabel,+ value: folder?.name ?? t.noteFolderNone,+ muted: folder == null,+ onTap: _pickFolder,+ ),if (exercise != null) ...[Divider(height: 1, thickness: 1, indent: 16, endIndent: 16, color: gc.border),_row(@@ -227,6 +241,11 @@ class _NoteEditScreenState extends State<NoteEditScreen> {);}+ Future<void> _pickFolder() async {+ final picked = await pickNoteFolder(context, _folder);+ if (picked != null && mounted) setState(() => _folder = picked);+ }+Widget _label(GymColors gc, String text) => Padding(padding: const EdgeInsets.only(bottom: 10),child: Text(text,@@ -242,6 +261,7 @@ class _NoteEditScreenState extends State<NoteEditScreen> {required VoidCallback onTap,Widget? trailing,bool muted = false,+ bool shrink = false,}) =>GestureDetector(behavior: HitTestBehavior.opaque,@@ -262,12 +282,21 @@ class _NoteEditScreenState extends State<NoteEditScreen> {),const SizedBox(width: 12),Expanded(- child: Text(value,- maxLines: 1,- overflow: TextOverflow.ellipsis,- textAlign: TextAlign.right,- style: AppTheme.f(13,- weight: FontWeight.w600, color: muted ? gc.textTertiary : gc.textSecondary)),+ child: shrink+ ? FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerEnd,+ child: Text(value,+ maxLines: 1,+ style: AppTheme.f(13,+ weight: FontWeight.w600, color: muted ? gc.textTertiary : gc.textSecondary)),+ )+ : Text(value,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ textAlign: TextAlign.right,+ style: AppTheme.f(13,+ weight: FontWeight.w600, color: muted ? gc.textTertiary : gc.textSecondary)),),const SizedBox(width: 6),trailing ?? Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),diff --git a/lib/screens/notes_screen.dart b/lib/screens/notes_screen.dartindex a3f5f39..9cab8d3 100644--- a/lib/screens/notes_screen.dart+++ b/lib/screens/notes_screen.dart@@ -7,6 +7,7 @@ import '../models/note.dart';import '../state/fit_state.dart';import '../theme/app_colors.dart';import '../theme/app_theme.dart';+import '../widgets/note_folder.dart';import '../widgets/note_kit.dart';import '../widgets/ui_kit.dart';@@ -18,6 +19,7 @@ class NotesScreen extends StatelessWidget {final gc = context.gc;final scoped = fit.noteScope.isEmpty ? null : fit.exerciseById(fit.noteScope);final all = fit.notesAllView;+ final folder = fit.openFolder;return SafeArea(bottom: false,@@ -26,7 +28,9 @@ class NotesScreen extends StatelessWidget {Padding(padding: const EdgeInsets.fromLTRB(20, 12, 20, 0),child: ScreenHeader(- title: scoped == null ? t.journal : exerciseName(scoped).toUpperCase(),+ title: folder != null+ ? folder.name.toUpperCase()+ : (scoped == null ? t.journal : exerciseName(scoped).toUpperCase()),subtitle: all ? t.noteCount(fit.notesInScope.length) : t.noteMonthCount(fit.notesInMonth),onBack: fit.backFromNotes,actions: [@@ -41,19 +45,27 @@ class NotesScreen extends StatelessWidget {),),const SizedBox(width: 8),- _action(- gc,- icon: all ? PhosphorIconsRegular.calendarBlank : PhosphorIconsRegular.listBullets,- label: all ? t.noteCalendar : t.noteAllNotes,- onTap: () => fit.setNotesAllView(!all),- ),+ if (folder != null)+ _action(+ gc,+ icon: PhosphorIconsBold.dotsThreeVertical,+ label: t.moreOptions,+ onTap: () => showNoteFolderMenu(context, folder),+ )+ else+ _action(+ gc,+ icon: all ? PhosphorIconsRegular.calendarBlank : PhosphorIconsRegular.listBullets,+ label: all ? t.noteCalendar : t.noteAllNotes,+ onTap: () => fit.setNotesAllView(!all),+ ),],),),const SizedBox(height: 16),Expanded(child: all- ? _allNotes(gc, scoped == null)+ ? _allNotes(context, gc, scoped == null, folders: scoped == null && folder == null): _calendar(context, gc, scoped == null)),],),@@ -108,7 +120,12 @@ class NotesScreen extends StatelessWidget {style: AppTheme.f(10.5,weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.5)),const SizedBox(height: 3),- Text(t.fullDate(day), style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary)),+ FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerStart,+ child: Text(t.fullDate(day),+ maxLines: 1, style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textTertiary)),+ ),],),),@@ -146,19 +163,85 @@ class NotesScreen extends StatelessWidget {);}- Widget _allNotes(GymColors gc, bool showExercise) {+ Widget _folders(BuildContext context, GymColors gc) {+ if (fit.noteFolders.isEmpty) {+ return Padding(+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 14),+ child: Pressable(+ scale: 0.98,+ onTap: () => showNoteFolderEditor(context),+ child: Container(+ height: 46,+ padding: const EdgeInsets.symmetric(horizontal: 14),+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(16),+ border: Border.all(color: gc.border, width: 1.2),+ ),+ child: Row(children: [+ Icon(PhosphorIconsRegular.folderPlus, size: 17, color: gc.textSecondary),+ const SizedBox(width: 10),+ Expanded(+ child: Text(t.noteFolderNew,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(13.5, weight: FontWeight.w700, color: gc.textSecondary)),+ ),+ Icon(PhosphorIconsBold.plus, size: 13, color: gc.textTertiary),+ ]),+ ),+ ),+ );+ }+ final byFolder = <String, List<GymNote>>{};+ for (final n in fit.notesSorted) {+ if (n.folder.isNotEmpty) (byFolder[n.folder] ??= []).add(n);+ }+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 20),+ child: SectionLabel(t.noteFolders),+ ),+ const SizedBox(height: 10),+ SizedBox(+ height: noteFolderHeight(context),+ child: ListView.separated(+ scrollDirection: Axis.horizontal,+ padding: const EdgeInsets.symmetric(horizontal: 20),+ itemCount: fit.noteFolders.length + 1,+ separatorBuilder: (_, _) => const SizedBox(width: 10),+ itemBuilder: (context, i) {+ if (i == fit.noteFolders.length) {+ return NewNoteFolderCard(onTap: () => showNoteFolderEditor(context));+ }+ final f = fit.noteFolders[i];+ return NoteFolderCard(+ folder: f,+ notes: byFolder[f.id] ?? const [],+ onTap: () => fit.openNoteFolder(f.id),+ onMenu: () => showNoteFolderMenu(context, f),+ );+ },+ ),+ ),+ const SizedBox(height: 18),+ ],+ );+ }++ Widget _allNotes(BuildContext context, GymColors gc, bool showExercise, {bool folders = false}) {final visible = fit.notesFiltered;return Column(children: [+ if (folders) _folders(context, gc),if (fit.notesInScope.isNotEmpty)- Padding(+ NoteFilterBar(+ selected: fit.noteFilter,+ counts: fit.noteKindCounts,+ onPick: fit.setNoteFilter,padding: const EdgeInsets.symmetric(horizontal: 20),- child: NoteFilterBar(- selected: fit.noteFilter,- counts: fit.noteKindCounts,- onPick: fit.setNoteFilter,- ),),Expanded(child: visible.isEmptydiff --git a/lib/state/notes_state.dart b/lib/state/notes_state.dartindex efa62ab..7aeb59e 100644--- a/lib/state/notes_state.dart+++ b/lib/state/notes_state.dart@@ -3,6 +3,8 @@ part of 'fit_state.dart';mixin NotesState on FitCore, LibraryState {NoteKind? noteFilter;String noteScope = '';+ String noteFolderScope = '';+ String noteDraftFolder = '';String? editingNoteId;String noteDraftExercise = '';DateTime noteDraftDate = DateTime.now();@@ -36,8 +38,68 @@ mixin NotesState on FitCore, LibraryState {GymNote? get editingNote => noteById(editingNoteId);- List<GymNote> get notesInScope =>- noteScope.isEmpty ? notesSorted : notesFor(noteScope);+ List<GymNote> get notesInScope {+ final base = noteScope.isEmpty ? notesSorted : notesFor(noteScope);+ return noteFolderScope.isEmpty ? base : base.where((n) => n.folder == noteFolderScope).toList();+ }++ NoteFolder? noteFolderById(String id) {+ for (final f in noteFolders) {+ if (f.id == id) return f;+ }+ return null;+ }++ NoteFolder? get openFolder => noteFolderById(noteFolderScope);++ List<GymNote> notesInFolder(String id) => notesSorted.where((n) => n.folder == id).toList();++ String addNoteFolder(String name, int color) {+ var id = 'f${DateTime.now().microsecondsSinceEpoch}';+ while (noteFolderById(id) != null) {+ id = '${id}x';+ }+ noteFolders.add(NoteFolder(id: id, name: name.trim(), color: color));+ _persist();+ notifyListeners();+ return id;+ }++ void editNoteFolder(String id, {String? name, int? color}) {+ final f = noteFolderById(id);+ if (f == null) return;+ if (name != null && name.trim().isNotEmpty) f.name = name.trim();+ if (color != null) f.color = color;+ _persist();+ notifyListeners();+ }++ void deleteNoteFolder(String id) {+ if (noteFolderById(id) == null) return;+ noteFolders.removeWhere((f) => f.id == id);+ for (var i = 0; i < notes.length; i++) {+ if (notes[i].folder == id) notes[i] = notes[i].copyWith(folder: '');+ }+ if (noteFolderScope == id) noteFolderScope = '';+ _persist();+ notifyListeners();+ }++ void moveNoteToFolder(String noteId, String folder) {+ final i = notes.indexWhere((n) => n.id == noteId);+ if (i < 0 || notes[i].folder == folder) return;+ notes[i] = notes[i].copyWith(folder: folder);+ _persist();+ notifyListeners();+ }++ void openNoteFolder(String id) {+ if (noteFolderById(id) == null) return;+ noteFolderScope = id;+ noteFilter = null;+ notesAllView = true;+ notifyListeners();+ }List<GymNote> get notesFiltered {final scoped = notesInScope;@@ -107,6 +169,7 @@ mixin NotesState on FitCore, LibraryState {required String text,List<String> media = const [],bool? pinned,+ String? folder,}) {final body = text.trim();if (body.isEmpty) return;@@ -123,6 +186,7 @@ mixin NotesState on FitCore, LibraryState {media: [...media],createdAt: DateTime.now(),pinned: (pinned ?? false) && exerciseId.isNotEmpty,+ folder: folder ?? '',));} else {final old = notes[index];@@ -136,6 +200,7 @@ mixin NotesState on FitCore, LibraryState {text: body,media: [...media],pinned: exerciseId.isEmpty ? false : pinned,+ folder: folder,);}noteDay = day;@@ -181,6 +246,7 @@ mixin NotesState on FitCore, LibraryState {void goNotes({String exerciseId = '', bool all = false}) {noteScope = exerciseId;+ noteFolderScope = '';noteFilter = null;notesAllView = all;noteDay = _dayKey(DateTime.now());@@ -189,6 +255,11 @@ mixin NotesState on FitCore, LibraryState {}void backFromNotes() {+ if (noteFolderScope.isNotEmpty) {+ noteFolderScope = '';+ notifyListeners();+ return;+ }if (notesAllView && noteScope.isEmpty) {notesAllView = false;notifyListeners();@@ -203,6 +274,7 @@ mixin NotesState on FitCore, LibraryState {noteDraftExercise = existing?.exerciseId ?? exerciseId;noteDraftDate = existing?.date ?? _dayKey(date ?? DateTime.now());noteDraftKind = existing?.kind ?? kind ?? NoteKind.note;+ noteDraftFolder = existing?.folder ?? noteFolderScope;pushRoute('note-edit');}diff --git a/lib/widgets/note_folder.dart b/lib/widgets/note_folder.dartnew file mode 100644index 0000000..0605aa9--- /dev/null+++ b/lib/widgets/note_folder.dart@@ -0,0 +1,445 @@+import 'package:flutter/material.dart';+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';++import '../l10n/l10n.dart';+import '../models/note.dart';+import '../services/media_store.dart';+import '../state/fit_state.dart';+import '../theme/app_colors.dart';+import '../theme/app_theme.dart';+import 'dialogs.dart';+import 'file_thumb.dart';+import 'glass.dart';+import 'note_kit.dart';+import 'routine_folder.dart';+import 'ui_kit.dart';++Color noteFolderHue(NoteFolder f) => kFolderHues[f.color.clamp(0, kFolderHues.length - 1)];++const double kNoteFolderWidth = 152;++double noteFolderHeight(BuildContext context) =>+ 124 + MediaQuery.textScalerOf(context).scale(15) * 1.15 * 2 + MediaQuery.textScalerOf(context).scale(11.5) * 1.3;++class NoteFolderCard extends StatelessWidget {+ const NoteFolderCard({super.key, required this.folder, required this.onTap, required this.onMenu, this.notes});++ final NoteFolder folder;+ final List<GymNote>? notes;+ final VoidCallback onTap;+ final VoidCallback onMenu;++ static const _tab = 14.0;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final hue = noteFolderHue(folder);+ final dark = gc.bg.computeLuminance() < 0.5;+ final notes = this.notes ?? fit.notesInFolder(folder.id);+ final pocket = Color.lerp(gc.bgRaised2, hue, dark ? 0.24 : 0.36)!;+ final back = Color.lerp(hue, Colors.black, dark ? 0.2 : 0.05)!;+ final tab = Color.lerp(gc.bgRaised, hue, dark ? 0.1 : 0.2)!;+ final paper = dark ? const Color(0xFFEDE9E4) : Colors.white;+ const ink = Color(0xFF2A2623);+ String? photo;+ for (final n in notes) {+ for (final m in n.media) {+ final path = MediaStore.pathFor(m);+ if (path != null && !MediaStore.isVideo(m)) {+ photo = path;+ break;+ }+ }+ if (photo != null) break;+ }+ final latest = notes.isEmpty ? null : notes.first;+ final detail = [+ t.noteCount(notes.length),+ if (latest != null) noteDayLabel(latest.date),+ ].join(' · ');++ return Pressable(+ onTap: onTap,+ onLongPress: onMenu,+ scale: 0.97,+ child: SizedBox(+ width: kNoteFolderWidth,+ height: noteFolderHeight(context),+ child: Stack(children: [+ Positioned(+ left: 0,+ top: 0,+ width: 58,+ height: _tab + 20,+ child: DecoratedBox(+ decoration: BoxDecoration(+ borderRadius: const BorderRadius.vertical(top: Radius.circular(12)),+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [Color.lerp(tab, Colors.white, dark ? 0.06 : 0.3)!, tab],+ ),+ ),+ ),+ ),+ Positioned.fill(+ top: _tab,+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: tab,+ borderRadius: const BorderRadius.only(+ topRight: Radius.circular(16),+ bottomLeft: Radius.circular(22),+ bottomRight: Radius.circular(22),+ ),+ ),+ ),+ ),+ Positioned(+ left: 14,+ right: 8,+ top: _tab + 4,+ height: 62,+ child: _paper(back, angle: 0.04, child: _lines(ink.withValues(alpha: 0.16))),+ ),+ if (photo != null)+ Positioned(+ left: 12,+ right: 22,+ top: _tab + 9,+ height: 66,+ child: _paper(+ paper,+ angle: -0.035,+ pad: const EdgeInsets.fromLTRB(4, 4, 4, 0),+ child: ClipRRect(+ borderRadius: BorderRadius.circular(6),+ child: FileThumb(photo, width: kNoteFolderWidth - 42, height: 52),+ ),+ ),+ )+ else if (latest != null)+ Positioned(+ left: 9,+ right: 15,+ top: _tab + 13,+ height: 62,+ child: _paper(+ paper,+ angle: -0.025,+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Text(latest.title,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(10, weight: FontWeight.w800, color: ink, height: 1.2)),+ const SizedBox(height: 5),+ _lines(ink.withValues(alpha: 0.18)),+ ]),+ ),+ ),+ Positioned(+ left: 4,+ right: 4,+ top: _tab + 48,+ bottom: 0,+ child: Container(+ padding: const EdgeInsets.fromLTRB(12, 10, 6, 10),+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(18),+ gradient: LinearGradient(+ begin: Alignment.topCenter,+ end: Alignment.bottomCenter,+ colors: [Color.lerp(pocket, Colors.white, dark ? 0.07 : 0.28)!, pocket, Color.lerp(pocket, Colors.black, dark ? 0.12 : 0.04)!],+ stops: const [0, 0.35, 1],+ ),+ boxShadow: [+ BoxShadow(+ color: Colors.black.withValues(alpha: dark ? 0.36 : 0.1),+ blurRadius: 12,+ offset: const Offset(0, -3),+ ),+ ],+ ),+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Expanded(+ child: Text(folder.name,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(15, weight: FontWeight.w800, color: gc.text, height: 1.15)),+ ),+ Semantics(+ button: true,+ label: t.moreOptions,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onMenu,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(6, 0, 2, 4),+ child: Icon(PhosphorIconsBold.dotsThreeVertical, size: 15, color: gc.textSecondary),+ ),+ ),+ ),+ ]),+ const Spacer(),+ Text(detail,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textSecondary)),+ ]),+ ),+ ),+ ]),+ ),+ );+ }++ Widget _paper(Color color, {required double angle, required Widget child, EdgeInsets pad = const EdgeInsets.fromLTRB(10, 8, 10, 0)}) =>+ Transform.rotate(+ angle: angle,+ child: Container(+ padding: pad,+ decoration: BoxDecoration(+ color: color,+ borderRadius: BorderRadius.circular(9),+ boxShadow: const [BoxShadow(color: Color(0x33000000), blurRadius: 4, offset: Offset(0, 1))],+ ),+ alignment: Alignment.topLeft,+ child: child,+ ),+ );++ Widget _lines(Color c) => Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ FractionallySizedBox(+ widthFactor: 0.7,+ child: Container(height: 2.5, decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(2))),+ ),+ const SizedBox(height: 4),+ FractionallySizedBox(+ widthFactor: 0.45,+ child: Container(height: 2.5, decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(2))),+ ),+ ]);+}++class NewNoteFolderCard extends StatelessWidget {+ const NewNoteFolderCard({super.key, required this.onTap});++ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ return Pressable(+ onTap: onTap,+ scale: 0.97,+ child: SizedBox(+ width: kNoteFolderWidth,+ height: noteFolderHeight(context),+ child: Container(+ margin: const EdgeInsets.only(top: 14),+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(22),+ border: Border.all(color: gc.border, width: 1.5),+ ),+ child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [+ Container(+ width: 38,+ height: 38,+ decoration: BoxDecoration(color: gc.bgRaised, shape: BoxShape.circle),+ child: Icon(PhosphorIconsBold.plus, size: 15, color: gc.text),+ ),+ const SizedBox(height: 10),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 10),+ child: Text(t.noteFolderNew,+ maxLines: 2,+ textAlign: TextAlign.center,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(12.5, weight: FontWeight.w700, color: gc.textSecondary)),+ ),+ ]),+ ),+ ),+ );+ }+}++Future<String?> showNoteFolderEditor(BuildContext context, {NoteFolder? folder}) => showAppSheet<String>(+ context: context,+ backgroundColor: Colors.transparent,+ builder: (_) => _FolderEditor(folder: folder),+ );++class _FolderEditor extends StatefulWidget {+ const _FolderEditor({this.folder});++ final NoteFolder? folder;++ @override+ State<_FolderEditor> createState() => _FolderEditorState();+}++class _FolderEditorState extends State<_FolderEditor> {+ late final _name = TextEditingController(text: widget.folder?.name ?? '');+ late int _hue = widget.folder?.color ?? fit.noteFolders.length % kFolderHues.length;++ @override+ void dispose() {+ _name.dispose();+ super.dispose();+ }++ bool get _ok => _name.text.trim().isNotEmpty;++ void _save() {+ if (!_ok) return;+ final f = widget.folder;+ if (f == null) {+ Navigator.of(context).pop(fit.addNoteFolder(_name.text, _hue));+ } else {+ fit.editNoteFolder(f.id, name: _name.text, color: _hue);+ Navigator.of(context).pop(f.id);+ }+ }++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ final preview = NoteFolder(id: widget.folder?.id ?? '-', name: _name.text.trim().isEmpty ? t.noteFolderName : _name.text.trim(), color: _hue);+ return Container(+ padding: sheetPad(context),+ decoration: sheetDecoration(gc),+ child: SingleChildScrollView(+ child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ const SheetHandle(),+ const SizedBox(height: 16),+ SheetTitle(widget.folder == null ? t.noteFolderNew : t.noteFolderEdit),+ const SizedBox(height: 16),+ Center(child: IgnorePointer(child: NoteFolderCard(folder: preview, onTap: () {}, onMenu: () {}))),+ const SizedBox(height: 18),+ Container(+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(16)),+ child: TextField(+ controller: _name,+ autofocus: widget.folder == null,+ maxLength: 32,+ textCapitalization: TextCapitalization.sentences,+ onChanged: (_) => setState(() {}),+ onSubmitted: (_) => _save(),+ cursorColor: gc.accent,+ style: AppTheme.f(15, weight: FontWeight.w600, color: gc.text),+ decoration: InputDecoration(+ border: InputBorder.none,+ counterText: '',+ hintText: t.noteFolderName,+ hintStyle: AppTheme.f(15, weight: FontWeight.w600, color: gc.textTertiary),+ ),+ ),+ ),+ const SizedBox(height: 16),+ Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [+ for (var i = 0; i < kFolderHues.length; i++)+ Pressable(+ scale: 0.88,+ onTap: () => setState(() => _hue = i),+ child: AnimatedContainer(+ duration: const Duration(milliseconds: 200),+ width: 38,+ height: 38,+ padding: EdgeInsets.all(i == _hue ? 4 : 0),+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ border: Border.all(color: i == _hue ? gc.text : Colors.transparent, width: 2),+ ),+ child: DecoratedBox(decoration: BoxDecoration(color: kFolderHues[i], shape: BoxShape.circle)),+ ),+ ),+ ]),+ const SizedBox(height: 22),+ PrimaryButton(+ label: t.save,+ onTap: _save,+ bg: _ok ? gc.ember : gc.mutedFill,+ fg: _ok ? gc.onEmber : gc.textTertiary,+ ),+ ]),+ ),+ );+ }+}++void showNoteFolderMenu(BuildContext context, NoteFolder f) {+ final gc = context.gc;+ showAppSheet<void>(+ context: context,+ backgroundColor: Colors.transparent,+ builder: (sheet) => Container(+ padding: sheetPad(sheet),+ decoration: sheetDecoration(gc),+ child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ const SheetHandle(),+ const SizedBox(height: 16),+ SheetTitle(f.name, subtitle: t.noteCount(fit.notesInFolder(f.id).length)),+ const SizedBox(height: 14),+ OptionGroup([+ OptionItem(t.noteFolderEdit, icon: PhosphorIconsRegular.pencilSimple, onTap: () {+ Navigator.pop(sheet);+ showNoteFolderEditor(context, folder: f);+ }),+ OptionItem(t.delete, icon: PhosphorIconsRegular.trash, danger: true, onTap: () async {+ Navigator.pop(sheet);+ final ok = await askConfirm(+ context,+ title: t.noteFolderDelete,+ body: t.noteFolderDeleteBody,+ confirmLabel: t.delete,+ danger: true,+ );+ if (ok) fit.deleteNoteFolder(f.id);+ }),+ ]),+ ]),+ ),+ );+}++Future<String?> pickNoteFolder(BuildContext context, String current) => showAppSheet<String>(+ context: context,+ backgroundColor: Colors.transparent,+ builder: (sheet) {+ final gc = sheet.gc;+ return Container(+ constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.7),+ padding: sheetPad(sheet),+ decoration: sheetDecoration(gc),+ child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [+ const SheetHandle(),+ const SizedBox(height: 16),+ SheetTitle(t.noteFolderLabel),+ const SizedBox(height: 14),+ Flexible(+ child: OptionGroup(scroll: true, [+ OptionItem(t.noteFolderNone,+ icon: PhosphorIconsRegular.tray, selected: current.isEmpty, onTap: () => Navigator.pop(sheet, '')),+ for (final f in fit.noteFolders)+ OptionItem(f.name,+ leading: Container(+ width: 14,+ height: 14,+ decoration: BoxDecoration(color: noteFolderHue(f), shape: BoxShape.circle),+ ),+ selected: f.id == current,+ onTap: () => Navigator.pop(sheet, f.id)),+ OptionItem(t.noteFolderNew, icon: PhosphorIconsRegular.folderPlus, onTap: () async {+ final id = await showNoteFolderEditor(sheet);+ if (id != null && sheet.mounted) Navigator.pop(sheet, id);+ }),+ ]),+ ),+ ]),+ );+ },+ );diff --git a/lib/widgets/note_kit.dart b/lib/widgets/note_kit.dartindex 20499cd..d2c597e 100644--- a/lib/widgets/note_kit.dart+++ b/lib/widgets/note_kit.dart@@ -6,13 +6,17 @@ import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';import 'package:video_player/video_player.dart';import '../l10n/l10n.dart';+import '../models/exercise.dart';import '../models/note.dart';import '../services/media_store.dart';import '../state/fit_state.dart';import '../theme/app_colors.dart';import '../theme/app_theme.dart';+import 'exercise_media.dart';+import 'exercise_preview.dart';import 'file_thumb.dart';import 'glass.dart';+import 'note_folder.dart';import 'ui_kit.dart';Color noteKindColor(GymColors gc, NoteKind k) => switch (k) {@@ -313,9 +317,11 @@ class NoteFilterBar extends StatelessWidget {required this.selected,required this.counts,required this.onPick,+ this.padding = EdgeInsets.zero,});final NoteKind? selected;+ final EdgeInsets padding;final Map<NoteKind, int> counts;final ValueChanged<NoteKind?> onPick;@@ -333,7 +339,7 @@ class NoteFilterBar extends StatelessWidget {behavior: HitTestBehavior.opaque,onTap: onTap,child: Container(- margin: const EdgeInsets.only(right: 8),+ margin: const EdgeInsetsDirectional.only(end: 8),padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 8),decoration: BoxDecoration(color: on ? color.withValues(alpha: 0.16) : gc.bgRaised,@@ -352,6 +358,7 @@ class NoteFilterBar extends StatelessWidget {height: 38,child: ListView(scrollDirection: Axis.horizontal,+ padding: padding.copyWith(right: padding.right - 8),children: [chip(label: t.noteFilterAll,@@ -391,106 +398,464 @@ class NoteCard extends StatelessWidget {Widget build(BuildContext context) {final gc = context.gc;final color = noteKindColor(gc, note.kind);- final exercise = showExercise ? fit.noteExerciseName(note) : '';+ final exercise = showExercise && !note.isGeneral ? fit.exerciseById(note.exerciseId) : null;+ final folder = fit.noteFolderScope.isEmpty ? fit.noteFolderById(note.folder) : null;final day = showDate ? noteDayLabel(note.date) : '';- final meta = [day, exercise].where((p) => p.isNotEmpty).join(' · ');+ final dark = gc.bg.computeLuminance() < 0.5;- return GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: onTap ?? () => fit.openNoteEditor(id: note.id),- child: Container(- margin: const EdgeInsets.only(bottom: 10),- clipBehavior: Clip.antiAlias,- decoration: BoxDecoration(- color: gc.bgRaised,- borderRadius: BorderRadius.circular(18),- ),- child: Stack(- children: [- Positioned.fill(child: CustomPaint(painter: _NoteRail(color))),- Padding(- padding: const EdgeInsets.fromLTRB(17, 13, 14, 14),+ return Padding(+ padding: const EdgeInsets.only(bottom: 10),+ child: Pressable(+ scale: 0.98,+ onTap: onTap ?? () => showNoteSheet(context, note),+ child: Stack(children: [+ Positioned(+ left: 12,+ right: 12,+ top: 12,+ bottom: 0,+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: Color.lerp(gc.bgRaised, Colors.black, dark ? 0.3 : 0.08),+ borderRadius: BorderRadius.circular(20),+ ),+ ),+ ),+ Container(+ margin: const EdgeInsets.only(bottom: 5),+ clipBehavior: Clip.antiAlias,+ decoration: BoxDecoration(+ color: gc.bgRaised,+ borderRadius: BorderRadius.circular(22),+ boxShadow: [+ BoxShadow(+ color: Colors.black.withValues(alpha: dark ? 0.28 : 0.06),+ blurRadius: 10,+ offset: const Offset(0, 3),+ ),+ ],+ ),+ child: CustomPaint(+ foregroundPainter: _NoteEar(color: color, bg: gc.bg, paper: gc.bgRaised, dark: dark),+ painter: _NoteGlow(color: color, glow: dark ? 0.13 : 0.1),+ child: Padding(+ padding: const EdgeInsets.fromLTRB(16, 14, 16, 14),child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [Row(children: [- NoteKindBadge(kind: note.kind, compact: true),- if (note.pinned) ...[- const SizedBox(width: 6),- Semantics(- label: t.workoutNoteEvery,- child: Icon(PhosphorIconsFill.pushPin, size: 13, color: gc.accent),+ if (exercise != null) ...[+ GestureDetector(+ onTap: () => showExercisePreview(context, exercise),+ child: SizedBox(+ width: 40,+ child: ExerciseMedia(ex: exercise, height: 40, radius: 12, bordered: false),+ ),),+ const SizedBox(width: 10),],- const SizedBox(width: 8),Expanded(- child: Text(- meta,- maxLines: 1,- overflow: TextOverflow.ellipsis,- textAlign: TextAlign.right,- style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary),- ),+ child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Row(children: [+ Icon(noteKindIcon(note.kind), size: 13, color: color),+ const SizedBox(width: 5),+ Flexible(+ child: Text(noteKindLabel(note.kind).toUpperCase(),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(10, weight: FontWeight.w800, color: color, letterSpacing: 1.2)),+ ),+ if (note.pinned) ...[+ const SizedBox(width: 6),+ Semantics(+ label: t.workoutNoteEvery,+ child: Icon(PhosphorIconsFill.pushPin, size: 12, color: gc.accent),+ ),+ ],+ ]),+ if (exercise != null) ...[+ const SizedBox(height: 2),+ Text(exerciseName(exercise),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textSecondary)),+ ],+ ]),),+ const SizedBox(width: 20),],),- const SizedBox(height: 9),+ const SizedBox(height: 10),Text(note.title,maxLines: 2,overflow: TextOverflow.ellipsis,- style: AppTheme.f(15, weight: FontWeight.w600, color: gc.text, height: 1.3)),+ style: AppTheme.f(16, weight: FontWeight.w800, color: gc.text, height: 1.25, letterSpacing: -0.2)),if (note.body.isNotEmpty) ...[const SizedBox(height: 4),Text(note.body,maxLines: 3,overflow: TextOverflow.ellipsis,- style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),+ style: AppTheme.f(13.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),],if (note.media.isNotEmpty) ...[const SizedBox(height: 12),- NoteMediaStrip(media: note.media, scope: note.id),+ NotePhotos(media: note.media, scope: note.id),+ ],+ if (folder != null || day.isNotEmpty) ...[+ const SizedBox(height: 12),+ Row(children: [+ if (folder != null)+ Flexible(+ child: Container(+ padding: const EdgeInsets.fromLTRB(8, 4, 10, 4),+ decoration: BoxDecoration(+ color: gc.text.withValues(alpha: 0.06),+ borderRadius: BorderRadius.circular(100),+ ),+ child: Row(mainAxisSize: MainAxisSize.min, children: [+ Container(+ width: 8,+ height: 8,+ decoration: BoxDecoration(color: noteFolderHue(folder), shape: BoxShape.circle),+ ),+ const SizedBox(width: 6),+ Flexible(+ child: Text(folder.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(11.5, weight: FontWeight.w700, color: gc.textSecondary)),+ ),+ ]),+ ),+ ),+ const Spacer(),+ if (day.isNotEmpty)+ Text(day, style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.textTertiary)),+ ]),],],),),- ],+ ),),+ ]),),);}}-class _NoteRail extends CustomPainter {- _NoteRail(this.color);+class _NoteGlow extends CustomPainter {+ _NoteGlow({required this.color, required this.glow});final Color color;- static const double _w = 3;- static const double _r = 18;+ final double glow;@overridevoid paint(Canvas canvas, Size size) {- final fade = LinearGradient(- begin: Alignment.centerLeft,- end: Alignment.centerRight,- colors: [color, color, color.withValues(alpha: 0)],- stops: const [0, 0.06, 0.26],- ).createShader(Offset.zero & size);-- canvas.drawRRect(- RRect.fromRectAndRadius(- Rect.fromLTWH(_w / 2, _w / 2, size.width - _w, size.height - _w),- const Radius.circular(_r - _w / 2),- ),+ final light = RadialGradient(+ center: const Alignment(-1, -1),+ radius: 1.1,+ colors: [color.withValues(alpha: glow), color.withValues(alpha: 0)],+ ).createShader(Rect.fromLTWH(0, 0, size.width * 0.9, size.height * 1.6));+ canvas.drawRect(Offset.zero & size, Paint()..shader = light);+ }++ @override+ bool shouldRepaint(_NoteGlow o) => o.color != color || o.glow != glow;+}++class _NoteEar extends CustomPainter {+ _NoteEar({required this.color, required this.bg, required this.paper, required this.dark});++ final Color color;+ final Color bg;+ final Color paper;+ final bool dark;++ static const double _ear = 24;++ @override+ void paint(Canvas canvas, Size size) {+ final x = size.width;+ canvas.drawPath(+ Path()+ ..moveTo(x - _ear, 0)+ ..lineTo(x, 0)+ ..lineTo(x, _ear)+ ..close(),+ Paint()..color = bg,+ );+ final flap = Path()+ ..moveTo(x - _ear, 0)+ ..lineTo(x - _ear, _ear - 5)+ ..quadraticBezierTo(x - _ear, _ear, x - _ear + 5, _ear)+ ..lineTo(x, _ear)+ ..close();+ canvas.drawPath(+ flap.shift(const Offset(-2, 2.5)),+ Paint()+ ..color = Colors.black.withValues(alpha: dark ? 0.45 : 0.16)+ ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 3),+ );+ final base = Color.lerp(paper, color, 0.22)!;+ canvas.drawPath(+ flap,+ Paint()+ ..shader = LinearGradient(+ begin: Alignment.topRight,+ end: Alignment.bottomLeft,+ colors: [+ Color.lerp(base, Colors.black, dark ? 0.28 : 0.1)!,+ base,+ Color.lerp(base, Colors.white, dark ? 0.12 : 0.35)!,+ ],+ stops: const [0, 0.55, 1],+ ).createShader(Rect.fromLTWH(x - _ear, 0, _ear, _ear)),+ );+ canvas.drawLine(+ Offset(x - _ear + 0.5, 0.5),+ Offset(x - 0.5, _ear - 0.5),Paint()- ..shader = fade- ..style = PaintingStyle.stroke- ..strokeWidth = _w,+ ..color = Colors.white.withValues(alpha: dark ? 0.1 : 0.4)+ ..strokeWidth = 1,+ );+ }++ @override+ bool shouldRepaint(_NoteEar o) => o.color != color || o.bg != bg || o.paper != paper || o.dark != dark;+}++class NotePhotos extends StatelessWidget {+ const NotePhotos({super.key, required this.media, this.scope});++ final List<String> media;+ final String? scope;++ @override+ Widget build(BuildContext context) {+ final gc = context.gc;+ Widget tile(int i, double w, double h, {String? badge}) {+ final name = media[i];+ final path = MediaStore.pathFor(name);+ final photo = path != null && !MediaStore.isVideo(name);+ Widget inner = photo+ ? FileThumb(path, width: w, height: h, errorBuilder: (_, _, _) => const SizedBox.shrink())+ : Center(+ child: Icon(path == null ? PhosphorIconsRegular.imageSquare : PhosphorIconsFill.playCircle,+ size: 26, color: gc.textSecondary));+ final tag = scope;+ if (photo && tag != null) inner = Hero(tag: noteHeroTag(tag, name), child: inner);+ return GestureDetector(+ onTap: () => showNoteMedia(context, media, i, scope: scope),+ child: Container(+ width: w,+ height: h,+ clipBehavior: Clip.antiAlias,+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(14)),+ child: Stack(fit: StackFit.expand, children: [+ inner,+ if (badge != null)+ ColoredBox(+ color: const Color(0x8C000000),+ child: Center(+ child: Text(badge, style: AppTheme.f(16, weight: FontWeight.w800, color: Colors.white)),+ ),+ ),+ ]),+ ),+ );+ }++ return LayoutBuilder(builder: (context, box) {+ final w = box.maxWidth;+ const gap = 6.0;+ if (media.length == 1) return tile(0, w, 160);+ if (media.length == 2) {+ final half = (w - gap) / 2;+ return Row(children: [tile(0, half, 130), const SizedBox(width: gap), tile(1, half, 130)]);+ }+ final big = (w - gap) * 0.62;+ final side = w - gap - big;+ final extra = media.length - 3;+ return Row(children: [+ tile(0, big, 160),+ const SizedBox(width: gap),+ Column(children: [+ tile(1, side, (160 - gap) / 2),+ const SizedBox(height: gap),+ tile(2, side, (160 - gap) / 2, badge: extra > 0 ? '+$extra' : null),+ ]),+ ]);+ });+ }+}++Future<void> showNoteSheet(BuildContext context, GymNote note) => showAppSheet<void>(+ context: context,+ isScrollControlled: true,+ backgroundColor: Colors.transparent,+ builder: (_) => _NoteSheetView(id: note.id),+ );++class _NoteSheetView extends StatelessWidget {+ const _NoteSheetView({required this.id});++ final String id;++ @override+ Widget build(BuildContext context) {+ return AnimatedBuilder(+ animation: fit,+ builder: (context, _) {+ final note = fit.noteById(id);+ if (note == null) return const SizedBox.shrink();+ final gc = context.gc;+ final color = noteKindColor(gc, note.kind);+ final exercise = note.isGeneral ? null : fit.exerciseById(note.exerciseId);+ final folder = fit.noteFolderById(note.folder);+ return AppSheet(maxHeight: 0.92, children: [+ Row(children: [+ Icon(noteKindIcon(note.kind), size: 15, color: color),+ const SizedBox(width: 6),+ Text(noteKindLabel(note.kind).toUpperCase(),+ style: AppTheme.f(11, weight: FontWeight.w800, color: color, letterSpacing: 1.3)),+ if (note.pinned) ...[+ const SizedBox(width: 8),+ Icon(PhosphorIconsFill.pushPin, size: 13, color: gc.accent),+ ],+ const SizedBox(width: 12),+ Expanded(+ child: FittedBox(+ fit: BoxFit.scaleDown,+ alignment: AlignmentDirectional.centerEnd,+ child: Text(t.fullDate(note.date),+ maxLines: 1, style: AppTheme.f(12, weight: FontWeight.w600, color: gc.textTertiary)),+ ),+ ),+ ]),+ const SizedBox(height: 14),+ Text(note.title,+ style: AppTheme.f(22, weight: FontWeight.w800, color: gc.text, height: 1.2, letterSpacing: -0.5)),+ if (note.body.isNotEmpty) ...[+ const SizedBox(height: 10),+ Text(note.body, style: AppTheme.f(15, weight: FontWeight.w500, color: gc.textSecondary, height: 1.55)),+ ],+ if (exercise != null) ...[+ const SizedBox(height: 18),+ Pressable(+ scale: 0.98,+ onTap: () => showExercisePreview(context, exercise),+ child: Container(+ padding: const EdgeInsets.all(8),+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(16)),+ child: Row(children: [+ SizedBox(width: 48, child: ExerciseMedia(ex: exercise, height: 48, radius: 12, bordered: false)),+ const SizedBox(width: 12),+ Expanded(+ child: Text(exerciseName(exercise),+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(14, weight: FontWeight.w700, color: gc.text, height: 1.25)),+ ),+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),+ const SizedBox(width: 6),+ ]),+ ),+ ),+ ],+ if (note.media.isNotEmpty) ...[+ const SizedBox(height: 18),+ _AllPhotos(media: note.media, scope: 'sheet${note.id}'),+ ],+ const SizedBox(height: 20),+ Row(children: [+ if (folder != null)+ Flexible(+ child: Container(+ padding: const EdgeInsets.fromLTRB(10, 6, 12, 6),+ decoration: BoxDecoration(color: gc.text.withValues(alpha: 0.06), borderRadius: BorderRadius.circular(100)),+ child: Row(mainAxisSize: MainAxisSize.min, children: [+ Container(+ width: 9,+ height: 9,+ decoration: BoxDecoration(color: noteFolderHue(folder), shape: BoxShape.circle),+ ),+ const SizedBox(width: 7),+ Flexible(+ child: Text(folder.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(12.5, weight: FontWeight.w700, color: gc.textSecondary)),+ ),+ ]),+ ),+ ),+ const Spacer(),+ ]),+ const SizedBox(height: 16),+ GhostButton(+ label: t.editNote,+ icon: PhosphorIconsRegular.pencilSimple,+ onTap: () {+ Navigator.of(context).pop();+ fit.openNoteEditor(id: note.id);+ },+ ),+ ]);+ },);}+}++class _AllPhotos extends StatelessWidget {+ const _AllPhotos({required this.media, required this.scope});++ final List<String> media;+ final String scope;@override- bool shouldRepaint(_NoteRail o) => o.color != color;+ Widget build(BuildContext context) {+ final gc = context.gc;+ Widget tile(int i, double w, double h) {+ final name = media[i];+ final path = MediaStore.pathFor(name);+ final photo = path != null && !MediaStore.isVideo(name);+ Widget inner = photo+ ? FileThumb(path, width: w, height: h, errorBuilder: (_, _, _) => const SizedBox.shrink())+ : Center(+ child: Icon(path == null ? PhosphorIconsRegular.imageSquare : PhosphorIconsFill.playCircle,+ size: 30, color: gc.textSecondary));+ if (photo) inner = Hero(tag: noteHeroTag(scope, name), child: inner);+ return GestureDetector(+ onTap: () => showNoteMedia(context, media, i, scope: scope),+ child: Container(+ width: w,+ height: h,+ clipBehavior: Clip.antiAlias,+ decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(16)),+ child: inner,+ ),+ );+ }++ return LayoutBuilder(builder: (context, box) {+ final w = box.maxWidth;+ const gap = 8.0;+ final half = (w - gap) / 2;+ final rest = media.length - 1;+ return Column(children: [+ tile(0, w, w * 0.66),+ for (var r = 0; r * 2 < rest; r++) ...[+ const SizedBox(height: gap),+ Row(children: [+ tile(1 + r * 2, 2 + r * 2 > rest ? w : half, half),+ if (2 + r * 2 <= rest) ...[const SizedBox(width: gap), tile(2 + r * 2, half, half)],+ ]),+ ],+ ]);+ });+ }}class NoteMediaStrip extends StatelessWidget {diff --git a/lib/widgets/workout_notes.dart b/lib/widgets/workout_notes.dartindex de40b68..3ede90b 100644--- a/lib/widgets/workout_notes.dart+++ b/lib/widgets/workout_notes.dart@@ -17,11 +17,44 @@ class WorkoutNoteStrip extends StatelessWidget {final String exerciseId;final bool onDark;+ static bool offers(String exerciseId) =>+ fit.workoutNotesFor(exerciseId).isNotEmpty ||+ (exerciseId.isNotEmpty && fit.notesFor(exerciseId).isEmpty && fit.exerciseHistory(exerciseId).length < 3);+@overrideWidget build(BuildContext context) {final notes = fit.workoutNotesFor(exerciseId);- if (notes.isEmpty) return const SizedBox.shrink();final gc = context.gc;+ if (notes.isEmpty) {+ if (!offers(exerciseId)) return const SizedBox.shrink();+ return Semantics(+ button: true,+ label: t.workoutNoteAdd,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => showWorkoutNoteEditor(context, exerciseId),+ child: Container(+ constraints: const BoxConstraints(minHeight: 40),+ padding: const EdgeInsets.fromLTRB(10, 8, 12, 8),+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(12),+ border: Border.all(color: gc.border.withValues(alpha: 0.8)),+ ),+ child: Row(children: [+ Icon(PhosphorIconsRegular.pushPin, size: 14, color: gc.textTertiary),+ const SizedBox(width: 8),+ Expanded(+ child: Text(t.workoutNoteAdd,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(12.5, weight: FontWeight.w600, color: gc.textTertiary, height: 1.3)),+ ),+ Icon(PhosphorIconsBold.plus, size: 13, color: gc.textTertiary),+ ]),+ ),+ ),+ );+ }return Semantics(button: true,label: t.workoutNotesTitle,diff --git a/test/exercise_notes_test.dart b/test/exercise_notes_test.dartindex 8ba5788..f5c47ec 100644--- a/test/exercise_notes_test.dart+++ b/test/exercise_notes_test.dart@@ -164,4 +164,22 @@ void main() {fit.noteScope = '';expect(fit.notesInScope, hasLength(1));});++ test('una carpeta agrupa sus notas y al borrarla las notas se quedan', () {+ fit.noteFolders.clear();+ final a = fit.addNoteFolder('Técnica', 1);+ final b = fit.addNoteFolder('Lesiones', 2);+ expect(a, isNot(b));+ fit.saveNote(exerciseId: '', date: DateTime.now(), kind: NoteKind.note, text: 'Codos pegados', folder: a);+ fit.saveNote(exerciseId: '', date: DateTime.now(), kind: NoteKind.pain, text: 'Rodilla');+ expect(fit.notesInFolder(a).map((n) => n.text), ['Codos pegados']);+ fit.openNoteFolder(a);+ expect(fit.notesInScope, hasLength(1));+ fit.backFromNotes();+ expect(fit.noteFolderScope, '');+ fit.deleteNoteFolder(a);+ expect(fit.noteFolders.map((f) => f.id), [b]);+ expect(fit.notes, hasLength(2));+ expect(fit.notes.every((n) => n.folder.isEmpty), isTrue);+ });}