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:
+114
-61
@@ -1,6 +1,7 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
|
||||
const ink = Color(0xff36413c),
|
||||
blue = Color(0xff274956),
|
||||
@@ -31,23 +32,25 @@ class InkButton extends StatelessWidget {
|
||||
final double size;
|
||||
final bool primary;
|
||||
@override
|
||||
Widget build(BuildContext context) => DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: blue.withValues(alpha: primary ? .5 : .18)),
|
||||
Widget build(BuildContext context) => PageSwipeBlocker(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: blue.withValues(alpha: primary ? .5 : .18)),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: onPressed,
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: blue,
|
||||
disabledForegroundColor: muted.withValues(alpha: .4),
|
||||
textStyle: hand(size),
|
||||
minimumSize: const Size(48, 48),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 8),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
child: TextButton(
|
||||
onPressed: onPressed,
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: blue,
|
||||
disabledForegroundColor: muted.withValues(alpha: .4),
|
||||
textStyle: hand(size),
|
||||
minimumSize: const Size(48, 48),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 8),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
),
|
||||
child: Text(label, textAlign: TextAlign.center),
|
||||
),
|
||||
child: Text(label, textAlign: TextAlign.center),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -61,7 +64,8 @@ class Paper extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PaperState extends State<Paper> {
|
||||
Offset? start;
|
||||
Offset _drag = Offset.zero;
|
||||
Offset _origin = Offset.zero;
|
||||
@override
|
||||
Widget build(BuildContext context) => ColoredBox(
|
||||
color: const Color(0xff314345),
|
||||
@@ -91,38 +95,55 @@ class _PaperState extends State<Paper> {
|
||||
top + h * .91,
|
||||
);
|
||||
return Listener(
|
||||
onPointerDown: (e) {
|
||||
start =
|
||||
(e.localPosition.dx < content.left ||
|
||||
e.localPosition.dx > content.right)
|
||||
? e.localPosition
|
||||
: null;
|
||||
onPointerCancel: (_) {
|
||||
_drag = Offset.zero;
|
||||
},
|
||||
onPointerUp: (e) {
|
||||
final origin = start;
|
||||
start = null;
|
||||
if (origin == null) return;
|
||||
final d = e.localPosition - origin;
|
||||
if (d.dx.abs() > 55 && d.dx.abs() > d.dy.abs() * 1.5) {
|
||||
widget.onTurn?.call(d.dx < 0 ? 1 : -1);
|
||||
}
|
||||
},
|
||||
child: Stack(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
Positioned(
|
||||
left: left,
|
||||
top: top,
|
||||
width: w,
|
||||
height: h,
|
||||
child: Image.asset(
|
||||
'assets/artwork/mara-single-page-v2.png',
|
||||
fit: BoxFit.fill,
|
||||
excludeFromSemantics: true,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onHorizontalDragStart: widget.onTurn == null
|
||||
? null
|
||||
: (details) {
|
||||
_origin = details.globalPosition;
|
||||
_drag = Offset.zero;
|
||||
},
|
||||
onHorizontalDragUpdate: widget.onTurn == null
|
||||
? null
|
||||
: (details) {
|
||||
_drag = details.globalPosition - _origin;
|
||||
},
|
||||
onHorizontalDragCancel: widget.onTurn == null
|
||||
? null
|
||||
: () {
|
||||
_drag = Offset.zero;
|
||||
},
|
||||
onHorizontalDragEnd: widget.onTurn == null
|
||||
? null
|
||||
: (_) {
|
||||
final drag = _drag;
|
||||
_drag = Offset.zero;
|
||||
if (drag.dx.abs() >= 48 &&
|
||||
drag.dx.abs() > drag.dy.abs() * 1.3) {
|
||||
widget.onTurn?.call(drag.dx < 0 ? 1 : -1);
|
||||
}
|
||||
},
|
||||
child: Stack(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
Positioned(
|
||||
left: left,
|
||||
top: top,
|
||||
width: w,
|
||||
height: h,
|
||||
child: Image.asset(
|
||||
'assets/artwork/mara-single-page-v2.png',
|
||||
fit: BoxFit.fill,
|
||||
excludeFromSemantics: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned.fromRect(rect: content, child: widget.child),
|
||||
],
|
||||
Positioned.fromRect(rect: content, child: widget.child),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -131,27 +152,59 @@ class _PaperState extends State<Paper> {
|
||||
);
|
||||
}
|
||||
|
||||
/// A descendant horizontal recognizer wins over the page recognizer on drags.
|
||||
/// Taps still reach the controls, and vertical drags can reach a ScrollView.
|
||||
class PageSwipeBlocker extends StatelessWidget {
|
||||
const PageSwipeBlocker({super.key, required this.child});
|
||||
final Widget child;
|
||||
@override
|
||||
Widget build(BuildContext context) => GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onHorizontalDragStart: (_) {},
|
||||
onHorizontalDragUpdate: (_) {},
|
||||
onHorizontalDragEnd: (_) {},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
class Leaf extends StatelessWidget {
|
||||
const Leaf({super.key, required this.body, this.footer, this.onTurn});
|
||||
const Leaf({
|
||||
super.key,
|
||||
required this.body,
|
||||
this.wideBody,
|
||||
this.footer,
|
||||
this.onTurn,
|
||||
});
|
||||
final Widget body;
|
||||
|
||||
/// Replaces [body] on a landscape page. The shorter page suits side-by-side
|
||||
/// columns better than one long scroll, so it should arrange its own panes.
|
||||
final Widget? wideBody;
|
||||
final Widget? footer;
|
||||
final ValueChanged<int>? onTurn;
|
||||
@override
|
||||
Widget build(BuildContext context) => Paper(
|
||||
onTurn: onTurn,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
key: const PageStorageKey('leaf-scroll'),
|
||||
padding: const EdgeInsets.fromLTRB(4, 0, 4, 8),
|
||||
child: body,
|
||||
Widget build(BuildContext context) {
|
||||
final wide =
|
||||
wideBody != null &&
|
||||
MediaQuery.orientationOf(context) == Orientation.landscape;
|
||||
return Paper(
|
||||
onTurn: onTurn,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: wide
|
||||
? wideBody!
|
||||
: SingleChildScrollView(
|
||||
key: const PageStorageKey('leaf-scroll'),
|
||||
padding: const EdgeInsets.fromLTRB(4, 0, 4, 8),
|
||||
child: body,
|
||||
),
|
||||
),
|
||||
),
|
||||
?footer,
|
||||
],
|
||||
),
|
||||
);
|
||||
?footer,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Cover extends StatelessWidget {
|
||||
|
||||
Reference in New Issue
Block a user