Fix home heading clipping and reset notebook page scrolling

This commit is contained in:
Hadrian Burkhardt
2026-11-03 05:05:39 +01:00
parent c6168f46ac
commit 5b9a76fb53
4 changed files with 200 additions and 84 deletions
+2 -1
View File
@@ -248,6 +248,7 @@ Content pipelines:
- All visible handwriting uses `hand(size)` (`MaraHand` → Dancing Script). Colours live in `lib/ui/paper.dart`: `ink` `#36413c`, `blue` `#274956`, `muted` `#796b55`, `cream` `#f3e7cc`, `amber` `#e0b568`.
- `writing()` adds paper spacing; `folio()` is the small blue label above a leaf's content.
- The home folio stays above the scroll viewport so its lettering remains fully visible during scrolling; the title, illustrations and actions scroll below it.
- `InkButton` is the only button style: transparent, underlined ink text, minimum 48 px touch target, optional `primary` emphasis, wrapped in `PageSwipeBlocker`.
### Paper and leaves
@@ -255,7 +256,7 @@ Content pipelines:
- `Paper` draws `assets/artwork/mara-single-page-v2.png` (1024×1536). Portrait scales to fit both dimensions; landscape scales to width, so the sheet is cropped vertically.
- Content area: portrait `x 11%–83%`, `y 12%–91%` of the sheet (8%–91% when narrower than 480 px); landscape `x 10%–83%`, `y 6%–94%` of the viewport.
- A page turns when a horizontal drag ends with `|dx| ≥ 48` and `|dx| > 1.3·|dy|`. `PageSwipeBlocker` installs a descendant horizontal recogniser so grid/button drags never reach the page; taps and vertical drags still pass through.
- `Leaf` is the standard page body: a scrolling column in portrait, and `wideBody` in landscape when supplied. The footer stays pinned. Scroll keys are `leaf-scroll` (portrait) and `leaf-side-scroll` (landscape side column).
- `Leaf` is the standard page body: a scrolling column in portrait, and `wideBody` in landscape when supplied. The footer stays pinned. Scroll keys are `leaf-scroll` (portrait) and `leaf-side-scroll` (landscape side column). These are ordinary value keys: opening or revisiting a leaf always starts at the top, without restoring a saved scroll offset. Both panes include top padding for handwriting ascenders.
- `Cover` is the tappable notebook cover on the home screen. `Sketch` draws pencil props (`match`, `envelope`).
### Puzzle board
+29 -7
View File
@@ -407,14 +407,28 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
Widget home() => ColoredBox(
color: cream,
child: SafeArea(
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(28, 34, 28, 8),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 650),
child: SizedBox(
width: double.infinity,
child: folio('L U M E N / AN ISLAND STORY'),
),
),
),
),
Expanded(
child: SingleChildScrollView(
key: const ValueKey('home-scroll'),
padding: const EdgeInsets.fromLTRB(28, 26, 28, 36),
padding: const EdgeInsets.fromLTRB(28, 0, 28, 36),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 650),
child: column([
folio('L U M E N / AN ISLAND STORY'),
writing('A light to come\nhome to.', size: 40),
Image.asset(
'assets/artwork/home-harbour-v2.png',
@@ -466,7 +480,10 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
size: 22,
color: muted,
),
action('Difficulty · ${g.difficulty.label} ▾', chooseDifficulty),
action(
'Difficulty · ${g.difficulty.label} ▾',
chooseDifficulty,
),
action(
'Practice · ${g.difficulty.label} · Level ${g.practiceLevel}',
() => unawaited(g.startPractice()),
@@ -476,8 +493,10 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
action('Privacy & advertising', privacy),
action(
'Open-source licenses',
() =>
showLicensePage(context: context, applicationName: 'Lumen'),
() => showLicensePage(
context: context,
applicationName: 'Lumen',
),
),
gap(),
writing(
@@ -490,6 +509,9 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
),
),
),
],
),
),
);
void bookmark() {
unawaited(
@@ -1069,8 +1091,8 @@ class _NotebookState extends State<Notebook> with WidgetsBindingObserver {
const SizedBox(width: 18),
Expanded(
child: SingleChildScrollView(
key: const PageStorageKey('leaf-side-scroll'),
padding: const EdgeInsets.fromLTRB(2, 0, 2, 8),
key: const ValueKey('leaf-side-scroll'),
padding: const EdgeInsets.fromLTRB(2, 8, 2, 8),
child: column(side),
),
),
+4 -2
View File
@@ -195,8 +195,10 @@ class Leaf extends StatelessWidget {
child: wide
? wideBody!
: SingleChildScrollView(
key: const PageStorageKey('leaf-scroll'),
padding: const EdgeInsets.fromLTRB(4, 0, 4, 8),
// Each newly opened leaf starts at the top, including
// leaves revisited with Previous or a bookmark.
key: const ValueKey('leaf-scroll'),
padding: const EdgeInsets.fromLTRB(4, 8, 4, 8),
child: body,
),
),
+91
View File
@@ -28,6 +28,97 @@ class _RewardAds extends Ads {
}
void main() {
testWidgets('home lettering stays fully above the scrolling content', (
tester,
) async {
addTearDown(tester.view.reset);
await tester.runAsync(() async {
final font = FontLoader('MaraHand')
..addFont(rootBundle.load('assets/fonts/DancingScript.ttf'));
await font.load();
});
final book = (await tester.runAsync(Book.load))!;
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
await tester.pumpWidget(
LumenApp(game: Game(book, Progress.memory()), adsEnabled: false),
);
await tester.pumpAndSettle();
final heading = find.text('L U M E N / AN ISLAND STORY');
final scroll = find.byKey(const ValueKey('home-scroll'));
final headingRect = tester.getRect(heading);
expect(headingRect.bottom, lessThan(tester.getRect(scroll).top));
for (final dy in [-40.0, -300.0, 500.0]) {
await tester.drag(scroll, Offset(0, dy));
await tester.pumpAndSettle();
expect(tester.getRect(heading), headingRect);
expect(heading.hitTestable(), findsOneWidget);
expect(tester.takeException(), isNull);
}
await tester.pumpWidget(const SizedBox());
}
});
testWidgets(
'opening and revisiting leaves starts at the top in both layouts',
(tester) async {
addTearDown(tester.view.reset);
final book = (await tester.runAsync(Book.load))!;
for (final size in [const Size(360, 640), const Size(960, 600)]) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
final wide = size.width > size.height;
final g = Game(book, Progress.memory({'story_access_level': 11}));
final first = wide ? 2 : 1;
final second = wide ? 7 : 3;
g.showStory(first);
await tester.pumpWidget(
MaterialApp(
home: MediaQuery(
data: MediaQueryData(
size: size,
textScaler: const TextScaler.linear(1.5),
),
child: Notebook(game: g, adsEnabled: false),
),
),
);
await tester.pumpAndSettle();
final pane = find.byKey(
ValueKey(wide ? 'leaf-side-scroll' : 'leaf-scroll'),
);
ScrollPosition position() => tester
.state<ScrollableState>(
find
.descendant(of: pane, matching: find.byType(Scrollable))
.first,
)
.position;
expect(position().pixels, 0);
await tester.drag(pane, const Offset(0, -220));
await tester.pumpAndSettle();
expect(position().pixels, greaterThan(0));
// Updates within a page should still preserve its reading position.
final offset = position().pixels;
g.showStory(first);
await tester.pumpAndSettle();
expect(position().pixels, offset);
g.showStory(second);
await tester.pumpAndSettle();
expect(position().pixels, 0);
await tester.drag(pane, const Offset(0, -180));
await tester.pumpAndSettle();
expect(position().pixels, greaterThan(0));
g.showStory(first);
await tester.pumpAndSettle();
expect(position().pixels, 0);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
}
},
);
testWidgets('atmosphere controls fit large text and remember mute', (
tester,
) async {