TF-2764 Support press Escape shortcut key on keyboard to close viewer
This commit is contained in:
@@ -60,6 +60,7 @@ class _PDFViewerState extends State<PDFViewer> {
|
|||||||
final ValueNotifier<Object?> _pdfViewStateNotifier = ValueNotifier<Object?>(null);
|
final ValueNotifier<Object?> _pdfViewStateNotifier = ValueNotifier<Object?>(null);
|
||||||
|
|
||||||
final DeviceInfoPlugin _deviceInfoPlugin = Get.find<DeviceInfoPlugin>();
|
final DeviceInfoPlugin _deviceInfoPlugin = Get.find<DeviceInfoPlugin>();
|
||||||
|
final FocusNode _keyboardFocusNode = FocusNode();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -116,12 +117,17 @@ class _PDFViewerState extends State<PDFViewer> {
|
|||||||
_downloadInteractorStreamSubscription?.cancel();
|
_downloadInteractorStreamSubscription?.cancel();
|
||||||
_downloadInteractorStreamSubscription = null;
|
_downloadInteractorStreamSubscription = null;
|
||||||
_downloadAttachmentCancelToken = null;
|
_downloadAttachmentCancelToken = null;
|
||||||
|
_keyboardFocusNode.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Center(
|
return RawKeyboardListener(
|
||||||
|
focusNode: _keyboardFocusNode,
|
||||||
|
autofocus: true,
|
||||||
|
onKey: _handleKeyboardEventListener,
|
||||||
|
child: Center(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
@@ -272,6 +278,7 @@ class _PDFViewerState extends State<PDFViewer> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,4 +286,10 @@ class _PDFViewerState extends State<PDFViewer> {
|
|||||||
_downloadAttachmentCancelToken?.cancel();
|
_downloadAttachmentCancelToken?.cancel();
|
||||||
Navigator.maybeOf(context)?.pop();
|
Navigator.maybeOf(context)?.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _handleKeyboardEventListener(RawKeyEvent event) {
|
||||||
|
if (event is RawKeyDownEvent && event.logicalKey == LogicalKeyboardKey.escape) {
|
||||||
|
_closeView();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
|||||||
import 'package:jmap_dart_client/jmap/core/capability/calendar_event_capability.dart';
|
import 'package:jmap_dart_client/jmap/core/capability/calendar_event_capability.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/state.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_response.dart';
|
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_response.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
|
|||||||
Reference in New Issue
Block a user