todo-app/lib/ui/capture_app_bar.dart
Krzysztof kuhy Rudnicki 3a747c2e51
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
Report errors and slow waits to the board
crdt_sync_flutter 0.9.0's installAppErrors in main(): uncaught errors and
every spinner shown over 1 s (WaitWatch: sync.run, mirror.test) upload to
RTDB /todo/errors/<device> with the versionCode, where the PC app-errors
ingest files board tickets (kuhyx/utils DOCS-app-errors.md).

The app moves to material_ui first: sync_settings_ui 0.8.x and
design_system 0.4.x sit on it, and Flutter 3.50 deprecates
flutter/material. Pins: crdt_sync 0.14.1, csf 0.9.0, ssui 0.8.3,
gda 0.5.1, design_system 0.4.1, image 4.13.1, mcp_dart 2.4.4.
file_picker stays 13.3.3, held by data_transfer_flutter 0.2.2
(allowlisted, self-clearing).

appRoute takes a route name so each report names its screen; the
release build passes APP_BUILD/APP_VERSION. Nothing new on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 23:07:58 +01:00

133 lines
4.3 KiB
Dart

/// The capture screen's app bar: note count, and the four actions.
///
/// Split out of `capture_screen.dart` for file size. Callback-only — the
/// screen still owns every action; this just lays the row out.
library;
import 'package:crdt_sync_flutter/crdt_sync_flutter.dart' show WaitWatch;
import 'package:flutter/foundation.dart';
import 'package:material_ui/material_ui.dart';
import 'package:todo/data/note_repository.dart';
import 'package:todo/frame_stats.dart';
import 'package:todo/ui/attachment_picking.dart';
import 'package:todo/ui/capture_confirm_mark.dart';
/// App bar for the capture screen.
class CaptureAppBar extends StatelessWidget implements PreferredSizeWidget {
/// Creates the capture screen's app bar.
const CaptureAppBar({
required this.repository,
required this.advanced,
required this.syncing,
required this.onNewNote,
required this.onSync,
required this.onOpenList,
required this.onOpenSettings,
required this.onAttachFiles,
required this.captured,
this.attachmentPicking,
super.key,
});
/// Store whose note count is shown live.
final NoteRepository repository;
/// Whether advanced mode is on; hides the manual Sync action when off.
final bool advanced;
/// Whether a sync is in flight, which disables and spins the Sync action.
final bool syncing;
/// Saves the current draft and clears the box for a new one.
final VoidCallback onNewNote;
/// Runs a manual sync.
final VoidCallback onSync;
/// Opens the notes list.
final VoidCallback onOpenList;
/// Opens the settings screen.
final VoidCallback onOpenSettings;
/// Receives files picked with the 📎 action.
final ValueChanged<List<XFile>> onAttachFiles;
/// Counts committed captures; each change plays the confirmation mark.
final ValueListenable<int> captured;
/// The picker behind 📎; null uses the platform one.
final AttachmentPicking? attachmentPicking;
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
@override
Widget build(BuildContext context) {
return AppBar(
actions: [
// TEMPORARY: forces continuous frame production so raster cost
// can be sampled at each window size. Armed by
// TODO_FRAME_STATS=1, which is never set under the test
// runner, so the branch is unreachable.
// coverage:ignore-start
if (frameStatsEnabled)
const Padding(
padding: EdgeInsets.only(right: 8),
child: Center(
child: SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
),
),
),
// coverage:ignore-end
// Not gated on advanced mode: attaching is basic capture.
AttachButton(onFiles: onAttachFiles, picking: attachmentPicking),
IconButton(
onPressed: onNewNote,
icon: const Icon(Icons.check, semanticLabel: 'New note'),
),
if (advanced)
IconButton(
onPressed: syncing ? null : onSync,
icon: syncing
? const WaitWatch(
operation: 'sync.run',
child: SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
),
)
: const Icon(Icons.sync, semanticLabel: 'Sync'),
),
IconButton(
onPressed: onOpenList,
icon: const Icon(Icons.list, semanticLabel: 'Notes'),
),
// Live count of stored notes, proving local persistence. Sits directly
// right of the Notes button it belongs to, and carries no icon of its
// own -- that button's Icons.list already names what is being counted.
StreamBuilder<int>(
stream: repository.watchCount(),
builder: (context, snapshot) {
final count = snapshot.data ?? 0;
return Padding(
padding: const EdgeInsets.only(right: 4),
child: Center(child: Text('$count')),
);
},
),
CaptureConfirmMark(captured: captured),
IconButton(
onPressed: onOpenSettings,
icon: const Icon(Icons.settings, semanticLabel: 'Settings'),
),
],
);
}
}