mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 19:07:02 +01:00
An app-bar toggle enters selection mode: a tap toggles a note (tint + check on grid tiles, ListTile.selected + check in the list), Ctrl/Cmd- click toggles and Shift-click range-selects on desktop, long-press outside the mode still opens the per-note sheet. While anything is selected an icon-only bottom bar sets status or priority for the whole selection in one bulkUpdate, assigns plain notes to a repo picked from the repos on notes or typed as owner/name, or clears the selection. A refused assign (note already in a repo) flashes a block icon. Labels are semantic only; menus pass an empty tooltip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWXdsB7CQPNXVN829G1
44 lines
1.6 KiB
Dart
44 lines
1.6 KiB
Dart
/// The notes list's multi-select wiring: the app-bar toggle, taps, and the
|
|
/// bottom action bar.
|
|
///
|
|
/// A `part` of `notes_list_screen.dart` because it reads the screen's
|
|
/// private selection and repository; split out for file size.
|
|
part of 'notes_list_screen.dart';
|
|
|
|
extension _Selecting on _NotesListScreenState {
|
|
/// App-bar toggle into and out of selection mode (tinted while on).
|
|
Widget _selectButton() => IconButton(
|
|
key: const ValueKey('select-mode'),
|
|
isSelected: _selection.active,
|
|
onPressed: _selection.toggleMode,
|
|
icon: const Icon(Icons.checklist, semanticLabel: 'Select'),
|
|
);
|
|
|
|
/// A tap on [note] of [notes]: selects in the mode or with Shift/Ctrl,
|
|
/// else opens it.
|
|
void _tap(Note note, List<Note> notes) {
|
|
if (_selection.handleTap(note, notes)) return;
|
|
unawaited(openNote(context, note, widget.repository, widget.appSettings));
|
|
}
|
|
|
|
/// A long-press: toggles in the mode, else the per-note sheet.
|
|
void _longPress(Note note) {
|
|
if (_selection.active) return _selection.toggle(note.id);
|
|
unawaited(openNoteActions(context, note, widget.repository));
|
|
}
|
|
|
|
/// The bar, only while something is selected. Status and priority are
|
|
/// ONE store write for the whole selection ([NoteRepository.bulkUpdate]).
|
|
Widget? _selectionBar() {
|
|
if (_selection.ids.isEmpty) return null;
|
|
final repo = widget.repository;
|
|
return NotesSelectionBar(
|
|
onStatus: (s) => unawaited(repo.bulkUpdate(_selection.ids, status: s)),
|
|
onPriority: (p) =>
|
|
unawaited(repo.bulkUpdate(_selection.ids, priority: p)),
|
|
onAssign: () => assignSelection(context, repo, _selection),
|
|
onClear: _selection.clear,
|
|
);
|
|
}
|
|
}
|