diff --git a/lib/app.dart b/lib/app.dart index 8e59f9b7c1..c248f74db3 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -32,7 +32,6 @@ import 'utils/extension/extension.dart'; import 'utils/hook.dart'; import 'utils/logger.dart'; import 'utils/system/system_fonts.dart'; -import 'utils/system/text_input.dart'; import 'utils/system/tray.dart'; import 'widgets/brightness_observer.dart'; import 'widgets/focus_helper.dart'; @@ -222,11 +221,7 @@ class _App extends StatelessWidget { ? textScaleFactor : mediaQueryData.textScaleFactor, ), - child: SystemTrayWidget( - child: TextInputActionHandler( - child: child!, - ), - ), + child: SystemTrayWidget(child: child!), ), ); }, diff --git a/lib/utils/system/text_input.dart b/lib/utils/system/text_input.dart deleted file mode 100644 index 5de4d3b7aa..0000000000 --- a/lib/utils/system/text_input.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/widgets.dart'; - -import '../logger.dart'; - -// remove this once https://github.com/flutter/flutter/issues/78061 is fixed. -class TextInputActionHandler extends StatefulWidget { - const TextInputActionHandler({ - Key? key, - required this.child, - }) : super(key: key); - - final Widget child; - - @override - State createState() => _TextInputActionHandlerState(); -} - -class _TextInputActionHandlerState extends State { - late final _actions = >{ - DeleteCharacterIntent: makeAction(context), - ExtendSelectionByCharacterIntent: - makeAction(context), - ExtendSelectionVerticallyToAdjacentLineIntent: - makeAction(context), - SelectAllTextIntent: makeAction(context), - PasteTextIntent: makeAction(context), - RedoTextIntent: makeAction(context), - UndoTextIntent: makeAction(context), - }; - - @override - Widget build(BuildContext context) { - if (!Platform.isMacOS) { - return widget.child; - } - return Actions( - actions: _actions, - child: widget.child, - ); - } -} - -Action makeAction(BuildContext context) => - Action.overridable( - defaultAction: _CallbackContextAction(), - context: context, - ); - -class _CallbackContextAction extends ContextAction { - _CallbackContextAction(); - - bool? _consumeKey; - - @override - bool consumesKey(T intent) { - final consumeKey = _consumeKey; - _consumeKey = null; - if (consumeKey != null) { - return consumeKey; - } - return callingAction?.consumesKey(intent) ?? true; - } - - @override - Object? invoke(T intent, [BuildContext? context]) { - if (context == null) { - e('No context provided to _CallbackContextAction'); - return callingAction?.invoke(intent); - } - final state = context.findAncestorStateOfType(); - if (state == null) { - e('failed to find EditableTextState'); - return callingAction?.invoke(intent); - } - - final composingRange = state.textEditingValue.composing; - - if (composingRange.isValid && !composingRange.isCollapsed) { - _consumeKey = false; - return null; - } - return callingAction?.invoke(intent); - } -}