add ClideLightbox — click image cards to enlarge (T-252)
The inline image cards (T-249) are often too small to read. Clicking one now opens a full-screen lightbox: zoom (scroll wheel / pinch), pan when zoomed, double-click to reset to fit, Esc / close button / backdrop click to dismiss. ClideLightbox is a reusable primitive (lib/widgets/) over Flutter's InteractiveViewer with clide-owned zoom gestures, shown via the DialogRouter (dimmed backdrop, single modal at a time, D-78). The card stays display-only; the click is a navigation gesture, not an inline control. CLI parity (D-6): `clide image show <path> --fullscreen` opens straight into the lightbox instead of injecting a card. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,14 @@ void main() {
|
||||
expect(published.single.data, {'path': '/abs/docs/diagram.png', 'caption': 'before the fix'});
|
||||
});
|
||||
|
||||
test('--fullscreen rides along in the payload (T-252)', () async {
|
||||
wire();
|
||||
final r = await show(['docs/diagram.png'], flags: {'fullscreen': true});
|
||||
expect(r.ok, isTrue, reason: r.error?.message);
|
||||
expect(r.data['fullscreen'], isTrue);
|
||||
expect(published.single.data, {'path': '/abs/docs/diagram.png', 'fullscreen': true});
|
||||
});
|
||||
|
||||
test('accepts the documented formats case-insensitively', () async {
|
||||
for (final name in ['a.PNG', 'b.jpg', 'c.jpeg', 'd.gif', 'e.webp', 'f.bmp']) {
|
||||
wire(found: {name});
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/// T-252: ClideLightbox — full-screen zoom/pan overlay primitive.
|
||||
library;
|
||||
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../helpers/kernel_fixture.dart';
|
||||
import '../helpers/widget_harness.dart';
|
||||
|
||||
bool _textHas(Object? w, String s) => w is ClideText && w.data.contains(s);
|
||||
|
||||
void main() {
|
||||
late KernelFixture f;
|
||||
setUp(() async => f = await KernelFixture.create());
|
||||
tearDown(() => f.dispose());
|
||||
|
||||
Widget box(VoidCallback onDismiss) => MediaQuery(
|
||||
data: const MediaQueryData(size: Size(800, 600)),
|
||||
child: ClideLightbox(onDismiss: onDismiss, child: const SizedBox(width: 200, height: 150)),
|
||||
);
|
||||
|
||||
testWidgets('renders the zoom hint and an InteractiveViewer', (tester) async {
|
||||
await tester.pumpWidget(harness(f, box(() {})));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(InteractiveViewer), findsOneWidget);
|
||||
expect(find.byWidgetPredicate((w) => _textHas(w, 'Esc to close')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Esc dismisses', (tester) async {
|
||||
var dismissed = false;
|
||||
await tester.pumpWidget(harness(f, box(() => dismissed = true)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(dismissed, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('the close button dismisses', (tester) async {
|
||||
var dismissed = false;
|
||||
await tester.pumpWidget(harness(f, box(() => dismissed = true)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.ancestor(of: find.byType(ClideIcon), matching: find.byType(GestureDetector)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(dismissed, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('double-tap resets without dismissing', (tester) async {
|
||||
var dismissed = false;
|
||||
await tester.pumpWidget(harness(f, box(() => dismissed = true)));
|
||||
await tester.pumpAndSettle();
|
||||
final viewer = find.byType(InteractiveViewer);
|
||||
await tester.tap(viewer);
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
await tester.tap(viewer);
|
||||
await tester.pumpAndSettle();
|
||||
expect(dismissed, isFalse);
|
||||
expect(find.byType(InteractiveViewer), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('scroll wheel zooms in and out', (tester) async {
|
||||
await tester.pumpWidget(harness(f, box(() {})));
|
||||
await tester.pumpAndSettle();
|
||||
final center = tester.getCenter(find.byType(InteractiveViewer));
|
||||
final pointer = TestPointer(1, PointerDeviceKind.mouse)..hover(center);
|
||||
await tester.sendEventToBinding(pointer.scroll(const Offset(0, -100))); // in
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendEventToBinding(pointer.scroll(const Offset(0, 100))); // out
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(InteractiveViewer), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user