import 'package:flutter/material.dart'; import '../domain/game.dart'; import '../domain/postcards.dart'; import 'translation.dart'; class ShelfActivities extends StatelessWidget { const ShelfActivities({ super.key, required this.game, required this.onPostcards, }); final Game game; final VoidCallback onPostcards; @override Widget build(BuildContext context) => Container( key: const ValueKey('shelf-activities'), margin: const EdgeInsets.only(bottom: 32), padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: const Color(0xffe5ebe2), borderRadius: BorderRadius.circular(12), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const CopyText( 'A little light, every day', style: TextStyle(fontFamily: 'serif', fontSize: 27), ), const SizedBox(height: 8), CopyText( game.todaySolved ? 'Today’s pattern is complete. Your next daily puzzle arrives tomorrow.' : 'One fresh daily pattern, or a short walk around Mara’s island.', style: const TextStyle(fontFamily: 'sans-serif', fontSize: 15), ), const SizedBox(height: 12), Wrap( spacing: 12, runSpacing: 8, children: [ FilledButton.icon( key: const ValueKey('shelf-daily'), onPressed: () => game.startDaily(DateTime.now()), icon: Icon( game.todaySolved ? Icons.check : Icons.wb_sunny_outlined, ), label: CopyText( game.todaySolved ? 'Revisit today’s puzzle' : 'Today’s puzzle', ), ), OutlinedButton.icon( key: const ValueKey('shelf-postcards'), onPressed: onPostcards, icon: const Icon(Icons.local_post_office_outlined), label: const CopyText('Island postcards'), ), ], ), const SizedBox(height: 8), CopyText( '${game.postcardsCollected} / 14 postcards collected', style: const TextStyle(fontFamily: 'sans-serif', fontSize: 13), ), ], ), ); } class PostcardCollectionView extends StatelessWidget { const PostcardCollectionView({ super.key, required this.game, required this.onBack, required this.onOpen, required this.onRead, }); final Game game; final VoidCallback onBack; final ValueChanged onOpen, onRead; @override Widget build(BuildContext context) => ColoredBox( color: const Color(0xfff6f1e7), child: SafeArea( child: SingleChildScrollView( key: const ValueKey('postcard-collection'), padding: const EdgeInsets.all(24), child: Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 760), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Align( alignment: Alignment.centerLeft, child: TextButton.icon( onPressed: onBack, icon: const Icon(Icons.arrow_back), label: const CopyText('Back to the shelf'), ), ), const SizedBox(height: 16), const CopyText( 'Island postcards', style: TextStyle(fontFamily: 'serif', fontSize: 36), ), const SizedBox(height: 12), const CopyText( 'Fourteen small outings after the lighthouse story. Solve three patterns to keep each postcard. Take them at your own pace; nothing expires.', style: TextStyle(fontFamily: 'sans-serif', fontSize: 16), ), const SizedBox(height: 8), const CopyText( 'Written postcards · English · No recorded reading', style: TextStyle(fontFamily: 'sans-serif', fontSize: 13), ), const SizedBox(height: 16), CopyText('${game.postcardsCollected} / 14 postcards collected'), if (game.store.contains('postcard_last') && game.postcardSolved( game.store.number('postcard_last').clamp(0, 13), ) < 3) Padding( padding: const EdgeInsets.only(top: 12), child: FilledButton( onPressed: () => onOpen( game.store.number('postcard_last').clamp(0, 13), ), child: const CopyText('Continue your outing'), ), ), 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', ), ), ], ), ), ), ], ), ), ), ), ), ); }