mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-30 13:19:44 +02:00
fix(player): swipe left to advance and right to return
This commit is contained in:
1 parent
fa4a03c754
commit
01adae5b9d
3 files changed
+25
-8
No files matched your search
@@ -200,13 +200,17 @@ void main() {
|
||||
.hitTestable();
|
||||
final rect = tester.getRect(cover);
|
||||
final gesture = await tester.startGesture(rect.center);
|
||||
await gesture.moveBy(const Offset(110, 0));
|
||||
await gesture.moveBy(const Offset(-110, 0));
|
||||
await tester.pump();
|
||||
expect(tester.getRect(cover), rect);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.selected, [1]);
|
||||
expect(find.text('Second').hitTestable(), findsOneWidget);
|
||||
await tester.drag(cover, const Offset(110, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.selected, [1, 0]);
|
||||
expect(find.text('First').hitTestable(), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ void main() {
|
||||
|
||||
for (final reducedMotion in [false, true]) {
|
||||
testWidgets(
|
||||
'cover drag moves only titles and selects once ($reducedMotion)',
|
||||
'left swipe advances and right swipe returns without moving cover ($reducedMotion)',
|
||||
(tester) async {
|
||||
var index = 0;
|
||||
final selected = <int>[];
|
||||
@@ -41,6 +41,7 @@ void main() {
|
||||
key: ValueKey('cover'),
|
||||
width: 200,
|
||||
height: 200,
|
||||
child: ColoredBox(color: Colors.black),
|
||||
),
|
||||
),
|
||||
PlayerTrackSwipeTitles(
|
||||
@@ -68,27 +69,39 @@ void main() {
|
||||
final coverRect = tester.getRect(cover);
|
||||
final titleX = tester.getTopLeft(find.text('Song 0')).dx;
|
||||
final gesture = await tester.startGesture(coverRect.center);
|
||||
await gesture.moveBy(const Offset(110, 0));
|
||||
await gesture.moveBy(const Offset(-110, 0));
|
||||
await tester.pump();
|
||||
expect(tester.getRect(cover), coverRect);
|
||||
expect(tester.getTopLeft(find.text('Song 0')).dx, greaterThan(titleX));
|
||||
expect(tester.getTopLeft(find.text('Song 0')).dx, lessThan(titleX));
|
||||
expect(find.text('Song 1'), findsOneWidget);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, [1]);
|
||||
expect(tester.getTopLeft(find.text('Song 1')).dx, closeTo(titleX, 0.1));
|
||||
|
||||
await tester.drag(find.text('Song 1'), const Offset(-180, 0));
|
||||
await tester.drag(find.text('Song 1'), const Offset(180, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, [1, 0]);
|
||||
// At the first song the previous direction resists, then returns.
|
||||
await tester.drag(cover, const Offset(-200, 0));
|
||||
await tester.drag(cover, const Offset(200, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, [1, 0]);
|
||||
expect(tester.getTopLeft(find.text('Song 0')).dx, closeTo(titleX, 0.1));
|
||||
await tester.drag(cover, const Offset(20, 0));
|
||||
await tester.drag(cover, const Offset(-20, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, [1, 0]);
|
||||
await tester.drag(cover, const Offset(-200, 0));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.drag(cover, const Offset(-200, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, [1, 0, 1, 2]);
|
||||
// At the last song, only the next direction is blocked.
|
||||
await tester.drag(cover, const Offset(-200, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, [1, 0, 1, 2]);
|
||||
await tester.drag(cover, const Offset(200, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, [1, 0, 1, 2, 1]);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user