Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/shared/widgets/app_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import 'package:querya_desktop/core/motion/querya_spring.dart';
///
/// Use instead of [showDialog] so every overlay has consistent blur.
/// Enter: fade + slight slide; exit uses [QueryaMotion.exit] via reverseCurve.
///
/// When [barrierDismissible] is true (default), Escape and backdrop tap dismiss.
/// Escape is handled by the modal route; backdrop tap by [_BlurredDialogScaffold]
/// (the route barrier stays transparent under the frosted layer).
Future<T?> showAppDialog<T>({
required BuildContext context,
required WidgetBuilder builder,
bool barrierDismissible = true,
}) {
return showGeneralDialog<T>(
context: context,
barrierDismissible: false,
barrierDismissible: barrierDismissible,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: Colors.transparent,
transitionDuration: context.motionDuration(QueryaMotion.standard),
Expand Down
42 changes: 42 additions & 0 deletions test/shared/app_dialog_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:ui' show ImageFilter;

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:querya_desktop/core/motion/querya_motion.dart';
import 'package:querya_desktop/core/motion/querya_motion_scope.dart';
Expand Down Expand Up @@ -70,6 +71,47 @@ void main() {
await future;
});

testWidgets('barrierDismissible true closes dialog on Escape', (tester) async {
final ctx = await pumpHost(tester);
var completed = false;

final future = showAppDialog<void>(
context: ctx,
barrierDismissible: true,
builder: (c) => const AlertDialog(title: Text('Escapable')),
).whenComplete(() => completed = true);

await tester.pumpAndSettle();
expect(find.text('Escapable'), findsOneWidget);

await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();

expect(find.text('Escapable'), findsNothing);
expect(completed, isTrue);
await future;
});

testWidgets('barrierDismissible false ignores Escape', (tester) async {
final ctx = await pumpHost(tester);

final future = showAppDialog<void>(
context: ctx,
barrierDismissible: false,
builder: (c) => const AlertDialog(title: Text('No escape')),
);

await tester.pumpAndSettle();
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();

expect(find.text('No escape'), findsOneWidget);

Navigator.of(ctx, rootNavigator: true).pop();
await tester.pumpAndSettle();
await future;
});

testWidgets('showAppDialog uses fade-slide (not scale) with BackdropFilter',
(tester) async {
final ctx = await pumpHost(tester);
Expand Down
Loading