fix(app): close the artifact viewer with Escape
This commit is contained in:
@@ -9,6 +9,7 @@ class ArrowKeyPager extends StatelessWidget {
|
||||
super.key,
|
||||
required this.onPrevious,
|
||||
required this.onNext,
|
||||
this.onEscape,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@@ -17,6 +18,10 @@ class ArrowKeyPager extends StatelessWidget {
|
||||
|
||||
/// Null at the last item.
|
||||
final VoidCallback? onNext;
|
||||
|
||||
/// Escape, when the surface can be dismissed (a viewer page). Absent means
|
||||
/// Escape keeps whatever meaning the surrounding page gives it.
|
||||
final VoidCallback? onEscape;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
@@ -26,6 +31,9 @@ class ArrowKeyPager extends StatelessWidget {
|
||||
onPrevious?.call(),
|
||||
const SingleActivator(LogicalKeyboardKey.arrowRight): () =>
|
||||
onNext?.call(),
|
||||
if (onEscape != null)
|
||||
const SingleActivator(LogicalKeyboardKey.escape): () =>
|
||||
onEscape!.call(),
|
||||
},
|
||||
child: Focus(autofocus: true, child: child),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user