Rearrange landscape puzzle layout
Landscape leaves now lay the puzzle out in two columns: the whole grid keeps one column (square, sized to the page) with the heading, area totals, hint/undo and notes beside it, and the leaf navigation folds into a single row. The game leaf also keeps its actions in a compact bottom bar, so the board and controls are visible without scrolling. - Leaf gains an optional wideBody used on landscape pages. - Board gains maxWidth, defaulting to the previous 350. - Split the puzzle body into area, board and note builders so both layouts share the same controls. - Add a landscape widget regression test and document the layout. This snapshot also carries the pending 2.0.2 notebook work already in the tree: read-ahead restore, bundled PCM WAV narration assets, the audio consistency comment, version 2.0.2+11, and the related unit, integration and script updates.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
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/puzzle.dart';
|
||||
import 'package:lumen/main.dart';
|
||||
import 'package:lumen/services/progress.dart';
|
||||
import 'package:lumen/ui/board.dart';
|
||||
import 'package:lumen/ui/paper.dart';
|
||||
|
||||
@@ -42,6 +46,98 @@ void main() {
|
||||
expect(marks, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
testWidgets(
|
||||
'reading swipes turn both ways; controls, scrolling and cancelled drags do not',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(600, 960);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
var turns = 0, plays = 0;
|
||||
final scroll = ScrollController();
|
||||
addTearDown(scroll.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Paper(
|
||||
onTurn: (direction) => turns += direction,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
controller: scroll,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
key: const ValueKey('reading-zone'),
|
||||
height: 130,
|
||||
width: double.infinity,
|
||||
child: writing(
|
||||
'My dear, take your time with these pages.',
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
key: const ValueKey('blank-zone'),
|
||||
height: 100,
|
||||
width: double.infinity,
|
||||
),
|
||||
for (var i = 0; i < 12; i++)
|
||||
SizedBox(
|
||||
height: 80,
|
||||
child: writing('A remembered passage $i.'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
InkButton('Play this reading', () => plays++),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.drag(
|
||||
find.byKey(const ValueKey('reading-zone')),
|
||||
const Offset(-150, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(turns, 1);
|
||||
await tester.dragFrom(
|
||||
tester.getCenter(find.byKey(const ValueKey('blank-zone'))),
|
||||
const Offset(150, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(turns, 0);
|
||||
await tester.drag(find.text('Play this reading'), const Offset(-120, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(turns, 0);
|
||||
expect(plays, 0);
|
||||
await tester.tap(find.text('Play this reading'));
|
||||
expect(plays, 1);
|
||||
await tester.drag(
|
||||
find.byKey(const ValueKey('reading-zone')),
|
||||
const Offset(-30, 0),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(turns, 0);
|
||||
final drag = await tester.startGesture(
|
||||
tester.getCenter(find.byKey(const ValueKey('reading-zone'))),
|
||||
);
|
||||
await drag.moveBy(const Offset(-140, 0));
|
||||
await drag.cancel();
|
||||
await tester.pumpAndSettle();
|
||||
expect(turns, 0);
|
||||
await tester.drag(
|
||||
find.byKey(const ValueKey('reading-zone')),
|
||||
const Offset(0, -200),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(scroll.offset, greaterThan(0));
|
||||
expect(turns, 0);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
testWidgets('paper supports small and landscape viewports and larger text', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -75,4 +171,45 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('landscape pages keep the whole grid beside its notes', (
|
||||
tester,
|
||||
) async {
|
||||
const width = 960.0, height = 600.0;
|
||||
tester.view.physicalSize = const Size(width, height);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final book = await Book.load();
|
||||
final game = Game(book, Progress.memory());
|
||||
game.startCampaign(0);
|
||||
await tester.pumpWidget(LumenApp(game: game, adsEnabled: false));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// The campaign leaf gives the board its own column, with the heading and
|
||||
// controls beside it rather than above the fold.
|
||||
final lastCell = tester.getRect(find.byKey(const ValueKey('cell-48')));
|
||||
expect(lastCell.bottom, lessThan(height * .94));
|
||||
expect(
|
||||
tester.getTopLeft(find.text('A spark in the drawer')).dx,
|
||||
greaterThan(lastCell.right),
|
||||
);
|
||||
expect(find.text('Hint · free'), findsOneWidget);
|
||||
expect(find.text('Back to notebook'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
// The opening notebook's puzzle leaf uses the same two columns, with the
|
||||
// grid on the page and its controls beside it.
|
||||
game.showStory(2);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
final storyLast = tester.getRect(find.byKey(const ValueKey('cell-48')));
|
||||
expect(storyLast.bottom, lessThan(height * .94));
|
||||
expect(
|
||||
tester.getTopLeft(find.text('Hint · free')).dx,
|
||||
greaterThan(storyLast.right),
|
||||
);
|
||||
expect(find.text('Next leaf →'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user