Ver Fonte

fix: #1968 UI inconsistency

Lucas.Xu há 2 anos atrás
pai
commit
609bf2a4ce

+ 6 - 33
frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/auto_completion_node_widget.dart

@@ -9,7 +9,6 @@ import 'package:flowy_infra_ui/style_widget/text.dart';
 import 'package:flowy_infra_ui/style_widget/text_field.dart';
 import 'package:flowy_infra_ui/widget/spacing.dart';
 import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
 import 'package:http/http.dart' as http;
 import 'package:appflowy/generated/locale_keys.g.dart';
 import 'package:easy_localization/easy_localization.dart';
@@ -127,26 +126,12 @@ class _AutoCompletionInputState extends State<_AutoCompletionInput> {
   }
 
   Widget _buildInputWidget(BuildContext context) {
-    return RawKeyboardListener(
-      focusNode: focusNode,
-      onKey: (RawKeyEvent event) async {
-        if (event is! RawKeyDownEvent) return;
-        if (event.logicalKey == LogicalKeyboardKey.enter) {
-          if (controller.text.isNotEmpty) {
-            textFieldFocusNode.unfocus();
-            await _onGenerate();
-          }
-        } else if (event.logicalKey == LogicalKeyboardKey.escape) {
-          await _onExit();
-        }
-      },
-      child: FlowyTextField(
-        hintText: LocaleKeys.document_plugins_autoGeneratorHintText.tr(),
-        controller: controller,
-        maxLines: 3,
-        focusNode: textFieldFocusNode,
-        autoFocus: false,
-      ),
+    return FlowyTextField(
+      hintText: LocaleKeys.document_plugins_autoGeneratorHintText.tr(),
+      controller: controller,
+      maxLines: 3,
+      focusNode: textFieldFocusNode,
+      autoFocus: false,
     );
   }
 
@@ -160,12 +145,6 @@ class _AutoCompletionInputState extends State<_AutoCompletionInput> {
                 text: '${LocaleKeys.button_generate.tr()}  ',
                 style: Theme.of(context).textTheme.bodyMedium,
               ),
-              TextSpan(
-                text: '↵',
-                style: Theme.of(context).textTheme.bodyMedium?.copyWith(
-                      color: Colors.grey,
-                    ),
-              ),
             ],
           ),
           onPressed: () async => await _onGenerate(),
@@ -178,12 +157,6 @@ class _AutoCompletionInputState extends State<_AutoCompletionInput> {
                 text: '${LocaleKeys.button_Cancel.tr()}  ',
                 style: Theme.of(context).textTheme.bodyMedium,
               ),
-              TextSpan(
-                text: LocaleKeys.button_esc.tr(),
-                style: Theme.of(context).textTheme.bodyMedium?.copyWith(
-                      color: Colors.grey,
-                    ),
-              ),
             ],
           ),
           onPressed: () async => await _onExit(),

+ 10 - 35
frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/openai/widgets/smart_edit_node_widget.dart

@@ -8,7 +8,6 @@ import 'package:flowy_infra_ui/style_widget/button.dart';
 import 'package:flowy_infra_ui/style_widget/text.dart';
 import 'package:flowy_infra_ui/widget/spacing.dart';
 import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
 import 'package:appflowy/generated/locale_keys.g.dart';
 import 'package:easy_localization/easy_localization.dart';
 import 'package:http/http.dart' as http;
@@ -99,28 +98,16 @@ class _SmartEditInputState extends State<_SmartEditInput> {
   }
 
   Widget _buildSmartEditPanel(BuildContext context) {
-    return RawKeyboardListener(
-      focusNode: focusNode,
-      onKey: (RawKeyEvent event) async {
-        if (event is! RawKeyDownEvent) return;
-        if (event.logicalKey == LogicalKeyboardKey.enter) {
-          await _onReplace();
-          await _onExit();
-        } else if (event.logicalKey == LogicalKeyboardKey.escape) {
-          await _onExit();
-        }
-      },
-      child: Column(
-        mainAxisSize: MainAxisSize.min,
-        crossAxisAlignment: CrossAxisAlignment.start,
-        children: [
-          _buildHeaderWidget(context),
-          const Space(0, 10),
-          _buildResultWidget(context),
-          const Space(0, 10),
-          _buildInputFooterWidget(context),
-        ],
-      ),
+    return Column(
+      mainAxisSize: MainAxisSize.min,
+      crossAxisAlignment: CrossAxisAlignment.start,
+      children: [
+        _buildHeaderWidget(context),
+        const Space(0, 10),
+        _buildResultWidget(context),
+        const Space(0, 10),
+        _buildInputFooterWidget(context),
+      ],
     );
   }
 
@@ -178,12 +165,6 @@ class _SmartEditInputState extends State<_SmartEditInput> {
                 text: '${LocaleKeys.button_replace.tr()}  ',
                 style: Theme.of(context).textTheme.bodyMedium,
               ),
-              TextSpan(
-                text: '↵',
-                style: Theme.of(context).textTheme.bodyMedium?.copyWith(
-                      color: Colors.grey,
-                    ),
-              ),
             ],
           ),
           onPressed: () {
@@ -199,12 +180,6 @@ class _SmartEditInputState extends State<_SmartEditInput> {
                 text: '${LocaleKeys.button_Cancel.tr()}  ',
                 style: Theme.of(context).textTheme.bodyMedium,
               ),
-              TextSpan(
-                text: LocaleKeys.button_esc.tr(),
-                style: Theme.of(context).textTheme.bodyMedium?.copyWith(
-                      color: Colors.grey,
-                    ),
-              ),
             ],
           ),
           onPressed: () async => await _onExit(),