Enhance postcard puzzles and narration

This commit is contained in:
Hadrian Burkhardt
2026-11-14 08:55:48 +01:00
parent abaab927d9
commit b19295472d
158 changed files with 5257 additions and 1695 deletions
+97 -6
View File
@@ -120,11 +120,14 @@ class Board extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
clue(
'${puzzle.rows[row]}',
complete(
List.generate(n, (i) => row * n + i),
puzzle.rows[row],
),
puzzle.hiddenRow == row
? '?'
: '${puzzle.rows[row]}',
puzzle.hiddenRow != row &&
complete(
List.generate(n, (i) => row * n + i),
puzzle.rows[row],
),
),
for (var col = 0; col < n; col++)
Builder(
@@ -132,6 +135,16 @@ class Board extends StatelessWidget {
final i = row * n + col,
value = cells[i],
fixed = puzzle.given[i],
lantern = puzzle.lanternPairs.any(
(pair) => pair.contains(i),
),
mirrored = puzzle.mirrorPairs.any(
(pair) => pair.contains(i),
),
footprint = puzzle.footprintTrails
.any(
(trail) => trail.contains(i),
),
inside = r?.contains(i, n) ?? false;
final state = value == 0
? 'empty'
@@ -142,7 +155,7 @@ class Board extends StatelessWidget {
selected: inside,
label: CopyScope.text(
context,
'Row ${row + 1}, column ${col + 1}, $state${fixed ? ', fixed clue' : ''}',
'Row ${row + 1}, column ${col + 1}, $state${fixed ? ', fixed clue' : ''}${lantern ? ', lantern pair: exactly one is lit' : ''}${mirrored ? ', mirrored pair: both cells match' : ''}${footprint ? ', footprint trail: two adjacent cells are lit' : ''}',
),
button: !fixed && !won,
enabled: !fixed && !won,
@@ -199,6 +212,84 @@ class Board extends StatelessWidget {
),
),
),
if (lantern)
Positioned(
left: 1,
top: 1,
child: Container(
key: ValueKey(
'lantern-$i',
),
decoration:
const BoxDecoration(
color: cream,
shape: BoxShape
.circle,
),
padding:
const EdgeInsets.all(
1,
),
child: Icon(
Icons
.lightbulb_outline,
size: u * .31,
color: regionInk,
),
),
),
if (mirrored)
Positioned(
left: 1,
top: 1,
child: Container(
key: ValueKey(
'mirror-$i',
),
decoration:
const BoxDecoration(
color: cream,
shape: BoxShape
.circle,
),
padding:
const EdgeInsets.all(
1,
),
child: Icon(
Icons
.auto_awesome,
size: u * .31,
color: regionInk,
),
),
),
if (footprint)
Positioned(
left: 1,
top: 1,
child: Container(
key: ValueKey(
'footprint-$i',
),
decoration:
const BoxDecoration(
color: cream,
shape: BoxShape
.circle,
),
padding:
const EdgeInsets.all(
1,
),
child: Icon(
Icons
.directions_walk,
size: u * .31,
color: regionInk,
),
),
),
if (fixed)
Positioned(
right: 3,
+228 -45
View File
@@ -1,9 +1,70 @@
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import '../domain/game.dart';
import '../domain/postcards.dart';
import '../services/browser_assets.dart';
import 'translation.dart';
/// A saved memory comes into focus and regains its colour.
class PostcardRevealArt extends StatelessWidget {
const PostcardRevealArt({super.key, required this.card});
final IslandPostcard card;
@override
Widget build(BuildContext context) => TweenAnimationBuilder<double>(
tween: Tween(begin: 0, end: 1),
duration: MediaQuery.disableAnimationsOf(context)
? Duration.zero
: const Duration(milliseconds: 1800),
curve: Curves.easeInOut,
child: Image.asset(
artworkAsset(card.illustrationAsset),
fit: BoxFit.cover,
semanticLabel: 'Watercolour illustration for ${card.title}',
),
builder: (context, progress, child) {
final faded = 1 - progress;
return ClipRect(
child: ColorFiltered(
key: const ValueKey('postcard-reveal-color'),
colorFilter: ColorFilter.matrix([
.2126 * faded + progress,
.7152 * faded,
.0722 * faded,
0,
0,
.2126 * faded,
.7152 * faded + progress,
.0722 * faded,
0,
0,
.2126 * faded,
.7152 * faded,
.0722 * faded + progress,
0,
0,
0,
0,
0,
1,
0,
]),
child: ImageFiltered(
imageFilter: ui.ImageFilter.blur(
sigmaX: 7 * faded,
sigmaY: 7 * faded,
),
enabled: progress < 1,
child: child,
),
),
);
},
);
}
class ShelfActivities extends StatelessWidget {
const ShelfActivities({
super.key,
@@ -114,7 +175,7 @@ class PostcardCollectionView extends StatelessWidget {
),
const SizedBox(height: 8),
const CopyText(
'Written postcards · English · No recorded reading',
'Illustrated postcards · English · Recorded readings',
style: TextStyle(fontFamily: 'sans-serif', fontSize: 13),
),
const SizedBox(height: 16),
@@ -135,51 +196,173 @@ class PostcardCollectionView extends StatelessWidget {
),
const SizedBox(height: 20),
for (var i = 0; i < islandPostcards.length; i++)
Card(
margin: const EdgeInsets.only(bottom: 16),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'${i + 1}. ${islandPostcards[i].title}',
style: const TextStyle(
fontFamily: 'serif',
fontSize: 25,
),
),
const SizedBox(height: 8),
Text(
islandPostcards[i].invitation,
style: const TextStyle(
fontFamily: 'sans-serif',
fontSize: 16,
height: 1.5,
),
),
const SizedBox(height: 12),
CopyText(
'${game.postcardSolved(i)} / 3 patterns found',
),
const SizedBox(height: 8),
if (game.postcardSolved(i) == 3)
FilledButton.tonal(
key: ValueKey('read-postcard-$i'),
onPressed: () => onRead(i),
child: const CopyText('Read your postcard'),
)
else
OutlinedButton(
key: ValueKey('start-postcard-$i'),
onPressed: () => onOpen(i),
child: CopyText(
game.postcardSolved(i) == 0
? 'Begin outing'
: 'Continue outing',
Semantics(
key: ValueKey('postcard-$i'),
button: true,
label:
'${islandPostcards[i].title}, ${game.postcardSolved(i)} of 3 patterns found. ${game.postcardSolved(i) == 3
? 'Read your postcard'
: game.postcardSolved(i) == 0
? 'Begin outing'
: 'Continue outing'}',
onTap: () =>
game.postcardSolved(i) == 3 ? onRead(i) : onOpen(i),
excludeSemantics: true,
child: Material(
color: Colors.transparent,
child: InkWell(
excludeFromSemantics: true,
onTap: () =>
game.postcardSolved(i) == 3 ? onRead(i) : onOpen(i),
child: Container(
margin: const EdgeInsets.only(bottom: 24),
padding: const EdgeInsets.all(9),
decoration: BoxDecoration(
color: const Color(0xfffffbef),
border: Border.all(color: const Color(0xffd2bf9c)),
boxShadow: const [
BoxShadow(
color: Color(0x253c3124),
blurRadius: 9,
offset: Offset(2, 4),
),
),
],
],
),
child: Column(
children: [
AspectRatio(
aspectRatio: 1.7,
child: Stack(
fit: StackFit.expand,
children: [
ColorFiltered(
key: ValueKey('postcard-art-$i'),
colorFilter: ColorFilter.matrix(
game.postcardSolved(i) == 3
? const <double>[
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
0,
]
: const <double>[
.2126,
.7152,
.0722,
0,
0,
.2126,
.7152,
.0722,
0,
0,
.2126,
.7152,
.0722,
0,
0,
0,
0,
0,
1,
0,
],
),
child: ClipRect(
child: ImageFiltered(
key: ValueKey('postcard-blur-$i'),
enabled: game.postcardSolved(i) < 3,
imageFilter: ui.ImageFilter.blur(
sigmaX: 7,
sigmaY: 7,
tileMode: TileMode.decal,
),
child: Image.asset(
artworkAsset(
islandPostcards[i]
.illustrationAsset,
),
fit: BoxFit.cover,
semanticLabel:
game.postcardSolved(i) == 3
? 'Watercolour illustration for ${islandPostcards[i].title}'
: 'Postcard artwork locked until all three patterns are solved',
),
),
),
),
if (game.postcardSolved(i) < 3)
const Center(
child: DecoratedBox(
decoration: BoxDecoration(
color: Color(0xaa243a38),
shape: BoxShape.circle,
),
child: Padding(
padding: EdgeInsets.all(12),
child: Icon(
Icons.lock_outline,
color: Colors.white,
),
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(
12,
16,
12,
12,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.stretch,
children: [
Text(
'${i + 1}. ${islandPostcards[i].title}',
style: const TextStyle(
fontFamily: 'MaraHand',
fontSize: 28,
),
),
const SizedBox(height: 8),
Text(
islandPostcards[i].invitation,
style: const TextStyle(
fontFamily: 'MaraHand',
fontSize: 21,
height: 1.3,
),
),
const SizedBox(height: 12),
CopyText(
'${game.postcardSolved(i)} / 3 patterns found',
),
],
),
),
],
),
),
),
),
),