Compare commits

..

No commits in common. "203e61d6ac64b31e37cf6eefa1070334fdfded11" and "a30e7b34a9b21ebc1311f6afa1436e700a0495c3" have entirely different histories.

74 changed files with 739 additions and 1708 deletions

View File

@ -11,7 +11,6 @@ import 'package:todo/data/note_repository.dart';
import 'package:todo/data/repository_factory.dart'; import 'package:todo/data/repository_factory.dart';
import 'package:todo/frame_stats.dart'; import 'package:todo/frame_stats.dart';
import 'package:todo/ui/capture_screen.dart'; import 'package:todo/ui/capture_screen.dart';
import 'package:todo/ui/text_free_localizations.dart';
Future<void> main() async { Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -70,7 +69,6 @@ class TodoApp extends StatelessWidget {
store: imageStore, store: imageStore,
child: MaterialApp( child: MaterialApp(
title: 'todo', title: 'todo',
localizationsDelegates: kTextFreeLocalizations,
theme: buildLightTheme(), theme: buildLightTheme(),
darkTheme: buildDarkTheme(), darkTheme: buildDarkTheme(),
home: CaptureScreen( home: CaptureScreen(

View File

@ -44,24 +44,18 @@ Future<List<XFile>> pickAttachments(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
ListTile( ListTile(
leading: const Icon( leading: const Icon(Icons.photo_camera_outlined),
Icons.photo_camera_outlined, title: const Text('Camera'),
semanticLabel: 'Camera',
),
onTap: () => Navigator.pop(context, AttachmentPickSource.camera), onTap: () => Navigator.pop(context, AttachmentPickSource.camera),
), ),
ListTile( ListTile(
leading: const Icon( leading: const Icon(Icons.photo_library_outlined),
Icons.photo_library_outlined, title: const Text('Gallery'),
semanticLabel: 'Gallery',
),
onTap: () => Navigator.pop(context, AttachmentPickSource.gallery), onTap: () => Navigator.pop(context, AttachmentPickSource.gallery),
), ),
ListTile( ListTile(
leading: const Icon( leading: const Icon(Icons.insert_drive_file_outlined),
Icons.insert_drive_file_outlined, title: const Text('File'),
semanticLabel: 'File',
),
onTap: () => Navigator.pop(context, AttachmentPickSource.file), onTap: () => Navigator.pop(context, AttachmentPickSource.file),
), ),
], ],
@ -108,7 +102,8 @@ class AttachButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return IconButton( return IconButton(
icon: const Icon(Icons.attach_file, semanticLabel: 'Attach'), tooltip: 'Attach',
icon: const Icon(Icons.attach_file),
onPressed: () async { onPressed: () async {
final files = await (picking ?? pickAttachments)(context); final files = await (picking ?? pickAttachments)(context);
if (files.isNotEmpty) onFiles(files); if (files.isNotEmpty) onFiles(files);

View File

@ -86,11 +86,13 @@ class CaptureAppBar extends StatelessWidget implements PreferredSizeWidget {
// Not gated on advanced mode: attaching is basic capture. // Not gated on advanced mode: attaching is basic capture.
AttachButton(onFiles: onAttachFiles, picking: attachmentPicking), AttachButton(onFiles: onAttachFiles, picking: attachmentPicking),
IconButton( IconButton(
tooltip: 'New note',
onPressed: onNewNote, onPressed: onNewNote,
icon: const Icon(Icons.check, semanticLabel: 'New note'), icon: const Icon(Icons.check),
), ),
if (advanced) if (advanced)
IconButton( IconButton(
tooltip: 'Sync',
onPressed: syncing ? null : onSync, onPressed: syncing ? null : onSync,
icon: syncing icon: syncing
? const SizedBox( ? const SizedBox(
@ -98,11 +100,12 @@ class CaptureAppBar extends StatelessWidget implements PreferredSizeWidget {
height: 18, height: 18,
child: CircularProgressIndicator(strokeWidth: 2), child: CircularProgressIndicator(strokeWidth: 2),
) )
: const Icon(Icons.sync, semanticLabel: 'Sync'), : const Icon(Icons.sync),
), ),
IconButton( IconButton(
tooltip: 'Notes',
onPressed: onOpenList, onPressed: onOpenList,
icon: const Icon(Icons.list, semanticLabel: 'Notes'), icon: const Icon(Icons.list),
), ),
// Live count of stored notes, proving local persistence. Sits directly // Live count of stored notes, proving local persistence. Sits directly
// right of the Notes button it belongs to, and carries no icon of its // right of the Notes button it belongs to, and carries no icon of its
@ -119,8 +122,9 @@ class CaptureAppBar extends StatelessWidget implements PreferredSizeWidget {
), ),
CaptureConfirmMark(captured: captured), CaptureConfirmMark(captured: captured),
IconButton( IconButton(
tooltip: 'Settings',
onPressed: onOpenSettings, onPressed: onOpenSettings,
icon: const Icon(Icons.settings, semanticLabel: 'Settings'), icon: const Icon(Icons.settings),
), ),
], ],
); );

View File

@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync/crdt_sync.dart'; import 'package:crdt_sync/crdt_sync.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
@ -21,7 +22,6 @@ import 'package:todo/ui/capture_draft.dart';
import 'package:todo/ui/capture_status.dart'; import 'package:todo/ui/capture_status.dart';
import 'package:todo/ui/capture_status_footer.dart'; import 'package:todo/ui/capture_status_footer.dart';
import 'package:todo/ui/capture_sync_runner.dart'; import 'package:todo/ui/capture_sync_runner.dart';
import 'package:todo/ui/cue_snack.dart';
import 'package:todo/ui/image_attach.dart'; import 'package:todo/ui/image_attach.dart';
import 'package:todo/ui/image_input.dart'; import 'package:todo/ui/image_input.dart';
import 'package:todo/ui/note_form.dart'; import 'package:todo/ui/note_form.dart';
@ -194,14 +194,7 @@ class _CaptureScreenState extends State<CaptureScreen>
Future<void> _sync() async { Future<void> _sync() async {
final settings = _settings ?? await SyncSettings.load(); final settings = _settings ?? await SyncSettings.load();
if (!settings.isConfigured && await openFirebase() == null) { if (!settings.isConfigured && await openFirebase() == null) {
// The cue plus the settings screen opening is the whole message. _showSnack('Connect Firebase (or add a GitHub token) in settings');
if (mounted) {
showCue(
context,
Icons.cloud_off,
'Connect Firebase (or add a GitHub token) in settings',
);
}
await _openSettings(); await _openSettings();
return; return;
} }
@ -222,7 +215,12 @@ class _CaptureScreenState extends State<CaptureScreen>
if (outcome.ok) 'detail': outcome.detail, if (outcome.ok) 'detail': outcome.detail,
}, },
); );
_showSyncCue(outcome); _showSnack(
outcome.ok
? 'Synced: ${outcome.detail}'
: 'Sync failed: ${outcome.detail}',
isError: !outcome.ok,
);
} finally { } finally {
if (mounted) setState(() => _syncing = false); if (mounted) setState(() => _syncing = false);
} }

View File

@ -104,20 +104,13 @@ extension _CaptureSyncBehaviour on _CaptureScreenState {
/// replace-don't-queue behaviour match every other app; [isError] picks /// replace-don't-queue behaviour match every other app; [isError] picks
/// the danger hue and the longer duration, because an error the user /// the danger hue and the longer duration, because an error the user
/// missed is an error they will hit again. /// missed is an error they will hit again.
/// A manual sync's result as a glyph: done, done-but-degraded (Firebase void _showSnack(String message, {bool isError = false}) {
/// off or a peer unreadable, in the danger hue), or failed. The summary
/// sentence is spoken only; the status line keeps the failure time.
void _showSyncCue(CaptureSyncOutcome outcome) {
if (!mounted) return; if (!mounted) return;
final spoken = outcome.ok if (isError) {
? 'Synced: ${outcome.detail}' showError(context, message);
: 'Sync failed: ${outcome.detail}'; } else {
final (icon, error) = !outcome.ok showToast(context, message);
? (Icons.sync_problem, true) }
: outcome.degraded
? (Icons.warning_amber, true)
: (Icons.cloud_done, false);
showCue(context, icon, spoken, error: error);
} }
/// Reloads the persisted last-sync outcome so the status line survives a /// Reloads the persisted last-sync outcome so the status line survives a

View File

@ -44,16 +44,16 @@ class CaptureStatusFooter extends StatelessWidget {
if (status == null || status.ok) { if (status == null || status.ok) {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
// Glyph + time in the danger hue; the error itself is spoken.
return Padding( return Padding(
padding: const EdgeInsets.only(top: 8), padding: const EdgeInsets.only(top: 8),
child: _cueLine( child: Text(
Icons.sync_problem,
formatSyncTime(status.time),
'Sync failed at ${formatSyncTime(status.time)} · ' 'Sync failed at ${formatSyncTime(status.time)} · '
'${status.detail}', '${status.detail}',
theme.textTheme.bodySmall, style: theme.textTheme.bodySmall?.copyWith(
theme.colorScheme.error, color: theme.colorScheme.error,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
), ),
); );
}, },
@ -63,45 +63,15 @@ class CaptureStatusFooter extends StatelessWidget {
padding: const EdgeInsets.only(top: 4), padding: const EdgeInsets.only(top: 4),
child: ValueListenableBuilder<DateTime?>( child: ValueListenableBuilder<DateTime?>(
valueListenable: lastSavedAt, valueListenable: lastSavedAt,
// Before the first save: the save glyph alone, muted. builder: (context, savedAt, _) => Text(
builder: (context, savedAt, _) => savedAt == null savedAt == null
? _cueLine( ? 'Autosaves as you type'
Icons.save_outlined, : 'Saved locally at ${formatSyncTime(savedAt)}',
'', style: theme.textTheme.bodySmall,
'Autosaves as you type',
theme.textTheme.bodySmall,
theme.colorScheme.outline,
)
: _cueLine(
Icons.save,
formatSyncTime(savedAt),
'Saved locally at ${formatSyncTime(savedAt)}',
theme.textTheme.bodySmall,
null,
), ),
), ),
), ),
], ],
); );
} }
/// One status line: a small glyph and a time, spoken as [spoken].
Widget _cueLine(
IconData icon,
String time,
String spoken,
TextStyle? style,
Color? color,
) => Semantics(
label: spoken,
excludeSemantics: true,
container: true,
child: Row(
children: [
Icon(icon, size: 16, color: color),
const SizedBox(width: 4),
Text(time, style: style?.copyWith(color: color)),
],
),
);
} }

View File

@ -26,16 +26,11 @@ class CaptureSyncOutcome {
required this.ok, required this.ok,
required this.detail, required this.detail,
this.reconciled, this.reconciled,
this.degraded = false,
}); });
/// Whether the pass completed without throwing. /// Whether the pass completed without throwing.
final bool ok; final bool ok;
/// A pass that completed but not fully: Firebase was not connected, or a
/// peer's file could not be read. Shown as a warning, not a plain success.
final bool degraded;
/// One-line summary: merged/skipped counts on success, the error otherwise. /// One-line summary: merged/skipped counts on success, the error otherwise.
final String detail; final String detail;
@ -95,12 +90,10 @@ class CaptureSyncRunner {
); );
final detail = describeSyncResult(result.syncResult); final detail = describeSyncResult(result.syncResult);
await status.record(ok: true, detail: detail, live: live()); await status.record(ok: true, detail: detail, live: live());
final synced = result.syncResult;
return CaptureSyncOutcome( return CaptureSyncOutcome(
ok: true, ok: true,
detail: detail, detail: detail,
reconciled: result.appSettings, reconciled: result.appSettings,
degraded: !synced.firebaseConnected || synced.skippedFiles.isNotEmpty,
); );
} on Exception catch (e) { } on Exception catch (e) {
await status.record(ok: false, detail: '$e', live: live()); await status.record(ok: false, detail: '$e', live: live());

View File

@ -11,7 +11,6 @@ import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:todo/attachments/image_password_store.dart'; import 'package:todo/attachments/image_password_store.dart';
@ -19,7 +18,6 @@ import 'package:todo/attachments/image_store_api.dart';
import 'package:todo/attachments/image_store_scope.dart'; import 'package:todo/attachments/image_store_scope.dart';
import 'package:todo/images/dufs_image_client.dart'; import 'package:todo/images/dufs_image_client.dart';
import 'package:todo/ui/app_route.dart'; import 'package:todo/ui/app_route.dart';
import 'package:todo/ui/status_cue.dart';
/// The command that creates the login, shown wherever it is missing. /// The command that creates the login, shown wherever it is missing.
const kAddLoginCommand = const kAddLoginCommand =
@ -36,7 +34,8 @@ class CloudImagesTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) => ListTile( Widget build(BuildContext context) => ListTile(
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
leading: const Icon(Icons.cloud, semanticLabel: 'Cloud images'), title: const Text('Cloud images'),
subtitle: const Text('Where attached images and files upload (dufs)'),
trailing: const Icon(Icons.chevron_right), trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.of(context).push<void>( onTap: () => Navigator.of(context).push<void>(
appRoute(context, (_) => CloudImagesScreen(httpClient: httpClient)), appRoute(context, (_) => CloudImagesScreen(httpClient: httpClient)),
@ -70,7 +69,7 @@ class CloudImagesScreen extends StatefulWidget {
class _CloudImagesScreenState extends State<CloudImagesScreen> { class _CloudImagesScreenState extends State<CloudImagesScreen> {
final _password = TextEditingController(); final _password = TextEditingController();
ImageStoreStatus? _status; ImageStoreStatus? _status;
StatusCue? _checkResult; String? _checkResult;
bool _checking = false; bool _checking = false;
@override @override
@ -99,11 +98,7 @@ class _CloudImagesScreenState extends State<CloudImagesScreen> {
final password = _password.text.trim(); final password = _password.text.trim();
setState(() => _checking = true); setState(() => _checking = true);
final saved = await widget.passwords.write(password); final saved = await widget.passwords.write(password);
var result = const StatusCue( var result = 'Could not save: the keystore is unavailable';
Icons.no_encryption,
'Could not save: the keystore is unavailable',
error: true,
);
if (saved) { if (saved) {
final client = DufsImageClient( final client = DufsImageClient(
DufsLogin(user: kDufsImagesUser, password: password), DufsLogin(user: kDufsImagesUser, password: password),
@ -111,17 +106,9 @@ class _CloudImagesScreenState extends State<CloudImagesScreen> {
); );
final check = await client.check(); final check = await client.check();
result = switch (check) { result = switch (check) {
DufsCheck.ok => const StatusCue.ok('Saved — dufs accepted the login'), DufsCheck.ok => 'Saved — dufs accepted the login',
DufsCheck.rejected => const StatusCue( DufsCheck.rejected => 'Saved, but dufs rejected the password',
Icons.lock, DufsCheck.unreachable => 'Saved — dufs is unreachable right now',
'Saved, but dufs rejected the password',
error: true,
),
DufsCheck.unreachable => const StatusCue(
Icons.cloud_off,
'Saved — dufs is unreachable right now',
error: true,
),
}; };
// Upload what queued up while there was no password, now rather than // Upload what queued up while there was no password, now rather than
// on the next sync. No note texts: an empty ref set only uploads, it // on the next sync. No note texts: an empty ref set only uploads, it
@ -142,9 +129,7 @@ class _CloudImagesScreenState extends State<CloudImagesScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final status = _status; final status = _status;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Cloud images')),
title: const Icon(Icons.cloud_outlined, semanticLabel: 'Cloud images'),
),
body: ListView( body: ListView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
children: [ children: [
@ -153,78 +138,36 @@ class _CloudImagesScreenState extends State<CloudImagesScreen> {
controller: _password, controller: _password,
obscureText: true, obscureText: true,
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon( labelText: 'Password for the "todo" dufs login',
Icons.lock_outline,
semanticLabel: 'Password for the "todo" dufs login',
),
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
FilledButton( FilledButton(
onPressed: _checking ? null : _saveAndTest, onPressed: _checking ? null : _saveAndTest,
child: const Icon(Icons.save, semanticLabel: 'Save & test'), child: const Text('Save & test'),
), ),
if (_checkResult case final result?) ...[ if (_checkResult case final result?) ...[
const SizedBox(height: 8), const SizedBox(height: 8),
StatusCueView(result), Text(result),
], ],
const SizedBox(height: 16), const SizedBox(height: 16),
], ],
if (status != null) ...[ if (status != null) ...[
// Shape + colour: a filled check, or a red error ring followed by Text(
// a copy button that puts the fixing command on the clipboard. status.configured
Row(
children: [
Icon(
status.configured ? Icons.check_circle : Icons.error_outline,
color: status.configured
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.error,
semanticLabel: status.configured
? 'Login: configured' ? 'Login: configured'
: 'Login: missing — create it on the PC with', : 'Login: missing — create it on the PC with',
), ),
if (!status.configured) if (!status.configured) const SelectableText(kAddLoginCommand),
IconButton(
onPressed: () => unawaited(
Clipboard.setData(
const ClipboardData(text: kAddLoginCommand),
),
),
icon: const Icon(
Icons.content_copy,
semanticLabel: 'Copy: $kAddLoginCommand',
),
),
],
),
const SizedBox(height: 8), const SizedBox(height: 8),
// Icon + the count itself: the number is the information. Text('Waiting to upload: ${status.pending}'),
Row(
children: [
const Icon(Icons.cloud_upload_outlined),
const SizedBox(width: 8),
Text(
'${status.pending}',
semanticsLabel: 'Waiting to upload: ${status.pending}',
),
],
),
], ],
const SizedBox(height: 16), const SizedBox(height: 16),
// Shrunk + no location, as glyphs; the sentence is spoken only. Text(
const Row( 'Images are shrunk to 2560px JPEGs without location data before '
children: [ 'they leave this device. Other files upload unchanged, at any '
Icon( 'size.',
Icons.photo_size_select_large, style: Theme.of(context).textTheme.bodySmall,
semanticLabel:
'Images are shrunk to 2560px JPEGs without location data '
'before they leave this device. Other files upload '
'unchanged, at any size.',
),
SizedBox(width: 8),
Icon(Icons.location_off),
],
), ),
], ],
), ),

View File

@ -1,58 +0,0 @@
/// Icon-only confirmation before deleting a note.
///
/// Replaces design_system's `confirmDestructive` here because that dialog
/// paints its title, message and button labels as text. The safety contract
/// is kept: Cancel is autofocused (a reflexive Return keeps the note), Escape
/// and the barrier answer "no", and the confirm glyph wears the error colour.
library;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
/// Asks whether to delete a note; true only when the delete glyph is pressed.
Future<bool> confirmDeleteNote(BuildContext context) async {
final confirmed = await showDialog<bool>(
context: context,
builder: (_) => const _ConfirmDeleteDialog(),
);
return confirmed ?? false;
}
class _ConfirmDeleteDialog extends StatelessWidget {
const _ConfirmDeleteDialog();
@override
Widget build(BuildContext context) {
final error = Theme.of(context).colorScheme.error;
return CallbackShortcuts(
bindings: {
const SingleActivator(LogicalKeyboardKey.escape): () =>
Navigator.of(context).pop(false),
},
child: AlertDialog(
// Spoken when the dialog opens; the old written body.
semanticLabel: 'This cannot be undone.',
title: Icon(
Icons.delete_forever,
size: 40,
color: error,
semanticLabel: 'Delete note?',
),
actionsAlignment: MainAxisAlignment.spaceEvenly,
actions: [
IconButton(
key: const ValueKey('confirm-cancel'),
autofocus: true,
onPressed: () => Navigator.of(context).pop(false),
icon: const Icon(Icons.close, semanticLabel: 'Cancel'),
),
IconButton(
key: const ValueKey('confirm-delete'),
onPressed: () => Navigator.of(context).pop(true),
icon: Icon(Icons.delete, color: error, semanticLabel: 'Delete'),
),
],
),
);
}
}

View File

@ -1,58 +0,0 @@
/// Transient feedback as a glyph, not a sentence (kuhy's textgate rule).
///
/// The design system's `showToast`/`showError` paint a message; this paints
/// an icon (plus an optional number) and keeps the old sentence as the
/// spoken label only. Colour is the second channel: errors use the danger
/// hue and stay up longer, as `showError` does.
library;
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
const Duration _toastDuration = Duration(seconds: 3);
const Duration _errorDuration = Duration(seconds: 5);
/// Shows [icon] (and [count], if given) in a snack bar; [spoken] is what a
/// screen reader says. Returns quietly when no `ScaffoldMessenger` is above
/// [context] (an async callback outliving its screen).
void showCue(
BuildContext context,
IconData icon,
String spoken, {
bool error = false,
int? count,
}) {
final messenger = ScaffoldMessenger.maybeOf(context);
if (messenger == null) return;
final colors = context.statusColors;
final fg = error ? colors.onStatus : null;
// Replace rather than queue: a queued cue describes an action the user
// has already moved on from.
messenger
..clearSnackBars()
..showSnackBar(
SnackBar(
content: Semantics(
label: spoken,
excludeSemantics: true,
// Its own node: otherwise the label merges into the snack bar's.
container: true,
child: Row(
children: [
Icon(icon, color: fg),
if (count != null) ...[
const SizedBox(width: AppSpacing.sm),
Text('$count', style: TextStyle(color: fg)),
],
],
),
),
backgroundColor: error ? colors.danger : null,
duration: error ? _errorDuration : _toastDuration,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.sm),
),
),
);
}

View File

@ -1,23 +0,0 @@
/// The notes list's empty state as a picture, not a sentence.
library;
import 'package:flutter/material.dart';
/// A large muted glyph: an empty inbox when there are no notes at all, a
/// crossed-out filter when the current filter hides every note (the filter
/// button's badge is the second channel saying a filter is on).
class EmptyNotesCue extends StatelessWidget {
/// Creates the cue; [filtered] picks the filter variant.
const EmptyNotesCue({required this.filtered, super.key});
/// Whether a filter is active (notes may exist but none match).
final bool filtered;
@override
Widget build(BuildContext context) => Icon(
filtered ? Icons.filter_alt_off_outlined : Icons.inbox_outlined,
size: 64,
color: Theme.of(context).colorScheme.outline,
semanticLabel: filtered ? 'No notes match these filters' : 'No notes yet',
);
}

View File

@ -1,105 +0,0 @@
/// Glyphs for the Priority and Status enums, and the chip row that picks
/// them, so every picker shows the same shape + colour for the same value.
///
/// The enum's `label` survives only as the spoken (semantics) label.
library;
import 'package:flutter/material.dart';
import 'package:todo/data/note.dart';
import 'package:todo/ui/note_grid_tile.dart';
/// Shape channel for a priority: up for high, level for medium, down for low.
/// Colour ([priorityColor]) is the second channel.
IconData priorityIcon(Priority p) => switch (p) {
Priority.high => Icons.keyboard_double_arrow_up,
Priority.medium => Icons.drag_handle,
Priority.low => Icons.keyboard_double_arrow_down,
};
/// Heading glyph standing for "status" (matches the bulk-status button).
const IconData kStatusHeadingIcon = Icons.task_alt;
/// Heading glyph standing for "priority" (matches the bulk-priority button).
const IconData kPriorityHeadingIcon = Icons.flag_outlined;
/// [s] as its glyph, spoken as its label.
Widget statusGlyph(Status s, {double? size}) =>
Icon(statusIcon(s), size: size, semanticLabel: s.label);
/// [p] as its tinted glyph, spoken as its label.
Widget priorityGlyph(BuildContext context, Priority p, {double? size}) => Icon(
priorityIcon(p),
size: size,
color: priorityColor(p, Theme.of(context).colorScheme),
semanticLabel: p.label,
);
/// A heading glyph followed by one chip per value, each chip a glyph.
///
/// [multi] switches between FilterChips (toggle many) and ChoiceChips (pick
/// one); either way the selected chips are filled and checked.
class GlyphChips<T> extends StatelessWidget {
/// Creates a chip row for [values].
const GlyphChips({
required this.heading,
required this.semanticLabel,
required this.values,
required this.selected,
required this.glyphOf,
required this.onTap,
this.multi = false,
super.key,
});
/// Glyph shown in front of the chips in place of a written heading.
final IconData heading;
/// Spoken name of the row (the old written heading).
final String semanticLabel;
/// Every value offered.
final List<T> values;
/// Values currently selected.
final Set<T> selected;
/// Builds the glyph for one value.
final Widget Function(T) glyphOf;
/// Called with the tapped value.
final ValueChanged<T> onTap;
/// Whether this is a multi-select (filter) row.
final bool multi;
@override
Widget build(BuildContext context) {
return Row(
children: [
Icon(heading, semanticLabel: semanticLabel),
const SizedBox(width: 12),
Expanded(
child: Wrap(
spacing: 8,
children: [
for (final v in values)
if (multi)
FilterChip(
label: glyphOf(v),
selected: selected.contains(v),
onSelected: (_) => onTap(v),
)
else
ChoiceChip(
label: glyphOf(v),
selected: selected.contains(v),
onSelected: (_) => onTap(v),
),
],
),
),
],
);
}
}

View File

@ -9,7 +9,6 @@ import 'package:todo/data/app_settings.dart';
import 'package:todo/data/note_repository.dart'; import 'package:todo/data/note_repository.dart';
import 'package:todo/sync/run_sync.dart'; import 'package:todo/sync/run_sync.dart';
import 'package:todo/sync/sync_settings.dart'; import 'package:todo/sync/sync_settings.dart';
import 'package:todo/ui/status_cue.dart';
part 'github_mirror_screen_widget.dart'; part 'github_mirror_screen_widget.dart';
@ -28,7 +27,7 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
); );
bool _testing = false; bool _testing = false;
StatusCue? _status; String? _status;
@override @override
void dispose() { void dispose() {
@ -50,13 +49,8 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
Future<void> _connectGitHub() async { Future<void> _connectGitHub() async {
final clientId = _clientId.text.trim(); final clientId = _clientId.text.trim();
if (clientId.isEmpty) { if (clientId.isEmpty) {
return _show( setState(() => _status = 'Enter the OAuth App client id first.');
const StatusCue( return;
Icons.key_off,
'Enter the OAuth App client id first.',
error: true,
),
);
} }
final auth = GitHubDeviceAuth( final auth = GitHubDeviceAuth(
clientId: clientId, clientId: clientId,
@ -73,19 +67,20 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
if (token != null && token.isNotEmpty) { if (token != null && token.isNotEmpty) {
setState(() { setState(() {
_token.text = token; _token.text = token;
_status = const StatusCue(Icons.sync, 'Connected — syncing…'); _status = 'Connected — syncing…';
}); });
await _current.save(); await _current.save();
await _syncAfterConnect(); await _syncAfterConnect();
} }
} on Exception catch (e) { } on Exception catch (e) {
_show(StatusCue.failed('Could not start device flow: $e')); if (mounted) setState(() => _status = 'Could not start device flow: $e');
} finally { } finally {
auth.close(); auth.close();
} }
} }
/// Syncs right after connecting so notes download at once, with a cue. /// Runs a sync right after connecting so the user's notes download
/// immediately and they get clear confirmation it worked.
Future<void> _syncAfterConnect() async { Future<void> _syncAfterConnect() async {
final s = _current; final s = _current;
try { try {
@ -101,29 +96,19 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
widget.appSettings.value = widget.appSettings.value.adopt( widget.appSettings.value = widget.appSettings.value.adopt(
run.appSettings, run.appSettings,
); );
_show( if (mounted) {
StatusCue.ok( setState(
() => _status =
'Connected and synced (merged ' 'Connected and synced (merged '
'${run.syncResult.mergedDevices} device(s)). Your notes are ' '${run.syncResult.mergedDevices} device(s)). Your notes are '
'up to date.', 'up to date.',
),
); );
}
} on Exception catch (e) { } on Exception catch (e) {
_show( if (mounted) setState(() => _status = 'Connected, but sync failed: $e');
StatusCue(
Icons.sync_problem,
'Connected, but sync failed: $e',
error: true,
),
);
} }
} }
/// Shows [cue] as the screen's latest result, if still mounted.
void _show(StatusCue cue) {
if (mounted) setState(() => _status = cue);
}
Future<void> _test() async { Future<void> _test() async {
setState(() { setState(() {
_testing = true; _testing = true;
@ -138,17 +123,13 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
); );
try { try {
final ok = await client.canAccessRepo(); final ok = await client.canAccessRepo();
_show( setState(
ok () => _status = ok
? const StatusCue.ok('Connected — repo is reachable.') ? 'Connected — repo is reachable.'
: StatusCue( : 'Could not access ${s.owner}/${s.repo}. Check token scope.',
Icons.lock,
'Could not access ${s.owner}/${s.repo}. Check token scope.',
error: true,
),
); );
} on Exception catch (e) { } on Exception catch (e) {
_show(StatusCue.failed('Error: $e')); setState(() => _status = 'Error: $e');
} finally { } finally {
client.close(); client.close();
if (mounted) setState(() => _testing = false); if (mounted) setState(() => _testing = false);
@ -164,27 +145,29 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Advanced sync (GitHub)')),
title: const Icon(
Icons.cloud_sync,
semanticLabel: 'Advanced sync (GitHub)',
),
),
body: ListView( body: ListView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
children: [ children: [
Text(
'Authorize in your browser — no token to paste. Syncs to '
'kuhyx/syncs by default.',
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 12),
Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: IconButton.filled( child: FilledButton.icon(
onPressed: _connectGitHub, onPressed: _connectGitHub,
icon: const Icon(Icons.login, semanticLabel: 'Connect GitHub'), icon: const Icon(Icons.login),
label: const Text('Connect GitHub'),
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
TextField( TextField(
controller: _owner, controller: _owner,
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon(Icons.person, semanticLabel: 'GitHub owner'), labelText: 'GitHub owner',
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
), ),
@ -192,7 +175,7 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
TextField( TextField(
controller: _repo, controller: _repo,
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon(Icons.folder, semanticLabel: 'Repository name'), labelText: 'Repository name',
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
), ),
@ -200,7 +183,8 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
TextField( TextField(
controller: _clientId, controller: _clientId,
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon(Icons.key, semanticLabel: 'OAuth App client id'), labelText: 'OAuth App client id',
helperText: 'Leave as the baked-in default unless self-hosting',
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
), ),
@ -209,17 +193,15 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
controller: _token, controller: _token,
obscureText: true, obscureText: true,
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon( labelText: 'Access token (fallback)',
Icons.vpn_key, helperText: 'Contents: read/write on the sync repo only',
semanticLabel: 'Access token (fallback)',
),
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
Row( Row(
children: [ children: [
IconButton.outlined( OutlinedButton.icon(
onPressed: _testing ? null : _test, onPressed: _testing ? null : _test,
icon: _testing icon: _testing
? const SizedBox( ? const SizedBox(
@ -227,21 +209,20 @@ class _GitHubMirrorScreenState extends State<GitHubMirrorScreen> {
height: 16, height: 16,
child: CircularProgressIndicator(strokeWidth: 2), child: CircularProgressIndicator(strokeWidth: 2),
) )
: const Icon( : const Icon(Icons.wifi_tethering),
Icons.wifi_tethering, label: const Text('Test connection'),
semanticLabel: 'Test connection',
),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
IconButton.filled( FilledButton.icon(
onPressed: _save, onPressed: _save,
icon: const Icon(Icons.save, semanticLabel: 'Save'), icon: const Icon(Icons.save),
label: const Text('Save'),
), ),
], ],
), ),
if (_status != null) ...[ if (_status != null) ...[
const SizedBox(height: 16), const SizedBox(height: 16),
StatusCueView(_status!), Text(_status!, style: Theme.of(context).textTheme.bodyMedium),
], ],
], ],
), ),

View File

@ -9,12 +9,12 @@ library;
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:design_system/design_system.dart';
import 'package:flutter/widgets.dart';
import 'package:todo/attachments/image_store_api.dart'; import 'package:todo/attachments/image_store_api.dart';
import 'package:todo/attachments/image_store_scope.dart'; import 'package:todo/attachments/image_store_scope.dart';
import 'package:todo/images/attachment_ref.dart'; import 'package:todo/images/attachment_ref.dart';
import 'package:todo/ui/cue_snack.dart';
/// Lets a screen insert lines into whichever editor is currently mounted. /// Lets a screen insert lines into whichever editor is currently mounted.
class ImageAttachController { class ImageAttachController {
@ -73,15 +73,11 @@ Future<void> attachImages(
target.insert([for (final ref in refs) ref.imageMarkdown]); target.insert([for (final ref in refs) ref.imageMarkdown]);
if (!context.mounted) return; if (!context.mounted) return;
if (failure != null) { if (failure != null) {
showCue(context, Icons.cloud_off, failure, error: true); showError(context, failure);
} else if (notImages > 0) { } else if (notImages > 0) {
// A broken-image glyph plus how many were refused. showError(
showCue(
context, context,
Icons.broken_image_outlined,
notImages == 1 ? 'Not an image' : '$notImages files were not images', notImages == 1 ? 'Not an image' : '$notImages files were not images',
error: true,
count: notImages,
); );
} }
} }
@ -108,7 +104,5 @@ Future<void> attachFiles(
} }
} }
target.insert([for (final attachment in attached) attachment.markdown]); target.insert([for (final attachment in attached) attachment.markdown]);
if (failure != null && context.mounted) { if (failure != null && context.mounted) showError(context, failure);
showCue(context, Icons.cloud_off, failure, error: true);
}
} }

View File

@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
import 'package:todo/attachments/image_store_api.dart'; import 'package:todo/attachments/image_store_api.dart';
import 'package:todo/attachments/image_store_scope.dart'; import 'package:todo/attachments/image_store_scope.dart';
import 'package:todo/images/attachment_ref.dart'; import 'package:todo/images/attachment_ref.dart';
import 'package:todo/ui/cue_snack.dart';
import 'package:todo/ui/images/file_opening.dart'; import 'package:todo/ui/images/file_opening.dart';
import 'package:todo/ui/images/image_embed.dart'; import 'package:todo/ui/images/image_embed.dart';
@ -52,9 +51,7 @@ class _FileEmbedState extends State<FileEmbed> {
Future<void> _open(ImageSource source) async { Future<void> _open(ImageSource source) async {
final failure = await widget.opening(source, widget.attachment.name); final failure = await widget.opening(source, widget.attachment.name);
if (failure != null && mounted) { if (failure != null && mounted) showError(context, failure);
showCue(context, Icons.block, failure, error: true);
}
} }
@override @override
@ -76,10 +73,9 @@ class _FileEmbedState extends State<FileEmbed> {
style: widget.compact ? theme.textTheme.bodySmall : null, style: widget.compact ? theme.textTheme.bodySmall : null,
); );
final pending = store.isPending(attachment.ref) final pending = store.isPending(attachment.ref)
? const Icon( ? const Tooltip(
Icons.cloud_upload_outlined, message: kImageWaitingToUpload,
size: 18, child: Icon(Icons.cloud_upload_outlined, size: 18),
semanticLabel: kImageWaitingToUpload,
) )
: null; : null;
final content = widget.compact final content = widget.compact
@ -108,10 +104,6 @@ class _FileEmbedState extends State<FileEmbed> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
name, name,
// Not downloaded: a download glyph; else the size.
if (size == null)
const Icon(Icons.cloud_download_outlined, size: 16)
else
Text(detail, style: theme.textTheme.bodySmall), Text(detail, style: theme.textTheme.bodySmall),
], ],
), ),
@ -119,10 +111,8 @@ class _FileEmbedState extends State<FileEmbed> {
?pending, ?pending,
], ],
); );
// Spoken only: nothing paints this string.
final semanticLabel = 'Attached file ${attachment.name}, $detail';
return Semantics( return Semantics(
label: semanticLabel, label: 'Attached file ${attachment.name}, $detail',
button: size != null, button: size != null,
child: Material( child: Material(
color: theme.colorScheme.surfaceContainerHighest, color: theme.colorScheme.surfaceContainerHighest,

View File

@ -33,10 +33,8 @@ class ImageEmbed extends StatelessWidget {
final store = ImageStoreScope.of(context); final store = ImageStoreScope.of(context);
final source = store.sourceFor(ref); final source = store.sourceFor(ref);
final picture = imageFor(source, fit: fit); final picture = imageFor(source, fit: fit);
// Spoken only: nothing paints this string.
const semanticLabel = 'Attached image';
return Semantics( return Semantics(
label: semanticLabel, label: 'Attached image',
button: source is! MissingImageSource, button: source is! MissingImageSource,
child: GestureDetector( child: GestureDetector(
onTap: source is MissingImageSource onTap: source is MissingImageSource
@ -54,10 +52,9 @@ class ImageEmbed extends StatelessWidget {
const Positioned( const Positioned(
right: 4, right: 4,
top: 4, top: 4,
child: Icon( child: Tooltip(
Icons.cloud_upload_outlined, message: kImageWaitingToUpload,
size: 18, child: Icon(Icons.cloud_upload_outlined, size: 18),
semanticLabel: kImageWaitingToUpload,
), ),
), ),
], ],
@ -88,7 +85,7 @@ Widget imageFor(ImageSource source, {required BoxFit fit}) {
}; };
} }
/// Grey box with a download glyph, spoken as [kImageNotDownloaded]. /// Grey box with [kImageNotDownloaded].
class ImagePlaceholder extends StatelessWidget { class ImagePlaceholder extends StatelessWidget {
/// Creates the placeholder. /// Creates the placeholder.
const ImagePlaceholder({super.key}); const ImagePlaceholder({super.key});
@ -101,10 +98,10 @@ class ImagePlaceholder extends StatelessWidget {
child: Center( child: Center(
child: Padding( child: Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Icon( child: Text(
Icons.cloud_download_outlined, kImageNotDownloaded,
color: theme.colorScheme.outline, textAlign: TextAlign.center,
semanticLabel: kImageNotDownloaded, style: theme.textTheme.bodySmall,
), ),
), ),
), ),

View File

@ -6,11 +6,10 @@ library;
import 'dart:async'; import 'dart:async';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/confirm_delete.dart';
import 'package:todo/ui/enum_glyphs.dart';
import 'package:todo/ui/note_sheet_details.dart'; import 'package:todo/ui/note_sheet_details.dart';
import 'package:todo/ui/note_task_details.dart'; import 'package:todo/ui/note_task_details.dart';
@ -62,55 +61,54 @@ class _NoteActionsSheetState extends State<NoteActionsSheet> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
// User content; untitled shows nothing, not a placeholder.
if (firstLine.isNotEmpty)
Text( Text(
firstLine, firstLine.isEmpty ? '(empty)' : firstLine,
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleMedium,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
NoteSheetDetails(note: widget.note), NoteSheetDetails(note: widget.note),
const SizedBox(height: 16), const SizedBox(height: 16),
GlyphChips<Status>( _EnumChips<Status>(
heading: kStatusHeadingIcon, label: 'Status',
semanticLabel: 'Status',
values: Status.values, values: Status.values,
selected: {_status}, selected: {_status},
glyphOf: statusGlyph, labelOf: (s) => s.label,
onTap: (s) { onSelected: (s) {
setState(() => _status = s); setState(() => _status = s);
unawaited(_persist()); unawaited(_persist());
}, },
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
GlyphChips<Priority>( _EnumChips<Priority>(
heading: kPriorityHeadingIcon, label: 'Priority',
semanticLabel: 'Priority',
values: Priority.values, values: Priority.values,
selected: {_priority}, selected: {_priority},
glyphOf: (p) => priorityGlyph(context, p), labelOf: (p) => p.label,
onTap: (p) { onSelected: (p) {
setState(() => _priority = p); setState(() => _priority = p);
unawaited(_persist()); unawaited(_persist());
}, },
), ),
NoteTaskDetails(note: widget.note), NoteTaskDetails(note: widget.note),
const SizedBox(height: 16), const SizedBox(height: 16),
Align( OutlinedButton.icon(
child: IconButton.outlined( icon: const Icon(Icons.delete_outline),
color: Theme.of(context).colorScheme.error, label: const Text('Delete note'),
icon: const Icon( style: OutlinedButton.styleFrom(
Icons.delete_outline, foregroundColor: Theme.of(context).colorScheme.error,
semanticLabel: 'Delete note',
), ),
onPressed: () async { onPressed: () async {
if (!await confirmDeleteNote(context)) return; final confirmed = await confirmDestructive(
context,
title: 'Delete note?',
message: 'This cannot be undone.',
);
if (!confirmed) return;
await widget.onDelete(); await widget.onDelete();
if (context.mounted) Navigator.of(context).pop(); if (context.mounted) Navigator.of(context).pop();
}, },
), ),
),
], ],
), ),
), ),
@ -118,3 +116,42 @@ class _NoteActionsSheetState extends State<NoteActionsSheet> {
); );
} }
} }
/// Single-select chip row for an enum (used for per-note priority/status).
class _EnumChips<T> extends StatelessWidget {
const _EnumChips({
required this.label,
required this.values,
required this.selected,
required this.labelOf,
required this.onSelected,
});
final String label;
final List<T> values;
final Set<T> selected;
final String Function(T) labelOf;
final ValueChanged<T> onSelected;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: Theme.of(context).textTheme.labelLarge),
const SizedBox(height: 8),
Wrap(
spacing: 8,
children: [
for (final v in values)
ChoiceChip(
label: Text(labelOf(v)),
selected: selected.contains(v),
onSelected: (_) => onSelected(v),
),
],
),
],
);
}
}

View File

@ -9,29 +9,19 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Glyph for "created" (a note added), shared by the filter and sort menus.
const IconData kCreatedIcon = Icons.post_add;
/// Glyph for "last updated", shared by the filter and sort menus.
const IconData kUpdatedIcon = Icons.update;
/// A labelled date range shown as one preset menu plus a custom picker. /// A labelled date range shown as one preset menu plus a custom picker.
class DateRangeField extends StatelessWidget { class DateRangeField extends StatelessWidget {
/// Creates a labelled date-range control. /// Creates a labelled date-range control.
const DateRangeField({ const DateRangeField({
required this.icon, required this.label,
required this.semanticLabel,
required this.from, required this.from,
required this.to, required this.to,
required this.onChanged, required this.onChanged,
super.key, super.key,
}); });
/// Glyph shown in the control's border in place of a written heading. /// Heading shown above the control (e.g. 'Created').
final IconData icon; final String label;
/// Spoken name of the control (e.g. 'Created'); never painted.
final String semanticLabel;
/// Start of the selected range, or null when unbounded. /// Start of the selected range, or null when unbounded.
final DateTime? from; final DateTime? from;
@ -96,16 +86,15 @@ class DateRangeField extends StatelessWidget {
// A popup menu rather than DropdownButton: re-picking "Custom…" while a // A popup menu rather than DropdownButton: re-picking "Custom…" while a
// custom range is shown must still reopen the picker. // custom range is shown must still reopen the picker.
return PopupMenuButton<_Preset>( return PopupMenuButton<_Preset>(
// Empty, not the label: a tooltip is painted on long-press. tooltip: label,
tooltip: '',
onSelected: (p) => _select(context, p), onSelected: (p) => _select(context, p),
itemBuilder: (_) => [ itemBuilder: (_) => [
for (final p in _Preset.values) for (final p in _Preset.values)
PopupMenuItem(value: p, child: p.glyph()), PopupMenuItem(value: p, child: Text(p.label)),
], ],
child: InputDecorator( child: InputDecorator(
decoration: InputDecoration( decoration: InputDecoration(
prefixIcon: Icon(icon, semanticLabel: semanticLabel), labelText: label,
isDense: true, isDense: true,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
contentPadding: const EdgeInsets.symmetric( contentPadding: const EdgeInsets.symmetric(
@ -114,9 +103,10 @@ class DateRangeField extends StatelessWidget {
), ),
suffixIcon: const Icon(Icons.arrow_drop_down), suffixIcon: const Icon(Icons.arrow_drop_down),
), ),
child: current == _Preset.custom child: Text(
? Text(_rangeLabel(), style: theme.textTheme.bodyMedium) current == _Preset.custom ? _rangeLabel() : current.label,
: current.glyph(), style: theme.textTheme.bodyMedium,
),
), ),
); );
} }
@ -141,26 +131,8 @@ enum _Preset {
const _Preset(this.label, this.days); const _Preset(this.label, this.days);
/// Spoken name only; what is painted is [glyph].
final String label; final String label;
final int? days; final int? days;
/// "Any" is an infinity sign, "today" the today-calendar, a span its day
/// count beside a range-calendar, "custom" the edit-calendar.
Widget glyph() => Semantics(
label: label,
excludeSemantics: true,
container: true,
child: switch (this) {
any => const Icon(Icons.all_inclusive),
today => const Icon(Icons.today),
custom => const Icon(Icons.edit_calendar),
week || month => Row(
mainAxisSize: MainAxisSize.min,
children: [const Icon(Icons.date_range), Text(' $days')],
),
},
);
static const List<_Preset> dayPresets = [today, week, month]; static const List<_Preset> dayPresets = [today, week, month];
} }

View File

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:todo/data/app_settings.dart'; import 'package:todo/data/app_settings.dart';
@ -7,7 +8,6 @@ import 'package:todo/data/note.dart';
import 'package:todo/data/note_repository.dart'; import 'package:todo/data/note_repository.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/attachment_picking.dart'; import 'package:todo/ui/attachment_picking.dart';
import 'package:todo/ui/confirm_delete.dart';
import 'package:todo/ui/image_attach.dart'; import 'package:todo/ui/image_attach.dart';
import 'package:todo/ui/image_input.dart'; import 'package:todo/ui/image_input.dart';
import 'package:todo/ui/note_form.dart'; import 'package:todo/ui/note_form.dart';
@ -85,7 +85,12 @@ class _NoteDetailScreenState extends State<NoteDetailScreen> {
_persist(_note.copyWith(text: text, updatedAt: DateTime.now())); _persist(_note.copyWith(text: text, updatedAt: DateTime.now()));
Future<void> _delete() async { Future<void> _delete() async {
if (!await confirmDeleteNote(context)) return; final confirmed = await confirmDestructive(
context,
title: 'Delete note?',
message: 'This cannot be undone.',
);
if (!confirmed) return;
await widget.repository.delete(_note.id); await widget.repository.delete(_note.id);
if (mounted) Navigator.of(context).pop(); if (mounted) Navigator.of(context).pop();
} }
@ -95,8 +100,7 @@ class _NoteDetailScreenState extends State<NoteDetailScreen> {
final title = noteTitle(_note.text); final title = noteTitle(_note.text);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
// An untitled note shows no title rather than a written placeholder. title: Text(title.isEmpty ? '(empty)' : title),
title: title.isEmpty ? null : Text(title),
actions: [ actions: [
AttachButton( AttachButton(
onFiles: _attachFiles, onFiles: _attachFiles,
@ -110,10 +114,8 @@ class _NoteDetailScreenState extends State<NoteDetailScreen> {
onPressed: _copy, onPressed: _copy,
), ),
IconButton( IconButton(
icon: const Icon( tooltip: 'Delete note',
Icons.delete_outline, icon: const Icon(Icons.delete_outline),
semanticLabel: 'Delete note',
),
onPressed: _delete, onPressed: _delete,
), ),
], ],

View File

@ -1,8 +1,8 @@
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/cue_snack.dart';
import 'package:todo/ui/image_attach.dart'; import 'package:todo/ui/image_attach.dart';
import 'package:todo/ui/markdown_view.dart'; import 'package:todo/ui/markdown_view.dart';
import 'package:todo/ui/note_editor_chrome.dart'; import 'package:todo/ui/note_editor_chrome.dart';
@ -127,12 +127,9 @@ class _NoteEditorState extends State<NoteEditor> {
case NoteEditorMode.guided: case NoteEditorMode.guided:
// raw -> guided: only if the edited text still fits the template. // raw -> guided: only if the edited text still fits the template.
if (!_doc.tryAdoptGuided()) { if (!_doc.tryAdoptGuided()) {
// The mode toggle staying on raw is the second channel. showError(
showCue(
context, context,
Icons.rule,
"Text doesn't match the template — staying in raw", "Text doesn't match the template — staying in raw",
error: true,
); );
return; return;
} }

View File

@ -10,7 +10,6 @@ import 'package:flutter/material.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/note_editor_mode.dart'; import 'package:todo/ui/note_editor_mode.dart';
import 'package:todo/ui/template_glyphs.dart';
/// Template dropdown above a segmented View / Guided / Raw selector. /// Template dropdown above a segmented View / Guided / Raw selector.
class NoteEditorChrome extends StatelessWidget { class NoteEditorChrome extends StatelessWidget {
@ -44,20 +43,20 @@ class NoteEditorChrome extends StatelessWidget {
DropdownButtonFormField<String>( DropdownButtonFormField<String>(
initialValue: template.id, initialValue: template.id,
decoration: const InputDecoration( decoration: const InputDecoration(
// A prefix, not a floating label: a floated icon sat on the labelText: 'Template',
// border on top of the selected template's glyph.
prefixIcon: Icon(Icons.description, semanticLabel: 'Template'),
isDense: true, isDense: true,
border: OutlineInputBorder(), border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8), contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
), ),
items: [ items: [
for (final t in NoteTemplate.all) for (final t in NoteTemplate.all)
DropdownMenuItem(value: t.id, child: templateGlyph(t)), DropdownMenuItem(value: t.id, child: Text(t.label)),
], ],
onChanged: (id) { onChanged: (id) {
if (id == null) return; if (id == null) return;
onTemplateSelected(NoteTemplate.all.firstWhere((t) => t.id == id)); onTemplateSelected(
NoteTemplate.all.firstWhere((t) => t.id == id),
);
}, },
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
@ -68,7 +67,8 @@ class NoteEditorChrome extends StatelessWidget {
segments: [ segments: [
const ButtonSegment( const ButtonSegment(
value: NoteEditorMode.preview, value: NoteEditorMode.preview,
icon: Icon(Icons.visibility_outlined, semanticLabel: 'View'), icon: Icon(Icons.visibility_outlined),
label: Text('View'),
), ),
// Guided is offered for any structured template; tapping it // Guided is offered for any structured template; tapping it
// on an empty draft opens the wizard, and is blocked at // on an empty draft opens the wizard, and is blocked at
@ -76,11 +76,13 @@ class NoteEditorChrome extends StatelessWidget {
if (!template.isFreeform) if (!template.isFreeform)
const ButtonSegment( const ButtonSegment(
value: NoteEditorMode.guided, value: NoteEditorMode.guided,
icon: Icon(Icons.checklist, semanticLabel: 'Guided'), icon: Icon(Icons.checklist),
label: Text('Guided'),
), ),
const ButtonSegment( const ButtonSegment(
value: NoteEditorMode.raw, value: NoteEditorMode.raw,
icon: Icon(Icons.notes, semanticLabel: 'Raw'), icon: Icon(Icons.notes),
label: Text('Raw'),
), ),
], ],
selected: {mode}, selected: {mode},

View File

@ -44,8 +44,10 @@ class NoteEditorRawField extends StatelessWidget {
textAlignVertical: TextAlignVertical.top, textAlignVertical: TextAlignVertical.top,
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
style: Theme.of(context).textTheme.bodyLarge, style: Theme.of(context).textTheme.bodyLarge,
// No hint: the cursor in an empty full-height box says "type". decoration: const InputDecoration(
decoration: const InputDecoration(border: InputBorder.none), border: InputBorder.none,
hintText: 'Write your idea…',
),
onChanged: (_) => onChanged(), onChanged: (_) => onChanged(),
), ),
), ),

View File

@ -16,7 +16,6 @@ import 'package:flutter/material.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/motion.dart'; import 'package:todo/ui/motion.dart';
import 'package:todo/ui/template_glyphs.dart';
/// One step of the guided editor: label, guidance, input, and navigation. /// One step of the guided editor: label, guidance, input, and navigation.
class NoteEditorStepPage extends StatelessWidget { class NoteEditorStepPage extends StatelessWidget {
@ -67,7 +66,8 @@ class NoteEditorStepPage extends StatelessWidget {
Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: IconButton( child: IconButton(
icon: const Icon(Icons.arrow_back, semanticLabel: 'Exit guided'), icon: const Icon(Icons.arrow_back),
tooltip: 'Exit guided',
onPressed: onExit, onPressed: onExit,
), ),
), ),
@ -96,14 +96,16 @@ class NoteEditorStepPage extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// A glyph per section; its label (the note's `## heading`) and Text(
// the helper sentence are spoken only. section.isTitle ? 'title' : section.label,
Icon( style: theme.textTheme.titleMedium,
sectionIcon(section), ),
color: theme.colorScheme.primary, const SizedBox(height: 4),
semanticLabel: section.isTitle Text(
? section.helper section.helper,
: '${section.label}: ${section.helper}', style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
], ],
@ -121,10 +123,9 @@ class NoteEditorStepPage extends StatelessWidget {
maxLines: null, maxLines: null,
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
textAlignVertical: TextAlignVertical.top, textAlignVertical: TextAlignVertical.top,
// No hintText: a hint is painted text. The section glyph decoration: InputDecoration(
// above already names the field. hintText: section.hint,
decoration: const InputDecoration( border: const OutlineInputBorder(),
border: OutlineInputBorder(),
isDense: true, isDense: true,
), ),
onChanged: (_) => onChanged(), onChanged: (_) => onChanged(),
@ -139,22 +140,16 @@ class NoteEditorStepPage extends StatelessWidget {
if (index > 0) if (index > 0)
TextButton( TextButton(
onPressed: () => onGoToStep(index - 1), onPressed: () => onGoToStep(index - 1),
child: const Icon( child: const Text('Back'),
Icons.navigate_before,
semanticLabel: 'Back',
),
), ),
const Spacer(), const Spacer(),
if (index < total - 1) if (index < total - 1)
FilledButton( FilledButton(
onPressed: () => onGoToStep(index + 1), onPressed: () => onGoToStep(index + 1),
child: const Icon(Icons.navigate_next, semanticLabel: 'Next'), child: const Text('Next'),
) )
else else
FilledButton( FilledButton(onPressed: onExit, child: const Text('Done')),
onPressed: onExit,
child: const Icon(Icons.check, semanticLabel: 'Done'),
),
], ],
), ),
), ),

View File

@ -13,8 +13,6 @@ import 'package:flutter/material.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/enum_glyphs.dart';
import 'package:todo/ui/template_glyphs.dart';
/// Asks for a priority, then a template, then hands both back via [onStart]. /// Asks for a priority, then a template, then hands both back via [onStart].
class NoteEditorWizard extends StatefulWidget { class NoteEditorWizard extends StatefulWidget {
@ -50,7 +48,7 @@ class _NoteEditorWizardState extends State<NoteEditorWizard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final semanticLabel = 'Step ${_step + 1} of 2'; final theme = Theme.of(context);
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -58,24 +56,11 @@ class _NoteEditorWizardState extends State<NoteEditorWizard> {
Row( Row(
children: [ children: [
IconButton( IconButton(
icon: const Icon(Icons.close, semanticLabel: 'Cancel'), icon: const Icon(Icons.close),
tooltip: 'Cancel',
onPressed: widget.onCancel, onPressed: widget.onCancel,
), ),
// Two step dots, the current one filled: position by shape. Text('Step ${_step + 1} of 2', style: theme.textTheme.labelLarge),
Semantics(
label: semanticLabel,
child: ExcludeSemantics(
child: Row(
children: [
for (var i = 0; i < 2; i++)
Icon(
i == _step ? Icons.circle : Icons.circle_outlined,
size: 12,
),
],
),
),
),
], ],
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
@ -89,14 +74,14 @@ class _NoteEditorWizardState extends State<NoteEditorWizard> {
DropdownButtonFormField<Priority>( DropdownButtonFormField<Priority>(
initialValue: _priority, initialValue: _priority,
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon(kPriorityHeadingIcon, semanticLabel: 'Priority'), labelText: 'Priority',
isDense: true, isDense: true,
border: OutlineInputBorder(), border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8), contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
), ),
items: [ items: [
for (final p in Priority.values) for (final p in Priority.values)
DropdownMenuItem(value: p, child: priorityGlyph(context, p)), DropdownMenuItem(value: p, child: Text(p.label)),
], ],
onChanged: (p) { onChanged: (p) {
if (p != null) setState(() => _priority = p); if (p != null) setState(() => _priority = p);
@ -107,7 +92,7 @@ class _NoteEditorWizardState extends State<NoteEditorWizard> {
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: FilledButton( child: FilledButton(
onPressed: () => setState(() => _step = 1), onPressed: () => setState(() => _step = 1),
child: const Icon(Icons.navigate_next, semanticLabel: 'Next'), child: const Text('Next'),
), ),
), ),
]; ];
@ -119,14 +104,14 @@ class _NoteEditorWizardState extends State<NoteEditorWizard> {
DropdownButtonFormField<String>( DropdownButtonFormField<String>(
initialValue: _template.id, initialValue: _template.id,
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon(Icons.description, semanticLabel: 'Template'), labelText: 'Template',
isDense: true, isDense: true,
border: OutlineInputBorder(), border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8), contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
), ),
items: [ items: [
for (final t in templates) for (final t in templates)
DropdownMenuItem(value: t.id, child: templateGlyph(t)), DropdownMenuItem(value: t.id, child: Text(t.label)),
], ],
onChanged: (id) { onChanged: (id) {
if (id == null) return; if (id == null) return;
@ -139,12 +124,12 @@ class _NoteEditorWizardState extends State<NoteEditorWizard> {
children: [ children: [
TextButton( TextButton(
onPressed: () => setState(() => _step = 0), onPressed: () => setState(() => _step = 0),
child: const Icon(Icons.arrow_back, semanticLabel: 'Back'), child: const Text('Back'),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
FilledButton( FilledButton(
onPressed: () => widget.onStart(_priority, _template), onPressed: () => widget.onStart(_priority, _template),
child: const Icon(Icons.play_arrow, semanticLabel: 'Start'), child: const Text('Start'),
), ),
], ],
), ),

View File

@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/enum_glyphs.dart';
/// Danger for high, the accent for medium, muted for low. /// Danger for high, the accent for medium, muted for low.
Color priorityColor(Priority p, ColorScheme scheme) => switch (p) { Color priorityColor(Priority p, ColorScheme scheme) => switch (p) {
@ -15,9 +14,6 @@ Color priorityColor(Priority p, ColorScheme scheme) => switch (p) {
Priority.low => scheme.outline, Priority.low => scheme.outline,
}; };
/// Painted in place of an empty note's title: a mark, not a word.
const String kEmptyTitle = '…';
/// The glyph standing for [s] wherever a status is shown without words. /// The glyph standing for [s] wherever a status is shown without words.
IconData statusIcon(Status s) => switch (s) { IconData statusIcon(Status s) => switch (s) {
Status.todo => Icons.radio_button_unchecked, Status.todo => Icons.radio_button_unchecked,
@ -89,7 +85,7 @@ class NoteGridTile extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
title.isEmpty ? kEmptyTitle : title, title.isEmpty ? '(empty)' : title,
maxLines: 3, maxLines: 3,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: theme.textTheme.bodyMedium?.copyWith( style: theme.textTheme.bodyMedium?.copyWith(
@ -119,20 +115,25 @@ class NoteGridTile extends StatelessWidget {
), ),
Row( Row(
children: [ children: [
// Shape + the tile's accent border carry status/priority;
// the enum words survive only as spoken labels.
Icon( Icon(
statusIcon(note.status), statusIcon(note.status),
size: 14, size: 14,
color: scheme.onSurfaceVariant, color: scheme.onSurfaceVariant,
semanticLabel: note.status.label, ),
const SizedBox(width: AppSpacing.xs),
Flexible(
child: Text(
note.status.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: cue,
),
), ),
const Spacer(), const Spacer(),
Icon( Text(
priorityIcon(note.priority), note.priority.label,
size: 14, maxLines: 1,
color: accentFor(scheme), style: cue?.copyWith(color: accentFor(scheme)),
semanticLabel: note.priority.label,
), ),
], ],
), ),

View File

@ -8,30 +8,24 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/ui/enum_glyphs.dart';
/// A compact dropdown for picking an enum value (priority/status), headed by /// A compact labelled dropdown for picking an enum value (priority/status).
/// a glyph and showing each value as its glyph.
/// ///
/// Generic over the enum type [T] so the same control drives both pickers /// Generic over the enum type [T] so the same control drives both pickers
/// without duplication; [glyphOf] maps a value to its glyph. /// without duplication; [labelOf] maps a value to its display string.
class MetaDropdown<T> extends StatelessWidget { class MetaDropdown<T> extends StatelessWidget {
/// Creates a dropdown showing [value] out of [values]. /// Creates a dropdown showing [value] out of [values].
const MetaDropdown({ const MetaDropdown({
required this.heading, required this.label,
required this.semanticLabel,
required this.value, required this.value,
required this.values, required this.values,
required this.glyphOf, required this.labelOf,
required this.onChanged, required this.onChanged,
super.key, super.key,
}); });
/// Glyph in the control's border in place of a written heading. /// Label shown above the control.
final IconData heading; final String label;
/// Spoken name of the control; never painted.
final String semanticLabel;
/// Currently selected value. /// Currently selected value.
final T value; final T value;
@ -39,8 +33,8 @@ class MetaDropdown<T> extends StatelessWidget {
/// Every selectable value. /// Every selectable value.
final List<T> values; final List<T> values;
/// Maps a value to its glyph. /// Maps a value to its display string.
final Widget Function(T) glyphOf; final String Function(T) labelOf;
/// Called with the newly picked value. /// Called with the newly picked value.
final ValueChanged<T> onChanged; final ValueChanged<T> onChanged;
@ -49,7 +43,7 @@ class MetaDropdown<T> extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InputDecorator( return InputDecorator(
decoration: InputDecoration( decoration: InputDecoration(
prefixIcon: Icon(heading, semanticLabel: semanticLabel), labelText: label,
isDense: true, isDense: true,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
@ -61,7 +55,7 @@ class MetaDropdown<T> extends StatelessWidget {
isExpanded: true, isExpanded: true,
items: [ items: [
for (final v in values) for (final v in values)
DropdownMenuItem<T>(value: v, child: glyphOf(v)), DropdownMenuItem<T>(value: v, child: Text(labelOf(v))),
], ],
onChanged: (v) { onChanged: (v) {
if (v != null) onChanged(v); if (v != null) onChanged(v);
@ -104,22 +98,20 @@ class NoteMetaRow extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
child: MetaDropdown<Priority>( child: MetaDropdown<Priority>(
heading: kPriorityHeadingIcon, label: 'Priority',
semanticLabel: 'Priority',
value: priority, value: priority,
values: Priority.values, values: Priority.values,
glyphOf: (p) => priorityGlyph(context, p), labelOf: (p) => p.label,
onChanged: onPriorityChanged, onChanged: onPriorityChanged,
), ),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
Expanded( Expanded(
child: MetaDropdown<Status>( child: MetaDropdown<Status>(
heading: kStatusHeadingIcon, label: 'Status',
semanticLabel: 'Status',
value: status, value: status,
values: Status.values, values: Status.values,
glyphOf: statusGlyph, labelOf: (s) => s.label,
onChanged: onStatusChanged, onChanged: onStatusChanged,
), ),
), ),

View File

@ -39,25 +39,12 @@ class NoteSheetDetails extends StatelessWidget {
Text(body, style: theme.bodyMedium), Text(body, style: theme.bodyMedium),
], ],
const SizedBox(height: 12), const SizedBox(height: 12),
Wrap( Text(
spacing: 12, 'Edited ${_stamp(note.updatedAt)}'
children: [ ' · Created ${_stamp(note.createdAt)}',
_dated(Icons.history, 'Edited', note.updatedAt, theme.bodySmall), style: theme.bodySmall,
_dated(Icons.add, 'Created', note.createdAt, theme.bodySmall),
],
), ),
], ],
); );
} }
/// A glyph (edited = history, created = plus) before its timestamp.
Widget _dated(IconData icon, String spoken, DateTime t, TextStyle? style) =>
Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 16, semanticLabel: spoken),
const SizedBox(width: 4),
Text(_stamp(t), style: style),
],
);
} }

View File

@ -12,27 +12,20 @@ class NoteTaskDetails extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context).textTheme; final theme = Theme.of(context).textTheme;
// A glyph per field in place of its written name (kept spoken only);
// the values are content and stay as typed.
final rows = [ final rows = [
(Icons.folder_outlined, 'Repo', note.repo), ('Repo', note.repo),
(Icons.fact_check_outlined, 'Done check', note.doneCheck), ('Done check', note.doneCheck),
(Icons.person_outline, 'By', note.by), ('By', note.by),
(Icons.verified_outlined, 'Evidence', note.evidence), ('Evidence', note.evidence),
].where((row) => row.$3 != null); ].where((row) => row.$2 != null);
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
for (final (icon, label, value) in rows) ...[ for (final (label, value) in rows) ...[
const SizedBox(height: 12), const SizedBox(height: 12),
Row( Text(label, style: theme.labelLarge),
crossAxisAlignment: CrossAxisAlignment.start, const SizedBox(height: 4),
children: [ Text(value!, style: theme.bodyMedium),
Icon(icon, size: 20, semanticLabel: label),
const SizedBox(width: 8),
Expanded(child: Text(value!, style: theme.bodyMedium)),
],
),
], ],
], ],
); );

View File

@ -8,8 +8,6 @@ import 'package:flutter/material.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/enum_glyphs.dart';
import 'package:todo/ui/note_grid_tile.dart';
/// One row in the notes list: title, metadata line, and an actions button. /// One row in the notes list: title, metadata line, and an actions button.
class NoteTile extends StatelessWidget { class NoteTile extends StatelessWidget {
@ -39,19 +37,27 @@ class NoteTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final firstLine = noteTitle(note.text); final firstLine = noteTitle(note.text);
// Every note has a status and a priority now, so both are always shown.
final meta = <String>[
note.status.label,
note.priority.label,
'edited ${_relative(note.updatedAt)}',
?note.repoName,
].join(' · ');
return ListTile( return ListTile(
selected: selected, selected: selected,
leading: selected leading: selected
? const Icon(Icons.check_circle, semanticLabel: 'Selected') ? const Icon(Icons.check_circle, semanticLabel: 'Selected')
: null, : null,
title: Text( title: Text(
firstLine.isEmpty ? kEmptyTitle : firstLine, firstLine.isEmpty ? '(empty)' : firstLine,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
subtitle: _meta(context), subtitle: Text(meta),
trailing: IconButton( trailing: IconButton(
icon: const Icon(Icons.more_vert, semanticLabel: 'Quick actions'), icon: const Icon(Icons.more_vert),
tooltip: 'Quick actions',
onPressed: onActions, onPressed: onActions,
), ),
onTap: onTap, onTap: onTap,
@ -59,28 +65,14 @@ class NoteTile extends StatelessWidget {
); );
} }
/// Status and priority glyphs, the edit age, and the repo (content). /// Compact relative time like "2m ago" for the list subtitle.
/// Every note has a status and a priority, so both are always shown. String _relative(DateTime t) {
Widget _meta(BuildContext context) => Row( final d = DateTime.now().difference(t);
children: [ if (d.inMinutes < 1) return 'just now';
statusGlyph(note.status, size: 16), if (d.inHours < 1) return '${d.inMinutes}m ago';
const SizedBox(width: 6), if (d.inDays < 1) return '${d.inHours}h ago';
priorityGlyph(context, note.priority, size: 16), return '${d.inDays}d ago';
const SizedBox(width: 6), }
const Icon(Icons.history, size: 16, semanticLabel: 'Edited'),
Text(relativeAge(note.updatedAt)),
if (note.repoName case final repo?) ...[
const SizedBox(width: 6),
Flexible(child: Text(repo, overflow: TextOverflow.ellipsis)),
],
],
);
} }
/// Compact age like "2m" / "3h" / "4d": a number plus a unit symbol. /// Bottom sheet for editing one note's priority/status or deleting it.
String relativeAge(DateTime t) {
final d = DateTime.now().difference(t);
if (d.inHours < 1) return '${d.inMinutes}m';
if (d.inDays < 1) return '${d.inHours}h';
return '${d.inDays}d';
}

View File

@ -10,7 +10,6 @@ import 'package:flutter/material.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/data/note_repository.dart'; import 'package:todo/data/note_repository.dart';
import 'package:todo/ui/enum_glyphs.dart';
import 'package:todo/ui/note_date_range_field.dart'; import 'package:todo/ui/note_date_range_field.dart';
import 'package:todo/ui/notes_list_defaults.dart'; import 'package:todo/ui/notes_list_defaults.dart';
@ -67,6 +66,7 @@ class _FilterSheetState extends State<FilterSheet> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context);
return SafeArea( return SafeArea(
child: Padding( child: Padding(
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
@ -82,38 +82,33 @@ class _FilterSheetState extends State<FilterSheet> {
children: [ children: [
Row( Row(
children: [ children: [
const Icon(Icons.filter_list, semanticLabel: 'Filters'), Text('Filters', style: theme.textTheme.titleLarge),
const Spacer(), const Spacer(),
TextButton( TextButton(
onPressed: _clearAll, onPressed: _clearAll,
child: const Icon(Icons.clear, semanticLabel: 'Clear all'), child: const Text('Clear all'),
), ),
], ],
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
GlyphChips<Status>( _MultiChips<Status>(
multi: true, label: 'Status',
heading: kStatusHeadingIcon,
semanticLabel: 'Status',
values: Status.values, values: Status.values,
selected: _statuses, selected: _statuses,
glyphOf: statusGlyph, labelOf: (s) => s.label,
onTap: (s) => _toggle(_statuses, s), onToggle: (s) => _toggle(_statuses, s),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
GlyphChips<Priority>( _MultiChips<Priority>(
multi: true, label: 'Priority',
heading: kPriorityHeadingIcon,
semanticLabel: 'Priority',
values: Priority.values, values: Priority.values,
selected: _priorities, selected: _priorities,
glyphOf: (p) => priorityGlyph(context, p), labelOf: (p) => p.label,
onTap: (p) => _toggle(_priorities, p), onToggle: (p) => _toggle(_priorities, p),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
DateRangeField( DateRangeField(
icon: kCreatedIcon, label: 'Created',
semanticLabel: 'Created',
from: _createdFrom, from: _createdFrom,
to: _createdTo, to: _createdTo,
onChanged: (from, to) => setState(() { onChanged: (from, to) => setState(() {
@ -123,8 +118,7 @@ class _FilterSheetState extends State<FilterSheet> {
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
DateRangeField( DateRangeField(
icon: kUpdatedIcon, label: 'Last updated',
semanticLabel: 'Last updated',
from: _updatedFrom, from: _updatedFrom,
to: _updatedTo, to: _updatedTo,
onChanged: (from, to) => setState(() { onChanged: (from, to) => setState(() {
@ -135,7 +129,7 @@ class _FilterSheetState extends State<FilterSheet> {
const SizedBox(height: 20), const SizedBox(height: 20),
FilledButton( FilledButton(
onPressed: () => Navigator.of(context).pop(_build()), onPressed: () => Navigator.of(context).pop(_build()),
child: const Icon(Icons.check, semanticLabel: 'Apply'), child: const Text('Apply'),
), ),
], ],
), ),
@ -145,6 +139,45 @@ class _FilterSheetState extends State<FilterSheet> {
} }
} }
/// Multi-select chip group for an enum (used by the filter sheet).
class _MultiChips<T> extends StatelessWidget {
const _MultiChips({
required this.label,
required this.values,
required this.selected,
required this.labelOf,
required this.onToggle,
});
final String label;
final List<T> values;
final Set<T> selected;
final String Function(T) labelOf;
final ValueChanged<T> onToggle;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: Theme.of(context).textTheme.labelLarge),
const SizedBox(height: 8),
Wrap(
spacing: 8,
children: [
for (final v in values)
FilterChip(
label: Text(labelOf(v)),
selected: selected.contains(v),
onSelected: (_) => onToggle(v),
),
],
),
],
);
}
}
/// A date-range control offering quick presets plus a custom range picker. /// A date-range control offering quick presets plus a custom range picker.
/// ///
/// Reports the chosen [from]/[to] (day granularity, both inclusive) back to /// Reports the chosen [from]/[to] (day granularity, both inclusive) back to

View File

@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:todo/data/app_settings.dart'; import 'package:todo/data/app_settings.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/data/note_repository.dart'; import 'package:todo/data/note_repository.dart';
import 'package:todo/ui/empty_notes_cue.dart';
import 'package:todo/ui/note_selection.dart'; import 'package:todo/ui/note_selection.dart';
import 'package:todo/ui/notes_assign_flow.dart'; import 'package:todo/ui/notes_assign_flow.dart';
import 'package:todo/ui/notes_filter_sheet.dart'; import 'package:todo/ui/notes_filter_sheet.dart';
@ -135,7 +134,7 @@ class _NotesListScreenState extends State<NotesListScreen> {
final badgeCount = userFacetCount(_filter); final badgeCount = userFacetCount(_filter);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Icon(Icons.note, semanticLabel: 'Notes'), title: const Text('Notes'),
actions: [ actions: [
_selectButton(), _selectButton(),
// Eye, no label: open = Claude-made notes shown, slashed = hidden. // Eye, no label: open = Claude-made notes shown, slashed = hidden.
@ -149,27 +148,26 @@ class _NotesListScreenState extends State<NotesListScreen> {
onPressed: _toggleClaudeNotes, onPressed: _toggleClaudeNotes,
), ),
PopupMenuButton<NoteSort>( PopupMenuButton<NoteSort>(
// Empty, not omitted: null falls back to the painted "Show menu". tooltip: 'Sort',
tooltip: '', icon: const Icon(Icons.sort),
icon: const Icon(Icons.sort, semanticLabel: 'Sort'),
initialValue: _sort, initialValue: _sort,
onSelected: _setSort, onSelected: _setSort,
itemBuilder: (_) => const [ itemBuilder: (_) => const [
PopupMenuItem( PopupMenuItem(
value: NoteSort.modifiedDesc, value: NoteSort.modifiedDesc,
child: Icon(Icons.update, semanticLabel: 'Last updated'), child: Text('Last updated'),
), ),
PopupMenuItem( PopupMenuItem(
value: NoteSort.createdDesc, value: NoteSort.createdDesc,
child: Icon(Icons.post_add, semanticLabel: 'Newest created'), child: Text('Newest created'),
), ),
PopupMenuItem( PopupMenuItem(
value: NoteSort.alphabetical, value: NoteSort.alphabetical,
child: Icon(Icons.sort_by_alpha, semanticLabel: 'Alphabetical'), child: Text('Alphabetical'),
), ),
PopupMenuItem( PopupMenuItem(
value: NoteSort.priorityDesc, value: NoteSort.priorityDesc,
child: Icon(Icons.flag_outlined, semanticLabel: 'Priority'), child: Text('Priority'),
), ),
], ],
), ),
@ -183,7 +181,8 @@ class _NotesListScreenState extends State<NotesListScreen> {
label: Text('$badgeCount'), label: Text('$badgeCount'),
offset: const Offset(-8, 4), offset: const Offset(-8, 4),
child: IconButton( child: IconButton(
icon: const Icon(Icons.filter_list, semanticLabel: 'Filter'), tooltip: 'Filter',
icon: const Icon(Icons.filter_list),
onPressed: _openFilters, onPressed: _openFilters,
), ),
), ),
@ -199,16 +198,15 @@ class _NotesListScreenState extends State<NotesListScreen> {
onChanged: _onSearchChanged, onChanged: _onSearchChanged,
textInputAction: TextInputAction.search, textInputAction: TextInputAction.search,
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Search notes…',
prefixIcon: const Icon(Icons.search), prefixIcon: const Icon(Icons.search),
isDense: true, isDense: true,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
suffixIcon: _searchController.text.isEmpty suffixIcon: _searchController.text.isEmpty
? null ? null
: IconButton( : IconButton(
icon: const Icon( tooltip: 'Clear search',
Icons.clear, icon: const Icon(Icons.clear),
semanticLabel: 'Clear search',
),
onPressed: () { onPressed: () {
_searchController.clear(); _searchController.clear();
_onSearchChanged(''); _onSearchChanged('');
@ -225,7 +223,11 @@ class _NotesListScreenState extends State<NotesListScreen> {
final notes = snapshot.data ?? const <Note>[]; final notes = snapshot.data ?? const <Note>[];
if (notes.isEmpty) { if (notes.isEmpty) {
return Center( return Center(
child: EmptyNotesCue(filtered: !_filter.isEmpty), child: Text(
_filter.isEmpty
? 'No notes yet'
: 'No notes match these filters',
),
); );
} }
return NotesListBody( return NotesListBody(

View File

@ -105,8 +105,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
/// session is available, best-effort mirrors it so the choice follows the /// session is available, best-effort mirrors it so the choice follows the
/// user to their other devices. /// user to their other devices.
/// ///
/// The local write always lands: a [FirebaseAuthError] from opening the /// The local write always lands — a signed-in-as-wrong-account device
/// client (wrong account) is caught on its own, before the write. /// throwing [FirebaseAuthError] out of `openFirebase()` must not take the
/// toggle down with it, so opening the client has its own try/catch,
/// separate from (and preceding) the try that guards the local write and
/// mirror push.
Future<void> _setAdvancedMode(bool value) async { Future<void> _setAdvancedMode(bool value) async {
final analytics = widget.analytics; final analytics = widget.analytics;
if (analytics != null) { if (analytics != null) {
@ -203,9 +206,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(title: const Text('Settings')),
title: const Icon(Icons.settings, semanticLabel: 'Settings'),
),
body: ListView( body: ListView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
children: [ children: [
@ -213,38 +214,33 @@ class _SettingsScreenState extends State<SettingsScreen> {
valueListenable: widget.appSettings, valueListenable: widget.appSettings,
builder: (context, settings, _) => SwitchListTile( builder: (context, settings, _) => SwitchListTile(
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
secondary: const Icon(Icons.tune, semanticLabel: _advanced), title: const Text('Enable advanced'),
subtitle: const Text(
'Priority/status, templates, view modes, and sync details '
'in the capture screen',
),
value: settings.advancedMode, value: settings.advancedMode,
onChanged: (value) => unawaited(_setAdvancedMode(value)), onChanged: (value) => unawaited(_setAdvancedMode(value)),
), ),
), ),
const Divider(), const Divider(),
_link( ListTile(
const Icon(Icons.sync, semanticLabel: 'Sync settings: Firebase'), contentPadding: EdgeInsets.zero,
_openSyncSettings, title: const Text('Sync settings'),
subtitle: const Text('Firebase sync and notes backup'),
trailing: const Icon(Icons.chevron_right),
onTap: () => unawaited(_openSyncSettings()),
), ),
CloudImagesTile(httpClient: widget.httpClient), CloudImagesTile(httpClient: widget.httpClient),
_link( ListTile(
Icon( contentPadding: EdgeInsets.zero,
Icons.cloud_sync, title: const Text('Advanced sync (GitHub)'),
color: Theme.of(context).colorScheme.outline, subtitle: const Text('Cutover mirror — not recommended'),
semanticLabel: 'Advanced sync (GitHub): not recommended', trailing: const Icon(Icons.chevron_right),
), onTap: () => unawaited(_openGitHubMirror()),
_openGitHubMirror,
), ),
], ],
), ),
); );
} }
// Spoken only: what the advanced switch turns on.
static const _advanced = 'Enable advanced: priority, status, view modes';
/// A row that opens a sub-screen: its glyph (muted = not recommended).
Widget _link(Icon icon, Future<void> Function() open) => ListTile(
contentPadding: EdgeInsets.zero,
leading: icon,
trailing: const Icon(Icons.chevron_right),
onTap: () => unawaited(open()),
);
} }

View File

@ -1,49 +0,0 @@
/// A screen's latest result as a glyph in place of a status sentence.
library;
import 'package:flutter/material.dart';
/// One result: what to paint, whether it is a failure, and the old
/// sentence, kept as the spoken label only.
class StatusCue {
/// Creates a cue.
const StatusCue(this.icon, this.spoken, {this.error = false});
/// A success: a check glyph in the accent colour.
const StatusCue.ok(this.spoken) : icon = Icons.check_circle, error = false;
/// A failure: an error glyph in the danger hue.
const StatusCue.failed(this.spoken) : icon = Icons.error, error = true;
/// The glyph painted.
final IconData icon;
/// What a screen reader says.
final String spoken;
/// Whether this is a failure (danger hue) rather than a success.
final bool error;
}
/// Paints [cue] as a large glyph; colour is the second channel.
class StatusCueView extends StatelessWidget {
/// Creates the view.
const StatusCueView(this.cue, {super.key});
/// The result shown.
final StatusCue cue;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return Align(
alignment: Alignment.centerLeft,
child: Icon(
cue.icon,
size: 32,
color: cue.error ? scheme.error : scheme.primary,
semanticLabel: cue.spoken,
),
);
}
}

View File

@ -1,30 +0,0 @@
/// Glyphs standing for note templates and their sections in the editor.
///
/// The section labels stay in `note_template.dart`: they are the note's own
/// `## heading` format, read by `parse()`, BACKLOG.md and the CLI. Only what
/// the editor paints around them is a glyph; the label and helper are spoken.
library;
import 'package:flutter/material.dart';
import 'package:todo/data/note_template.dart';
/// The glyph for template [t]: a structured form, or a blank page.
IconData templateIcon(NoteTemplate t) =>
t.isFreeform ? Icons.note_outlined : Icons.assignment_outlined;
/// [t] as its glyph, spoken as its label.
Widget templateGlyph(NoteTemplate t) =>
Icon(templateIcon(t), semanticLabel: t.label);
/// The glyph heading a guided step, keyed by the section's stable `key`.
IconData sectionIcon(TemplateSection s) => switch (s.key) {
'title' => Icons.title,
'what' => Icons.lightbulb_outline,
'where' => Icons.place_outlined,
'must' => Icons.rule,
'done' => Icons.emoji_events_outlined,
'verify' => Icons.devices,
'refs' => Icons.menu_book_outlined,
_ => Icons.notes,
};

View File

@ -1,55 +0,0 @@
/// Framework strings the app paints without asking for them.
///
/// Material's own buttons (the app bar back arrow, a dialog's close, the
/// drawer, the overflow menu) carry tooltips from [MaterialLocalizations],
/// and a tooltip is painted on long-press and hover. kuhy's textgate rule
/// says nothing he sees has words he did not ask for, so these tooltips are
/// blanked: an empty tooltip is not built at all. Screen readers still get
/// the button's semantics from the icon itself.
library;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
/// English Material strings with every button tooltip blanked.
class TextFreeMaterialLocalizations extends DefaultMaterialLocalizations {
/// Creates the localizations.
const TextFreeMaterialLocalizations();
@override
String get backButtonTooltip => '';
@override
String get closeButtonTooltip => '';
@override
String get openAppDrawerTooltip => '';
@override
String get showMenuTooltip => '';
@override
String get moreButtonTooltip => '';
@override
String get deleteButtonTooltip => '';
}
class _Delegate extends LocalizationsDelegate<MaterialLocalizations> {
const _Delegate();
@override
bool isSupported(Locale locale) => locale.languageCode == 'en';
@override
Future<MaterialLocalizations> load(Locale locale) =>
SynchronousFuture(const TextFreeMaterialLocalizations());
@override
bool shouldReload(_Delegate old) => false;
}
/// Pass as `MaterialApp.localizationsDelegates`.
const List<LocalizationsDelegate<dynamic>> kTextFreeLocalizations = [
_Delegate(),
];

View File

@ -399,11 +399,11 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: github_device_auth path: github_device_auth
ref: "github_device_auth-v0.4.0" ref: "github_device_auth-v0.3.2"
resolved-ref: "3084080d744c348a217727e26a6be838e7d5a4ff" resolved-ref: "4ccaba1bb3e495ef72d70c6a7e7d7ec98d755792"
url: "https://github.com/kuhyx/utils" url: "https://github.com/kuhyx/utils"
source: git source: git
version: "0.4.0" version: "0.3.2"
glob: glob:
dependency: transitive dependency: transitive
description: description:
@ -1006,11 +1006,11 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: sync_settings_ui path: sync_settings_ui
ref: "sync_settings_ui-v0.7.0" ref: "sync_settings_ui-v0.6.3"
resolved-ref: "3084080d744c348a217727e26a6be838e7d5a4ff" resolved-ref: eef7af4c86837ee82891493587ff3456297e5dea
url: "https://github.com/kuhyx/utils" url: "https://github.com/kuhyx/utils"
source: git source: git
version: "0.7.0" version: "0.6.3"
synchronized: synchronized:
dependency: transitive dependency: transitive
description: description:

View File

@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.77+1 version: 1.0.72+1
environment: environment:
sdk: ^3.12.2 sdk: ^3.12.2
@ -59,7 +59,7 @@ dependencies:
github_device_auth: github_device_auth:
git: git:
url: https://github.com/kuhyx/utils url: https://github.com/kuhyx/utils
ref: github_device_auth-v0.4.0 ref: github_device_auth-v0.3.2
path: github_device_auth path: github_device_auth
# One-tap Google ID token via the framework AccountManager chooser (FOSS, # One-tap Google ID token via the framework AccountManager chooser (FOSS,
# no Play Services sign-in SDK). Used by the sync backend in lib/sync/. # no Play Services sign-in SDK). Used by the sync backend in lib/sync/.
@ -97,7 +97,7 @@ dependencies:
sync_settings_ui: sync_settings_ui:
git: git:
url: https://github.com/kuhyx/utils url: https://github.com/kuhyx/utils
ref: sync_settings_ui-v0.7.0 ref: sync_settings_ui-v0.6.3
path: sync_settings_ui path: sync_settings_ui
url_launcher: 6.3.3 url_launcher: 6.3.3
uuid: 4.6.0 uuid: 4.6.0

View File

@ -20,7 +20,6 @@ import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
import 'capture_screen_harness.dart'; import 'capture_screen_harness.dart';
import 'text_free_guard.dart';
void main() { void main() {
testWidgets( testWidgets(
@ -141,7 +140,7 @@ void main() {
// Capture must never be interrupted by a snackbar… // Capture must never be interrupted by a snackbar…
expect(find.byType(SnackBar), findsNothing); expect(find.byType(SnackBar), findsNothing);
// …but the failure is no longer swallowed: the status line shows it. // …but the failure is no longer swallowed: the status line shows it.
expect(spoken('Sync failed at'), findsOneWidget); expect(find.textContaining('Sync failed at'), findsOneWidget);
expect(spoken('offline'), findsOneWidget); expect(find.textContaining('offline'), findsOneWidget);
}); });
} }

View File

@ -20,7 +20,6 @@ import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
import 'capture_screen_harness.dart'; import 'capture_screen_harness.dart';
import 'text_free_guard.dart';
void main() { void main() {
testWidgets('defaults to Raw, with Guided available via the entry wizard', ( testWidgets('defaults to Raw, with Guided available via the entry wizard', (
@ -30,18 +29,18 @@ void main() {
// Defaults to Raw: a single text field, no note persisted yet. // Defaults to Raw: a single text field, no note persisted yet.
expect(find.byType(TextField), findsOneWidget); expect(find.byType(TextField), findsOneWidget);
expect(find.bySemanticsLabel('Guided'), findsOneWidget); expect(find.text('Guided'), findsOneWidget);
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);
// Tapping Guided on the empty draft opens the priority+template wizard // Tapping Guided on the empty draft opens the priority+template wizard
// rather than jumping straight into the stepper. // rather than jumping straight into the stepper.
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
expect(find.bySemanticsLabel('Step 1 of 2'), findsOneWidget); expect(find.text('Step 1 of 2'), findsOneWidget);
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('Start')); await tester.tap(find.text('Start'));
await tester.pump(); await tester.pump();
// Now on step 1 of the full-screen step page. // Now on step 1 of the full-screen step page.
@ -50,13 +49,13 @@ void main() {
find.text('1 / ${NoteTemplate.llmDesignSpec.sections.length}'), find.text('1 / ${NoteTemplate.llmDesignSpec.sections.length}'),
findsOneWidget, findsOneWidget,
); );
expect(spoken('imperative'), findsOneWidget); // title helper expect(find.textContaining('imperative'), findsOneWidget); // title helper
}); });
testWidgets('saving the untouched template creates no note', (tester) async { testWidgets('saving the untouched template creates no note', (tester) async {
final repo = await pumpCapture(tester); final repo = await pumpCapture(tester);
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(); await tester.pump();
expect(await repo.listNotes(), isEmpty); expect(await repo.listNotes(), isEmpty);
@ -84,7 +83,7 @@ void main() {
await tester.enterText(find.byType(TextField).first, 'A real idea'); await tester.enterText(find.byType(TextField).first, 'A real idea');
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(); await tester.pump();
expect(await repo.listNotes(), hasLength(1)); expect(await repo.listNotes(), hasLength(1));
@ -99,16 +98,15 @@ void main() {
) async { ) async {
await pumpCapture(tester); // empty prefs → no token → not configured await pumpCapture(tester); // empty prefs → no token → not configured
await tester.tap(find.bySemanticsLabel('Sync')); await tester.tap(find.byTooltip('Sync'));
await tester.pump(); // settings load + snackbar await tester.pump(); // settings load + snackbar
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 500)); // snack fades in
// The behaviour that matters is the routing, not the wording: an // The behaviour that matters is the routing, not the wording: an
// unconfigured device is sent to settings to connect a backend. Asserting // unconfigured device is sent to settings to connect a backend. Asserting
// on the snackbar text tied this to one phrasing, and the snackbar is // on the snackbar text tied this to one phrasing, and the snackbar is
// gone by the time settings has pushed anyway. // gone by the time settings has pushed anyway.
expect(spoken('Connect Firebase'), findsWidgets); expect(find.textContaining('Connect Firebase'), findsWidgets);
}); });
testWidgets('the notes-list button navigates to the list screen', ( testWidgets('the notes-list button navigates to the list screen', (
@ -116,11 +114,11 @@ void main() {
) async { ) async {
await pumpCapture(tester); await pumpCapture(tester);
await tester.tap(find.bySemanticsLabel('Notes')); await tester.tap(find.byTooltip('Notes'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); // route transition await tester.pump(const Duration(milliseconds: 300)); // route transition
expect(find.byIcon(Icons.note), findsOneWidget); // list screen title expect(find.text('Notes'), findsOneWidget); // list screen app bar title
}); });
testWidgets('changing the priority dropdown updates the saved note', ( testWidgets('changing the priority dropdown updates the saved note', (
@ -136,7 +134,7 @@ void main() {
); );
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 400)); // menu open await tester.pump(const Duration(milliseconds: 400)); // menu open
await tester.tap(find.bySemanticsLabel('High').last); await tester.tap(find.text('High').last);
await tester.pump(); await tester.pump();
expect((await repo.listNotes()).single.priority, Priority.high); expect((await repo.listNotes()).single.priority, Priority.high);
@ -155,7 +153,7 @@ void main() {
); );
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 400)); // menu open await tester.pump(const Duration(milliseconds: 400)); // menu open
await tester.tap(find.bySemanticsLabel('In progress').last); await tester.tap(find.text('In progress').last);
await tester.pump(); await tester.pump();
expect((await repo.listNotes()).single.status, Status.inProgress); expect((await repo.listNotes()).single.status, Status.inProgress);

View File

@ -28,7 +28,6 @@ import 'package:todo/ui/attachment_picking.dart';
import 'package:todo/ui/capture_screen.dart'; import 'package:todo/ui/capture_screen.dart';
import 'package:todo/ui/github_mirror_screen.dart'; import 'package:todo/ui/github_mirror_screen.dart';
import 'package:todo/ui/settings_screen.dart'; import 'package:todo/ui/settings_screen.dart';
import 'package:todo/ui/text_free_localizations.dart';
import 'fake_note_repository.dart'; import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
@ -74,8 +73,6 @@ Future<FakeNoteRepository> pumpCapture(
debounce: Duration.zero, debounce: Duration.zero,
); );
final app = MaterialApp( final app = MaterialApp(
// As in main.dart: Material's own button tooltips are blanked.
localizationsDelegates: kTextFreeLocalizations,
home: CaptureScreen( home: CaptureScreen(
repository: repo, repository: repo,
appSettings: appSettings:

View File

@ -20,7 +20,6 @@ import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
import 'capture_screen_harness.dart'; import 'capture_screen_harness.dart';
import 'text_free_guard.dart';
void main() { void main() {
testWidgets( testWidgets(
@ -36,8 +35,8 @@ void main() {
await tester.pump(); await tester.pump();
// Only a failure is worth surfacing; a routine success is silent. // Only a failure is worth surfacing; a routine success is silent.
expect(spoken('Synced at'), findsNothing); expect(find.textContaining('Synced at'), findsNothing);
expect(spoken('merged 0 device(s)'), findsNothing); expect(find.textContaining('merged 0 device(s)'), findsNothing);
}, },
); );
@ -54,8 +53,8 @@ void main() {
); );
await tester.pump(); await tester.pump();
expect(spoken('Sync failed at 12:00:00'), findsOneWidget); expect(find.textContaining('Sync failed at 12:00:00'), findsOneWidget);
expect(spoken('rate limited'), findsOneWidget); expect(find.textContaining('rate limited'), findsOneWidget);
}); });
testWidgets('losing focus triggers a debounced auto-sync', (tester) async { testWidgets('losing focus triggers a debounced auto-sync', (tester) async {

View File

@ -20,7 +20,6 @@ import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
import 'capture_screen_harness.dart'; import 'capture_screen_harness.dart';
import 'text_free_guard.dart';
void main() { void main() {
testWidgets('Sync with a configured token runs the sync service', ( testWidgets('Sync with a configured token runs the sync service', (
@ -36,17 +35,18 @@ void main() {
}); });
await pumpCapture(tester, prefs: configuredPrefs, httpClient: mock); await pumpCapture(tester, prefs: configuredPrefs, httpClient: mock);
await tester.tap(find.bySemanticsLabel('Sync')); await tester.tap(find.byTooltip('Sync'));
await tester.pump(); // setState(_syncing = true) await tester.pump(); // setState(_syncing = true)
await tester.pump(); // service runs, snackbar scheduled await tester.pump(); // service runs, snackbar scheduled
await tester.pump(); // snackbar builds await tester.pump(); // snackbar builds
await tester.pump(const Duration(milliseconds: 500)); // snack fades in
// No firebaseFactory was injected, so this runs over GitHub alone -- // No firebaseFactory was injected, so this runs over GitHub alone --
// the status line must say so rather than reading identically to a // the status line must say so rather than reading identically to a
// Firebase-connected sync. // Firebase-connected sync.
expect( expect(
spoken('Synced: GitHub-only (Firebase not connected) — merged 0 device'), find.textContaining(
'Synced: GitHub-only (Firebase not connected) — merged 0 device',
),
findsOneWidget, findsOneWidget,
); );
}); });
@ -55,15 +55,14 @@ void main() {
final mock = MockClient((_) async => throw Exception('offline')); final mock = MockClient((_) async => throw Exception('offline'));
await pumpCapture(tester, prefs: configuredPrefs, httpClient: mock); await pumpCapture(tester, prefs: configuredPrefs, httpClient: mock);
await tester.tap(find.bySemanticsLabel('Sync')); await tester.tap(find.byTooltip('Sync'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 500)); // snack fades in
// 'Sync failed:' is the snackbar; the status line says 'Sync failed at'. // 'Sync failed:' is the snackbar; the status line says 'Sync failed at'.
expect(spoken('Sync failed:'), findsOneWidget); expect(find.textContaining('Sync failed:'), findsOneWidget);
expect(spoken('Sync failed at'), findsOneWidget); expect(find.textContaining('Sync failed at'), findsOneWidget);
}); });
testWidgets('manual sync reports peer files it could not decode', ( testWidgets('manual sync reports peer files it could not decode', (
@ -86,14 +85,13 @@ void main() {
}); });
await pumpCapture(tester, prefs: configuredPrefs, httpClient: mock); await pumpCapture(tester, prefs: configuredPrefs, httpClient: mock);
await tester.tap(find.bySemanticsLabel('Sync')); await tester.tap(find.byTooltip('Sync'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 500)); // snack fades in
expect( expect(
spoken('skipped 1 unreadable file(s)'), find.textContaining('skipped 1 unreadable file(s)'),
findsWidgets, // snackbar and status line both call it out findsWidgets, // snackbar and status line both call it out
); );
}); });
@ -103,7 +101,7 @@ void main() {
) async { ) async {
await pumpCapture(tester); await pumpCapture(tester);
await tester.tap(find.bySemanticsLabel('Settings')); await tester.tap(find.byTooltip('Settings'));
await tester.pumpAndSettle(); // route transition await tester.pumpAndSettle(); // route transition
expect(find.byType(SettingsScreen), findsOneWidget); // settings is up expect(find.byType(SettingsScreen), findsOneWidget); // settings is up
@ -114,19 +112,19 @@ void main() {
// without popping a result at all, so a stale in-memory value would be // without popping a result at all, so a stale in-memory value would be
// wrong there too). This exercises that reload-after-return path, then // wrong there too). This exercises that reload-after-return path, then
// Back returns to capture. // Back returns to capture.
await tester.tap(find.byIcon(Icons.cloud_sync)); await tester.tap(find.text('Advanced sync (GitHub)'));
await tester.pumpAndSettle(); // route transition await tester.pumpAndSettle(); // route transition
expect(find.byType(GitHubMirrorScreen), findsOneWidget); expect(find.byType(GitHubMirrorScreen), findsOneWidget);
await tester.tap(find.bySemanticsLabel('Save')); await tester.tap(find.text('Save'));
await tester.pumpAndSettle(); // save + pop transition back to Settings await tester.pumpAndSettle(); // save + pop transition back to Settings
expect(find.byType(SettingsScreen), findsOneWidget); expect(find.byType(SettingsScreen), findsOneWidget);
await tester.tap(find.byType(BackButton)); // no 'Back' tooltip to find await tester.pageBack();
await tester.pumpAndSettle(); // pop transition back to capture await tester.pumpAndSettle(); // pop transition back to capture
expect(find.byType(SettingsScreen), findsNothing); // back on capture expect(find.byType(SettingsScreen), findsNothing); // back on capture
expect(find.bySemanticsLabel('Settings'), findsOneWidget); expect(find.byTooltip('Settings'), findsOneWidget);
}); });
// A MockClient that records request methods and answers the sync flow: // A MockClient that records request methods and answers the sync flow:
@ -150,26 +148,31 @@ void main() {
await tester.pump(); await tester.pump();
// The editor's own template/mode chrome is gone. // The editor's own template/mode chrome is gone.
expect(find.bySemanticsLabel('Guided'), findsNothing); expect(find.text('Guided'), findsNothing);
expect(find.bySemanticsLabel('Template'), findsNothing); expect(find.text('Template'), findsNothing);
// The capture screen's priority/status row is gone. // The capture screen's priority/status row is gone.
expect(find.bySemanticsLabel('Priority'), findsNothing); expect(find.text('Priority'), findsNothing);
expect(find.bySemanticsLabel('Status'), findsNothing); expect(find.text('Status'), findsNothing);
// Routine status chatter is gone; only a badge count remains. // Routine status chatter is gone; only a badge count remains.
expect(spoken('Autosaves as you type'), findsNothing); expect(find.textContaining('Autosaves as you type'), findsNothing);
expect(find.text('1'), findsOneWidget); expect(find.text('1'), findsOneWidget);
// The note still persisted normally underneath the simplified UI. // The note still persisted normally underneath the simplified UI.
expect(find.text('A plain idea'), findsOneWidget); expect(find.text('A plain idea'), findsOneWidget);
}, },
); );
testWidgets('draft text survives an advancedMode toggle mid-typing', ( testWidgets(
tester, 'draft text survives an advancedMode toggle mid-typing',
) async { (tester) async {
final appSettings = ValueNotifier(const AppSettings(advancedMode: true)); final appSettings = ValueNotifier(
const AppSettings(advancedMode: true),
);
await pumpCapture(tester, appSettings: appSettings); await pumpCapture(tester, appSettings: appSettings);
await tester.enterText(find.byType(TextField).first, 'my important idea'); await tester.enterText(
find.byType(TextField).first,
'my important idea',
);
await tester.pump(); await tester.pump();
// NoteForm's metadata row is conditionally present, so toggling // NoteForm's metadata row is conditionally present, so toggling
@ -181,5 +184,6 @@ void main() {
final field = tester.widget<TextField>(find.byType(TextField).first); final field = tester.widget<TextField>(find.byType(TextField).first);
expect(field.controller?.text, contains('my important idea')); expect(field.controller?.text, contains('my important idea'));
}); },
);
} }

View File

@ -1,57 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:todo/ui/confirm_delete.dart';
/// Opens the dialog and returns a getter for its eventual answer.
Future<bool? Function()> _open(WidgetTester tester) async {
bool? answer;
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) => Scaffold(
body: TextButton(
onPressed: () async => answer = await confirmDeleteNote(context),
child: const SizedBox.square(dimension: 40),
),
),
),
),
);
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
return () => answer;
}
void main() {
testWidgets('the delete glyph answers yes', (tester) async {
final answer = await _open(tester);
expect(find.bySemanticsLabel('Delete note?'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('confirm-delete')));
await tester.pumpAndSettle();
expect(answer(), isTrue);
});
testWidgets('cancel is autofocused, so Return keeps the note', (
tester,
) async {
final answer = await _open(tester);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(answer(), isFalse);
});
testWidgets('Escape answers no', (tester) async {
final answer = await _open(tester);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(answer(), isFalse);
});
testWidgets('tapping the barrier answers no', (tester) async {
final answer = await _open(tester);
await tester.tapAt(const Offset(5, 5));
await tester.pumpAndSettle();
expect(answer(), isFalse);
});
}

View File

@ -18,7 +18,6 @@ import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
import 'github_mirror_harness.dart'; import 'github_mirror_harness.dart';
import 'text_free_guard.dart';
/// Stub launcher that records the URL instead of opening it, so `_openPage` /// Stub launcher that records the URL instead of opening it, so `_openPage`
/// can be exercised without a real platform channel. /// can be exercised without a real platform channel.
@ -73,7 +72,7 @@ void main() {
httpClient: mock, httpClient: mock,
); );
await tester.tap(find.bySemanticsLabel('Connect GitHub')); await tester.tap(find.text('Connect GitHub'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
@ -81,7 +80,7 @@ void main() {
await tester.pump(); await tester.pump();
} }
expect(spoken('sync failed'), findsOneWidget); expect(find.textContaining('sync failed'), findsOneWidget);
}); });
testWidgets('Save persists the settings and closes the screen', ( testWidgets('Save persists the settings and closes the screen', (
@ -136,7 +135,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 400)); // route transition await tester.pump(const Duration(milliseconds: 400)); // route transition
expect(find.byType(GitHubMirrorScreen), findsOneWidget); // screen is up expect(find.byType(GitHubMirrorScreen), findsOneWidget); // screen is up
await tester.tap(find.bySemanticsLabel('Save')); await tester.tap(find.text('Save'));
await tester.pump(); // run _save (persist + pop) await tester.pump(); // run _save (persist + pop)
await tester.pump(const Duration(milliseconds: 400)); // pop transition await tester.pump(const Duration(milliseconds: 400)); // pop transition
@ -196,15 +195,14 @@ void main() {
httpClient: mock, httpClient: mock,
); );
await tester.tap(find.bySemanticsLabel('Connect GitHub')); await tester.tap(find.text('Connect GitHub'));
await tester.pump(); // requestDeviceCode await tester.pump(); // requestDeviceCode
await tester.pump(); // dialog builds, poll starts (interval 0) await tester.pump(); // dialog builds, poll starts (interval 0)
expect(find.text('WXYZ-1234'), findsOneWidget); expect(find.text('WXYZ-1234'), findsOneWidget);
await tester.pump(const Duration(milliseconds: 1)); // _delay(0) fires await tester.pump(const Duration(milliseconds: 1)); // _delay(0) fires
await tester.pump(); // token error throws → _error set await tester.pump(); // token error throws → _error set
await tester.pump(const Duration(milliseconds: 300)); // dialog faded in expect(find.textContaining('nope'), findsOneWidget); // error rendered
expect(spoken('nope'), findsOneWidget); // error rendered (spoken glyph)
// Tap the "open on GitHub" action: copies the code and launches the URL. // Tap the "open on GitHub" action: copies the code and launches the URL.
// _openPage awaits Clipboard.setData then the launcher's supportsMode + // _openPage awaits Clipboard.setData then the launcher's supportsMode +
@ -214,7 +212,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(launcher.launched, 'https://github.com/login/device'); expect(launcher.launched, 'https://github.com/login/device');
await tester.tap(find.bySemanticsLabel('Cancel')); await tester.tap(find.text('Cancel'));
await tester.pumpAndSettle(); // finish the dialog pop animation await tester.pumpAndSettle(); // finish the dialog pop animation
expect(find.text('WXYZ-1234'), findsNothing); // dialog dismissed expect(find.text('WXYZ-1234'), findsNothing); // dialog dismissed
}); });

View File

@ -18,7 +18,6 @@ import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
import 'github_mirror_harness.dart'; import 'github_mirror_harness.dart';
import 'text_free_guard.dart';
/// Stub launcher that records the URL instead of opening it, so `_openPage` /// Stub launcher that records the URL instead of opening it, so `_openPage`
/// can be exercised without a real platform channel. /// can be exercised without a real platform channel.
@ -44,42 +43,45 @@ void main() {
tester, tester,
) async { ) async {
await pumpMirror(tester); await pumpMirror(tester);
await tester.tap(find.bySemanticsLabel('Connect GitHub')); await tester.tap(find.text('Connect GitHub'));
await tester.pump(); await tester.pump();
expect(spoken('Enter the OAuth App client id'), findsOneWidget); expect(
find.textContaining('Enter the OAuth App client id'),
findsOneWidget,
);
}); });
testWidgets('Test connection reports a reachable repo', (tester) async { testWidgets('Test connection reports a reachable repo', (tester) async {
final mock = MockClient((_) async => http.Response('{}', 200)); final mock = MockClient((_) async => http.Response('{}', 200));
await pumpMirror(tester, httpClient: mock); await pumpMirror(tester, httpClient: mock);
await tester.tap(find.bySemanticsLabel('Test connection')); await tester.tap(find.text('Test connection'));
await tester.pump(); // start await tester.pump(); // start
await tester.pump(); // resolve future + rebuild await tester.pump(); // resolve future + rebuild
expect(spoken('reachable'), findsOneWidget); expect(find.textContaining('reachable'), findsOneWidget);
}); });
testWidgets('Test connection reports an inaccessible repo', (tester) async { testWidgets('Test connection reports an inaccessible repo', (tester) async {
final mock = MockClient((_) async => http.Response('', 404)); final mock = MockClient((_) async => http.Response('', 404));
await pumpMirror(tester, httpClient: mock); await pumpMirror(tester, httpClient: mock);
await tester.tap(find.bySemanticsLabel('Test connection')); await tester.tap(find.text('Test connection'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(spoken('Could not access'), findsOneWidget); expect(find.textContaining('Could not access'), findsOneWidget);
}); });
testWidgets('Test connection surfaces a network error', (tester) async { testWidgets('Test connection surfaces a network error', (tester) async {
final mock = MockClient((_) async => throw Exception('offline')); final mock = MockClient((_) async => throw Exception('offline'));
await pumpMirror(tester, httpClient: mock); await pumpMirror(tester, httpClient: mock);
await tester.tap(find.bySemanticsLabel('Test connection')); await tester.tap(find.text('Test connection'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(spoken('Error:'), findsOneWidget); expect(find.textContaining('Error:'), findsOneWidget);
}); });
testWidgets('device flow failure to start shows a message', (tester) async { testWidgets('device flow failure to start shows a message', (tester) async {
@ -95,11 +97,11 @@ void main() {
httpClient: mock, httpClient: mock,
); );
await tester.tap(find.bySemanticsLabel('Connect GitHub')); await tester.tap(find.text('Connect GitHub'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(spoken('Could not start device flow'), findsOneWidget); expect(find.textContaining('Could not start device flow'), findsOneWidget);
}); });
testWidgets('device flow happy path saves the token', (tester) async { testWidgets('device flow happy path saves the token', (tester) async {
@ -131,7 +133,7 @@ void main() {
httpClient: mock, httpClient: mock,
); );
await tester.tap(find.bySemanticsLabel('Connect GitHub')); await tester.tap(find.text('Connect GitHub'));
await tester.pump(); // requestDeviceCode await tester.pump(); // requestDeviceCode
await tester.pump(); // dialog builds, shows the user code await tester.pump(); // dialog builds, shows the user code
expect(find.text('WXYZ-1234'), findsOneWidget); expect(find.text('WXYZ-1234'), findsOneWidget);
@ -143,6 +145,6 @@ void main() {
await tester.pump(); await tester.pump();
} }
expect(spoken('Connected and synced'), findsOneWidget); expect(find.textContaining('Connected and synced'), findsOneWidget);
}); });
} }

View File

@ -38,7 +38,7 @@ void main() {
await pumpCapture(tester); await pumpCapture(tester);
await _type(tester); await _type(tester);
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(); // one frame: the cue must not wait for anything await tester.pump(); // one frame: the cue must not wait for anything
expect(haptics, [_lightImpact]); expect(haptics, [_lightImpact]);
@ -52,7 +52,7 @@ void main() {
await pumpCapture(tester); await pumpCapture(tester);
await _type(tester); await _type(tester);
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 100)); await tester.pump(const Duration(milliseconds: 100));
expect(_mark, findsOneWidget); expect(_mark, findsOneWidget);
@ -74,7 +74,7 @@ void main() {
final haptics = recordHaptics(tester); final haptics = recordHaptics(tester);
await pumpCapture(tester); await pumpCapture(tester);
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(const Duration(milliseconds: 100)); await tester.pump(const Duration(milliseconds: 100));
expect(haptics, isEmpty); expect(haptics, isEmpty);
@ -87,18 +87,16 @@ void main() {
final haptics = recordHaptics(tester); final haptics = recordHaptics(tester);
await pumpCapture(tester); await pumpCapture(tester);
await _type(tester); await _type(tester);
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(); // the ticker's clock starts on its first frame await tester.pump(); // the ticker's clock starts on its first frame
await tester.pump(const Duration(milliseconds: 700)); await tester.pump(const Duration(milliseconds: 700));
await tester.tap( await tester.tap(find.byTooltip('New note')); // nothing new to capture
find.bySemanticsLabel('New note'),
); // nothing new to capture
await tester.pump(const Duration(milliseconds: 100)); await tester.pump(const Duration(milliseconds: 100));
expect(haptics, hasLength(1)); expect(haptics, hasLength(1));
expect(_mark, findsNothing); expect(_mark, findsNothing);
await _type(tester); await _type(tester);
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(const Duration(milliseconds: 100)); await tester.pump(const Duration(milliseconds: 100));
expect(haptics, hasLength(2)); expect(haptics, hasLength(2));
expect(_mark, findsOneWidget); expect(_mark, findsOneWidget);
@ -113,7 +111,7 @@ void main() {
await pumpCapture(tester); await pumpCapture(tester);
await _type(tester); await _type(tester);
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(); await tester.pump();
expect(haptics, [_lightImpact]); expect(haptics, [_lightImpact]);
@ -132,7 +130,7 @@ void main() {
await pumpCapture(tester); await pumpCapture(tester);
final before = tester.getTopLeft(find.text('0')); final before = tester.getTopLeft(find.text('0'));
await _type(tester); await _type(tester);
await tester.tap(find.bySemanticsLabel('New note')); await tester.tap(find.byTooltip('New note'));
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
expect(tester.getTopLeft(find.text('1')), before); expect(tester.getTopLeft(find.text('1')), before);
await tester.pump(const Duration(milliseconds: 400)); await tester.pump(const Duration(milliseconds: 400));

View File

@ -73,7 +73,7 @@ void main() {
final total = spec.sections.length; final total = spec.sections.length;
expect(_barValue(tester), closeTo(1 / total, 1e-9)); expect(_barValue(tester), closeTo(1 / total, 1e-9));
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
await tester.pump(AppDuration.base ~/ 2); await tester.pump(AppDuration.base ~/ 2);
expect(_barValue(tester), inExclusiveRange(1 / total, 2 / total)); expect(_barValue(tester), inExclusiveRange(1 / total, 2 / total));
@ -85,7 +85,7 @@ void main() {
testWidgets('remove-animations: the progress bar jumps', (tester) async { testWidgets('remove-animations: the progress bar jumps', (tester) async {
disableAnimations(tester); disableAnimations(tester);
await pumpEditor(tester, initialTemplate: spec); await pumpEditor(tester, initialTemplate: spec);
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
expect(_barValue(tester), closeTo(2 / spec.sections.length, 1e-9)); expect(_barValue(tester), closeTo(2 / spec.sections.length, 1e-9));
}); });

View File

@ -61,7 +61,7 @@ void main() {
find.byWidgetPredicate((w) => w is DropdownButton<Priority>), find.byWidgetPredicate((w) => w is DropdownButton<Priority>),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('High').last); await tester.tap(find.text('High').last);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect((await repo.listNotes()).single.priority, Priority.high); expect((await repo.listNotes()).single.priority, Priority.high);
@ -74,7 +74,7 @@ void main() {
find.byWidgetPredicate((w) => w is DropdownButton<Status>), find.byWidgetPredicate((w) => w is DropdownButton<Status>),
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('Done').last); await tester.tap(find.text('Done').last);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect((await repo.listNotes()).single.status, Status.done); expect((await repo.listNotes()).single.status, Status.done);
@ -85,7 +85,7 @@ void main() {
) async { ) async {
final repo = await pumpDetail(tester, seedNote('# T\n\n## what\nold')); final repo = await pumpDetail(tester, seedNote('# T\n\n## what\nold'));
await tester.tap(find.bySemanticsLabel('Raw')); await tester.tap(find.text('Raw'));
await tester.pump(); await tester.pump();
await tester.enterText(find.byType(TextField), '# T\n\n## what\nnew body'); await tester.enterText(find.byType(TextField), '# T\n\n## what\nnew body');
await tester.pump(); await tester.pump();
@ -101,20 +101,20 @@ void main() {
await tester.enterText(find.byType(TextField), ''); await tester.enterText(find.byType(TextField), '');
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
expect(find.bySemanticsLabel('Step 1 of 2'), findsOneWidget); expect(find.text('Step 1 of 2'), findsOneWidget);
// Wizard hides the Status dropdown (onChromeVisibleChanged(false)). // Wizard hides the Status dropdown (onChromeVisibleChanged(false)).
expect(find.bySemanticsLabel('Status'), findsNothing); expect(find.text('Status'), findsNothing);
await tester.tap(find.byType(DropdownButtonFormField<Priority>)); await tester.tap(find.byType(DropdownButtonFormField<Priority>));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('High').last); await tester.tap(find.text('High').last);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('Start')); await tester.tap(find.text('Start'));
await tester.pump(); await tester.pump();
expect((await repo.listNotes()).single.priority, Priority.high); expect((await repo.listNotes()).single.priority, Priority.high);
@ -134,11 +134,11 @@ void main() {
advancedMode: false, advancedMode: false,
); );
expect(find.bySemanticsLabel('Template'), findsNothing); expect(find.text('Template'), findsNothing);
expect(find.bySemanticsLabel('Guided'), findsNothing); expect(find.text('Guided'), findsNothing);
expect(find.bySemanticsLabel('Raw'), findsNothing); expect(find.text('Raw'), findsNothing);
expect(find.bySemanticsLabel('Priority'), findsNothing); expect(find.text('Priority'), findsNothing);
expect(find.bySemanticsLabel('Status'), findsNothing); expect(find.text('Status'), findsNothing);
// The body itself is still editable — only the chrome is gone. // The body itself is still editable — only the chrome is gone.
expect(find.byType(TextField), findsOneWidget); expect(find.byType(TextField), findsOneWidget);
}); });
@ -146,13 +146,13 @@ void main() {
testWidgets('the delete action removes the note and pops', (tester) async { testWidgets('the delete action removes the note and pops', (tester) async {
final repo = await pumpDetail(tester, seedNote('# Bye')); final repo = await pumpDetail(tester, seedNote('# Bye'));
await tester.tap(find.bySemanticsLabel('Delete note')); await tester.tap(find.byTooltip('Delete note'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Delete is now confirmed. Deleting a note is irreversible and there is no // Delete is now confirmed. Deleting a note is irreversible and there is no
// undo, so a single Return on a focused control must not destroy it. // undo, so a single Return on a focused control must not destroy it.
expect(find.bySemanticsLabel('Delete note?'), findsOneWidget); expect(find.text('Delete note?'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('confirm-delete'))); await tester.tap(find.text('Delete'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(await repo.listNotes(), isEmpty); expect(await repo.listNotes(), isEmpty);
@ -162,9 +162,9 @@ void main() {
testWidgets('cancelling the delete keeps the note', (tester) async { testWidgets('cancelling the delete keeps the note', (tester) async {
final repo = await pumpDetail(tester, seedNote('# Keep me')); final repo = await pumpDetail(tester, seedNote('# Keep me'));
await tester.tap(find.bySemanticsLabel('Delete note')); await tester.tap(find.byTooltip('Delete note'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('confirm-cancel'))); await tester.tap(find.text('Cancel'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(await repo.listNotes(), hasLength(1)); expect(await repo.listNotes(), hasLength(1));

View File

@ -4,10 +4,8 @@ import 'package:todo/data/note.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/ui/markdown_view.dart'; import 'package:todo/ui/markdown_view.dart';
import 'package:todo/ui/note_editor.dart'; import 'package:todo/ui/note_editor.dart';
import 'package:todo/ui/template_glyphs.dart';
import 'note_editor_harness.dart'; import 'note_editor_harness.dart';
import 'text_free_guard.dart';
void main() { void main() {
testWidgets('guided: typing the title emits an assembled # heading', ( testWidgets('guided: typing the title emits an assembled # heading', (
@ -15,7 +13,7 @@ void main() {
) async { ) async {
final emitted = await pumpEditor(tester, initialTemplate: spec); final emitted = await pumpEditor(tester, initialTemplate: spec);
expect(find.bySemanticsLabel('Exit guided'), findsOneWidget); expect(find.byTooltip('Exit guided'), findsOneWidget);
await tester.enterText(find.byType(TextField).first, 'Dark mode'); await tester.enterText(find.byType(TextField).first, 'Dark mode');
await tester.pump(); await tester.pump();
@ -30,11 +28,11 @@ void main() {
expect(find.byType(LinearProgressIndicator), findsOneWidget); expect(find.byType(LinearProgressIndicator), findsOneWidget);
expect(find.text('1 / ${spec.sections.length}'), findsOneWidget); expect(find.text('1 / ${spec.sections.length}'), findsOneWidget);
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
expect(find.text('2 / ${spec.sections.length}'), findsOneWidget); expect(find.text('2 / ${spec.sections.length}'), findsOneWidget);
await tester.tap(find.bySemanticsLabel('Back')); await tester.tap(find.text('Back'));
await tester.pump(); await tester.pump();
expect(find.text('1 / ${spec.sections.length}'), findsOneWidget); expect(find.text('1 / ${spec.sections.length}'), findsOneWidget);
expect(find.byType(LinearProgressIndicator), findsOneWidget); expect(find.byType(LinearProgressIndicator), findsOneWidget);
@ -51,22 +49,21 @@ void main() {
for (var i = 0; i < spec.sections.length; i++) { for (var i = 0; i < spec.sections.length; i++) {
final section = spec.sections[i]; final section = spec.sections[i];
expect(find.text('${i + 1} / ${spec.sections.length}'), findsOneWidget); expect(find.text('${i + 1} / ${spec.sections.length}'), findsOneWidget);
// Each step paints its section glyph; label + helper are spoken.
expect( expect(
find.byIcon(sectionIcon(section)), find.text(section.isTitle ? 'title' : section.label),
findsOneWidget, findsWidgets,
reason: 'step ${i + 1} should show "${section.label}"', reason: 'step ${i + 1} should show "${section.label}"',
); );
expect(spoken(section.helper), findsOneWidget); expect(find.text(section.helper), findsOneWidget);
if (i < spec.sections.length - 1) { if (i < spec.sections.length - 1) {
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
} }
} }
// The last step is `read first`; there is no Next past it. // The last step is `read first`; there is no Next past it.
expect(spec.sections.last.label, 'read first'); expect(spec.sections.last.label, 'read first');
expect(find.bySemanticsLabel('Next'), findsNothing); expect(find.text('Next'), findsNothing);
}); });
testWidgets('pasting a bare link drops the draft to the blank template', ( testWidgets('pasting a bare link drops the draft to the blank template', (
@ -77,7 +74,7 @@ void main() {
initialTemplate: spec, initialTemplate: spec,
initialMode: NoteEditorMode.raw, initialMode: NoteEditorMode.raw,
); );
expect(find.byIcon(Icons.assignment_outlined), findsOneWidget); expect(find.text('LLM design spec'), findsOneWidget);
await tester.enterText( await tester.enterText(
find.byType(TextField).first, find.byType(TextField).first,
@ -86,8 +83,8 @@ void main() {
await tester.pump(); await tester.pump();
// Freeform now, so there is no seven-step stepper to walk for a link. // Freeform now, so there is no seven-step stepper to walk for a link.
expect(find.byIcon(Icons.note_outlined), findsOneWidget); expect(find.text('Blank'), findsOneWidget);
expect(find.bySemanticsLabel('Guided'), findsNothing); expect(find.text('Guided'), findsNothing);
// Adding prose puts the spec template back — lossless in both directions. // Adding prose puts the spec template back — lossless in both directions.
await tester.enterText( await tester.enterText(
@ -95,8 +92,8 @@ void main() {
'https://example.com/x — port this to Dart', 'https://example.com/x — port this to Dart',
); );
await tester.pump(); await tester.pump();
expect(find.byIcon(Icons.assignment_outlined), findsOneWidget); expect(find.text('LLM design spec'), findsOneWidget);
expect(find.bySemanticsLabel('Guided'), findsOneWidget); expect(find.text('Guided'), findsOneWidget);
}); });
testWidgets('an explicit template choice survives further typing', ( testWidgets('an explicit template choice survives further typing', (
@ -108,16 +105,16 @@ void main() {
initialMode: NoteEditorMode.raw, initialMode: NoteEditorMode.raw,
); );
await tester.tap(find.byIcon(Icons.assignment_outlined)); await tester.tap(find.text('LLM design spec'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.byIcon(Icons.note_outlined).last); await tester.tap(find.text('Blank').last);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byIcon(Icons.note_outlined), findsOneWidget); expect(find.text('Blank'), findsOneWidget);
// Prose would normally re-select the spec template; an explicit pick wins. // Prose would normally re-select the spec template; an explicit pick wins.
await tester.enterText(find.byType(TextField).first, 'build a thing'); await tester.enterText(find.byType(TextField).first, 'build a thing');
await tester.pump(); await tester.pump();
expect(find.byIcon(Icons.note_outlined), findsOneWidget); expect(find.text('Blank'), findsOneWidget);
}); });
testWidgets('switching to View renders the note as Markdown', (tester) async { testWidgets('switching to View renders the note as Markdown', (tester) async {
@ -129,7 +126,7 @@ void main() {
await tester.enterText(find.byType(TextField).first, '# Render me'); await tester.enterText(find.byType(TextField).first, '# Render me');
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('View')); await tester.tap(find.text('View'));
await tester.pump(); await tester.pump();
expect(find.byType(MarkdownView), findsOneWidget); expect(find.byType(MarkdownView), findsOneWidget);

View File

@ -6,7 +6,6 @@ import 'package:todo/ui/markdown_view.dart';
import 'package:todo/ui/note_editor.dart'; import 'package:todo/ui/note_editor.dart';
import 'note_editor_harness.dart'; import 'note_editor_harness.dart';
import 'text_free_guard.dart';
void main() { void main() {
testWidgets( testWidgets(
@ -16,7 +15,7 @@ void main() {
await tester.enterText(find.byType(TextField).first, 'T'); await tester.enterText(find.byType(TextField).first, 'T');
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('Exit guided')); await tester.tap(find.byTooltip('Exit guided'));
await tester.pump(); await tester.pump();
final raw = tester.widget<TextField>(find.byType(TextField)); final raw = tester.widget<TextField>(find.byType(TextField));
@ -39,11 +38,10 @@ void main() {
); );
// Structured template + non-conforming raw text → switching is refused. // Structured template + non-conforming raw text → switching is refused.
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 500)); // snack fades in
expect(spoken("doesn't match the template"), findsOneWidget); expect(find.textContaining("doesn't match the template"), findsOneWidget);
expect(find.byType(LinearProgressIndicator), findsNothing); // still raw expect(find.byType(LinearProgressIndicator), findsNothing); // still raw
}); });
@ -58,28 +56,25 @@ void main() {
// Bare guided -> raw via the back arrow makes the (still conforming) // Bare guided -> raw via the back arrow makes the (still conforming)
// body the source… // body the source…
await tester.tap(find.bySemanticsLabel('Exit guided')); await tester.tap(find.byTooltip('Exit guided'));
await tester.pump(); await tester.pump();
expect(find.byType(LinearProgressIndicator), findsNothing); expect(find.byType(LinearProgressIndicator), findsNothing);
// …then raw -> guided re-parses the conforming body straight back into // …then raw -> guided re-parses the conforming body straight back into
// the bare stepper — no wizard, since the content isn't empty. // the bare stepper — no wizard, since the content isn't empty.
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
expect(find.byType(LinearProgressIndicator), findsOneWidget); expect(find.byType(LinearProgressIndicator), findsOneWidget);
expect( expect(find.text('Step 1 of 2'), findsNothing); // wizard was skipped
find.bySemanticsLabel('Step 1 of 2'),
findsNothing,
); // wizard was skipped
}, },
); );
testWidgets('freeform template offers only View and Raw', (tester) async { testWidgets('freeform template offers only View and Raw', (tester) async {
final emitted = await pumpEditor(tester, initialTemplate: blank); final emitted = await pumpEditor(tester, initialTemplate: blank);
expect(find.bySemanticsLabel('Guided'), findsNothing); expect(find.text('Guided'), findsNothing);
expect(find.bySemanticsLabel('View'), findsOneWidget); expect(find.text('View'), findsOneWidget);
expect(find.bySemanticsLabel('Raw'), findsOneWidget); expect(find.text('Raw'), findsOneWidget);
await tester.enterText(find.byType(TextField), 'free text'); await tester.enterText(find.byType(TextField), 'free text');
await tester.pump(); await tester.pump();
@ -94,20 +89,15 @@ void main() {
initialTemplate: spec, initialTemplate: spec,
initialMode: NoteEditorMode.raw, initialMode: NoteEditorMode.raw,
); );
expect( expect(find.text('Guided'), findsOneWidget); // structured: Guided offered
find.bySemanticsLabel('Guided'),
findsOneWidget,
); // structured: Guided offered
await tester.tap( await tester.tap(find.text('LLM design spec').first); // open the menu
find.byIcon(Icons.assignment_outlined).first,
); // open the menu
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.byIcon(Icons.note_outlined).last); await tester.tap(find.text('Blank').last);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Freeform now: Guided is no longer offered. // Freeform now: Guided is no longer offered.
expect(find.bySemanticsLabel('Guided'), findsNothing); expect(find.text('Guided'), findsNothing);
}); });
testWidgets('detects a conforming note (no template given) as guided', ( testWidgets('detects a conforming note (no template given) as guided', (
@ -120,7 +110,7 @@ void main() {
find.byType(LinearProgressIndicator), find.byType(LinearProgressIndicator),
findsOneWidget, findsOneWidget,
); // guided by default ); // guided by default
expect(find.bySemanticsLabel('Exit guided'), findsOneWidget); expect(find.byTooltip('Exit guided'), findsOneWidget);
}); });
testWidgets('detects a legacy note (no template given) as freeform raw', ( testWidgets('detects a legacy note (no template given) as freeform raw', (
@ -130,7 +120,7 @@ void main() {
// Non-conforming → blank/raw, no guided stepper offered. // Non-conforming → blank/raw, no guided stepper offered.
expect(find.byType(LinearProgressIndicator), findsNothing); expect(find.byType(LinearProgressIndicator), findsNothing);
expect(find.bySemanticsLabel('Guided'), findsNothing); expect(find.text('Guided'), findsNothing);
}); });
testWidgets('initialMode preview opens directly in the rendered view', ( testWidgets('initialMode preview opens directly in the rendered view', (
@ -157,7 +147,7 @@ void main() {
initialMode: NoteEditorMode.preview, initialMode: NoteEditorMode.preview,
); );
await tester.tap(find.bySemanticsLabel('Raw')); await tester.tap(find.text('Raw'));
await tester.pump(); await tester.pump();
final raw = tester.widget<TextField>(find.byType(TextField)); final raw = tester.widget<TextField>(find.byType(TextField));

View File

@ -6,7 +6,6 @@ import 'package:todo/ui/markdown_view.dart';
import 'package:todo/ui/note_editor.dart'; import 'package:todo/ui/note_editor.dart';
import 'note_editor_harness.dart'; import 'note_editor_harness.dart';
import 'text_free_guard.dart';
void main() { void main() {
testWidgets( testWidgets(
@ -18,10 +17,10 @@ void main() {
initialMode: NoteEditorMode.raw, initialMode: NoteEditorMode.raw,
); );
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
expect(find.bySemanticsLabel('Step 1 of 2'), findsOneWidget); expect(find.text('Step 1 of 2'), findsOneWidget);
expect(find.byType(DropdownButtonFormField<Priority>), findsOneWidget); expect(find.byType(DropdownButtonFormField<Priority>), findsOneWidget);
expect(find.byType(LinearProgressIndicator), findsNothing); expect(find.byType(LinearProgressIndicator), findsNothing);
}, },
@ -35,17 +34,17 @@ void main() {
initialTemplate: spec, initialTemplate: spec,
initialMode: NoteEditorMode.raw, initialMode: NoteEditorMode.raw,
); );
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
expect(find.bySemanticsLabel('Step 2 of 2'), findsOneWidget); expect(find.text('Step 2 of 2'), findsOneWidget);
expect(find.byType(DropdownButtonFormField<String>), findsOneWidget); expect(find.byType(DropdownButtonFormField<String>), findsOneWidget);
await tester.tap(find.bySemanticsLabel('Back')); await tester.tap(find.text('Back'));
await tester.pump(); await tester.pump();
expect(find.bySemanticsLabel('Step 1 of 2'), findsOneWidget); expect(find.text('Step 1 of 2'), findsOneWidget);
}, },
); );
@ -57,21 +56,19 @@ void main() {
initialTemplate: spec, initialTemplate: spec,
initialMode: NoteEditorMode.raw, initialMode: NoteEditorMode.raw,
); );
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
await tester.tap( await tester.tap(find.text('LLM design spec').first); // open the menu
find.byIcon(Icons.assignment_outlined).first,
); // open the menu
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byIcon(Icons.note_outlined), findsNothing); expect(find.text('Blank'), findsNothing);
// Select the (only) offered template, exercising the dropdown's onChanged. // Select the (only) offered template, exercising the dropdown's onChanged.
await tester.tap(find.byIcon(Icons.assignment_outlined).last); await tester.tap(find.text('LLM design spec').last);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.bySemanticsLabel('Step 2 of 2'), findsOneWidget); expect(find.text('Step 2 of 2'), findsOneWidget);
}); });
testWidgets( testWidgets(
@ -84,22 +81,22 @@ void main() {
initialMode: NoteEditorMode.raw, initialMode: NoteEditorMode.raw,
onPriorityChanged: (p) => committed = p, onPriorityChanged: (p) => committed = p,
); );
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
await tester.tap(find.byType(DropdownButtonFormField<Priority>)); await tester.tap(find.byType(DropdownButtonFormField<Priority>));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('High').last); await tester.tap(find.text('High').last);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('Start')); await tester.tap(find.text('Start'));
await tester.pump(); await tester.pump();
expect(committed, Priority.high); expect(committed, Priority.high);
expect(find.byType(LinearProgressIndicator), findsOneWidget); expect(find.byType(LinearProgressIndicator), findsOneWidget);
expect(find.bySemanticsLabel('Exit guided'), findsOneWidget); expect(find.byTooltip('Exit guided'), findsOneWidget);
}, },
); );
@ -113,19 +110,16 @@ void main() {
initialMode: NoteEditorMode.raw, initialMode: NoteEditorMode.raw,
onChromeVisibleChanged: chromeVisible.add, onChromeVisibleChanged: chromeVisible.add,
); );
await tester.tap(find.bySemanticsLabel('Guided')); await tester.tap(find.text('Guided'));
await tester.pump(); await tester.pump();
expect(chromeVisible.last, false); expect(chromeVisible.last, false);
await tester.tap(find.bySemanticsLabel('Cancel')); await tester.tap(find.byTooltip('Cancel'));
await tester.pump(); await tester.pump();
expect(chromeVisible.last, true); expect(chromeVisible.last, true);
expect(find.byType(LinearProgressIndicator), findsNothing); expect(find.byType(LinearProgressIndicator), findsNothing);
expect( expect(find.text('Raw'), findsOneWidget); // chrome's mode selector is back
find.bySemanticsLabel('Raw'),
findsOneWidget,
); // chrome's mode selector is back
}); });
testWidgets('exiting bare Guided via the back arrow restores the chrome', ( testWidgets('exiting bare Guided via the back arrow restores the chrome', (
@ -141,11 +135,11 @@ void main() {
); );
expect(find.byType(LinearProgressIndicator), findsOneWidget); expect(find.byType(LinearProgressIndicator), findsOneWidget);
await tester.tap(find.bySemanticsLabel('Exit guided')); await tester.tap(find.byTooltip('Exit guided'));
await tester.pump(); await tester.pump();
expect(chromeVisible, contains(true)); expect(chromeVisible, contains(true));
expect(find.bySemanticsLabel('Raw'), findsOneWidget); expect(find.text('Raw'), findsOneWidget);
}); });
testWidgets('last step shows Done instead of Next', (tester) async { testWidgets('last step shows Done instead of Next', (tester) async {
@ -153,12 +147,12 @@ void main() {
// Navigate to the final step. // Navigate to the final step.
for (var i = 0; i < spec.sections.length - 1; i++) { for (var i = 0; i < spec.sections.length - 1; i++) {
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
} }
expect(find.bySemanticsLabel('Done'), findsOneWidget); expect(find.text('Done'), findsOneWidget);
expect(find.bySemanticsLabel('Next'), findsNothing); expect(find.text('Next'), findsNothing);
expect( expect(
find.text('${spec.sections.length} / ${spec.sections.length}'), find.text('${spec.sections.length} / ${spec.sections.length}'),
findsOneWidget, findsOneWidget,
@ -173,10 +167,10 @@ void main() {
await tester.pump(); await tester.pump();
for (var i = 0; i < spec.sections.length - 1; i++) { for (var i = 0; i < spec.sections.length - 1; i++) {
await tester.tap(find.bySemanticsLabel('Next')); await tester.tap(find.text('Next'));
await tester.pump(); await tester.pump();
} }
await tester.tap(find.bySemanticsLabel('Done')); await tester.tap(find.text('Done'));
await tester.pump(); await tester.pump();
expect(find.byType(LinearProgressIndicator), findsNothing); expect(find.byType(LinearProgressIndicator), findsNothing);

View File

@ -7,8 +7,6 @@ import 'package:todo/data/note.dart';
import 'package:todo/ui/note_grid_tile.dart'; import 'package:todo/ui/note_grid_tile.dart';
import 'notes_list_harness.dart'; import 'notes_list_harness.dart';
import 'package:todo/ui/enum_glyphs.dart';
import 'package:todo/ui/empty_notes_cue.dart';
void _phone(WidgetTester t) { void _phone(WidgetTester t) {
t.view t.view
@ -55,10 +53,10 @@ void main() {
); );
expect(find.text('Buy milk'), findsOneWidget); expect(find.text('Buy milk'), findsOneWidget);
expect(find.byIcon(priorityIcon(Priority.high)), findsOneWidget); expect(find.text('High'), findsOneWidget);
expect(find.byIcon(statusIcon(Status.inProgress)), findsOneWidget); expect(find.text('In progress'), findsOneWidget);
expect(find.textContaining('Two litres'), findsNothing); expect(find.textContaining('Two litres'), findsNothing);
expect(find.byIcon(Icons.history), findsNothing); expect(find.textContaining('edited'), findsNothing);
expect(find.byTooltip('Quick actions'), findsNothing); expect(find.byTooltip('Quick actions'), findsNothing);
}); });
@ -95,7 +93,7 @@ void main() {
testWidgets('an empty note reads (empty)', (t) async { testWidgets('an empty note reads (empty)', (t) async {
_phone(t); _phone(t);
await pumpList(t, seed: [note('a', '')]); await pumpList(t, seed: [note('a', '')]);
expect(find.text(kEmptyTitle), findsOneWidget); expect(find.text('(empty)'), findsOneWidget);
}); });
testWidgets('tap opens the note', (t) async { testWidgets('tap opens the note', (t) async {
@ -105,8 +103,8 @@ void main() {
await t.tap(find.text('Open me')); await t.tap(find.text('Open me'));
await t.pumpAndSettle(); await t.pumpAndSettle();
expect(find.bySemanticsLabel('Priority'), findsOneWidget); expect(find.text('Priority'), findsOneWidget);
expect(find.bySemanticsLabel('View'), findsOneWidget); expect(find.text('View'), findsOneWidget);
}); });
testWidgets('long-press opens the sheet with body, dates and actions', ( testWidgets('long-press opens the sheet with body, dates and actions', (
@ -121,18 +119,12 @@ void main() {
await _openSheet(t, 'Buy milk'); await _openSheet(t, 'Buy milk');
expect(find.textContaining('Two litres of oat'), findsOneWidget); expect(find.textContaining('Two litres of oat'), findsOneWidget);
expect(find.byIcon(Icons.history), findsOneWidget); expect(find.textContaining('Edited'), findsOneWidget);
expect( expect(find.textContaining('Created'), findsOneWidget);
find.descendant( await t.tap(find.text('In progress'));
of: find.byType(BottomSheet),
matching: find.byIcon(Icons.add),
),
findsOneWidget,
);
await t.tap(find.bySemanticsLabel('In progress'));
await t.pump(); await t.pump();
expect((await repo.listNotes()).single.status, Status.inProgress); expect((await repo.listNotes()).single.status, Status.inProgress);
expect(find.bySemanticsLabel('Delete note'), findsOneWidget); expect(find.text('Delete note'), findsOneWidget);
}); });
testWidgets('a title-only note adds no body to the sheet', (t) async { testWidgets('a title-only note adds no body to the sheet', (t) async {
@ -142,7 +134,7 @@ void main() {
await _openSheet(t, 'Just a title'); await _openSheet(t, 'Just a title');
expect(find.text('Just a title'), findsNWidgets(2)); expect(find.text('Just a title'), findsNWidgets(2));
expect(find.byIcon(Icons.history), findsOneWidget); expect(find.textContaining('Edited'), findsOneWidget);
}); });
testWidgets('the sheet can delete a grid note', (t) async { testWidgets('the sheet can delete a grid note', (t) async {
@ -150,9 +142,9 @@ void main() {
final repo = await pumpList(t, seed: [note('a', 'Delete me')]); final repo = await pumpList(t, seed: [note('a', 'Delete me')]);
await _openSheet(t, 'Delete me'); await _openSheet(t, 'Delete me');
await t.tap(find.bySemanticsLabel('Delete note')); await t.tap(find.text('Delete note'));
await t.pumpAndSettle(); await t.pumpAndSettle();
await t.tap(find.byKey(const ValueKey('confirm-delete'))); await t.tap(find.text('Delete'));
await t.pumpAndSettle(); await t.pumpAndSettle();
expect(await repo.listNotes(), isEmpty); expect(await repo.listNotes(), isEmpty);
@ -162,7 +154,7 @@ void main() {
_phone(t); _phone(t);
final repo = await pumpList(t); final repo = await pumpList(t);
expect(find.byType(EmptyNotesCue), findsOneWidget); expect(find.textContaining('No notes'), findsOneWidget);
expect(repo.lastFilter!.statuses, {Status.todo, Status.inProgress}); expect(repo.lastFilter!.statuses, {Status.todo, Status.inProgress});
expect(t.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse); expect(t.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
}); });

View File

@ -7,14 +7,13 @@ import 'package:todo/ui/notes_list_screen.dart';
import 'fake_note_repository.dart'; import 'fake_note_repository.dart';
import 'notes_list_harness.dart'; import 'notes_list_harness.dart';
import 'text_free_guard.dart';
/// Opens a date field's menu and picks [entry]. /// Opens a date field's menu and picks [entry].
Future<void> pickRange(WidgetTester tester, String field, String entry) async { Future<void> pickRange(WidgetTester tester, String field, String entry) async {
await tester.tap(find.bySemanticsLabel(field)); await tester.tap(find.byTooltip(field));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
await tester.tap(spoken(entry).last); await tester.tap(find.text(entry).last);
await tester.pump(); await tester.pump();
} }
@ -69,10 +68,10 @@ void main() {
], ],
); );
expect(find.text('0m'), findsOneWidget); expect(find.textContaining('just now'), findsOneWidget);
expect(find.text('5m'), findsOneWidget); expect(find.textContaining('5m ago'), findsOneWidget);
expect(find.text('2h'), findsOneWidget); expect(find.textContaining('2h ago'), findsOneWidget);
expect(find.text('3d'), findsOneWidget); expect(find.textContaining('3d ago'), findsOneWidget);
}); });
testWidgets('Clear all resets the filter sheet to the default', ( testWidgets('Clear all resets the filter sheet to the default', (
@ -83,9 +82,9 @@ void main() {
await tester.tap(find.byIcon(Icons.filter_list)); await tester.tap(find.byIcon(Icons.filter_list));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.bySemanticsLabel('Done')); // non-default status await tester.tap(find.text('Done')); // add a non-default status
await tester.pump(); await tester.pump();
await tester.tap(find.bySemanticsLabel('Clear all')); await tester.tap(find.text('Clear all'));
await tester.pump(); await tester.pump();
await tapApply(tester); await tapApply(tester);
await tester.pump(); await tester.pump();
@ -140,7 +139,7 @@ void main() {
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.bySemanticsLabel('High')); // priority chip toggle await tester.tap(find.text('High')); // priority chip toggle
await pickRange(tester, 'Last updated', 'Today'); await pickRange(tester, 'Last updated', 'Today');
await tapApply(tester); await tapApply(tester);
await tester.pump(); await tester.pump();
@ -179,10 +178,10 @@ void main() {
testWidgets('per-note sheet changes priority via a chip', (tester) async { testWidgets('per-note sheet changes priority via a chip', (tester) async {
final repo = await pumpList(tester, seed: [note('a', 'Repriortise me')]); final repo = await pumpList(tester, seed: [note('a', 'Repriortise me')]);
await tester.tap(find.bySemanticsLabel('Quick actions')); await tester.tap(find.byTooltip('Quick actions'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.bySemanticsLabel('Low')); // Medium → Low await tester.tap(find.text('Low')); // default is Medium → change to Low
await tester.pump(); await tester.pump();
expect((await repo.listNotes()).single.priority, Priority.low); expect((await repo.listNotes()).single.priority, Priority.low);
@ -197,7 +196,7 @@ void main() {
// The detail screen shows the note title in its app bar plus the // The detail screen shows the note title in its app bar plus the
// Priority/Status meta dropdowns and the editor mode toggle. // Priority/Status meta dropdowns and the editor mode toggle.
expect(find.bySemanticsLabel('Priority'), findsOneWidget); expect(find.text('Priority'), findsOneWidget);
expect(find.bySemanticsLabel('View'), findsOneWidget); expect(find.text('View'), findsOneWidget);
}); });
} }

View File

@ -37,7 +37,7 @@ void main() {
) async { ) async {
await pumpList(tester, seed: [note('a', 'Buy milk')]); await pumpList(tester, seed: [note('a', 'Buy milk')]);
await editNoteAndSwipeBack(tester); await editNoteAndSwipeBack(tester);
expect(find.byIcon(Icons.search), findsOneWidget); expect(find.text('Search notes…'), findsOneWidget);
expect(textFieldFocused(), isFalse); expect(textFieldFocused(), isFalse);
}); });
@ -48,7 +48,7 @@ void main() {
await tester.tap(find.byType(TextField).first); await tester.tap(find.byType(TextField).first);
await tester.pump(); await tester.pump();
await editNoteAndSwipeBack(tester); await editNoteAndSwipeBack(tester);
expect(find.byIcon(Icons.search), findsOneWidget); expect(find.text('Search notes…'), findsOneWidget);
expect(textFieldFocused(), isFalse); expect(textFieldFocused(), isFalse);
}); });
} }

View File

@ -10,7 +10,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:todo/data/app_settings.dart'; import 'package:todo/data/app_settings.dart';
import 'package:todo/data/note.dart'; import 'package:todo/data/note.dart';
import 'package:todo/ui/notes_list_screen.dart'; import 'package:todo/ui/notes_list_screen.dart';
import 'package:todo/ui/text_free_localizations.dart';
import 'fake_note_repository.dart'; import 'fake_note_repository.dart';
@ -43,8 +42,6 @@ Future<FakeNoteRepository> pumpList(
addTearDown(settings.dispose); addTearDown(settings.dispose);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
// As in main.dart: Material's own button tooltips are blanked.
localizationsDelegates: kTextFreeLocalizations,
home: NotesListScreen(repository: repo, appSettings: settings), home: NotesListScreen(repository: repo, appSettings: settings),
), ),
); );
@ -56,8 +53,7 @@ Future<FakeNoteRepository> pumpList(
/// sheet, so on a short viewport it legitimately sits below the fold: /// sheet, so on a short viewport it legitimately sits below the fold:
/// scroll it into view first, as a user would. /// scroll it into view first, as a user would.
Future<void> tapApply(WidgetTester tester) async { Future<void> tapApply(WidgetTester tester) async {
final apply = find.widgetWithIcon(FilledButton, Icons.check); await tester.ensureVisible(find.text('Apply'));
await tester.ensureVisible(apply);
await tester.pump(); await tester.pump();
await tester.tap(apply); await tester.tap(find.text('Apply'));
} }

View File

@ -79,10 +79,7 @@ void main() {
if (axisDirectionToAxis(s.axisDirection) == Axis.vertical) if (axisDirectionToAxis(s.axisDirection) == Axis.vertical)
expect(s.position.maxScrollExtent, 0); expect(s.position.maxScrollExtent, 0);
} }
expect( expect(find.text('Apply').hitTestable(), findsOneWidget);
find.widgetWithIcon(FilledButton, Icons.check).hitTestable(),
findsOneWidget,
);
expect(find.text('Repo tasks'), findsNothing); expect(find.text('Repo tasks'), findsNothing);
expect(find.text('Ideas'), findsNothing); expect(find.text('Ideas'), findsNothing);
expect(find.byType(ActionChip), findsNothing); expect(find.byType(ActionChip), findsNothing);

View File

@ -53,15 +53,15 @@ void main() {
expect(find.text('make check'), findsOneWidget); expect(find.text('make check'), findsOneWidget);
expect(find.text('claude'), findsOneWidget); expect(find.text('claude'), findsOneWidget);
expect(find.text('abc 0'), findsOneWidget); expect(find.text('abc 0'), findsOneWidget);
expect(find.byIcon(Icons.fact_check_outlined), findsOneWidget); expect(find.text('Done check'), findsOneWidget);
expect(find.byIcon(Icons.verified_outlined), findsOneWidget); expect(find.text('Evidence'), findsOneWidget);
expect(find.byType(TextField), findsNothing); expect(find.byType(TextField), findsNothing);
}); });
testWidgets('a plain idea shows no task fields', (tester) async { testWidgets('a plain idea shows no task fields', (tester) async {
await pumpActions(tester, note('i', 'An idea')); await pumpActions(tester, note('i', 'An idea'));
expect(find.byIcon(Icons.folder_outlined), findsNothing); expect(find.text('Repo'), findsNothing);
expect(find.byIcon(Icons.fact_check_outlined), findsNothing); expect(find.text('Done check'), findsNothing);
expect(find.byIcon(Icons.verified_outlined), findsNothing); expect(find.text('Evidence'), findsNothing);
}); });
} }

View File

@ -7,9 +7,6 @@ import 'package:todo/ui/notes_list_screen.dart';
import 'fake_note_repository.dart'; import 'fake_note_repository.dart';
import 'notes_list_harness.dart'; import 'notes_list_harness.dart';
import 'package:todo/ui/enum_glyphs.dart';
import 'package:todo/ui/note_grid_tile.dart';
import 'package:todo/ui/empty_notes_cue.dart';
void main() { void main() {
testWidgets('renders notes with a status · priority · time subtitle', ( testWidgets('renders notes with a status · priority · time subtitle', (
@ -21,8 +18,8 @@ void main() {
); );
expect(find.text('First note'), findsOneWidget); expect(find.text('First note'), findsOneWidget);
expect(find.byIcon(statusIcon(Status.todo)), findsOneWidget); expect(find.textContaining('To do'), findsOneWidget);
expect(find.byIcon(priorityIcon(Priority.high)), findsOneWidget); expect(find.textContaining('High'), findsOneWidget);
}); });
testWidgets('defaults to hiding Done/Abandoned with no filter badge', ( testWidgets('defaults to hiding Done/Abandoned with no filter badge', (
@ -54,7 +51,7 @@ void main() {
await tester.tap(find.byIcon(Icons.sort)); await tester.tap(find.byIcon(Icons.sort));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); // menu open await tester.pump(const Duration(milliseconds: 300)); // menu open
await tester.tap(find.bySemanticsLabel('Alphabetical').last); await tester.tap(find.text('Alphabetical').last);
await tester.pump(); await tester.pump();
expect(repo.lastSort, NoteSort.alphabetical); expect(repo.lastSort, NoteSort.alphabetical);
@ -66,9 +63,9 @@ void main() {
await tester.tap(find.byIcon(Icons.filter_list)); await tester.tap(find.byIcon(Icons.filter_list));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); // sheet open await tester.pump(const Duration(milliseconds: 300)); // sheet open
await tester.tap(find.bySemanticsLabel('Done')); await tester.tap(find.text('Done'));
await tester.pump(); await tester.pump();
await tapApply(tester); await tester.tap(find.text('Apply'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); // sheet close await tester.pump(const Duration(milliseconds: 300)); // sheet close
@ -80,16 +77,16 @@ void main() {
testWidgets('per-note sheet deletes the note', (tester) async { testWidgets('per-note sheet deletes the note', (tester) async {
final repo = await pumpList(tester, seed: [note('a', 'Delete me')]); final repo = await pumpList(tester, seed: [note('a', 'Delete me')]);
await tester.tap(find.bySemanticsLabel('Quick actions')); await tester.tap(find.byTooltip('Quick actions'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); // sheet open await tester.pump(const Duration(milliseconds: 300)); // sheet open
await tester.tap(find.bySemanticsLabel('Delete note')); await tester.tap(find.text('Delete note'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// Delete is now confirmed on this path too: it is irreversible, has no // Delete is now confirmed on this path too: it is irreversible, has no
// undo, and is one Tab from a Return in the sheet's chip rows. // undo, and is one Tab from a Return in the sheet's chip rows.
expect(find.bySemanticsLabel('Delete note?'), findsOneWidget); expect(find.text('Delete note?'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('confirm-delete'))); await tester.tap(find.text('Delete'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(await repo.listNotes(), isEmpty); expect(await repo.listNotes(), isEmpty);
@ -98,12 +95,12 @@ void main() {
testWidgets('cancelling the sheet delete keeps the note', (tester) async { testWidgets('cancelling the sheet delete keeps the note', (tester) async {
final repo = await pumpList(tester, seed: [note('a', 'Keep me')]); final repo = await pumpList(tester, seed: [note('a', 'Keep me')]);
await tester.tap(find.bySemanticsLabel('Quick actions')); await tester.tap(find.byTooltip('Quick actions'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.bySemanticsLabel('Delete note')); await tester.tap(find.text('Delete note'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('confirm-cancel'))); await tester.tap(find.text('Cancel'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(await repo.listNotes(), hasLength(1)); expect(await repo.listNotes(), hasLength(1));
@ -112,10 +109,10 @@ void main() {
testWidgets('per-note sheet changes status via a chip', (tester) async { testWidgets('per-note sheet changes status via a chip', (tester) async {
final repo = await pumpList(tester, seed: [note('a', 'Change me')]); final repo = await pumpList(tester, seed: [note('a', 'Change me')]);
await tester.tap(find.bySemanticsLabel('Quick actions')); await tester.tap(find.byTooltip('Quick actions'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 300)); await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.bySemanticsLabel('In progress')); await tester.tap(find.text('In progress'));
await tester.pump(); await tester.pump();
expect((await repo.listNotes()).single.status, Status.inProgress); expect((await repo.listNotes()).single.status, Status.inProgress);
@ -125,6 +122,6 @@ void main() {
await pumpList(tester); // no seed await pumpList(tester); // no seed
// The default filter hides Done/Abandoned, so it's the "no match" // The default filter hides Done/Abandoned, so it's the "no match"
// variant rather than "No notes yet" — either way, an empty message. // variant rather than "No notes yet" — either way, an empty message.
expect(find.byType(EmptyNotesCue), findsOneWidget); expect(find.textContaining('No notes'), findsOneWidget);
}); });
} }

View File

@ -24,7 +24,6 @@ import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
import 'settings_screen_harness.dart'; import 'settings_screen_harness.dart';
import 'text_free_guard.dart';
/// Stub file picker that returns a fixed in-memory file (no disk I/O, so the /// Stub file picker that returns a fixed in-memory file (no disk I/O, so the
/// `_import` flow stays timer-free and deterministic under the widget tester). /// `_import` flow stays timer-free and deterministic under the widget tester).
@ -97,12 +96,12 @@ void main() {
], ],
); );
await tester.tap(find.byIcon(Icons.sync)); await tester.tap(find.text('Sync settings'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// _export does real file I/O on desktop, so drive it under runAsync. // _export does real file I/O on desktop, so drive it under runAsync.
await tester.runAsync(() async { await tester.runAsync(() async {
await tester.tap(find.bySemanticsLabel('Export notes')); await tester.tap(find.text('Export notes'));
await Future<void>.delayed(const Duration(milliseconds: 50)); await Future<void>.delayed(const Duration(milliseconds: 50));
}); });
await tester.pump(); await tester.pump();
@ -117,16 +116,16 @@ void main() {
) async { ) async {
await pumpSettings(tester, repository: _ExplodingRepo()); await pumpSettings(tester, repository: _ExplodingRepo());
await tester.tap(find.byIcon(Icons.sync)); await tester.tap(find.text('Sync settings'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.runAsync(() async { await tester.runAsync(() async {
await tester.tap(find.bySemanticsLabel('Export notes')); await tester.tap(find.text('Export notes'));
await Future<void>.delayed(const Duration(milliseconds: 50)); await Future<void>.delayed(const Duration(milliseconds: 50));
}); });
await tester.pump(); await tester.pump();
expect(spoken('Export failed'), findsOneWidget); expect(find.textContaining('Export failed'), findsOneWidget);
}); });
testWidgets('Import notes reads the picked file and merges', ( testWidgets('Import notes reads the picked file and merges', (
@ -150,10 +149,10 @@ void main() {
final repo = await pumpSettings(tester); final repo = await pumpSettings(tester);
await tester.tap(find.byIcon(Icons.sync)); await tester.tap(find.text('Sync settings'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('Import notes')); await tester.tap(find.text('Import notes'));
await tester.pump(); // openFile resolves (in-memory) await tester.pump(); // openFile resolves (in-memory)
await tester.pump(); // read + parse + merge + setState await tester.pump(); // read + parse + merge + setState
@ -166,10 +165,10 @@ void main() {
FileSelectorPlatform.instance = _FakeFileSelector(null); // cancelled FileSelectorPlatform.instance = _FakeFileSelector(null); // cancelled
final repo = await pumpSettings(tester); final repo = await pumpSettings(tester);
await tester.tap(find.byIcon(Icons.sync)); await tester.tap(find.text('Sync settings'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('Import notes')); await tester.tap(find.text('Import notes'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
@ -184,14 +183,14 @@ void main() {
FileSelectorPlatform.instance = _ThrowingFileSelector(); FileSelectorPlatform.instance = _ThrowingFileSelector();
final repo = await pumpSettings(tester); final repo = await pumpSettings(tester);
await tester.tap(find.byIcon(Icons.sync)); await tester.tap(find.text('Sync settings'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel('Import notes')); await tester.tap(find.text('Import notes'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(spoken('Import failed'), findsOneWidget); expect(find.textContaining('Import failed'), findsOneWidget);
expect(await repo.listNotes(), isEmpty); expect(await repo.listNotes(), isEmpty);
}); });
}); });

View File

@ -26,7 +26,6 @@ import 'package:todo/sync/notes_markdown.dart';
import 'package:todo/sync/sync_settings.dart'; import 'package:todo/sync/sync_settings.dart';
import 'package:todo/ui/github_mirror_screen.dart'; import 'package:todo/ui/github_mirror_screen.dart';
import 'package:todo/ui/settings_screen.dart'; import 'package:todo/ui/settings_screen.dart';
import 'package:todo/ui/text_free_localizations.dart';
import 'fake_note_repository.dart'; import 'fake_note_repository.dart';
import 'fake_secure_storage.dart'; import 'fake_secure_storage.dart';
@ -94,8 +93,6 @@ Future<FakeNoteRepository> pumpSettings(
addTearDown(repo.close); addTearDown(repo.close);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
// As in main.dart: Material's own button tooltips are blanked.
localizationsDelegates: kTextFreeLocalizations,
home: SettingsScreen( home: SettingsScreen(
initial: initial, initial: initial,
repository: repo, repository: repo,

View File

@ -61,25 +61,30 @@ class _ThrowingFileSelector extends FileSelectorPlatform
} }
void main() { void main() {
testWidgets('Enable advanced toggles and persists locally with no client', ( testWidgets(
tester, 'Enable advanced toggles and persists locally with no client',
) async { (tester) async {
final appSettings = ValueNotifier(const AppSettings(advancedMode: false)); final appSettings = ValueNotifier(
const AppSettings(advancedMode: false),
);
await pumpSettings( await pumpSettings(
tester, tester,
appSettings: appSettings, appSettings: appSettings,
firebaseFactory: () async => null, firebaseFactory: () async => null,
); );
await tester.tap(find.byIcon(Icons.tune)); await tester.tap(find.text('Enable advanced'));
await tester.pump(); await tester.pump();
expect(appSettings.value.advancedMode, isTrue); expect(appSettings.value.advancedMode, isTrue);
final reloaded = await AppSettings.load(); final reloaded = await AppSettings.load();
expect(reloaded.advancedMode, isTrue); expect(reloaded.advancedMode, isTrue);
}); },
);
testWidgets('Enable advanced mirrors the toggle to Firebase', (tester) async { testWidgets('Enable advanced mirrors the toggle to Firebase', (
tester,
) async {
String? putPath; String? putPath;
final firebase = FirebaseRestClient( final firebase = FirebaseRestClient(
databaseUrl: 'https://x-rtdb.europe-west1.firebasedatabase.app', databaseUrl: 'https://x-rtdb.europe-west1.firebasedatabase.app',
@ -105,7 +110,7 @@ void main() {
firebaseFactory: () async => firebase, firebaseFactory: () async => firebase,
); );
await tester.tap(find.byIcon(Icons.tune)); await tester.tap(find.text('Enable advanced'));
await tester.pump(); await tester.pump();
expect(appSettings.value.advancedMode, isTrue); expect(appSettings.value.advancedMode, isTrue);
@ -115,14 +120,16 @@ void main() {
testWidgets( testWidgets(
'Enable advanced still persists locally when opening Firebase throws', 'Enable advanced still persists locally when opening Firebase throws',
(tester) async { (tester) async {
final appSettings = ValueNotifier(const AppSettings(advancedMode: false)); final appSettings = ValueNotifier(
const AppSettings(advancedMode: false),
);
await pumpSettings( await pumpSettings(
tester, tester,
appSettings: appSettings, appSettings: appSettings,
firebaseFactory: () async => throw FirebaseAuthError('wrong account'), firebaseFactory: () async => throw FirebaseAuthError('wrong account'),
); );
await tester.tap(find.byIcon(Icons.tune)); await tester.tap(find.text('Enable advanced'));
await tester.pump(); await tester.pump();
// A signed-in-as-wrong-account device must not lose the local toggle. // A signed-in-as-wrong-account device must not lose the local toggle.
@ -130,7 +137,9 @@ void main() {
}, },
); );
testWidgets('Enable advanced logs a settings_toggle event', (tester) async { testWidgets('Enable advanced logs a settings_toggle event', (
tester,
) async {
const analytics = AnalyticsService(nodeId: 'device-a'); const analytics = AnalyticsService(nodeId: 'device-a');
final appSettings = ValueNotifier(const AppSettings(advancedMode: false)); final appSettings = ValueNotifier(const AppSettings(advancedMode: false));
await pumpSettings( await pumpSettings(
@ -140,7 +149,7 @@ void main() {
firebaseFactory: () async => null, firebaseFactory: () async => null,
); );
await tester.tap(find.byIcon(Icons.tune)); await tester.tap(find.text('Enable advanced'));
await tester.pump(); await tester.pump();
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
@ -153,9 +162,9 @@ void main() {
await pumpSettings(tester); await pumpSettings(tester);
// The slim screen only links out; neither sync surface's own widgets // The slim screen only links out; neither sync surface's own widgets
// should be inlined here anymore. // should be inlined here anymore.
expect(find.byIcon(Icons.sync), findsOneWidget); expect(find.text('Sync settings'), findsOneWidget);
expect(find.byIcon(Icons.cloud_sync), findsOneWidget); expect(find.text('Advanced sync (GitHub)'), findsOneWidget);
expect(find.bySemanticsLabel('Connect GitHub'), findsNothing); expect(find.text('Connect GitHub'), findsNothing);
expect(find.text('Sign in with Google'), findsNothing); expect(find.text('Sign in with Google'), findsNothing);
}); });
@ -164,7 +173,7 @@ void main() {
) async { ) async {
await pumpSettings(tester); await pumpSettings(tester);
await tester.tap(find.byIcon(Icons.sync)); await tester.tap(find.text('Sync settings'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(SyncSettingsScreen), findsOneWidget); expect(find.byType(SyncSettingsScreen), findsOneWidget);
@ -177,7 +186,7 @@ void main() {
const initial = SyncSettings(owner: 'o', repo: 'r', token: 'tok'); const initial = SyncSettings(owner: 'o', repo: 'r', token: 'tok');
final repo = await pumpSettings(tester, initial: initial); final repo = await pumpSettings(tester, initial: initial);
await tester.tap(find.byIcon(Icons.cloud_sync)); await tester.tap(find.text('Advanced sync (GitHub)'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(GitHubMirrorScreen), findsOneWidget); expect(find.byType(GitHubMirrorScreen), findsOneWidget);

View File

@ -1,49 +0,0 @@
/// The "no words" guard: kuhy's textgate rule says nothing he sees carries
/// app-written text. This walks every painted string in the widget tree and
/// fails on any run of two letters that is not note content.
///
/// Deliberately NOT named `*_test.dart`: it is a helper with no `main()`.
library;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
final RegExp _word = RegExp('[A-Za-z]{2,}');
/// Finds a node whose spoken (semantics) label contains [part] literally.
/// The old visible sentences live on as spoken labels, so tests that used
/// `find.textContaining` now look here.
Finder spoken(String part) =>
find.bySemanticsLabel(RegExp(RegExp.escape(part)));
/// Every string the tree paints: each [RichText] (which is what [Text] builds)
/// and every non-empty [Tooltip] message, since a tooltip is shown on
/// long-press. Text being typed lives in an [EditableText] and is the user's,
/// so it is never painted through a [RichText] and is not collected.
List<String> paintedStrings(WidgetTester tester) => [
for (final w in tester.widgetList<RichText>(find.byType(RichText)))
w.text.toPlainText(),
for (final t in tester.widgetList<Tooltip>(find.byType(Tooltip)))
if ((t.message ?? '').isNotEmpty) t.message!,
];
/// Fails if any painted string still holds a word once every [content]
/// string (note text, typed values: things kuhy wrote) is removed from it.
///
/// An empty tree is a failure too: a guard that saw nothing proves nothing.
void expectNoChromeWords(
WidgetTester tester, {
List<String> content = const [],
}) {
final painted = paintedStrings(tester);
expect(painted, isNotEmpty, reason: 'guard saw no painted strings');
final offenders = <String>[];
for (final s in painted) {
var rest = s;
for (final c in content) {
rest = rest.replaceAll(c, '');
}
if (_word.hasMatch(rest)) offenders.add(s);
}
expect(offenders, isEmpty, reason: 'app-written words are painted');
}

View File

@ -1,108 +0,0 @@
/// Textgate guard for the notes list and the sheets it opens: nothing
/// app-written is painted, only note content, numbers and glyphs.
library;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:todo/data/note.dart';
import 'notes_list_harness.dart';
import 'text_free_guard.dart';
const _content = [
'Buy milk',
'Fix sync',
'kuhyx/todo-app',
'flutter test',
'claude',
'green run',
'todo-app',
];
final _task = Note(
id: 't',
text: 'Fix sync',
priority: Priority.high,
status: Status.inProgress,
createdAt: DateTime(2026, 6, 15, 9),
updatedAt: DateTime(2026, 6, 15, 9),
repo: 'kuhyx/todo-app',
doneCheck: 'flutter test',
by: 'claude',
evidence: 'green run',
);
void _size(WidgetTester t, Size s, double dpr) {
t.view
..physicalSize = s
..devicePixelRatio = dpr;
addTearDown(t.view.reset);
}
void _desktop(WidgetTester t) => _size(t, const Size(1600, 1000), 1);
void _phone(WidgetTester t) => _size(t, const Size(1080, 2400), 2.625);
Future<void> _settle(WidgetTester t) async {
await t.pump();
await t.pump(const Duration(milliseconds: 300));
}
void main() {
testWidgets('the empty list paints no words', (t) async {
_desktop(t);
await pumpList(t);
expectNoChromeWords(t);
});
testWidgets('the filtered-empty list paints no words', (t) async {
_desktop(t);
await pumpList(
t,
seed: [note('a', 'Buy milk', status: Status.done)],
applyFilter: true,
);
expectNoChromeWords(t);
});
testWidgets('the desktop list paints only note content', (t) async {
_desktop(t);
await pumpList(t, seed: [note('a', 'Buy milk'), note('e', ''), _task]);
expectNoChromeWords(t, content: _content);
});
testWidgets('the phone grid paints only note content', (t) async {
_phone(t);
await pumpList(t, seed: [note('a', 'Buy milk'), note('e', ''), _task]);
expectNoChromeWords(t, content: _content);
});
testWidgets('the filter sheet paints no words', (t) async {
_phone(t);
await pumpList(t, seed: [note('a', 'Buy milk')], applyFilter: true);
await t.tap(find.byIcon(Icons.filter_list));
await _settle(t);
expectNoChromeWords(t, content: _content);
});
testWidgets('an opened note paints only its content', (t) async {
_desktop(t);
await pumpList(t, seed: [_task]);
await t.tap(find.text('Fix sync'));
await _settle(t);
expectNoChromeWords(t, content: _content);
});
for (final (name, title) in [
('plain note', 'Buy milk'),
('task', 'Fix sync'),
]) {
testWidgets('the $name sheet paints only note content', (t) async {
_phone(t);
await pumpList(t, seed: [note('a', 'Buy milk'), _task]);
await t.longPress(find.text(title));
await _settle(t);
expectNoChromeWords(t, content: _content);
});
}
}

View File

@ -1,30 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:todo/ui/text_free_localizations.dart';
void main() {
test('every button tooltip is blank', () {
const l = TextFreeMaterialLocalizations();
expect([
l.backButtonTooltip,
l.closeButtonTooltip,
l.openAppDrawerTooltip,
l.showMenuTooltip,
l.moreButtonTooltip,
l.deleteButtonTooltip,
], everyElement(isEmpty));
// Everything else is still the default English.
expect(l.okButtonLabel, const DefaultMaterialLocalizations().okButtonLabel);
});
test('the delegate loads them for English only, once', () async {
final delegate = kTextFreeLocalizations.single;
expect(delegate.isSupported(const Locale('en')), isTrue);
expect(delegate.isSupported(const Locale('pl')), isFalse);
expect(
await delegate.load(const Locale('en')),
isA<TextFreeMaterialLocalizations>(),
);
expect(delegate.shouldReload(delegate), isFalse);
});
}

View File

@ -1,114 +0,0 @@
/// Textgate guard for the capture screen, the editor and the settings
/// screens: nothing app-written is painted, only typed content and numbers.
library;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:http/testing.dart';
import 'package:todo/data/note_template.dart';
import 'package:todo/ui/cloud_images_settings.dart';
import 'package:todo/ui/note_editor_mode.dart';
import 'capture_screen_harness.dart';
import 'github_mirror_harness.dart';
import 'note_editor_harness.dart';
import 'settings_screen_harness.dart';
import 'text_free_guard.dart';
Future<void> _frames(WidgetTester t) async {
await t.pump();
await t.pump(const Duration(milliseconds: 300));
}
void main() {
testWidgets('the capture screen paints no words', (t) async {
await pumpCapture(t);
expectNoChromeWords(t);
});
testWidgets('a saved draft paints no words', (t) async {
await pumpCapture(t);
await t.enterText(find.byType(TextField), 'Buy milk');
await _frames(t);
expectNoChromeWords(t);
});
testWidgets('sync with nothing configured paints no words', (t) async {
await pumpCapture(t);
await t.tap(find.bySemanticsLabel('Sync'));
await _frames(t);
expectNoChromeWords(t);
});
testWidgets('a failed sync paints no words', (t) async {
await pumpCapture(
t,
prefs: configuredPrefs,
httpClient: MockClient((_) async => http.Response('boom', 500)),
);
await t.tap(find.bySemanticsLabel('Sync'));
await _frames(t);
expectNoChromeWords(t, content: const ['boom']);
});
testWidgets('the guided wizard and its steps paint no words', (t) async {
await pumpCapture(t);
await t.tap(find.bySemanticsLabel('Guided'));
await t.pump();
expectNoChromeWords(t);
await t.tap(find.bySemanticsLabel('Next'));
await t.pump();
expectNoChromeWords(t);
await t.tap(find.bySemanticsLabel('Start'));
await t.pump();
expectNoChromeWords(t);
await t.tap(find.bySemanticsLabel('Next'));
await _frames(t);
expectNoChromeWords(t);
});
testWidgets('a guided step paints no words', (t) async {
await pumpEditor(t, initialTemplate: NoteTemplate.llmDesignSpec);
expectNoChromeWords(t);
});
testWidgets('the raw editor paints no words', (t) async {
await pumpEditor(t, initialMode: NoteEditorMode.raw);
expectNoChromeWords(t);
});
testWidgets('settings paint no words', (t) async {
await pumpSettings(t);
expectNoChromeWords(t);
});
testWidgets('sync settings paint no words', (t) async {
await pumpSettings(t);
await t.tap(find.bySemanticsLabel('Sync settings: Firebase'));
await _frames(t);
await _frames(t);
expectNoChromeWords(t);
});
testWidgets('GitHub sync and its test result paint no words', (t) async {
await pumpMirror(
t,
httpClient: MockClient((_) async => http.Response('{}', 404)),
);
expectNoChromeWords(t, content: const ['kuhyx', 'syncs']);
await t.tap(find.bySemanticsLabel('Test connection'));
await _frames(t);
expectNoChromeWords(t, content: const ['kuhyx', 'syncs']);
});
for (final field in [true, false]) {
testWidgets('cloud images (field: $field) paint no words', (t) async {
await t.pumpWidget(
MaterialApp(home: CloudImagesScreen(showPasswordField: field)),
);
await t.pump();
expectNoChromeWords(t);
});
}
}

View File

@ -7,7 +7,6 @@ import 'package:todo/attachments/image_store_scope.dart';
import 'package:todo/ui/image_attach.dart'; import 'package:todo/ui/image_attach.dart';
import '../fake_image_store.dart'; import '../fake_image_store.dart';
import '../text_free_guard.dart';
void main() { void main() {
late FakeImageStore store; late FakeImageStore store;
@ -72,8 +71,7 @@ void main() {
); );
await tester.pump(); await tester.pump();
expect(inserted.single, hasLength(1)); expect(inserted.single, hasLength(1));
await tester.pump(const Duration(milliseconds: 500)); // snack fades in expect(find.text('full'), findsOneWidget);
expect(spoken('full'), findsOneWidget);
}); });
testWidgets('nothing is shown once the screen closed mid-attach', ( testWidgets('nothing is shown once the screen closed mid-attach', (
@ -94,6 +92,6 @@ void main() {
gate.complete(); gate.complete();
await done; await done;
await tester.pump(); await tester.pump();
expect(spoken('full'), findsNothing); expect(find.text('full'), findsNothing);
}); });
} }

View File

@ -15,11 +15,11 @@ void main() {
), ),
), ),
); );
await tester.tap(find.bySemanticsLabel('Attach')); await tester.tap(find.byTooltip('Attach'));
await tester.pump(); await tester.pump();
expect(got, isEmpty); expect(got, isEmpty);
result = [XFile('/picked/a.pdf')]; result = [XFile('/picked/a.pdf')];
await tester.tap(find.bySemanticsLabel('Attach')); await tester.tap(find.byTooltip('Attach'));
await tester.pump(); await tester.pump();
expect(got.single.single.name, 'a.pdf'); expect(got.single.single.name, 'a.pdf');
}); });
@ -55,7 +55,7 @@ void main() {
Future<void> choose(WidgetTester tester, String entry) async { Future<void> choose(WidgetTester tester, String entry) async {
await tester.tap(find.text('pick')); await tester.tap(find.text('pick'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.bySemanticsLabel(entry)); await tester.tap(find.text(entry));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
@ -64,9 +64,9 @@ void main() {
) async { ) async {
final asked = <AttachmentPickSource>[]; final asked = <AttachmentPickSource>[];
await openSheet(tester, asked); await openSheet(tester, asked);
expect(find.bySemanticsLabel('Camera'), findsOneWidget); expect(find.text('Camera'), findsOneWidget);
expect(find.bySemanticsLabel('File'), findsOneWidget); expect(find.text('File'), findsOneWidget);
await tester.tap(find.bySemanticsLabel('Gallery')); await tester.tap(find.text('Gallery'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await choose(tester, 'Camera'); await choose(tester, 'Camera');
await choose(tester, 'File'); await choose(tester, 'File');

View File

@ -10,7 +10,6 @@ import 'package:todo/ui/images/attachment_strip.dart';
import '../capture_screen_harness.dart'; import '../capture_screen_harness.dart';
import '../fake_image_store.dart'; import '../fake_image_store.dart';
import '../text_free_guard.dart';
void main() { void main() {
testWidgets('📎 on an empty draft creates the note under the file id', ( testWidgets('📎 on an empty draft creates the note under the file id', (
@ -26,7 +25,7 @@ void main() {
], ],
appSettings: ValueNotifier(const AppSettings(advancedMode: false)), appSettings: ValueNotifier(const AppSettings(advancedMode: false)),
); );
await tester.tap(find.bySemanticsLabel('Attach')); await tester.tap(find.byTooltip('Attach'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect(store.attachedFiles, hasLength(2)); expect(store.attachedFiles, hasLength(2));
@ -48,7 +47,7 @@ void main() {
await tester.enterText(find.byType(TextField), 'idea'); await tester.enterText(find.byType(TextField), 'idea');
await tester.pump(); await tester.pump();
final id = (await repo.listNotes()).single.id; final id = (await repo.listNotes()).single.id;
await tester.tap(find.bySemanticsLabel('Attach')); await tester.tap(find.byTooltip('Attach'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
final text = (await repo.listNotes()).single.text; final text = (await repo.listNotes()).single.text;
@ -91,7 +90,7 @@ void main() {
); );
await tester.pump(); await tester.pump();
final before = store.reconciles.length; final before = store.reconciles.length;
await tester.tap(find.bySemanticsLabel('Sync')); await tester.tap(find.byTooltip('Sync'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
expect(store.reconciles.length, greaterThan(before)); expect(store.reconciles.length, greaterThan(before));
@ -133,7 +132,6 @@ void main() {
(await repo.listNotes()).single.id, (await repo.listNotes()).single.id,
store.attached.keys.single.noteId, store.attached.keys.single.noteId,
); );
await tester.pump(const Duration(milliseconds: 500)); // snack fades in expect(find.text('Not an image'), findsOneWidget);
expect(spoken('Not an image'), findsOneWidget);
}); });
} }

View File

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:http/testing.dart'; import 'package:http/testing.dart';
@ -34,7 +33,7 @@ void main() {
Future<void> saveWith(WidgetTester tester, String password) async { Future<void> saveWith(WidgetTester tester, String password) async {
await tester.enterText(find.byType(TextField), password); await tester.enterText(find.byType(TextField), password);
await tester.tap(find.bySemanticsLabel('Save & test')); await tester.tap(find.text('Save & test'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
} }
@ -44,7 +43,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp(home: Scaffold(body: CloudImagesTile())), const MaterialApp(home: Scaffold(body: CloudImagesTile())),
); );
await tester.tap(find.bySemanticsLabel('Cloud images')); await tester.tap(find.text('Cloud images'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(CloudImagesScreen), findsOneWidget); expect(find.byType(CloudImagesScreen), findsOneWidget);
}); });
@ -56,8 +55,8 @@ void main() {
tester.widget<TextField>(find.byType(TextField)).controller!.text, tester.widget<TextField>(find.byType(TextField)).controller!.text,
'saved', 'saved',
); );
expect(find.bySemanticsLabel('Login: configured'), findsOneWidget); expect(find.text('Login: configured'), findsOneWidget);
expect(find.bySemanticsLabel('Waiting to upload: 0'), findsOneWidget); expect(find.text('Waiting to upload: 0'), findsOneWidget);
}); });
testWidgets('an accepted password is saved and the queue uploads', ( testWidgets('an accepted password is saved and the queue uploads', (
@ -67,10 +66,7 @@ void main() {
final store = FakeImageStore(); final store = FakeImageStore();
await pump(tester, store: store, client: answer(207)); await pump(tester, store: store, client: answer(207));
await saveWith(tester, ' pw '); await saveWith(tester, ' pw ');
expect( expect(find.text('Saved — dufs accepted the login'), findsOneWidget);
find.bySemanticsLabel('Saved — dufs accepted the login'),
findsOneWidget,
);
expect(store.reconciles.single, isEmpty); expect(store.reconciles.single, isEmpty);
}); });
@ -81,10 +77,7 @@ void main() {
final store = FakeImageStore(); final store = FakeImageStore();
await pump(tester, store: store, client: answer(401)); await pump(tester, store: store, client: answer(401));
await saveWith(tester, 'bad'); await saveWith(tester, 'bad');
expect( expect(find.text('Saved, but dufs rejected the password'), findsOneWidget);
find.bySemanticsLabel('Saved, but dufs rejected the password'),
findsOneWidget,
);
expect(store.reconciles, isEmpty); expect(store.reconciles, isEmpty);
}); });
@ -96,10 +89,7 @@ void main() {
client: MockClient((_) => throw const SocketException('down')), client: MockClient((_) => throw const SocketException('down')),
); );
await saveWith(tester, 'pw'); await saveWith(tester, 'pw');
expect( expect(find.text('Saved — dufs is unreachable right now'), findsOneWidget);
find.bySemanticsLabel('Saved — dufs is unreachable right now'),
findsOneWidget,
);
}); });
testWidgets('no keystore means nothing is saved', (tester) async { testWidgets('no keystore means nothing is saved', (tester) async {
@ -107,7 +97,7 @@ void main() {
await pump(tester, store: FakeImageStore(), client: answer(207)); await pump(tester, store: FakeImageStore(), client: answer(207));
await saveWith(tester, 'pw'); await saveWith(tester, 'pw');
expect( expect(
find.bySemanticsLabel('Could not save: the keystore is unavailable'), find.text('Could not save: the keystore is unavailable'),
findsOneWidget, findsOneWidget,
); );
}); });
@ -118,28 +108,10 @@ void main() {
await pump(tester, field: false); await pump(tester, field: false);
expect(find.byType(TextField), findsNothing); expect(find.byType(TextField), findsNothing);
expect( expect(
find.bySemanticsLabel('Login: missing — create it on the PC with'), find.text('Login: missing — create it on the PC with'),
findsOneWidget, findsOneWidget,
); );
expect(find.bySemanticsLabel('Copy: $kAddLoginCommand'), findsOneWidget); expect(find.text(kAddLoginCommand), findsOneWidget);
// The command is copied, not painted: the button puts it on the
// clipboard (stubbed channel; the test host has no clipboard plugin).
final copied = <Object?>[];
final messenger =
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
messenger.setMockMethodCallHandler(SystemChannels.platform, (call) async {
if (call.method == 'Clipboard.setData') copied.add(call.arguments);
return null;
});
addTearDown(
() => messenger.setMockMethodCallHandler(SystemChannels.platform, null),
);
await tester.tap(find.bySemanticsLabel('Copy: $kAddLoginCommand'));
await tester.pump();
expect(copied, [
{'text': kAddLoginCommand},
]);
}); });
testWidgets('closing the screen mid-test is harmless', (tester) async { testWidgets('closing the screen mid-test is harmless', (tester) async {
@ -148,7 +120,7 @@ void main() {
final store = FakeImageStore(); final store = FakeImageStore();
await pump(tester, store: store, client: MockClient((_) => reply.future)); await pump(tester, store: store, client: MockClient((_) => reply.future));
await tester.enterText(find.byType(TextField), 'pw'); await tester.enterText(find.byType(TextField), 'pw');
await tester.tap(find.bySemanticsLabel('Save & test')); await tester.tap(find.text('Save & test'));
await tester.pump(); await tester.pump();
await tester.pumpWidget(const SizedBox()); await tester.pumpWidget(const SizedBox());
reply.complete(http.Response('', 207)); reply.complete(http.Response('', 207));

View File

@ -58,7 +58,7 @@ void main() {
await tester.pump(); await tester.pump();
tester.widget<TextField>(find.byType(TextField)).controller!.selection = tester.widget<TextField>(find.byType(TextField)).controller!.selection =
const TextSelection.collapsed(offset: 5); const TextSelection.collapsed(offset: 5);
await tester.tap(find.bySemanticsLabel('Attach')); await tester.tap(find.byTooltip('Attach'));
await tester.pump(); await tester.pump();
await tester.pump(); await tester.pump();
expect( expect(
@ -81,7 +81,7 @@ void main() {
await tester.pump(); await tester.pump();
expect((await repo.listNotes()).single.text, contains('[Raport.pdf](')); expect((await repo.listNotes()).single.text, contains('[Raport.pdf]('));
// View mode renders inline and hides the strip. // View mode renders inline and hides the strip.
await tester.tap(find.bySemanticsLabel('View')); await tester.tap(find.text('View'));
await tester.pump(); await tester.pump();
expect(find.byType(AttachmentStrip), findsNothing); expect(find.byType(AttachmentStrip), findsNothing);
expect(find.byType(ImageEmbed), findsNWidgets(2)); expect(find.byType(ImageEmbed), findsNWidgets(2));

View File

@ -8,7 +8,6 @@ import 'package:todo/ui/images/file_embed.dart';
import 'package:todo/ui/images/image_embed.dart'; import 'package:todo/ui/images/image_embed.dart';
import '../fake_image_store.dart'; import '../fake_image_store.dart';
import '../text_free_guard.dart';
void main() { void main() {
final pdf = AttachmentRef.forFile('n1', 'a.pdf'); final pdf = AttachmentRef.forFile('n1', 'a.pdf');
@ -58,14 +57,13 @@ void main() {
await pump(tester, embed()); await pump(tester, embed());
await tester.tap(find.text('Raport.pdf')); await tester.tap(find.text('Raport.pdf'));
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 500)); // snack fades in expect(find.text(failure!), findsOneWidget);
expect(spoken(failure!), findsOneWidget);
}); });
testWidgets('a file not here yet says so and does not open', (tester) async { testWidgets('a file not here yet says so and does not open', (tester) async {
store.missing.add(pdf); store.missing.add(pdf);
await pump(tester, embed()); await pump(tester, embed());
expect(find.byIcon(Icons.cloud_download_outlined), findsOneWidget); expect(find.text(kImageNotDownloaded), findsOneWidget);
await tester.tap(find.text('Raport.pdf')); await tester.tap(find.text('Raport.pdf'));
await tester.pump(); await tester.pump();
expect(opened, isEmpty); expect(opened, isEmpty);
@ -76,15 +74,15 @@ void main() {
) async { ) async {
store.pending.add(pdf); store.pending.add(pdf);
await pump(tester, embed()); await pump(tester, embed());
expect(find.byIcon(Icons.cloud_upload_outlined), findsOneWidget); expect(find.byTooltip(kImageWaitingToUpload), findsOneWidget);
await pump(tester, embed(compact: true)); await pump(tester, embed(compact: true));
expect(find.byIcon(Icons.cloud_upload_outlined), findsOneWidget); expect(find.byTooltip(kImageWaitingToUpload), findsOneWidget);
}); });
testWidgets('the size is asked again when the store changes', (tester) async { testWidgets('the size is asked again when the store changes', (tester) async {
store.missing.add(pdf); store.missing.add(pdf);
await pump(tester, embed()); await pump(tester, embed());
expect(find.byIcon(Icons.cloud_download_outlined), findsOneWidget); expect(find.text(kImageNotDownloaded), findsOneWidget);
store store
..missing.clear() ..missing.clear()
..changed(); ..changed();

View File

@ -8,7 +8,6 @@ import 'package:todo/attachments/image_store_scope.dart';
import 'package:todo/ui/image_attach.dart'; import 'package:todo/ui/image_attach.dart';
import '../fake_image_store.dart'; import '../fake_image_store.dart';
import '../text_free_guard.dart';
void main() { void main() {
test('the controller inserts only while an editor is bound', () { test('the controller inserts only while an editor is bound', () {
@ -90,8 +89,7 @@ void main() {
], ],
); );
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 500)); // snack fades in expect(find.text('Not an image'), findsOneWidget);
expect(spoken('Not an image'), findsOneWidget);
}); });
testWidgets('counts dropped non-images together', (tester) async { testWidgets('counts dropped non-images together', (tester) async {
@ -107,8 +105,7 @@ void main() {
rejected: 2, rejected: 2,
); );
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 500)); // snack fades in expect(find.text('3 files were not images'), findsOneWidget);
expect(spoken('3 files were not images'), findsOneWidget);
}); });
testWidgets('a store failure is shown and stops the batch', (tester) async { testWidgets('a store failure is shown and stops the batch', (tester) async {
@ -125,8 +122,7 @@ void main() {
], ],
); );
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 500)); // snack fades in expect(find.text('helper down'), findsOneWidget);
expect(spoken('helper down'), findsOneWidget);
}); });
testWidgets('nothing is shown once the screen closed mid-attach', ( testWidgets('nothing is shown once the screen closed mid-attach', (

View File

@ -37,7 +37,7 @@ void main() {
testWidgets('a local image renders and opens full screen', (tester) async { testWidgets('a local image renders and opens full screen', (tester) async {
await pump(tester, ImageEmbed(ref: ref)); await pump(tester, ImageEmbed(ref: ref));
expect(find.byType(Image), findsOneWidget); expect(find.byType(Image), findsOneWidget);
expect(find.byIcon(Icons.cloud_upload_outlined), findsNothing); expect(find.byTooltip(kImageWaitingToUpload), findsNothing);
await tester.tap(find.byType(ImageEmbed)); await tester.tap(find.byType(ImageEmbed));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(ImageViewerScreen), findsOneWidget); expect(find.byType(ImageViewerScreen), findsOneWidget);
@ -47,7 +47,7 @@ void main() {
testWidgets('a queued image carries the upload badge', (tester) async { testWidgets('a queued image carries the upload badge', (tester) async {
store.pending.add(ref); store.pending.add(ref);
await pump(tester, ImageEmbed(ref: ref)); await pump(tester, ImageEmbed(ref: ref));
expect(find.byIcon(Icons.cloud_upload_outlined), findsOneWidget); expect(find.byTooltip(kImageWaitingToUpload), findsOneWidget);
}); });
testWidgets('a missing image is a placeholder and not tappable', ( testWidgets('a missing image is a placeholder and not tappable', (
@ -55,7 +55,7 @@ void main() {
) async { ) async {
store.missing.add(ref); store.missing.add(ref);
await pump(tester, ImageEmbed(ref: ref)); await pump(tester, ImageEmbed(ref: ref));
expect(find.byIcon(Icons.cloud_download_outlined), findsOneWidget); expect(find.text(kImageNotDownloaded), findsOneWidget);
await tester.tap(find.byType(ImageEmbed)); await tester.tap(find.byType(ImageEmbed));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(ImageViewerScreen), findsNothing); expect(find.byType(ImageViewerScreen), findsNothing);
@ -70,7 +70,7 @@ void main() {
() => Future<void>.delayed(const Duration(milliseconds: 50)), () => Future<void>.delayed(const Duration(milliseconds: 50)),
); );
await tester.pump(); await tester.pump();
expect(find.byIcon(Icons.cloud_download_outlined), findsOneWidget); expect(find.text(kImageNotDownloaded), findsOneWidget);
store.network = true; store.network = true;
store.changed(); store.changed();
await tester.pump(); await tester.pump();
@ -78,7 +78,7 @@ void main() {
() => Future<void>.delayed(const Duration(milliseconds: 50)), () => Future<void>.delayed(const Duration(milliseconds: 50)),
); );
await tester.pump(); await tester.pump();
expect(find.byIcon(Icons.cloud_download_outlined), findsOneWidget); expect(find.text(kImageNotDownloaded), findsOneWidget);
}); });
testWidgets('the strip shows one thumbnail per linked image', (tester) async { testWidgets('the strip shows one thumbnail per linked image', (tester) async {

View File

@ -88,8 +88,7 @@ void main() {
template: NoteTemplate.llmDesignSpec, template: NoteTemplate.llmDesignSpec,
mode: NoteEditorMode.guided, mode: NoteEditorMode.guided,
); );
// In the guided stepper: its exit arrow is present. expect(find.text('Exit guided'), findsNothing);
expect(find.bySemanticsLabel('Exit guided'), findsOneWidget);
attach.insert(['IMG']); attach.insert(['IMG']);
await tester.pump(); await tester.pump();
expect(field(tester).text, 'IMG\n'); expect(field(tester).text, 'IMG\n');
@ -104,7 +103,7 @@ void main() {
template: NoteTemplate.blank, template: NoteTemplate.blank,
onModeChanged: modes.add, onModeChanged: modes.add,
); );
await tester.tap(find.bySemanticsLabel('View')); await tester.tap(find.text('View'));
await tester.pump(); await tester.pump();
expect(modes, [NoteEditorMode.preview]); expect(modes, [NoteEditorMode.preview]);
attach.insert(['IMG']); attach.insert(['IMG']);