diff --git a/lib/ui/control_surface.dart b/lib/ui/control_surface.dart index 8161ce8..fed27fb 100644 --- a/lib/ui/control_surface.dart +++ b/lib/ui/control_surface.dart @@ -18,6 +18,7 @@ InputDecoration kapyFieldDecoration( Color? fillColor, double? borderWidth, double? radius, + bool neutralFocus = false, }) { final palette = context.palette; final error = Theme.of(context).colorScheme.error; @@ -45,7 +46,9 @@ InputDecoration kapyFieldDecoration( border: border(palette.controlBorder), enabledBorder: border(palette.controlBorder), disabledBorder: border(palette.controlBorder.withValues(alpha: 0.55)), - focusedBorder: border(palette.selectedBorder, width: 1.25), + focusedBorder: neutralFocus + ? border(palette.controlBorder) + : border(palette.selectedBorder, width: 1.25), errorBorder: border(error.withValues(alpha: 0.8)), focusedErrorBorder: border(error, width: 1.25), ); diff --git a/lib/ui/notes_list.dart b/lib/ui/notes_list.dart index eeb3741..c342699 100644 --- a/lib/ui/notes_list.dart +++ b/lib/ui/notes_list.dart @@ -62,12 +62,23 @@ class NoteGlance { /// What [line] calculates to, when it is a calculation. final String? result; + /// [line] as written when it is nothing but an amount, "₹75,60,000", which + /// a card shows as its figure whether or not there are rates to read it by. + String? get amount { + final line = this.line; + return line != null && _amount.hasMatch(line) ? line : null; + } + /// Ticked boxes, of [boxes] checkboxes in the whole note. final int done; final int boxes; final Set media; static final _read = Expando<(CalcEngine?, NoteGlance)>(); + static final _amount = RegExp( + r'^\p{Sc}?\s?-?\d[\d,]*(\.\d+)?$', + unicode: true, + ); static final _marks = RegExp(r'^(#{1,6}\s*|[☐☑•]\s*)'); static NoteGlance of(Note note, CalcEngine? engine) { @@ -291,7 +302,7 @@ class NoteCardFace extends StatelessWidget { final blank = note.isEmpty; final title = _handwritten(14, 18, FontWeight.w500, palette.cardTitle); final glance = this.glance; - final result = snippet == null ? glance.result : null; + final result = snippet == null ? glance.amount ?? glance.result : null; final preview = snippet ?? (blank ? 'Empty' : glance.line ?? (note.isDrawing ? 'Sketch' : null)); @@ -353,13 +364,16 @@ class NoteCardFace extends StatelessWidget { Text( heading, maxLines: - constraints.maxHeight >= scaler.scale(36) + constraints.maxHeight >= + scaler.scale(36 + 6) ? 2 : 1, overflow: TextOverflow.ellipsis, style: title, ), if (oneLine && roomy && glance.boxes == 0) ...[ + if (result != null || preview != null) + const SizedBox(height: 3), if (result != null) Text( result, @@ -376,8 +390,7 @@ class NoteCardFace extends StatelessWidget { color: palette.resultPillText, ), ) - else if (preview != null) ...[ - const SizedBox(height: 3), + else if (preview != null) Text( preview, maxLines: 1, @@ -391,7 +404,6 @@ class NoteCardFace extends StatelessWidget { : palette.textMuted, ), ), - ], ], ], ), @@ -940,36 +952,44 @@ class NotesListHeading extends StatelessWidget { leading, const SizedBox(width: 6), ], - Flexible( - child: Semantics( - header: true, - child: Text( - label, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: _handwritten( - 14, - 20, - FontWeight.w600, - palette.textSubheading, + Expanded( + child: Row( + children: [ + Flexible( + child: Semantics( + header: true, + child: Text( + label, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: _handwritten( + 14, + 20, + FontWeight.w600, + palette.textSubheading, + ), + ), + ), ), - ), - ), - ), - const SizedBox(width: 7), - Tooltip( - message: count == 1 ? '1 $noun' : '$count ${noun}s', - child: Text( - '$count', - style: _figtree( - AppTypeScale.small, - 16, - FontWeight.w600, - palette.textTertiary, - ).copyWith(fontFeatures: const [FontFeature.tabularFigures()]), + const SizedBox(width: 7), + Tooltip( + message: count == 1 ? '1 $noun' : '$count ${noun}s', + child: Text( + '$count', + style: + _figtree( + AppTypeScale.small, + 16, + FontWeight.w600, + palette.textTertiary, + ).copyWith( + fontFeatures: const [FontFeature.tabularFigures()], + ), + ), + ), + ], ), ), - const Spacer(), ?trailing, ], ), diff --git a/lib/ui/settings_search.dart b/lib/ui/settings_search.dart index cb41154..389ec4e 100644 --- a/lib/ui/settings_search.dart +++ b/lib/ui/settings_search.dart @@ -204,6 +204,7 @@ class SettingsSearchField extends StatelessWidget { fillColor: pointer ? palette.surfaceBackground : null, borderWidth: pointer ? 1.5 : null, radius: pointer ? 10 : null, + neutralFocus: pointer, // InputDecorator gives its prefix the whole adornment slot. // Center loosens those constraints so the glyph keeps its // intended size. diff --git a/test/golden_test.dart b/test/golden_test.dart index cef3839..839744b 100644 --- a/test/golden_test.dart +++ b/test/golden_test.dart @@ -817,6 +817,35 @@ void main() { ); }); + // The pinned cards Paper's 5TS-0 draws: a checklist under a title too + // long for one line, See all at the heading's end, and amounts in mono. + testWidgets('desktop dark pinned cards', (tester) async { + await pumpForGolden( + tester, + size: const Size(760, 520), + brightness: Brightness.dark, + withNote: false, + ); + for (final (index, body) in [ + 'Groceries\nMilk, eggs', + 'land\n₹75,60,000', + 'car issues\n₹18,400', + 'Ideas\nA quieter dock', + 'Goals - Oct 2026\nShip the redesign', + 'Todos\nRenew domain, gym', + 'Reading list\nThree books', + 'SnowSEO Issues backlog\n☑ Crawl\n☐ Fix titles\n☐ Sitemap', + ].indexed) { + final note = goldenNotes.create(body: body); + if (index > 2) goldenNotes.togglePinned(note.id); + } + await tester.pumpAndSettle(); + await expectLater( + find.byType(KapyNotesApp), + matchesGoldenFile('goldens/desktop_dark_pinned_cards.png'), + ); + }); + testWidgets('desktop dark note with images', (tester) async { await pumpForGolden( tester, diff --git a/test/goldens/desktop_dark_archive.png b/test/goldens/desktop_dark_archive.png index 091d606..7385593 100644 Binary files a/test/goldens/desktop_dark_archive.png and b/test/goldens/desktop_dark_archive.png differ diff --git a/test/goldens/desktop_dark_archive_selecting.png b/test/goldens/desktop_dark_archive_selecting.png index 604b2fa..be0c264 100644 Binary files a/test/goldens/desktop_dark_archive_selecting.png and b/test/goldens/desktop_dark_archive_selecting.png differ diff --git a/test/goldens/desktop_dark_pinned_cards.png b/test/goldens/desktop_dark_pinned_cards.png new file mode 100644 index 0000000..dc40842 Binary files /dev/null and b/test/goldens/desktop_dark_pinned_cards.png differ diff --git a/test/goldens/desktop_dark_settings.png b/test/goldens/desktop_dark_settings.png index 10de57a..b5873df 100644 Binary files a/test/goldens/desktop_dark_settings.png and b/test/goldens/desktop_dark_settings.png differ diff --git a/test/goldens/desktop_dark_settings_appearance_end.png b/test/goldens/desktop_dark_settings_appearance_end.png index 368493f..31973b3 100644 Binary files a/test/goldens/desktop_dark_settings_appearance_end.png and b/test/goldens/desktop_dark_settings_appearance_end.png differ diff --git a/test/goldens/desktop_dark_settings_shortcuts.png b/test/goldens/desktop_dark_settings_shortcuts.png index 72c6dd8..35ce286 100644 Binary files a/test/goldens/desktop_dark_settings_shortcuts.png and b/test/goldens/desktop_dark_settings_shortcuts.png differ diff --git a/test/goldens/desktop_dark_settings_updates.png b/test/goldens/desktop_dark_settings_updates.png index ac80288..d369ac9 100644 Binary files a/test/goldens/desktop_dark_settings_updates.png and b/test/goldens/desktop_dark_settings_updates.png differ diff --git a/test/goldens/desktop_light_settings_appearance.png b/test/goldens/desktop_light_settings_appearance.png index 7475787..50c5f79 100644 Binary files a/test/goldens/desktop_light_settings_appearance.png and b/test/goldens/desktop_light_settings_appearance.png differ diff --git a/test/goldens/desktop_windows_dark_settings.png b/test/goldens/desktop_windows_dark_settings.png index f0d22b2..ffb4ae9 100644 Binary files a/test/goldens/desktop_windows_dark_settings.png and b/test/goldens/desktop_windows_dark_settings.png differ diff --git a/test/goldens/desktop_windows_dark_update.png b/test/goldens/desktop_windows_dark_update.png index 13a1509..3d20d45 100644 Binary files a/test/goldens/desktop_windows_dark_update.png and b/test/goldens/desktop_windows_dark_update.png differ diff --git a/test/riverbank_fidelity_test.dart b/test/riverbank_fidelity_test.dart new file mode 100644 index 0000000..d76428d --- /dev/null +++ b/test/riverbank_fidelity_test.dart @@ -0,0 +1,97 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:kapy_notes/core/theme.dart'; +import 'package:kapy_notes/ui/notes_list.dart'; +import 'package:material_ui/material_ui.dart'; + +import 'golden_test.dart' show goldenNotes, pumpForGolden, tapSettings; +import 'test_fonts.dart'; + +/// Where the running app drifted from the final Paper design (5TS-0, 6EV-0). +void main() { + setUpAll(loadTestFonts); + + Future pumpWindow(WidgetTester tester, List bodies) async { + await pumpForGolden( + tester, + size: const Size(1440, 900), + brightness: Brightness.dark, + withNote: false, + ); + for (final body in bodies) { + goldenNotes.create(body: body); + } + await tester.pumpAndSettle(); + } + + Finder onCard(String title, Finder finder) => find.descendant( + of: find.byWidgetPredicate( + (widget) => widget is NoteCardFace && widget.note.title == title, + ), + matching: finder, + ); + + testWidgets('a long title over a checklist keeps clear of its progress', ( + tester, + ) async { + const title = 'SnowSEO Issues backlog for the launch'; + await pumpWindow(tester, ['$title\n☑ crawl\n☐ fix titles']); + + // The cards lean, so this measures inside the card rather than on screen. + final card = tester.renderObject( + find.byWidgetPredicate( + (widget) => widget is NoteCardFace && widget.note.title == title, + ), + ); + Rect inCard(Finder finder) { + final box = tester.renderObject(finder); + return box.localToGlobal(Offset.zero, ancestor: card) & box.size; + } + + final heading = inCard(onCard(title, find.text(title))); + final date = inCard(onCard(title, find.text('Today · 15:38'))); + expect(heading.height, 18, reason: 'one line'); + expect(date.top - 6 - 4 - heading.bottom, greaterThanOrEqualTo(6)); + }); + + testWidgets('an amount on a card is set in Geist Mono', (tester) async { + await pumpWindow(tester, ['land\n₹75,60,000']); + + final amount = tester.widget(onCard('land', find.text('₹75,60,000'))); + expect(amount.style?.fontFamily, AppFonts.mono); + }); + + testWidgets('See all sits at the end of the Pinned heading', (tester) async { + await pumpWindow(tester, [for (var i = 0; i < 5; i++) 'Pinned $i']); + for (final note in goldenNotes.notes) { + goldenNotes.togglePinned(note.id); + } + await tester.pumpAndSettle(); + + expect( + tester + .getRect(find.byKey(const ValueKey('sidebar-see-all-pinned'))) + .right, + tester + .getRect(find.byKey(const ValueKey('sidebar-pinned-heading'))) + .right, + ); + }); + + testWidgets('the settings search keeps a neutral border in focus', ( + tester, + ) async { + await pumpWindow(tester, ['Groceries']); + await tapSettings(tester); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const ValueKey('settings-search'))); + await tester.pumpAndSettle(); + + final decoration = tester + .widget(find.byKey(const ValueKey('settings-search'))) + .decoration!; + expect( + decoration.focusedBorder!.borderSide.color, + KapyTheme.darkPalette.controlBorder, + ); + }); +}