TF-3911 Support mail keyboard shortcut actions in email detailed view on web

This commit is contained in:
dab246
2025-07-29 02:00:32 +07:00
committed by Dat H. Pham
parent 1c7778d6cc
commit b2989521d9
36 changed files with 763 additions and 270 deletions
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
typedef OnHandleKeyEventAction = void Function(KeyEvent event);
class KeyboardHandlerWrapper extends StatelessWidget {
final Widget child;
final FocusNode focusNode;
final OnHandleKeyEventAction onKeyDownEventAction;
final OnHandleKeyEventAction? onKeyUpEventAction;
const KeyboardHandlerWrapper({
Key? key,
required this.child,
required this.focusNode,
required this.onKeyDownEventAction,
this.onKeyUpEventAction,
}) : super(key: key);
void _handleKeyEvent(KeyEvent event) {
if (event is KeyDownEvent) {
onKeyDownEventAction(event);
} else if (event is KeyUpEvent) {
onKeyUpEventAction?.call(event);
}
}
@override
Widget build(BuildContext context) {
return KeyboardListener(
focusNode: focusNode,
autofocus: true,
onKeyEvent: _handleKeyEvent,
child: child,
);
}
}