test: add integration test for ltr/rtl mode

This commit is contained in:
Lucas.Xu
2023-09-23 10:55:05 +08:00
parent f2f3506b29
commit 89face4f02
5 changed files with 107 additions and 10 deletions

View File

@ -160,16 +160,7 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
LayoutDirection.rtlLayout;
final layoutDirection = isRTL ? TextDirection.rtl : TextDirection.ltr;
// only show the rtl item when the layout direction is ltr.
for (final item in textDirectionItems) {
if (isRTL) {
if (toolbarItems.every((element) => element.id != item.id)) {
toolbarItems.add(item);
}
} else {
toolbarItems.removeWhere((element) => element.id == item.id);
}
}
_setRTLToolbarItems(isRTL);
final editorScrollController = EditorScrollController(
editorState: widget.editorState,
@ -475,4 +466,16 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
customizeShortcuts,
);
}
void _setRTLToolbarItems(bool isRTL) {
final textDirectionItemIds = textDirectionItems.map((e) => e.id);
// clear all the text direction items
toolbarItems.removeWhere(
(item) => textDirectionItemIds.contains(item.id),
);
// only show the rtl item when the layout direction is ltr.
if (isRTL) {
toolbarItems.addAll(textDirectionItems);
}
}
}