Disable language tool check for text field
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/utils/direction_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:languagetool_textfield/languagetool_textfield.dart';
|
||||
|
||||
class TextFieldBuilder extends StatefulWidget {
|
||||
|
||||
@@ -26,7 +25,6 @@ class TextFieldBuilder extends StatefulWidget {
|
||||
final TextDirection textDirection;
|
||||
final bool readOnly;
|
||||
final MouseCursor? mouseCursor;
|
||||
final LanguageToolController? languageToolController;
|
||||
|
||||
const TextFieldBuilder({
|
||||
super.key,
|
||||
@@ -42,7 +40,6 @@ class TextFieldBuilder extends StatefulWidget {
|
||||
this.maxLines,
|
||||
this.minLines,
|
||||
this.controller,
|
||||
this.languageToolController,
|
||||
this.keyboardType,
|
||||
this.focusNode,
|
||||
this.fromValue,
|
||||
@@ -61,66 +58,24 @@ class TextFieldBuilder extends StatefulWidget {
|
||||
class _TextFieldBuilderState extends State<TextFieldBuilder> {
|
||||
|
||||
TextEditingController? _controller;
|
||||
LanguageToolController? _languageToolController;
|
||||
|
||||
late TextDirection _textDirection;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.languageToolController != null) {
|
||||
_languageToolController = widget.languageToolController;
|
||||
if (widget.fromValue != null) {
|
||||
_languageToolController?.value = TextEditingValue(text: widget.fromValue!);
|
||||
}
|
||||
if (widget.fromValue != null) {
|
||||
_controller = TextEditingController.fromValue(
|
||||
TextEditingValue(text: widget.fromValue!),
|
||||
);
|
||||
} else {
|
||||
if (widget.fromValue != null) {
|
||||
_controller = TextEditingController.fromValue(TextEditingValue(text: widget.fromValue!));
|
||||
} else {
|
||||
_controller = widget.controller ?? TextEditingController();
|
||||
}
|
||||
_controller = widget.controller ?? TextEditingController();
|
||||
}
|
||||
_textDirection = widget.textDirection;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_languageToolController != null) {
|
||||
return LanguageToolTextField(
|
||||
key: widget.key,
|
||||
controller: _languageToolController!,
|
||||
cursorColor: widget.cursorColor,
|
||||
autocorrect: widget.autocorrect,
|
||||
textInputAction: widget.textInputAction,
|
||||
decoration: widget.decoration,
|
||||
maxLines: widget.maxLines,
|
||||
minLines: widget.minLines,
|
||||
keyboardAppearance: widget.keyboardAppearance,
|
||||
style: widget.textStyle,
|
||||
keyboardType: widget.keyboardType,
|
||||
autoFocus: widget.autoFocus,
|
||||
focusNode: widget.focusNode,
|
||||
alignCenter: false,
|
||||
textDirection: _textDirection,
|
||||
readOnly: widget.readOnly,
|
||||
mouseCursor: widget.mouseCursor,
|
||||
onTextChange: (value) {
|
||||
widget.onTextChange?.call(value);
|
||||
if (value.isNotEmpty) {
|
||||
final directionByText = DirectionUtils.getDirectionByEndsText(value);
|
||||
if (directionByText != _textDirection) {
|
||||
setState(() {
|
||||
_textDirection = directionByText;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
onTextSubmitted: widget.onTextSubmitted,
|
||||
onTap: widget.onTap,
|
||||
onTapOutside: widget.onTapOutside,
|
||||
);
|
||||
}
|
||||
|
||||
return TextField(
|
||||
key: widget.key,
|
||||
controller: _controller,
|
||||
@@ -139,31 +94,30 @@ class _TextFieldBuilderState extends State<TextFieldBuilder> {
|
||||
textDirection: _textDirection,
|
||||
readOnly: widget.readOnly,
|
||||
mouseCursor: widget.mouseCursor,
|
||||
onChanged: (value) {
|
||||
widget.onTextChange?.call(value);
|
||||
if (value.isNotEmpty) {
|
||||
final directionByText = DirectionUtils.getDirectionByEndsText(value);
|
||||
if (directionByText != _textDirection) {
|
||||
setState(() {
|
||||
_textDirection = directionByText;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
onChanged: _onTextChanged,
|
||||
onSubmitted: widget.onTextSubmitted,
|
||||
onTap: widget.onTap,
|
||||
onTapOutside: widget.onTapOutside,
|
||||
);
|
||||
}
|
||||
|
||||
void _onTextChanged(String value) {
|
||||
widget.onTextChange?.call(value);
|
||||
|
||||
if (value.trim().isEmpty) return;
|
||||
|
||||
final directionByText = DirectionUtils.getDirectionByEndsText(value);
|
||||
if (directionByText != _textDirection) {
|
||||
setState(() {
|
||||
_textDirection = directionByText;
|
||||
});
|
||||
}
|
||||
}
|
||||
@override
|
||||
void dispose() {
|
||||
if (widget.controller == null) {
|
||||
_controller?.dispose();
|
||||
}
|
||||
if (widget.languageToolController == null) {
|
||||
_languageToolController?.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/individual_header_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:languagetool_textfield/languagetool_textfield.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
@@ -152,9 +151,7 @@ class ComposerController extends BaseController
|
||||
List<EmailAddress> listBccEmailAddress = <EmailAddress>[];
|
||||
ContactSuggestionSource _contactSuggestionSource = ContactSuggestionSource.tMailContact;
|
||||
|
||||
final subjectEmailInputController = LanguageToolController(
|
||||
delay: const Duration(milliseconds: 200),
|
||||
);
|
||||
final subjectEmailInputController = TextEditingController();
|
||||
final toEmailAddressController = TextEditingController();
|
||||
final ccEmailAddressController = TextEditingController();
|
||||
final bccEmailAddressController = TextEditingController();
|
||||
@@ -1947,7 +1944,6 @@ class ComposerController extends BaseController
|
||||
|
||||
void handleOnFocusHtmlEditorWeb() {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
subjectEmailInputController.popupWidget?.popupRenderer.dismiss();
|
||||
richTextWebController?.editorController.setFocus();
|
||||
richTextWebController?.closeAllMenuPopup();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import 'package:core/presentation/views/text/text_field_builder.dart';
|
||||
import 'package:core/utils/direction_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:languagetool_textfield/languagetool_textfield.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/styles/subject_composer_widget_style.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class SubjectComposerWidget extends StatelessWidget {
|
||||
|
||||
final FocusNode? focusNode;
|
||||
final LanguageToolController textController;
|
||||
final TextEditingController textController;
|
||||
final ValueChanged<String>? onTextChange;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
@@ -51,7 +50,7 @@ class SubjectComposerWidget extends StatelessWidget {
|
||||
decoration: const InputDecoration(border: InputBorder.none),
|
||||
textDirection: DirectionUtils.getDirectionByLanguage(context),
|
||||
textStyle: SubjectComposerWidgetStyle.inputTextStyle,
|
||||
languageToolController: textController,
|
||||
controller: textController,
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
+1
-1
@@ -1289,7 +1289,7 @@ packages:
|
||||
source: hosted
|
||||
version: "6.6.1"
|
||||
languagetool_textfield:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "."
|
||||
ref: twake-supported
|
||||
|
||||
@@ -104,13 +104,6 @@ dependencies:
|
||||
url: https://github.com/linagora/flutter_pdf_render.git
|
||||
ref: main
|
||||
|
||||
# TODO: We will change it when the PR in upstream repository will be merged
|
||||
# https://github.com/solid-software/languagetool_textfield/pull/83
|
||||
languagetool_textfield:
|
||||
git:
|
||||
url: https://github.com/dab246/languagetool_textfield.git
|
||||
ref: twake-supported
|
||||
|
||||
linagora_design_flutter:
|
||||
git:
|
||||
url: https://github.com/linagora/linagora-design-flutter.git
|
||||
|
||||
Reference in New Issue
Block a user