From 493bdbc54ddc55e24be740901a2fd3625577c4dc Mon Sep 17 00:00:00 2001 From: Cat <114286961+CatHood0@users.noreply.github.com> Date: Wed, 24 Jul 2024 13:27:31 -0400 Subject: [PATCH] Fix: manual checking of directionality (#2063) * fix: removed manual directionality checking * chore: run before push script --------- Co-authored-by: CatHood0 --- lib/src/common/utils/directionality.dart | 25 ------------------- .../editor/raw_editor/raw_editor_state.dart | 4 +-- lib/src/editor/widgets/text/text_block.dart | 4 +-- 3 files changed, 4 insertions(+), 29 deletions(-) delete mode 100644 lib/src/common/utils/directionality.dart diff --git a/lib/src/common/utils/directionality.dart b/lib/src/common/utils/directionality.dart deleted file mode 100644 index a39c1b20..00000000 --- a/lib/src/common/utils/directionality.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; - -bool isRTLLanguage(Locale locale) { - final rtlLanguages = [ - 'ar', // Arabic - 'dv', // Divehi (Maldivian) - 'fa', // Persian (Farsi) - 'ha', // Hausa (in Ajami script) - 'he', // Hebrew - 'khw', // Khowar (in Arabic script) - 'ks', // Kashmiri (in Arabic script) - 'ku', // Kurdish (Sorani) - 'ps', // Pashto - 'ur', // Urdu - 'yi', // Yiddish - 'sd', // Sindhi - 'ug', // Uyghur - ]; - return rtlLanguages.contains(locale.languageCode); -} - -bool isRTL(BuildContext context) { - return isRTLLanguage(Localizations.localeOf(context)); -} diff --git a/lib/src/editor/raw_editor/raw_editor_state.dart b/lib/src/editor/raw_editor/raw_editor_state.dart index b0e2174d..37f4bc2c 100644 --- a/lib/src/editor/raw_editor/raw_editor_state.dart +++ b/lib/src/editor/raw_editor/raw_editor_state.dart @@ -23,7 +23,6 @@ import '../../common/structs/horizontal_spacing.dart'; import '../../common/structs/offset_value.dart'; import '../../common/structs/vertical_spacing.dart'; import '../../common/utils/cast.dart'; -import '../../common/utils/directionality.dart'; import '../../common/utils/platform.dart'; import '../../controller/quill_controller.dart'; import '../../delta/delta_diff.dart'; @@ -981,7 +980,8 @@ class QuillRawEditorState extends EditorState // and watch if the system language is a RTL language and avoid putting // to the edge of the left side any checkbox or list point/number if is a // RTL language - if (nodeTextDirection == TextDirection.ltr && isRTL(context)) { + if (nodeTextDirection == TextDirection.ltr && + _textDirection == TextDirection.rtl) { nodeTextDirection = TextDirection.rtl; } if (node is Line) { diff --git a/lib/src/editor/widgets/text/text_block.dart b/lib/src/editor/widgets/text/text_block.dart index 8d8c0a5b..0553089a 100644 --- a/lib/src/editor/widgets/text/text_block.dart +++ b/lib/src/editor/widgets/text/text_block.dart @@ -3,7 +3,6 @@ import 'package:flutter/rendering.dart'; import '../../../common/structs/horizontal_spacing.dart'; import '../../../common/structs/vertical_spacing.dart'; -import '../../../common/utils/directionality.dart'; import '../../../common/utils/font.dart'; import '../../../controller/quill_controller.dart'; import '../../../delta/delta_diff.dart'; @@ -199,7 +198,8 @@ class EditableTextBlock extends StatelessWidget { // and watch if the system language is a RTL language and avoid putting // to the edge of the left side any checkbox or list point/number if is a // RTL language - if (nodeTextDirection == TextDirection.ltr && isRTL(context)) { + if (nodeTextDirection == TextDirection.ltr && + textDirection == TextDirection.rtl) { nodeTextDirection = TextDirection.rtl; } children.add(