- Give the floating bar and search satellite the app's one shadow (nooDialogShadow) plus a smaller, tighter height on both platforms. - Let every tab's scrollable list compute its own bottom clearance (bottomBarClearance) instead of a flat 100px, so the floating bar no longer overlaps the last row/card. - Square the Android upload FAB off to a rounded-square radius when the bottom bar is attached, keeping it fully round only when floating. - Let a swipe on a file row trigger its action directly once dragged past 1.8x the reveal width, instead of requiring a second tap. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
107 lines
3.0 KiB
Dart
107 lines
3.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:noo/widgets/noo/files/noo_swipe_action.dart';
|
|
|
|
import 'noo_test_utils.dart';
|
|
|
|
void main() {
|
|
setUpNooTests();
|
|
|
|
group('NooSwipeAction', () {
|
|
testNooWidgets('a moderate swipe opens the action without triggering it', (
|
|
tester,
|
|
theme,
|
|
c,
|
|
) async {
|
|
var triggered = 0;
|
|
await pumpNoo(
|
|
tester,
|
|
SizedBox(
|
|
width: 360,
|
|
height: 64,
|
|
child: NooSwipeAction(
|
|
endAction: NooSwipeActionSpec(
|
|
kind: NooSwipeActionKind.delete,
|
|
onTriggered: () => triggered++,
|
|
),
|
|
child: const ColoredBox(
|
|
color: Colors.white,
|
|
child: SizedBox(width: 360, height: 64),
|
|
),
|
|
),
|
|
),
|
|
theme: theme,
|
|
);
|
|
// Half the block's own width (96) is well past the "snap open"
|
|
// threshold but nowhere near the 1.8x trigger extent.
|
|
await tester.drag(find.byType(NooSwipeAction), const Offset(-60, 0));
|
|
await tester.pumpAndSettle();
|
|
expect(triggered, 0);
|
|
expect(find.text('Delete'), findsOneWidget);
|
|
});
|
|
|
|
testNooWidgets(
|
|
'swiping past the trigger extent fires the action on release - no '
|
|
'second tap needed',
|
|
(tester, theme, c) async {
|
|
var triggered = 0;
|
|
await pumpNoo(
|
|
tester,
|
|
SizedBox(
|
|
width: 360,
|
|
height: 64,
|
|
child: NooSwipeAction(
|
|
endAction: NooSwipeActionSpec(
|
|
kind: NooSwipeActionKind.delete,
|
|
onTriggered: () => triggered++,
|
|
),
|
|
child: const ColoredBox(
|
|
color: Colors.white,
|
|
child: SizedBox(width: 360, height: 64),
|
|
),
|
|
),
|
|
),
|
|
theme: theme,
|
|
);
|
|
// 300px of drag on a 96px-wide block clears the 1.8x (~173px)
|
|
// trigger extent well past the clamp ceiling.
|
|
await tester.drag(find.byType(NooSwipeAction), const Offset(-300, 0));
|
|
await tester.pump();
|
|
expect(triggered, 1);
|
|
},
|
|
);
|
|
|
|
testNooWidgets('tapping the revealed block still triggers the action too', (
|
|
tester,
|
|
theme,
|
|
c,
|
|
) async {
|
|
var triggered = 0;
|
|
await pumpNoo(
|
|
tester,
|
|
SizedBox(
|
|
width: 360,
|
|
height: 64,
|
|
child: NooSwipeAction(
|
|
startAction: NooSwipeActionSpec(
|
|
kind: NooSwipeActionKind.favorite,
|
|
onTriggered: () => triggered++,
|
|
),
|
|
child: const ColoredBox(
|
|
color: Colors.white,
|
|
child: SizedBox(width: 360, height: 64),
|
|
),
|
|
),
|
|
),
|
|
theme: theme,
|
|
);
|
|
await tester.drag(find.byType(NooSwipeAction), const Offset(60, 0));
|
|
await tester.pumpAndSettle();
|
|
expect(triggered, 0);
|
|
await tester.tap(find.text('Favorite'));
|
|
await tester.pump();
|
|
expect(triggered, 1);
|
|
});
|
|
});
|
|
}
|