mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 20:27:01 +01:00
Editing an existing note looked nothing like capturing a new one: it always showed the template dropdown, the View/Guided/Raw pills and the priority/status row. The cause was one missing argument -- both screens already embedded the same NoteEditor, but NoteDetailScreen never passed advancedMode, which defaults to true in the widget while the app-wide AppSettings.advancedMode defaults to false. Extract the shared form as three single-purpose components rather than one widget owning several jobs: - note_meta_row.dart renders the priority/status row (was capture_meta_row.dart; drops the private _MetaDropdown duplicate the detail screen carried, which used DropdownButtonFormField where the shared one uses DropdownButton). - note_form_chrome_gate.dart owns chrome visibility and nothing else, replacing the _chromeVisible flag both screens copy-pasted. - note_form.dart composes those two with NoteEditor. appSettings is now a required parameter through NotesListScreen and NoteDetailScreen. Required, not defaulted: a silent default is exactly what caused this, so it must not be reintroducible. Also in the capture app bar: drop the decorative Icons.list_alt_outlined beside the note count, since the adjacent Icons.list button already names what is counted, and move the count to the right of that button. The finalize-and-clear action becomes Icons.check instead of Icons.add -- it never saved anything (every keystroke is already persisted), so a plus sign misdescribed it. 314 tests, 100% line coverage. Verified in a running web build that edit and capture render identically with advanced mode both off and on. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
59 lines
1.8 KiB
Dart
59 lines
1.8 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/app_settings.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,
|
|
ValueNotifier<AppSettings> appSettings,
|
|
) async {
|
|
await Navigator.of(context).push<void>(
|
|
MaterialPageRoute(
|
|
builder: (_) => NoteDetailScreen(
|
|
note: note,
|
|
repository: repository,
|
|
appSettings: appSettings,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 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);
|
|
},
|
|
),
|
|
);
|
|
}
|