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 = [ folio('THE COTTAGE / ${g.storyIndex + 1} OF ${g.book.pages.length}'), writing(p.title, size: 31), ]; final body = [...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( artworkAsset(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 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(); } }