Files
logic-puzzle/lib/ui/mara_story.dart
T
Hadrian Burkhardt 0718e3f252 Open Lumen on a responsive bookshelf and land pending story work
- Start the app on a shelf of every installed book instead of the last
  book's home. Cards show the cover, translated metadata, available
  languages, restored patterns and either "Continue reading" or a way in.
- Keep each book's saved route: the shelf is never written to
  flutter_screen, so choosing a book resumes its own leaf.
- Lay the shelf out responsively: dense single-column cards on phones,
  a two-column grid from 720 logical pixels, a centred 860 px column on
  tablets and a chevron that exists in the bundled handwriting font.
- Keep Settings reachable from the shelf and let the home page's story
  library button open the shelf instead of a dialog.
- Add tool/shelf_screenshots_test.dart, which renders the shelf at phone
  and tablet metrics, checks that every card and Settings stay reachable
  without overflow, and writes artifacts/library/shelf-*.png.
- Commit the pending Midnight Invitation package (campaign, notebook,
  narration and artwork), cast drama and ambience tooling, region
  selection, phone/tablet integration coverage and related docs.

flutter analyze is clean and all 74 widget/domain tests pass.
2026-11-05 14:29:50 +01:00

168 lines
5.5 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
part of '../main.dart';
// The original story's folded note and repair inspection are optional book
// presentation behavior. Standard story packages use the reusable page renderer.
extension _MaraStory on _NotebookState {
Widget maraStory() {
final p = g.book.pages[g.storyIndex];
final heading = <Widget>[
folio('THE COTTAGE / ${g.storyIndex + 1} OF ${g.book.pages.length}'),
writing(p.title, size: 31),
];
final body = <Widget>[...heading];
Widget? wideBody;
Widget? fittedBody;
switch (p.type) {
case StoryPageType.dedication:
body.addAll([
writing('A few things worth keeping', size: 20, color: muted),
divider(),
reading(p.text),
audio(),
]);
case StoryPageType.entry:
body.addAll([
if (p.illustrationAsset case final asset?)
Image.asset(
asset,
height: 155,
fit: BoxFit.contain,
semanticLabel: 'Watercolour of Gran’s stone cottage, blue door and warm window.',
),
writing(p.speaker, size: 17, color: muted),
reading(p.text),
if (p.continuation.isNotEmpty) reading(p.continuation),
if (g.book.tracks.containsKey(p.id)) audio(),
if (p.campaignIndex != 0)
action('Turn to the pattern →', () => turn(1)),
]);
case StoryPageType.puzzle:
final intro = writing(
g.campaignIndex < 2
? 'Restore a small light, or leave a bookmark and read on.'
: 'Compare the shared areas. Each cell counts in every area it belongs to.',
size: 21,
color: muted,
);
body.addAll([intro, puzzleBody()]);
fittedBody = fittedPuzzle(
details: [areaPicker(), ...puzzleNotes(), ...heading, intro],
);
wideBody = splitPuzzle(
side: [...heading, intro, areaPicker(), ...puzzleNotes()],
);
case StoryPageType.memory:
body.addAll([
discoveryArt(g.book.levels[p.campaignIndex!], height: 155),
writing(
g.recovered(p.campaignIndex!)
? 'A pattern restored · a memory kept'
: 'A memory to read · your puzzle can wait',
size: 17,
color: muted,
),
reading(p.text),
if (p.continuation.isNotEmpty) reading(p.continuation),
if (g.book.tracks.containsKey(p.id)) audio(),
action(
g.recovered(p.campaignIndex!)
? 'View the solved pattern'
: 'Return to this pattern',
() => g.showStory(
g.book.pageFor(p.campaignIndex!, StoryPageType.puzzle),
),
),
]);
case StoryPageType.note:
if (!prefs.flag('notebook_note_open')) {
body.addAll([
writing('A folded scrap, tucked between the leaves.'),
GestureDetector(
onTap: openLetter,
child: const Sketch('envelope', height: 190),
),
action('Unfold Gran’s note', openLetter),
writing(
'You don’t have to solve anything to discover this.',
size: 20,
color: muted,
),
]);
} else {
body.addAll([
writing(
'For the crossing',
size: 28,
color: const Color(0xff70503b),
),
reading(p.text),
audio(),
action('Fold the note again', () {
unawaited(narrator.stop());
unawaited(prefs.set('notebook_note_open', false));
refreshNotebook();
}),
]);
}
case StoryPageType.inspection:
body.addAll([
writing(
prefs.flag('notebook_handle_seen')
? 'A repair made to keep small fingers safe.'
: 'A repair note, tucked into the margin.',
size: 20,
color: muted,
),
reading(p.text),
audio(),
action('Read Gran’s margin note', inspect),
action('Follow the lantern into the next entry →', () => turn(1)),
]);
case StoryPageType.closing:
body.addAll([
reading(p.text),
if (g.book.tracks.containsKey(p.id)) audio(),
writing(
'Four memories in the cottage · ${List.generate(4, (i) => g.recovered(i)).where((v) => v).length} patterns restored',
size: 19,
color: muted,
),
action(
'Take the path to the harbour →',
crossToHarbour,
primary: true,
),
writing(
'Your unfinished patterns will wait here for you.',
size: 19,
color: muted,
),
]);
}
return Leaf(
key: ValueKey('story-${g.storyIndex}'),
onTurn: (d) => turn(d),
body: column(body),
fittedBody: fittedBody,
wideBody: wideBody,
footer: navigation(),
);
}
void openLetter() {
unawaited(prefs.set('notebook_note_open', true));
_scheduleAutoplay();
refreshNotebook();
}
Future<void> inspect() async {
await prefs.set('notebook_handle_seen', true);
await message(
'A careful repair',
'The wire is hidden under a strip of cloth. In the margin, Gran has written: “The light matters. So do the hands carrying it.”',
close: 'Keep that thought',
);
if (mounted) refreshNotebook();
}
}