Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/ui/control_surface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
);
Expand Down
84 changes: 52 additions & 32 deletions lib/ui/notes_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<NoteMedia> 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) {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -391,7 +404,6 @@ class NoteCardFace extends StatelessWidget {
: palette.textMuted,
),
),
],
],
],
),
Expand Down Expand Up @@ -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,
],
),
Expand Down
1 change: 1 addition & 0 deletions lib/ui/settings_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 29 additions & 0 deletions test/golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Binary file modified test/goldens/desktop_dark_archive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/desktop_dark_archive_selecting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/goldens/desktop_dark_pinned_cards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/desktop_dark_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/desktop_dark_settings_appearance_end.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/desktop_dark_settings_shortcuts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/desktop_dark_settings_updates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/desktop_light_settings_appearance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/desktop_windows_dark_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/desktop_windows_dark_update.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions test/riverbank_fidelity_test.dart
Original file line number Diff line number Diff line change
@@ -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<void> pumpWindow(WidgetTester tester, List<String> 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<RenderBox>(
find.byWidgetPredicate(
(widget) => widget is NoteCardFace && widget.note.title == title,
),
);
Rect inCard(Finder finder) {
final box = tester.renderObject<RenderBox>(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<Text>(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<TextField>(find.byKey(const ValueKey('settings-search')))
.decoration!;
expect(
decoration.focusedBorder!.borderSide.color,
KapyTheme.darkPalette.controlBorder,
);
});
}
Loading