Open Lumen on a responsive bookshelf and land pending story work
- Start the app on a shelf of every installed book instead of the last book's home. Cards show the cover, translated metadata, available languages, restored patterns and either "Continue reading" or a way in. - Keep each book's saved route: the shelf is never written to flutter_screen, so choosing a book resumes its own leaf. - Lay the shelf out responsively: dense single-column cards on phones, a two-column grid from 720 logical pixels, a centred 860 px column on tablets and a chevron that exists in the bundled handwriting font. - Keep Settings reachable from the shelf and let the home page's story library button open the shelf instead of a dialog. - Add tool/shelf_screenshots_test.dart, which renders the shelf at phone and tablet metrics, checks that every card and Settings stay reachable without overflow, and writes artifacts/library/shelf-*.png. - Commit the pending Midnight Invitation package (campaign, notebook, narration and artwork), cast drama and ambience tooling, region selection, phone/tablet integration coverage and related docs. flutter analyze is clean and all 74 widget/domain tests pass.
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lumen/domain/book.dart';
|
||||
import 'package:lumen/domain/game.dart';
|
||||
import 'package:lumen/domain/library.dart';
|
||||
import 'package:lumen/main.dart';
|
||||
import 'package:lumen/services/progress.dart';
|
||||
import 'package:lumen/ui/board.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'selected region follows its exact cells and never blocks marking',
|
||||
(tester) async {
|
||||
addTearDown(tester.view.reset);
|
||||
final library = (await tester.runAsync(StoryLibrary.load))!;
|
||||
final book = (await tester.runAsync(
|
||||
() => library.open('midnight-invitation'),
|
||||
))!;
|
||||
for (final size in [const Size(360, 640), const Size(960, 600)]) {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
final game = Game(book, Progress.memory(), library: library);
|
||||
game.showStory(book.pageFor(2, StoryPageType.puzzle));
|
||||
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Undo a mark'), findsNothing);
|
||||
for (var index = 0; index < game.puzzle!.regions.length; index++) {
|
||||
final button = find.byKey(ValueKey('area-$index'));
|
||||
await tester.ensureVisible(button);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(button);
|
||||
await tester.pumpAndSettle();
|
||||
expect(game.selectedArea, index);
|
||||
expect(tester.widget<RegionButton>(button).selected, true);
|
||||
expect(
|
||||
find.descendant(of: button, matching: find.byIcon(Icons.check)),
|
||||
findsNothing,
|
||||
);
|
||||
final region = game.puzzle!.regions[index];
|
||||
final n = game.puzzle!.size;
|
||||
final first = find.byKey(
|
||||
ValueKey('cell-${region.top * n + region.left}'),
|
||||
);
|
||||
final last = find.byKey(
|
||||
ValueKey(
|
||||
'cell-${(region.top + region.height - 1) * n + region.left + region.width - 1}',
|
||||
),
|
||||
);
|
||||
final outline = tester.getRect(
|
||||
find.byKey(const ValueKey('selected-region-outline')),
|
||||
);
|
||||
final cells = Rect.fromPoints(
|
||||
tester.getTopLeft(first),
|
||||
tester.getBottomRight(last),
|
||||
);
|
||||
expect(outline.left, closeTo(cells.left, .01));
|
||||
expect(outline.top, closeTo(cells.top, .01));
|
||||
expect(outline.width, closeTo(cells.width, .01));
|
||||
expect(outline.height, closeTo(cells.height, .01));
|
||||
final cell = List.generate(
|
||||
n * n,
|
||||
(i) => i,
|
||||
).firstWhere((i) => region.contains(i, n) && !game.puzzle!.given[i]);
|
||||
final target = find.byKey(ValueKey('cell-$cell'));
|
||||
final original = game.cells[cell];
|
||||
await tester.ensureVisible(target);
|
||||
await tester.pumpAndSettle();
|
||||
for (var count = 0; count < 3; count++) {
|
||||
await tester.tap(target);
|
||||
await tester.pumpAndSettle();
|
||||
expect(game.cells[cell], (original + count + 1) % 3);
|
||||
}
|
||||
}
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Halloween paper follows reading and contents and switches back with the book',
|
||||
(tester) async {
|
||||
final library = (await tester.runAsync(StoryLibrary.load))!;
|
||||
final book = (await tester.runAsync(
|
||||
() => library.open('midnight-invitation'),
|
||||
))!;
|
||||
final game = Game(book, Progress.memory(), library: library);
|
||||
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
|
||||
game.openNotebook();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.image(AssetImage(book.paperAsset!)), findsOneWidget);
|
||||
expect(
|
||||
find.image(const AssetImage('assets/artwork/mara-single-page-v2.png')),
|
||||
findsNothing,
|
||||
);
|
||||
game.contents();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.image(AssetImage(book.paperAsset!)), findsOneWidget);
|
||||
await tester.runAsync(() => game.selectStory('mara-island'));
|
||||
game.openNotebook();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.image(const AssetImage('assets/artwork/mara-single-page-v2.png')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.image(AssetImage(book.paperAsset!)), findsNothing);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user