From d8692b564ed6bcfd7971629b435caf8e7a8daa3c Mon Sep 17 00:00:00 2001 From: Semsem-programmer <78271194+Semsem-programmer@users.noreply.github.com> Date: Sun, 28 Jan 2024 07:54:57 +0300 Subject: [PATCH 1/6] Change direction of textField --- lib/presentation/language_tool_text_field.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/presentation/language_tool_text_field.dart b/lib/presentation/language_tool_text_field.dart index bbb41b7..6f3077b 100644 --- a/lib/presentation/language_tool_text_field.dart +++ b/lib/presentation/language_tool_text_field.dart @@ -92,6 +92,8 @@ class _LanguageToolTextFieldState extends State { padding: const EdgeInsets.all(_padding), child: Center( child: TextField( + textAlign: TextAlign.right, + textDirection: TextDirection.rtl, focusNode: _focusNode, controller: widget.controller, scrollController: _scrollController, From e9da610b07e8b4cf1f601eec6e97d92d0f67db7b Mon Sep 17 00:00:00 2001 From: Semsem-programmer <78271194+Semsem-programmer@users.noreply.github.com> Date: Sun, 28 Jan 2024 07:57:52 +0300 Subject: [PATCH 2/6] Make LanguageToolTextField understand Arabic sympols --- lib/client/language_tool_client.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/client/language_tool_client.dart b/lib/client/language_tool_client.dart index e328c9c..68a5a41 100644 --- a/lib/client/language_tool_client.dart +++ b/lib/client/language_tool_client.dart @@ -38,7 +38,8 @@ class LanguageToolClient { ); final languageToolAnswer = LanguageToolRaw.fromJson( - json.decode(result.body) as Map, + //json.decode(result.body) as Map, + json.decode(utf8.decode(result.bodyBytes)) as Map, ); return _parseRawAnswer(languageToolAnswer); From fc725427087de9a608c4b3391ce2695f5a0714c3 Mon Sep 17 00:00:00 2001 From: Semsem-programmer <78271194+Semsem-programmer@users.noreply.github.com> Date: Sun, 28 Jan 2024 09:45:35 +0300 Subject: [PATCH 3/6] Let user determines prefer direction for text. --- lib/presentation/language_tool_text_field.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/presentation/language_tool_text_field.dart b/lib/presentation/language_tool_text_field.dart index 6f3077b..1169507 100644 --- a/lib/presentation/language_tool_text_field.dart +++ b/lib/presentation/language_tool_text_field.dart @@ -42,6 +42,8 @@ class LanguageToolTextField extends StatefulWidget { this.maxLines = 1, this.minLines, this.expands = false, + this.textAlign = TextAlign.right, + this.textDirection = TextDirection.rtl, super.key, }); @@ -92,8 +94,8 @@ class _LanguageToolTextFieldState extends State { padding: const EdgeInsets.all(_padding), child: Center( child: TextField( - textAlign: TextAlign.right, - textDirection: TextDirection.rtl, + textAlign: widget.textAlign, + textDirection: widget.textDirection, focusNode: _focusNode, controller: widget.controller, scrollController: _scrollController, From f0c98e3365c1a2de9f6c24a81da0be1bb29a081c Mon Sep 17 00:00:00 2001 From: Semsem-programmer <78271194+Semsem-programmer@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:18:02 +0300 Subject: [PATCH 4/6] Update lib/presentation/language_tool_text_field.dart Co-authored-by: Yurii Prykhodko <144313329+yurii-prykhodko-solid@users.noreply.github.com> --- lib/presentation/language_tool_text_field.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/presentation/language_tool_text_field.dart b/lib/presentation/language_tool_text_field.dart index 1169507..a940702 100644 --- a/lib/presentation/language_tool_text_field.dart +++ b/lib/presentation/language_tool_text_field.dart @@ -42,8 +42,8 @@ class LanguageToolTextField extends StatefulWidget { this.maxLines = 1, this.minLines, this.expands = false, - this.textAlign = TextAlign.right, - this.textDirection = TextDirection.rtl, + this.textAlign = TextAlign.start, + this.textDirection, super.key, }); From 1c6e7727058bce821211402c76079a13609249e2 Mon Sep 17 00:00:00 2001 From: Semsem-programmer <78271194+Semsem-programmer@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:18:20 +0300 Subject: [PATCH 5/6] Update lib/client/language_tool_client.dart Co-authored-by: Yurii Prykhodko <144313329+yurii-prykhodko-solid@users.noreply.github.com> --- lib/client/language_tool_client.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/client/language_tool_client.dart b/lib/client/language_tool_client.dart index 68a5a41..79ae5e7 100644 --- a/lib/client/language_tool_client.dart +++ b/lib/client/language_tool_client.dart @@ -38,7 +38,6 @@ class LanguageToolClient { ); final languageToolAnswer = LanguageToolRaw.fromJson( - //json.decode(result.body) as Map, json.decode(utf8.decode(result.bodyBytes)) as Map, ); From eaa77dbc2ff1aa13dd549a82e8328e7b3b306521 Mon Sep 17 00:00:00 2001 From: Semsem-programmer Date: Tue, 30 Jan 2024 07:24:58 +0300 Subject: [PATCH 6/6] Format files --- lib/client/language_tool_client.dart | 2 +- lib/presentation/language_tool_text_field.dart | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/client/language_tool_client.dart b/lib/client/language_tool_client.dart index 79ae5e7..48e70a9 100644 --- a/lib/client/language_tool_client.dart +++ b/lib/client/language_tool_client.dart @@ -38,7 +38,7 @@ class LanguageToolClient { ); final languageToolAnswer = LanguageToolRaw.fromJson( - json.decode(utf8.decode(result.bodyBytes)) as Map, + json.decode(utf8.decode(result.bodyBytes)) as Map, ); return _parseRawAnswer(languageToolAnswer); diff --git a/lib/presentation/language_tool_text_field.dart b/lib/presentation/language_tool_text_field.dart index a940702..78c7b27 100644 --- a/lib/presentation/language_tool_text_field.dart +++ b/lib/presentation/language_tool_text_field.dart @@ -32,6 +32,13 @@ class LanguageToolTextField extends StatefulWidget { /// ```language``` = 'auto' by default. final String language; + /// Determine text alignment + /// textAlign = [TextAlign.start] by default. + final TextAlign textAlign; + + /// Determine text Direction + final TextDirection? textDirection; + /// Creates a widget that checks grammar errors. const LanguageToolTextField({ required this.controller, @@ -42,8 +49,8 @@ class LanguageToolTextField extends StatefulWidget { this.maxLines = 1, this.minLines, this.expands = false, - this.textAlign = TextAlign.start, - this.textDirection, + this.textAlign = TextAlign.start, + this.textDirection, super.key, }); @@ -94,8 +101,8 @@ class _LanguageToolTextFieldState extends State { padding: const EdgeInsets.all(_padding), child: Center( child: TextField( - textAlign: widget.textAlign, - textDirection: widget.textDirection, + textAlign: widget.textAlign, + textDirection: widget.textDirection, focusNode: _focusNode, controller: widget.controller, scrollController: _scrollController,