Enhance postcard puzzles and narration
This commit is contained in:
+228
-45
@@ -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',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user