Add browser playtest and improve library, media and input

Bundle web bootstrap, icons, local font fallbacks and hosting instructions.
Add optimized WebP/MP3 packaging, asset checks and a browser narration
regression tool. Support browser audio handoff and ad-free explained hints.

Refresh the responsive bookshelf and reduce unnecessary app, narration and
paper repaint work. Preserve deliberate page swipes while tolerating small
mouse movements during cell and navigation clicks.

Validation: all 77 Flutter tests pass; shell, JavaScript and Python scripts
parse; locale and web manifests are valid JSON; git diff --check passes.
This commit is contained in:
Hadrian Burkhardt
2026-11-06 03:33:26 +01:00
parent 7855aafade
commit 7e6b203a02
34 changed files with 1370 additions and 269 deletions
+254
View File
@@ -0,0 +1,254 @@
import '../services/browser_assets.dart';
import 'package:flutter/material.dart';
import '../domain/book.dart';
import 'translation.dart';
const _shelfPaper = Color(0xfff6f1e7);
const _shelfInk = Color(0xff283e37);
const _shelfMuted = Color(0xff746f62);
TextStyle _type(double size, {Color color = _shelfInk, bool serif = false}) =>
TextStyle(
fontFamily: serif ? 'serif' : 'sans-serif',
fontSize: size,
height: serif ? 1.2 : 1.5,
color: color,
);
/// The collection has its own quiet surface, outside any one story's notebook.
class LibraryShelf extends StatelessWidget {
const LibraryShelf({
super.key,
required this.builder,
required this.onSettings,
});
final Widget Function(BuildContext context, double width) builder;
final VoidCallback onSettings;
@override
Widget build(BuildContext context) => ColoredBox(
color: _shelfPaper,
child: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
final compact = constraints.maxWidth < 600;
final padding = compact ? 24.0 : 48.0;
return SingleChildScrollView(
key: const ValueKey('library-scroll'),
padding: EdgeInsets.fromLTRB(padding, 20, padding, 48),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 1120),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 24,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.auto_stories_outlined,
color: _shelfInk,
size: 22,
),
const SizedBox(width: 10),
Text('L U M E N', style: _type(13)),
],
),
TextButton.icon(
onPressed: onSettings,
icon: const Icon(Icons.tune_rounded, size: 18),
label: CopyText('Settings', style: _type(13)),
style: TextButton.styleFrom(
foregroundColor: _shelfInk,
minimumSize: const Size(48, 48),
),
),
],
),
const SizedBox(height: 20),
Divider(color: _shelfInk.withValues(alpha: .18)),
SizedBox(height: compact ? 28 : 44),
CopyText(
'Choose a book',
style: _type(compact ? 36 : 48, serif: true),
),
const SizedBox(height: 12),
CopyText(
'Open a book to continue where you left off.',
style: _type(15, color: _shelfMuted),
),
SizedBox(height: compact ? 30 : 40),
LayoutBuilder(
builder: (context, c) => builder(context, c.maxWidth),
),
],
),
),
),
);
},
),
),
);
}
class LibraryBookCard extends StatelessWidget {
const LibraryBookCard({
super.key,
required this.story,
required this.restored,
required this.resuming,
required this.languages,
required this.onOpen,
});
final Book story;
final int restored;
final bool resuming;
final List<String> languages;
final VoidCallback onOpen;
@override
Widget build(BuildContext context) {
final (cloth, light) = switch (story.id) {
'mara-island' => (const Color(0xff355751), const Color(0xffe0e5d6)),
'paper-boat' => (const Color(0xff526c85), const Color(0xffe1e9e8)),
_ => (const Color(0xff51445e), const Color(0xffe8dfd8)),
};
return Semantics(
button: true,
child: Material(
color: Colors.transparent,
child: InkWell(
key: ValueKey('library-book-${story.id}'),
onTap: onOpen,
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// A cloth-bound cover with a recessed illustrated panel. The
// artwork keeps its natural proportions inside each book.
Container(
height: 276,
padding: const EdgeInsets.fromLTRB(22, 20, 14, 20),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [cloth, Color.lerp(cloth, Colors.black, .2)!],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
boxShadow: [
BoxShadow(
color: cloth.withValues(alpha: .22),
offset: const Offset(0, 10),
blurRadius: 16,
spreadRadius: -5,
),
],
border: Border(
left: BorderSide(
color: Color.lerp(cloth, Colors.black, .35)!,
width: 7,
),
right: BorderSide(color: light, width: 3),
),
),
child: Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
border: Border.all(color: light.withValues(alpha: .4)),
),
child: Column(
children: [
Icon(
Icons.auto_awesome_outlined,
size: 18,
color: light,
),
const SizedBox(height: 12),
Expanded(
child: story.coverAsset == null
? Icon(Icons.menu_book, size: 64, color: light)
: Image.asset(
artworkAsset(story.coverAsset!),
fit: BoxFit.contain,
excludeFromSemantics: true,
errorBuilder: (_, _, _) => Icon(
Icons.menu_book,
size: 64,
color: light,
),
),
),
const SizedBox(height: 12),
SizedBox(width: 38, child: Divider(color: light)),
],
),
),
),
const SizedBox(height: 24),
CopyText(story.title, style: _type(25, serif: true)),
const SizedBox(height: 10),
if (story.description.isNotEmpty)
CopyText(
story.description,
style: _type(14, color: _shelfMuted),
),
if (languages.length > 1) ...[
const SizedBox(height: 10),
Text(
languages.join(' · '),
style: _type(12, color: _shelfMuted),
),
],
const SizedBox(height: 20),
if (story.levels.isNotEmpty) ...[
ClipRRect(
borderRadius: BorderRadius.circular(2),
child: LinearProgressIndicator(
value: restored / story.levels.length,
minHeight: 3,
color: cloth,
backgroundColor: cloth.withValues(alpha: .13),
),
),
const SizedBox(height: 8),
CopyText(
'$restored / ${story.levels.length} memories restored',
style: _type(12, color: _shelfMuted),
),
],
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: CopyText(
resuming ? 'Continue reading' : 'Open this book ›',
style: _type(
14,
color: cloth,
).copyWith(fontWeight: FontWeight.w600),
),
),
Icon(Icons.arrow_forward_rounded, size: 18, color: cloth),
],
),
const SizedBox(height: 8),
],
),
),
),
),
);
}
}