feat: accept edge swipes across the whole margin beside the text column
This commit is contained in:
parent
56f3d959fa
commit
6f9c0e587a
3 changed files with 70 additions and 9 deletions
|
|
@ -20,8 +20,10 @@ SwipeNavigator _navigator({
|
|||
required VoidCallback onForward,
|
||||
bool canGoBack = true,
|
||||
bool canGoForward = true,
|
||||
double? contentWidth,
|
||||
}) =>
|
||||
SwipeNavigator(
|
||||
contentWidth: contentWidth,
|
||||
canGoBack: canGoBack,
|
||||
canGoForward: canGoForward,
|
||||
backTitle: 'Previous page',
|
||||
|
|
@ -101,6 +103,47 @@ void main() {
|
|||
expect(find.text('Previous page'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('swipes anywhere in the margin beside the column',
|
||||
(tester) async {
|
||||
var back = 0;
|
||||
await tester.pumpWidget(_wrap(_navigator(
|
||||
onBack: () => back++,
|
||||
onForward: () {},
|
||||
// A 40em column leaves 200px margins on an 800px surface.
|
||||
contentWidth: 400,
|
||||
)));
|
||||
|
||||
final center = tester.getCenter(find.byType(SwipeNavigator));
|
||||
// Deep inside the left margin, far past the base edge zone.
|
||||
final gesture = await tester.startGesture(Offset(180, center.dy));
|
||||
await gesture.moveBy(const Offset(300, 0));
|
||||
await tester.pump();
|
||||
expect(find.text('Previous page'), findsOneWidget);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(back, 1);
|
||||
});
|
||||
|
||||
testWidgets('drags over the content column still belong to selection',
|
||||
(tester) async {
|
||||
var back = 0;
|
||||
await tester.pumpWidget(_wrap(_navigator(
|
||||
onBack: () => back++,
|
||||
onForward: () {},
|
||||
contentWidth: 400,
|
||||
)));
|
||||
|
||||
final center = tester.getCenter(find.byType(SwipeNavigator));
|
||||
// Inside the column: no swipe, nothing peeks.
|
||||
final gesture = await tester.startGesture(Offset(400, center.dy));
|
||||
await gesture.moveBy(const Offset(300, 0));
|
||||
await tester.pump();
|
||||
expect(find.text('Previous page'), findsNothing);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(back, 0);
|
||||
});
|
||||
|
||||
testWidgets('directions without pages rubber-band and never commit',
|
||||
(tester) async {
|
||||
var back = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue