todo-app/lib/ui/notes_list_navigation.dart
Krzysztof kuhy Rudnicki 9d2aa1c178 Enforce the 250-line file cap, and split the first four files
Wires the shared gate (~/utils/scripts/check_file_length.sh) into a new
.pre-commit-config.yaml as a local hook, checking only the files in the
commit and failing rather than warning. No baseline, no allowlist.

The repo had a hand-written .git/hooks/pre-commit running two checks;
both are ported verbatim into the config rather than dropped, with the
version bump ordered last so it cannot rewrite pubspec.yaml for a commit
a gate is still about to reject. scripts/install_hooks.sh now installs
pre-commit (and removes the legacy hook) instead of writing its own.

.github/workflows/file-length.yml runs the same check on push, kept
separate from release-apk.yml so an over-long file fails lint rather than
blocking an APK release.

Splits the four cleanest violations, all behaviour-preserving:

  note_template.dart      370 -> 203 + parser (186)
  firebase_backend.dart   308 -> barrel (24) + project/store/client
  port_guard.dart         315 -> 232 + linux_system_probe (100)
  notes_list_screen.dart  698 -> 225 + 5 widget/nav files

Where a file had external callers, the original path stays as a barrel
that re-exports the split parts, so no call site changed.

Verified: 313 tests pass, coverage identical at 99.9% / 1922 lines
(per-file too -- notes_list's 281 covered lines are now 81+75+51+41+22+11),
flutter analyze clean, and a staged 260-line file makes git commit fail.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-14 16:01:24 +02:00

53 lines
1.6 KiB
Dart

/// Navigation out of the notes list: the detail screen and the actions sheet.
///
/// Split out of `notes_list_screen.dart` for file size. Plain functions rather
/// than methods because neither needs the screen's state -- they only need a
/// context, the note, and the store.
library;
import 'package:flutter/material.dart';
import 'package:todo/data/note.dart';
import 'package:todo/data/note_repository.dart';
import 'package:todo/ui/note_actions_sheet.dart';
import 'package:todo/ui/note_detail_screen.dart';
/// Opens the full note: read it, edit the body, change priority/status.
Future<void> openNote(
BuildContext context,
Note note,
NoteRepository repository,
) async {
await Navigator.of(context).push<void>(
MaterialPageRoute(
builder: (_) => NoteDetailScreen(note: note, repository: repository),
),
);
}
/// Opens the per-note quick-actions sheet (priority, status, delete).
Future<void> openNoteActions(
BuildContext context,
Note note,
NoteRepository repository,
) async {
await showModalBottomSheet<void>(
context: context,
showDragHandle: true,
// Scroll-controlled so the sheet can exceed the default 9/16 of the
// viewport. On a 768px-tall screen that default is only ~432px, and this
// sheet's content grows with the note title and its chip rows -- an
// unscrollable sheet would clip the Delete action out of reach.
isScrollControlled: true,
builder: (_) => NoteActionsSheet(
note: note,
onChanged: (updated) async {
await repository.upsert(updated);
},
onDelete: () async {
await repository.delete(note.id);
},
),
);
}