From 4b4c1489465f37595f5076b9ebe6f6bc8cffd5fe Mon Sep 17 00:00:00 2001 From: Ellet Date: Tue, 5 Dec 2023 11:09:48 +0300 Subject: [PATCH] Organize files --- CHANGELOG.md | 5 + .../lib/presentation/quill/quill_toolbar.dart | 8 +- lib/flutter_quill.dart | 15 +- lib/src/extensions/quill_provider.dart | 16 +- .../models/config/editor/configurations.dart | 10 +- .../models/config/quill_configurations.dart | 4 +- .../config/quill_shared_configurations.dart | 5 +- .../config/raw_editor/configurations.dart | 10 +- .../toolbar/base_toolbar_configurations.dart | 33 -- .../models/config/toolbar/buttons/color.dart | 2 +- .../config/toolbar/buttons/font_family.dart | 2 +- .../config/toolbar/buttons/font_size.dart | 4 +- .../toolbar/buttons/select_header_style.dart | 2 +- .../simple_toolbar_configurations.dart | 317 ++++++++++++++++++ .../toolbar/toolbar_configurations.dart | 312 +---------------- lib/src/models/documents/document.dart | 2 +- lib/src/models/documents/nodes/container.dart | 2 +- lib/src/models/documents/nodes/leaf.dart | 2 +- lib/src/models/documents/nodes/line.dart | 2 +- lib/src/models/documents/nodes/node.dart | 2 +- lib/src/utils/embeds.dart | 2 +- lib/src/widgets/editor/editor.dart | 12 +- lib/src/widgets/{ => others}/box.dart | 2 +- lib/src/widgets/{ => others}/controller.dart | 20 +- lib/src/widgets/{ => others}/cursor.dart | 2 +- .../widgets/{ => others}/default_styles.dart | 10 +- lib/src/widgets/{ => others}/delegate.dart | 8 +- lib/src/widgets/{ => others}/embeds.dart | 8 +- .../widgets/{ => others}/float_cursor.dart | 0 .../{ => others}/keyboard_listener.dart | 0 lib/src/widgets/{ => others}/link.dart | 6 +- lib/src/widgets/{ => others}/proxy.dart | 0 lib/src/widgets/{ => others}/text_block.dart | 20 +- lib/src/widgets/{ => others}/text_line.dart | 24 +- .../widgets/{ => others}/text_selection.dart | 4 +- .../quill_single_child_scroll_view.dart | 0 .../raw_editor/raw_editor_render_object.dart | 2 +- .../widgets/raw_editor/raw_editor_state.dart | 20 +- .../widgets/style_widgets/number_point.dart | 2 +- lib/src/widgets/toolbar/base_toolbar.dart | 12 +- .../toolbar/buttons/clear_format_button.dart | 2 +- .../toolbar/buttons/color/color_button.dart | 2 +- .../toolbar/buttons/custom_button_button.dart | 2 +- .../toolbar/buttons/font_family_button.dart | 2 +- .../toolbar/buttons/font_size_button.dart | 2 +- .../toolbar/buttons/history_button.dart | 2 +- .../toolbar/buttons/indent_button.dart | 2 +- .../toolbar/buttons/link_style2_button.dart | 4 +- .../toolbar/buttons/link_style_button.dart | 4 +- .../toolbar/buttons/search/search_button.dart | 2 +- .../toolbar/buttons/search/search_dialog.dart | 2 +- .../buttons/select_alignment_button.dart | 2 +- .../buttons/select_header_style_button.dart | 2 +- .../buttons/select_header_style_buttons.dart | 2 +- .../buttons/toggle_check_list_button.dart | 2 +- .../toolbar/buttons/toggle_style_button.dart | 2 +- .../{toolbar.dart => simple_toolbar.dart} | 73 ++-- lib/src/widgets/utils/provider.dart | 10 +- test/bug_fix_test.dart | 6 +- version.dart | 2 +- 60 files changed, 522 insertions(+), 514 deletions(-) delete mode 100644 lib/src/models/config/toolbar/base_toolbar_configurations.dart create mode 100644 lib/src/models/config/toolbar/simple_toolbar_configurations.dart rename lib/src/widgets/{ => others}/box.dart (98%) rename lib/src/widgets/{ => others}/controller.dart (96%) rename lib/src/widgets/{ => others}/cursor.dart (99%) rename lib/src/widgets/{ => others}/default_styles.dart (97%) rename lib/src/widgets/{ => others}/delegate.dart (98%) rename lib/src/widgets/{ => others}/embeds.dart (77%) rename lib/src/widgets/{ => others}/float_cursor.dart (100%) rename lib/src/widgets/{ => others}/keyboard_listener.dart (100%) rename lib/src/widgets/{ => others}/link.dart (97%) rename lib/src/widgets/{ => others}/proxy.dart (100%) rename lib/src/widgets/{ => others}/text_block.dart (97%) rename lib/src/widgets/{ => others}/text_line.dart (98%) rename lib/src/widgets/{ => others}/text_selection.dart (99%) rename lib/src/widgets/{ => raw_editor}/quill_single_child_scroll_view.dart (100%) rename lib/src/widgets/toolbar/{toolbar.dart => simple_toolbar.dart} (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60b64f0f..4363db5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## 9.0.0-dev-3 +* Breaking Changes: + * Rename `QuillToolbar` to `QuillSimpleToolbar` + * Rename `QuillBaseToolbar` to `QuillToolbar` + ## 9.0.0-dev-2 * An attemp to fix CI automated publishing diff --git a/example/lib/presentation/quill/quill_toolbar.dart b/example/lib/presentation/quill/quill_toolbar.dart index 0a9174c6..bf79b5da 100644 --- a/example/lib/presentation/quill/quill_toolbar.dart +++ b/example/lib/presentation/quill/quill_toolbar.dart @@ -100,8 +100,8 @@ class MyQuillToolbar extends StatelessWidget { if (state.useCustomQuillToolbar) { // For more info // https://github.com/singerdmx/flutter-quill/blob/master/doc/custom_toolbar.md - return QuillBaseToolbar( - configurations: QuillBaseToolbarConfigurations( + return QuillToolbar( + configurations: QuillToolbarConfigurations( toolbarSize: 15 * 2, multiRowsDisplay: false, buttonOptions: const QuillToolbarButtonOptions( @@ -224,8 +224,8 @@ class MyQuillToolbar extends StatelessWidget { ), ); } - return QuillToolbar( - configurations: QuillToolbarConfigurations( + return QuillSimpleToolbar( + configurations: QuillSimpleToolbarConfigurations( controller: controller, showAlignmentButtons: true, buttonOptions: QuillToolbarButtonOptions( diff --git a/lib/flutter_quill.dart b/lib/flutter_quill.dart index 2c317061..6a98667f 100644 --- a/lib/flutter_quill.dart +++ b/lib/flutter_quill.dart @@ -3,7 +3,7 @@ library flutter_quill; export 'src/extensions/quill_provider.dart'; export 'src/models/config/quill_configurations.dart'; export 'src/models/config/raw_editor/configurations.dart'; -export 'src/models/config/toolbar/base_toolbar_configurations.dart'; +export 'src/models/config/toolbar/toolbar_configurations.dart'; export 'src/models/documents/attribute.dart'; export 'src/models/documents/document.dart'; export 'src/models/documents/nodes/block.dart'; @@ -22,15 +22,16 @@ export 'src/models/structs/vertical_spacing.dart'; export 'src/models/themes/quill_dialog_theme.dart'; export 'src/models/themes/quill_icon_theme.dart'; export 'src/utils/embeds.dart'; -export 'src/widgets/controller.dart'; -export 'src/widgets/cursor.dart'; -export 'src/widgets/default_styles.dart'; +export 'src/widgets/others/controller.dart'; +export 'src/widgets/others/cursor.dart'; +export 'src/widgets/others/default_styles.dart'; export 'src/widgets/editor/editor.dart'; -export 'src/widgets/embeds.dart'; -export 'src/widgets/link.dart' show LinkActionPickerDelegate, LinkMenuAction; +export 'src/widgets/others/embeds.dart'; +export 'src/widgets/others/link.dart' + show LinkActionPickerDelegate, LinkMenuAction; export 'src/widgets/raw_editor/raw_editor.dart'; export 'src/widgets/raw_editor/raw_editor_state.dart'; export 'src/widgets/style_widgets/style_widgets.dart'; export 'src/widgets/toolbar/base_toolbar.dart'; -export 'src/widgets/toolbar/toolbar.dart'; +export 'src/widgets/toolbar/simple_toolbar.dart'; export 'src/widgets/utils/provider.dart'; diff --git a/lib/src/extensions/quill_provider.dart b/lib/src/extensions/quill_provider.dart index 29d251af..e6fbc165 100644 --- a/lib/src/extensions/quill_provider.dart +++ b/lib/src/extensions/quill_provider.dart @@ -68,39 +68,39 @@ extension QuillProviderExt on BuildContext { return QuillEditorProvider.of(this)?.editorConfigurations; } - /// return [QuillToolbarConfigurations] as not null . Since the quill + /// return [QuillSimpleToolbarConfigurations] as not null . Since the quill /// toolbar configurations is in the [QuillToolbarProvider] /// then we need to get the /// provider widget first and then we will return toolbar configurations /// throw exception if [QuillProvider] is not in the widget tree - QuillToolbarConfigurations get requireQuillToolbarConfigurations { + QuillSimpleToolbarConfigurations get requireQuillToolbarConfigurations { return QuillToolbarProvider.ofNotNull(this).toolbarConfigurations; } - /// return nullable [QuillToolbarConfigurations]. Since the quill + /// return nullable [QuillSimpleToolbarConfigurations]. Since the quill /// toolbar configurations is in the [QuillToolbarProvider] /// then we need to get the /// provider widget first and then we will return toolbar configurations /// don't throw exception if [QuillProvider] is not in the widget tree - QuillToolbarConfigurations? get quillToolbarConfigurations { + QuillSimpleToolbarConfigurations? get quillToolbarConfigurations { return QuillToolbarProvider.of(this)?.toolbarConfigurations; } - /// return [QuillBaseToolbarConfigurations] as not null . Since the quill + /// return [QuillToolbarConfigurations] as not null . Since the quill /// toolbar configurations is in the [QuillBaseToolbarProvider] /// then we need to get the /// provider widget first and then we will return toolbar configurations /// throw exception if [QuillBaseToolbarProvider] is not in the widget tree - QuillBaseToolbarConfigurations get requireQuillBaseToolbarConfigurations { + QuillToolbarConfigurations get requireQuillBaseToolbarConfigurations { return QuillBaseToolbarProvider.ofNotNull(this).toolbarConfigurations; } - /// return nullable [QuillBaseToolbarConfigurations]. Since the quill + /// return nullable [QuillToolbarConfigurations]. Since the quill /// toolbar configurations is in the [QuillBaseToolbarProvider] /// then we need to get the /// provider widget first and then we will return toolbar configurations /// don't throw exception if [QuillBaseToolbarProvider] is not in the widget tree - QuillBaseToolbarConfigurations? get quillBaseToolbarConfigurations { + QuillToolbarConfigurations? get quillBaseToolbarConfigurations { return QuillBaseToolbarProvider.of(this)?.toolbarConfigurations; } diff --git a/lib/src/models/config/editor/configurations.dart b/lib/src/models/config/editor/configurations.dart index a08ff076..23d80e11 100644 --- a/lib/src/models/config/editor/configurations.dart +++ b/lib/src/models/config/editor/configurations.dart @@ -6,13 +6,13 @@ import 'package:flutter/material.dart' import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart' show experimental; -import '../../../widgets/controller.dart'; -import '../../../widgets/default_styles.dart'; -import '../../../widgets/delegate.dart'; +import '../../../widgets/others/controller.dart'; +import '../../../widgets/others/default_styles.dart'; +import '../../../widgets/others/delegate.dart'; import '../../../widgets/editor/editor.dart'; import '../../../widgets/editor/editor_builder.dart'; -import '../../../widgets/embeds.dart'; -import '../../../widgets/link.dart'; +import '../../../widgets/others/embeds.dart'; +import '../../../widgets/others/link.dart'; import '../../../widgets/raw_editor/raw_editor.dart'; import '../../themes/quill_dialog_theme.dart'; import 'element_options.dart'; diff --git a/lib/src/models/config/quill_configurations.dart b/lib/src/models/config/quill_configurations.dart index b18f6396..60b30aaf 100644 --- a/lib/src/models/config/quill_configurations.dart +++ b/lib/src/models/config/quill_configurations.dart @@ -5,7 +5,7 @@ import '../../../flutter_quill.dart'; export './editor/configurations.dart'; export 'quill_shared_configurations.dart'; -export 'toolbar/toolbar_configurations.dart'; +export 'toolbar/simple_toolbar_configurations.dart'; @immutable class QuillConfigurations extends Equatable { @@ -22,7 +22,7 @@ class QuillConfigurations extends Equatable { // final QuillController controller; /// The shared configurations between [QuillEditorConfigurations] and - /// [QuillToolbarConfigurations] so we don't duplicate things + /// [QuillSimpleToolbarConfigurations] so we don't duplicate things final QuillSharedConfigurations sharedConfigurations; @override diff --git a/lib/src/models/config/quill_shared_configurations.dart b/lib/src/models/config/quill_shared_configurations.dart index 2f62ea69..ddf5f776 100644 --- a/lib/src/models/config/quill_shared_configurations.dart +++ b/lib/src/models/config/quill_shared_configurations.dart @@ -3,12 +3,13 @@ import 'package:flutter/material.dart' show Color, Colors, Locale; import '../themes/quill_dialog_theme.dart'; import './editor/configurations.dart' show QuillEditorConfigurations; -import 'toolbar/toolbar_configurations.dart' show QuillToolbarConfigurations; +import 'toolbar/simple_toolbar_configurations.dart' + show QuillSimpleToolbarConfigurations; export './others/animations.dart'; /// The shared configurations between [QuillEditorConfigurations] and -/// [QuillToolbarConfigurations] so we don't duplicate things +/// [QuillSimpleToolbarConfigurations] so we don't duplicate things class QuillSharedConfigurations extends Equatable { const QuillSharedConfigurations({ this.dialogBarrierColor = Colors.black54, diff --git a/lib/src/models/config/raw_editor/configurations.dart b/lib/src/models/config/raw_editor/configurations.dart index 9d486e91..1ddb9973 100644 --- a/lib/src/models/config/raw_editor/configurations.dart +++ b/lib/src/models/config/raw_editor/configurations.dart @@ -25,11 +25,11 @@ import 'package:flutter/widgets.dart' Widget; import 'package:meta/meta.dart' show immutable; -import '../../../widgets/controller.dart'; -import '../../../widgets/cursor.dart'; -import '../../../widgets/default_styles.dart'; -import '../../../widgets/delegate.dart'; -import '../../../widgets/link.dart'; +import '../../../widgets/others/controller.dart'; +import '../../../widgets/others/cursor.dart'; +import '../../../widgets/others/default_styles.dart'; +import '../../../widgets/others/delegate.dart'; +import '../../../widgets/others/link.dart'; import '../../../widgets/raw_editor/raw_editor.dart'; import '../../../widgets/raw_editor/raw_editor_state.dart'; import '../../themes/quill_dialog_theme.dart'; diff --git a/lib/src/models/config/toolbar/base_toolbar_configurations.dart b/lib/src/models/config/toolbar/base_toolbar_configurations.dart deleted file mode 100644 index 3450a9de..00000000 --- a/lib/src/models/config/toolbar/base_toolbar_configurations.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:flutter/widgets.dart' - show Axis, WrapAlignment, WrapCrossAlignment, immutable; - -import '../../../widgets/toolbar/base_toolbar.dart'; -import 'toolbar_shared_configurations.dart'; - -@immutable -class QuillBaseToolbarConfigurations extends QuillSharedToolbarProperties { - const QuillBaseToolbarConfigurations({ - required this.childrenBuilder, - super.axis = Axis.horizontal, - super.toolbarSize = kDefaultIconSize * 2, - super.toolbarSectionSpacing = kToolbarSectionSpacing, - super.toolbarIconAlignment = WrapAlignment.center, - super.toolbarIconCrossAlignment = WrapCrossAlignment.center, - super.color, - super.customButtons = const [], - super.sectionDividerColor, - super.sectionDividerSpace, - super.linkDialogAction, - super.multiRowsDisplay = true, - super.decoration, - - /// Note this only used when you using the quill toolbar buttons like - /// `QuillToolbarHistoryButton` inside it - super.buttonOptions = const QuillToolbarButtonOptions(), - }); - - final QuillBaseToolbarChildrenBuilder childrenBuilder; - - @override - List get props => []; -} diff --git a/lib/src/models/config/toolbar/buttons/color.dart b/lib/src/models/config/toolbar/buttons/color.dart index 7c722d98..edb75142 100644 --- a/lib/src/models/config/toolbar/buttons/color.dart +++ b/lib/src/models/config/toolbar/buttons/color.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart' show Color; -import '../../../../widgets/controller.dart'; +import '../../../../widgets/others/controller.dart'; import '../../quill_shared_configurations.dart' show QuillSharedConfigurations; import 'base.dart'; diff --git a/lib/src/models/config/toolbar/buttons/font_family.dart b/lib/src/models/config/toolbar/buttons/font_family.dart index 41319bbb..5674232c 100644 --- a/lib/src/models/config/toolbar/buttons/font_family.dart +++ b/lib/src/models/config/toolbar/buttons/font_family.dart @@ -61,7 +61,7 @@ class QuillToolbarFontFamilyButtonOptions extends QuillToolbarBaseButtonOptions< final double hoverElevation; final double highlightElevation; - /// By default it will be [fontFamilyValues] from [QuillToolbarConfigurations] + /// By default it will be [fontFamilyValues] from [QuillSimpleToolbarConfigurations] /// You can override this if you want final Map? rawItemsMap; final ValueChanged? onSelected; diff --git a/lib/src/models/config/toolbar/buttons/font_size.dart b/lib/src/models/config/toolbar/buttons/font_size.dart index 45464ecf..5cebf9f6 100644 --- a/lib/src/models/config/toolbar/buttons/font_size.dart +++ b/lib/src/models/config/toolbar/buttons/font_size.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart' import 'package:flutter/widgets.dart' show Color, EdgeInsets, EdgeInsetsGeometry, TextOverflow, TextStyle; -import '../../../../widgets/controller.dart'; +import '../../../../widgets/others/controller.dart'; import '../../../documents/attribute.dart'; import '../../../themes/quill_icon_theme.dart'; import '../../quill_configurations.dart'; @@ -58,7 +58,7 @@ class QuillToolbarFontSizeButtonOptions extends QuillToolbarBaseButtonOptions< final double hoverElevation; final double highlightElevation; - /// By default it will be [fontSizesValues] from [QuillToolbarConfigurations] + /// By default it will be [fontSizesValues] from [QuillSimpleToolbarConfigurations] /// You can override this if you want final Map? rawItemsMap; final ValueChanged? onSelected; diff --git a/lib/src/models/config/toolbar/buttons/select_header_style.dart b/lib/src/models/config/toolbar/buttons/select_header_style.dart index 6e70c9eb..975b4770 100644 --- a/lib/src/models/config/toolbar/buttons/select_header_style.dart +++ b/lib/src/models/config/toolbar/buttons/select_header_style.dart @@ -37,7 +37,7 @@ class QuillToolbarSelectHeaderStyleButtonsOptions /// ] final List? attributes; - /// By default we will the toolbar axis from [QuillToolbarConfigurations] + /// By default we will the toolbar axis from [QuillSimpleToolbarConfigurations] final Axis? axis; final double? iconSize; final double? iconButtonFactor; diff --git a/lib/src/models/config/toolbar/simple_toolbar_configurations.dart b/lib/src/models/config/toolbar/simple_toolbar_configurations.dart new file mode 100644 index 00000000..e946a4f0 --- /dev/null +++ b/lib/src/models/config/toolbar/simple_toolbar_configurations.dart @@ -0,0 +1,317 @@ +import 'package:equatable/equatable.dart'; +import 'package:flutter/foundation.dart' show immutable; +import 'package:flutter/widgets.dart' + show Axis, Widget, WrapAlignment, WrapCrossAlignment; + +import '../../../widgets/others/controller.dart'; +import '../../../widgets/others/embeds.dart'; +import '../../themes/quill_dialog_theme.dart'; +import '../../themes/quill_icon_theme.dart'; +import 'buttons/base.dart'; +import 'buttons/clear_format.dart'; +import 'buttons/color.dart'; +import 'buttons/custom_button.dart'; +import 'buttons/font_family.dart'; +import 'buttons/font_size.dart'; +import 'buttons/history.dart'; +import 'buttons/indent.dart'; +import 'buttons/link_style.dart'; +import 'buttons/link_style2.dart'; +import 'buttons/search.dart'; +import 'buttons/select_alignment.dart'; +import 'buttons/select_header_style.dart'; +import 'buttons/toggle_check_list.dart'; +import 'buttons/toggle_style.dart'; +import 'toolbar_shared_configurations.dart'; + +export './../../../widgets/toolbar/buttons/search/search_dialog.dart'; +export './buttons/base.dart'; +export './buttons/clear_format.dart'; +export './buttons/color.dart'; +export './buttons/custom_button.dart'; +export './buttons/font_family.dart'; +export './buttons/font_size.dart'; +export './buttons/history.dart'; +export './buttons/indent.dart'; +export './buttons/link_style.dart'; +export './buttons/link_style2.dart'; +export './buttons/search.dart'; +export './buttons/select_alignment.dart'; +export './buttons/select_header_style.dart'; +export './buttons/toggle_check_list.dart'; +export './buttons/toggle_style.dart'; + +/// The default size of the icon of a button. +const double kDefaultIconSize = 18; + +/// The default size for the toolbar (width, height) +const double defaultToolbarSize = kDefaultIconSize * 2; + +/// The factor of how much larger the button is in relation to the icon. +const double kIconButtonFactor = 1.77; + +/// The horizontal margin between the contents of each toolbar section. +const double kToolbarSectionSpacing = 4; + +enum LinkStyleType { + /// Defines the original [QuillToolbarLinkStyleButton]. + original, + + /// Defines the alternative [QuillToolbarLinkStyleButton2]. + alternative; + + bool get isOriginal => this == LinkStyleType.original; + bool get isAlternative => this == LinkStyleType.alternative; +} + +/// The configurations for the toolbar widget of flutter quill +@immutable +class QuillSimpleToolbarConfigurations extends QuillSharedToolbarProperties { + const QuillSimpleToolbarConfigurations({ + required this.controller, + super.toolbarSectionSpacing = kToolbarSectionSpacing, + super.toolbarIconAlignment = WrapAlignment.center, + super.toolbarIconCrossAlignment = WrapCrossAlignment.center, + super.buttonOptions = const QuillToolbarButtonOptions(), + super.multiRowsDisplay = true, + this.fontSizesValues, + this.showDividers = true, + this.showFontFamily = true, + this.showFontSize = true, + this.showBoldButton = true, + this.showItalicButton = true, + this.showSmallButton = false, + this.showUnderLineButton = true, + this.showStrikeThrough = true, + this.showInlineCode = true, + this.showColorButton = true, + this.showBackgroundColorButton = true, + this.showClearFormat = true, + this.showAlignmentButtons = false, + this.showLeftAlignment = true, + this.showCenterAlignment = true, + this.showRightAlignment = true, + this.showJustifyAlignment = true, + this.showHeaderStyle = true, + this.showListNumbers = true, + this.showListBullets = true, + this.showListCheck = true, + this.showCodeBlock = true, + this.showQuote = true, + this.showIndent = true, + this.showLink = true, + this.showUndo = true, + this.showRedo = true, + this.showDirection = false, + this.showSearchButton = true, + this.showSubscript = true, + this.showSuperscript = true, + this.linkStyleType = LinkStyleType.original, + super.customButtons = const [], + + /// The decoration to use for the toolbar. + super.decoration, + + /// Toolbar items to display for controls of embed blocks + this.embedButtons, + super.linkDialogAction, + + ///The theme to use for the icons in the toolbar, uses type [QuillIconTheme] + // this.iconTheme, + this.dialogTheme, + super.axis = Axis.horizontal, + super.color, + super.sectionDividerColor, + super.sectionDividerSpace, + this.spacerWidget, + + /// By default it will calculated based on the [globalIconSize] from + /// [base] in [QuillToolbarButtonOptions] + /// You can change it but the the change only apply if + /// the [multiRowsDisplay] is false, if [multiRowsDisplay] then the value + /// will be [kDefaultIconSize] * 2 + super.toolbarSize, + }) : _toolbarSize = toolbarSize; + + final double? _toolbarSize; + + /// The toolbar size, by default it will be `baseButtonOptions.iconSize * 2` + @override + double get toolbarSize { + final alternativeToolbarSize = _toolbarSize; + if (alternativeToolbarSize != null) { + return alternativeToolbarSize; + } + return buttonOptions.base.globalIconSize * 2; + } + + final QuillController controller; + + /// A widget that will placed between each button in the toolbar + /// can be used as a spacer + /// it will not used before the first button + /// it will not used after the last button + /// it will also not used in the toolbar dividers + /// Default value will be [SizedBox.shrink()] + /// some widgets like the header styles will be considered as one widget + final Widget? spacerWidget; + + /// By default it will be + /// ``` + /// { + /// 'Small'.i18n: 'small', + /// 'Large'.i18n: 'large', + /// 'Huge'.i18n: 'huge', + /// 'Clear'.loc: '0' + /// } + /// ``` + final Map? fontSizesValues; + + final bool showDividers; + final bool showFontFamily; + final bool showFontSize; + final bool showBoldButton; + final bool showItalicButton; + final bool showSmallButton; + final bool showUnderLineButton; + final bool showStrikeThrough; + final bool showInlineCode; + final bool showColorButton; + final bool showBackgroundColorButton; + final bool showClearFormat; + final bool showAlignmentButtons; + final bool showLeftAlignment; + final bool showCenterAlignment; + final bool showRightAlignment; + final bool showJustifyAlignment; + final bool showHeaderStyle; + final bool showListNumbers; + final bool showListBullets; + final bool showListCheck; + final bool showCodeBlock; + final bool showQuote; + final bool showIndent; + final bool showLink; + final bool showUndo; + final bool showRedo; + final bool showDirection; + final bool showSearchButton; + final bool showSubscript; + final bool showSuperscript; + + /// Toolbar items to display for controls of embed blocks + final List? embedButtons; + + // ///The theme to use for the icons in the toolbar, uses type [QuillIconTheme] + // final QuillIconTheme? iconTheme; + + ///The theme to use for the theming of the [LinkDialog()], + ///shown when embedding an image, for example + final QuillDialogTheme? dialogTheme; + + /// Defines which dialog is used for applying link attribute. + final LinkStyleType linkStyleType; + + @override + List get props => [ + buttonOptions, + multiRowsDisplay, + fontSizesValues, + toolbarSize, + axis, + ]; +} + +/// The configurations for the buttons of the toolbar widget of flutter quill +@immutable +class QuillToolbarButtonOptions extends Equatable { + const QuillToolbarButtonOptions({ + this.base = const QuillToolbarBaseButtonOptions(), + this.undoHistory = const QuillToolbarHistoryButtonOptions( + isUndo: true, + ), + this.redoHistory = const QuillToolbarHistoryButtonOptions( + isUndo: false, + ), + this.fontFamily = const QuillToolbarFontFamilyButtonOptions(), + this.fontSize = const QuillToolbarFontSizeButtonOptions(), + this.bold = const QuillToolbarToggleStyleButtonOptions(), + this.subscript = const QuillToolbarToggleStyleButtonOptions(), + this.superscript = const QuillToolbarToggleStyleButtonOptions(), + this.italic = const QuillToolbarToggleStyleButtonOptions(), + this.small = const QuillToolbarToggleStyleButtonOptions(), + this.underLine = const QuillToolbarToggleStyleButtonOptions(), + this.strikeThrough = const QuillToolbarToggleStyleButtonOptions(), + this.inlineCode = const QuillToolbarToggleStyleButtonOptions(), + this.direction = const QuillToolbarToggleStyleButtonOptions(), + this.listNumbers = const QuillToolbarToggleStyleButtonOptions(), + this.listBullets = const QuillToolbarToggleStyleButtonOptions(), + this.codeBlock = const QuillToolbarToggleStyleButtonOptions(), + this.quote = const QuillToolbarToggleStyleButtonOptions(), + this.toggleCheckList = const QuillToolbarToggleCheckListButtonOptions(), + this.indentIncrease = const QuillToolbarIndentButtonOptions(), + this.indentDecrease = const QuillToolbarIndentButtonOptions(), + this.color = const QuillToolbarColorButtonOptions(), + this.backgroundColor = const QuillToolbarColorButtonOptions(), + this.clearFormat = const QuillToolbarClearFormatButtonOptions(), + this.selectAlignmentButtons = + const QuillToolbarSelectAlignmentButtonOptions(), + this.search = const QuillToolbarSearchButtonOptions(), + this.selectHeaderStyleButtons = + const QuillToolbarSelectHeaderStyleButtonsOptions(), + this.linkStyle = const QuillToolbarLinkStyleButtonOptions(), + this.linkStyle2 = const QuillToolbarLinkStyleButton2Options(), + this.customButtons = const QuillToolbarCustomButtonOptions(), + }); + + /// The base configurations for all the buttons which will apply to all + /// but if the options overrided in the spesefic button options + /// then it will use that instead + final QuillToolbarBaseButtonOptions base; + final QuillToolbarHistoryButtonOptions undoHistory; + final QuillToolbarHistoryButtonOptions redoHistory; + final QuillToolbarFontFamilyButtonOptions fontFamily; + final QuillToolbarFontSizeButtonOptions fontSize; + final QuillToolbarToggleStyleButtonOptions bold; + final QuillToolbarToggleStyleButtonOptions subscript; + final QuillToolbarToggleStyleButtonOptions superscript; + final QuillToolbarToggleStyleButtonOptions italic; + final QuillToolbarToggleStyleButtonOptions small; + final QuillToolbarToggleStyleButtonOptions underLine; + final QuillToolbarToggleStyleButtonOptions strikeThrough; + final QuillToolbarToggleStyleButtonOptions inlineCode; + final QuillToolbarToggleStyleButtonOptions direction; + final QuillToolbarToggleStyleButtonOptions listNumbers; + final QuillToolbarToggleStyleButtonOptions listBullets; + final QuillToolbarToggleStyleButtonOptions codeBlock; + final QuillToolbarToggleStyleButtonOptions quote; + final QuillToolbarToggleCheckListButtonOptions toggleCheckList; + final QuillToolbarIndentButtonOptions indentIncrease; + final QuillToolbarIndentButtonOptions indentDecrease; + final QuillToolbarColorButtonOptions color; + final QuillToolbarColorButtonOptions backgroundColor; + final QuillToolbarClearFormatButtonOptions clearFormat; + + /// The reason we call this buttons in the end because this is responsible + /// for all the alignment buttons and not just one, you still + /// can customize the icons and tooltips + /// and you have child builder + final QuillToolbarSelectAlignmentButtonOptions selectAlignmentButtons; + + final QuillToolbarSearchButtonOptions search; + + /// The reason we call this buttons in the end because this is responsible + /// for all the header style buttons and not just one, you still + /// can customize it and you also have child builder + final QuillToolbarSelectHeaderStyleButtonsOptions selectHeaderStyleButtons; + + final QuillToolbarLinkStyleButtonOptions linkStyle; + final QuillToolbarLinkStyleButton2Options linkStyle2; + + final QuillToolbarCustomButtonOptions customButtons; + + @override + List get props => [ + base, + ]; +} diff --git a/lib/src/models/config/toolbar/toolbar_configurations.dart b/lib/src/models/config/toolbar/toolbar_configurations.dart index 92b5b460..187a6117 100644 --- a/lib/src/models/config/toolbar/toolbar_configurations.dart +++ b/lib/src/models/config/toolbar/toolbar_configurations.dart @@ -1,317 +1,33 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter/foundation.dart' show immutable; import 'package:flutter/widgets.dart' - show Axis, Widget, WrapAlignment, WrapCrossAlignment; + show Axis, WrapAlignment, WrapCrossAlignment, immutable; -import '../../../widgets/controller.dart'; -import '../../../widgets/embeds.dart'; -import '../../themes/quill_dialog_theme.dart'; -import '../../themes/quill_icon_theme.dart'; -import 'buttons/base.dart'; -import 'buttons/clear_format.dart'; -import 'buttons/color.dart'; -import 'buttons/custom_button.dart'; -import 'buttons/font_family.dart'; -import 'buttons/font_size.dart'; -import 'buttons/history.dart'; -import 'buttons/indent.dart'; -import 'buttons/link_style.dart'; -import 'buttons/link_style2.dart'; -import 'buttons/search.dart'; -import 'buttons/select_alignment.dart'; -import 'buttons/select_header_style.dart'; -import 'buttons/toggle_check_list.dart'; -import 'buttons/toggle_style.dart'; +import '../../../widgets/toolbar/base_toolbar.dart'; import 'toolbar_shared_configurations.dart'; -export './../../../widgets/toolbar/buttons/search/search_dialog.dart'; -export './buttons/base.dart'; -export './buttons/clear_format.dart'; -export './buttons/color.dart'; -export './buttons/custom_button.dart'; -export './buttons/font_family.dart'; -export './buttons/font_size.dart'; -export './buttons/history.dart'; -export './buttons/indent.dart'; -export './buttons/link_style.dart'; -export './buttons/link_style2.dart'; -export './buttons/search.dart'; -export './buttons/select_alignment.dart'; -export './buttons/select_header_style.dart'; -export './buttons/toggle_check_list.dart'; -export './buttons/toggle_style.dart'; - -/// The default size of the icon of a button. -const double kDefaultIconSize = 18; - -/// The default size for the toolbar (width, height) -const double defaultToolbarSize = kDefaultIconSize * 2; - -/// The factor of how much larger the button is in relation to the icon. -const double kIconButtonFactor = 1.77; - -/// The horizontal margin between the contents of each toolbar section. -const double kToolbarSectionSpacing = 4; - -enum LinkStyleType { - /// Defines the original [QuillToolbarLinkStyleButton]. - original, - - /// Defines the alternative [QuillToolbarLinkStyleButton2]. - alternative; - - bool get isOriginal => this == LinkStyleType.original; - bool get isAlternative => this == LinkStyleType.alternative; -} - -/// The configurations for the toolbar widget of flutter quill @immutable class QuillToolbarConfigurations extends QuillSharedToolbarProperties { const QuillToolbarConfigurations({ - required this.controller, + required this.childrenBuilder, + super.axis = Axis.horizontal, + super.toolbarSize = kDefaultIconSize * 2, super.toolbarSectionSpacing = kToolbarSectionSpacing, super.toolbarIconAlignment = WrapAlignment.center, super.toolbarIconCrossAlignment = WrapCrossAlignment.center, - super.buttonOptions = const QuillToolbarButtonOptions(), - super.multiRowsDisplay = true, - this.fontSizesValues, - this.showDividers = true, - this.showFontFamily = true, - this.showFontSize = true, - this.showBoldButton = true, - this.showItalicButton = true, - this.showSmallButton = false, - this.showUnderLineButton = true, - this.showStrikeThrough = true, - this.showInlineCode = true, - this.showColorButton = true, - this.showBackgroundColorButton = true, - this.showClearFormat = true, - this.showAlignmentButtons = false, - this.showLeftAlignment = true, - this.showCenterAlignment = true, - this.showRightAlignment = true, - this.showJustifyAlignment = true, - this.showHeaderStyle = true, - this.showListNumbers = true, - this.showListBullets = true, - this.showListCheck = true, - this.showCodeBlock = true, - this.showQuote = true, - this.showIndent = true, - this.showLink = true, - this.showUndo = true, - this.showRedo = true, - this.showDirection = false, - this.showSearchButton = true, - this.showSubscript = true, - this.showSuperscript = true, - this.linkStyleType = LinkStyleType.original, - super.customButtons = const [], - - /// The decoration to use for the toolbar. - super.decoration, - - /// Toolbar items to display for controls of embed blocks - this.embedButtons, - super.linkDialogAction, - - ///The theme to use for the icons in the toolbar, uses type [QuillIconTheme] - // this.iconTheme, - this.dialogTheme, - super.axis = Axis.horizontal, super.color, + super.customButtons = const [], super.sectionDividerColor, super.sectionDividerSpace, - this.spacerWidget, - - /// By default it will calculated based on the [globalIconSize] from - /// [base] in [QuillToolbarButtonOptions] - /// You can change it but the the change only apply if - /// the [multiRowsDisplay] is false, if [multiRowsDisplay] then the value - /// will be [kDefaultIconSize] * 2 - super.toolbarSize, - }) : _toolbarSize = toolbarSize; - - final double? _toolbarSize; - - /// The toolbar size, by default it will be `baseButtonOptions.iconSize * 2` - @override - double get toolbarSize { - final alternativeToolbarSize = _toolbarSize; - if (alternativeToolbarSize != null) { - return alternativeToolbarSize; - } - return buttonOptions.base.globalIconSize * 2; - } - - final QuillController controller; - - /// A widget that will placed between each button in the toolbar - /// can be used as a spacer - /// it will not used before the first button - /// it will not used after the last button - /// it will also not used in the toolbar dividers - /// Default value will be [SizedBox.shrink()] - /// some widgets like the header styles will be considered as one widget - final Widget? spacerWidget; - - /// By default it will be - /// ``` - /// { - /// 'Small'.i18n: 'small', - /// 'Large'.i18n: 'large', - /// 'Huge'.i18n: 'huge', - /// 'Clear'.loc: '0' - /// } - /// ``` - final Map? fontSizesValues; - - final bool showDividers; - final bool showFontFamily; - final bool showFontSize; - final bool showBoldButton; - final bool showItalicButton; - final bool showSmallButton; - final bool showUnderLineButton; - final bool showStrikeThrough; - final bool showInlineCode; - final bool showColorButton; - final bool showBackgroundColorButton; - final bool showClearFormat; - final bool showAlignmentButtons; - final bool showLeftAlignment; - final bool showCenterAlignment; - final bool showRightAlignment; - final bool showJustifyAlignment; - final bool showHeaderStyle; - final bool showListNumbers; - final bool showListBullets; - final bool showListCheck; - final bool showCodeBlock; - final bool showQuote; - final bool showIndent; - final bool showLink; - final bool showUndo; - final bool showRedo; - final bool showDirection; - final bool showSearchButton; - final bool showSubscript; - final bool showSuperscript; - - /// Toolbar items to display for controls of embed blocks - final List? embedButtons; - - // ///The theme to use for the icons in the toolbar, uses type [QuillIconTheme] - // final QuillIconTheme? iconTheme; - - ///The theme to use for the theming of the [LinkDialog()], - ///shown when embedding an image, for example - final QuillDialogTheme? dialogTheme; - - /// Defines which dialog is used for applying link attribute. - final LinkStyleType linkStyleType; - - @override - List get props => [ - buttonOptions, - multiRowsDisplay, - fontSizesValues, - toolbarSize, - axis, - ]; -} + super.linkDialogAction, + super.multiRowsDisplay = true, + super.decoration, -/// The configurations for the buttons of the toolbar widget of flutter quill -@immutable -class QuillToolbarButtonOptions extends Equatable { - const QuillToolbarButtonOptions({ - this.base = const QuillToolbarBaseButtonOptions(), - this.undoHistory = const QuillToolbarHistoryButtonOptions( - isUndo: true, - ), - this.redoHistory = const QuillToolbarHistoryButtonOptions( - isUndo: false, - ), - this.fontFamily = const QuillToolbarFontFamilyButtonOptions(), - this.fontSize = const QuillToolbarFontSizeButtonOptions(), - this.bold = const QuillToolbarToggleStyleButtonOptions(), - this.subscript = const QuillToolbarToggleStyleButtonOptions(), - this.superscript = const QuillToolbarToggleStyleButtonOptions(), - this.italic = const QuillToolbarToggleStyleButtonOptions(), - this.small = const QuillToolbarToggleStyleButtonOptions(), - this.underLine = const QuillToolbarToggleStyleButtonOptions(), - this.strikeThrough = const QuillToolbarToggleStyleButtonOptions(), - this.inlineCode = const QuillToolbarToggleStyleButtonOptions(), - this.direction = const QuillToolbarToggleStyleButtonOptions(), - this.listNumbers = const QuillToolbarToggleStyleButtonOptions(), - this.listBullets = const QuillToolbarToggleStyleButtonOptions(), - this.codeBlock = const QuillToolbarToggleStyleButtonOptions(), - this.quote = const QuillToolbarToggleStyleButtonOptions(), - this.toggleCheckList = const QuillToolbarToggleCheckListButtonOptions(), - this.indentIncrease = const QuillToolbarIndentButtonOptions(), - this.indentDecrease = const QuillToolbarIndentButtonOptions(), - this.color = const QuillToolbarColorButtonOptions(), - this.backgroundColor = const QuillToolbarColorButtonOptions(), - this.clearFormat = const QuillToolbarClearFormatButtonOptions(), - this.selectAlignmentButtons = - const QuillToolbarSelectAlignmentButtonOptions(), - this.search = const QuillToolbarSearchButtonOptions(), - this.selectHeaderStyleButtons = - const QuillToolbarSelectHeaderStyleButtonsOptions(), - this.linkStyle = const QuillToolbarLinkStyleButtonOptions(), - this.linkStyle2 = const QuillToolbarLinkStyleButton2Options(), - this.customButtons = const QuillToolbarCustomButtonOptions(), + /// Note this only used when you using the quill toolbar buttons like + /// `QuillToolbarHistoryButton` inside it + super.buttonOptions = const QuillToolbarButtonOptions(), }); - /// The base configurations for all the buttons which will apply to all - /// but if the options overrided in the spesefic button options - /// then it will use that instead - final QuillToolbarBaseButtonOptions base; - final QuillToolbarHistoryButtonOptions undoHistory; - final QuillToolbarHistoryButtonOptions redoHistory; - final QuillToolbarFontFamilyButtonOptions fontFamily; - final QuillToolbarFontSizeButtonOptions fontSize; - final QuillToolbarToggleStyleButtonOptions bold; - final QuillToolbarToggleStyleButtonOptions subscript; - final QuillToolbarToggleStyleButtonOptions superscript; - final QuillToolbarToggleStyleButtonOptions italic; - final QuillToolbarToggleStyleButtonOptions small; - final QuillToolbarToggleStyleButtonOptions underLine; - final QuillToolbarToggleStyleButtonOptions strikeThrough; - final QuillToolbarToggleStyleButtonOptions inlineCode; - final QuillToolbarToggleStyleButtonOptions direction; - final QuillToolbarToggleStyleButtonOptions listNumbers; - final QuillToolbarToggleStyleButtonOptions listBullets; - final QuillToolbarToggleStyleButtonOptions codeBlock; - final QuillToolbarToggleStyleButtonOptions quote; - final QuillToolbarToggleCheckListButtonOptions toggleCheckList; - final QuillToolbarIndentButtonOptions indentIncrease; - final QuillToolbarIndentButtonOptions indentDecrease; - final QuillToolbarColorButtonOptions color; - final QuillToolbarColorButtonOptions backgroundColor; - final QuillToolbarClearFormatButtonOptions clearFormat; - - /// The reason we call this buttons in the end because this is responsible - /// for all the alignment buttons and not just one, you still - /// can customize the icons and tooltips - /// and you have child builder - final QuillToolbarSelectAlignmentButtonOptions selectAlignmentButtons; - - final QuillToolbarSearchButtonOptions search; - - /// The reason we call this buttons in the end because this is responsible - /// for all the header style buttons and not just one, you still - /// can customize it and you also have child builder - final QuillToolbarSelectHeaderStyleButtonsOptions selectHeaderStyleButtons; - - final QuillToolbarLinkStyleButtonOptions linkStyle; - final QuillToolbarLinkStyleButton2Options linkStyle2; - - final QuillToolbarCustomButtonOptions customButtons; + final QuillBaseToolbarChildrenBuilder childrenBuilder; @override - List get props => [ - base, - ]; + List get props => []; } diff --git a/lib/src/models/documents/document.dart b/lib/src/models/documents/document.dart index 4649765f..1b4f9696 100644 --- a/lib/src/models/documents/document.dart +++ b/lib/src/models/documents/document.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import '../../widgets/embeds.dart'; +import '../../widgets/others/embeds.dart'; import '../quill_delta.dart'; import '../rules/rule.dart'; import '../structs/doc_change.dart'; diff --git a/lib/src/models/documents/nodes/container.dart b/lib/src/models/documents/nodes/container.dart index 605e472e..5b5e0941 100644 --- a/lib/src/models/documents/nodes/container.dart +++ b/lib/src/models/documents/nodes/container.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import '../../../widgets/embeds.dart'; +import '../../../widgets/others/embeds.dart'; import '../style.dart'; import 'leaf.dart'; import 'line.dart'; diff --git a/lib/src/models/documents/nodes/leaf.dart b/lib/src/models/documents/nodes/leaf.dart index 4f1fd3b0..314bb4ee 100644 --- a/lib/src/models/documents/nodes/leaf.dart +++ b/lib/src/models/documents/nodes/leaf.dart @@ -1,6 +1,6 @@ import 'dart:math' as math; -import '../../../widgets/embeds.dart'; +import '../../../widgets/others/embeds.dart'; import '../../quill_delta.dart'; import '../style.dart'; import 'embeddable.dart'; diff --git a/lib/src/models/documents/nodes/line.dart b/lib/src/models/documents/nodes/line.dart index 75dfbde0..bc2920cb 100644 --- a/lib/src/models/documents/nodes/line.dart +++ b/lib/src/models/documents/nodes/line.dart @@ -2,7 +2,7 @@ import 'dart:math' as math; import 'package:collection/collection.dart'; -import '../../../widgets/embeds.dart'; +import '../../../widgets/others/embeds.dart'; import '../../quill_delta.dart'; import '../../structs/offset_value.dart'; import '../attribute.dart'; diff --git a/lib/src/models/documents/nodes/node.dart b/lib/src/models/documents/nodes/node.dart index c196b47f..4b9bcd7d 100644 --- a/lib/src/models/documents/nodes/node.dart +++ b/lib/src/models/documents/nodes/node.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import '../../../widgets/embeds.dart'; +import '../../../widgets/others/embeds.dart'; import '../../quill_delta.dart'; import '../attribute.dart'; import '../style.dart'; diff --git a/lib/src/utils/embeds.dart b/lib/src/utils/embeds.dart index 7164f1d5..973942bb 100644 --- a/lib/src/utils/embeds.dart +++ b/lib/src/utils/embeds.dart @@ -2,7 +2,7 @@ import 'dart:math'; import '../models/documents/nodes/leaf.dart'; import '../models/structs/offset_value.dart'; -import '../widgets/controller.dart'; +import '../widgets/others/controller.dart'; OffsetValue getEmbedNode(QuillController controller, int offset) { var offset = controller.selection.start; diff --git a/lib/src/widgets/editor/editor.dart b/lib/src/widgets/editor/editor.dart index b0995b74..2fe82da0 100644 --- a/lib/src/widgets/editor/editor.dart +++ b/lib/src/widgets/editor/editor.dart @@ -16,13 +16,13 @@ import '../../models/documents/nodes/container.dart' as container_node; import '../../models/documents/nodes/leaf.dart'; import '../../models/structs/offset_value.dart'; import '../../utils/platform.dart'; -import '../box.dart'; -import '../cursor.dart'; -import '../delegate.dart'; -import '../embeds.dart'; -import '../float_cursor.dart'; +import '../others/box.dart'; +import '../others/cursor.dart'; +import '../others/delegate.dart'; +import '../others/embeds.dart'; +import '../others/float_cursor.dart'; import '../raw_editor/raw_editor.dart'; -import '../text_selection.dart'; +import '../others/text_selection.dart'; import '../utils/provider.dart'; import 'editor_builder.dart'; diff --git a/lib/src/widgets/box.dart b/lib/src/widgets/others/box.dart similarity index 98% rename from lib/src/widgets/box.dart rename to lib/src/widgets/others/box.dart index 8b4f5f00..85dc8dff 100644 --- a/lib/src/widgets/box.dart +++ b/lib/src/widgets/others/box.dart @@ -1,6 +1,6 @@ import 'package:flutter/rendering.dart'; -import '../models/documents/nodes/container.dart'; +import '../../models/documents/nodes/container.dart'; /// A common interface to render boxes which represent a piece of rich text /// content. diff --git a/lib/src/widgets/controller.dart b/lib/src/widgets/others/controller.dart similarity index 96% rename from lib/src/widgets/controller.dart rename to lib/src/widgets/others/controller.dart index b48ab9eb..0928cf88 100644 --- a/lib/src/widgets/controller.dart +++ b/lib/src/widgets/others/controller.dart @@ -3,16 +3,16 @@ import 'dart:math' as math; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; -import '../models/documents/attribute.dart'; -import '../models/documents/document.dart'; -import '../models/documents/nodes/embeddable.dart'; -import '../models/documents/nodes/leaf.dart'; -import '../models/documents/style.dart'; -import '../models/quill_delta.dart'; -import '../models/structs/doc_change.dart'; -import '../models/structs/image_url.dart'; -import '../models/structs/offset_value.dart'; -import '../utils/delta.dart'; +import '../../models/documents/attribute.dart'; +import '../../models/documents/document.dart'; +import '../../models/documents/nodes/embeddable.dart'; +import '../../models/documents/nodes/leaf.dart'; +import '../../models/documents/style.dart'; +import '../../models/quill_delta.dart'; +import '../../models/structs/doc_change.dart'; +import '../../models/structs/image_url.dart'; +import '../../models/structs/offset_value.dart'; +import '../../utils/delta.dart'; typedef ReplaceTextCallback = bool Function(int index, int len, Object? data); typedef DeleteCallback = void Function(int cursorPosition, bool forward); diff --git a/lib/src/widgets/cursor.dart b/lib/src/widgets/others/cursor.dart similarity index 99% rename from lib/src/widgets/cursor.dart rename to lib/src/widgets/others/cursor.dart index 929118b1..41513308 100644 --- a/lib/src/widgets/cursor.dart +++ b/lib/src/widgets/others/cursor.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/widgets.dart'; -import '../utils/platform.dart'; +import '../../utils/platform.dart'; import 'box.dart'; /// Style properties of editing cursor. diff --git a/lib/src/widgets/default_styles.dart b/lib/src/widgets/others/default_styles.dart similarity index 97% rename from lib/src/widgets/default_styles.dart rename to lib/src/widgets/others/default_styles.dart index 5d5949f8..575a5273 100644 --- a/lib/src/widgets/default_styles.dart +++ b/lib/src/widgets/others/default_styles.dart @@ -2,11 +2,11 @@ import 'dart:ui'; import 'package:flutter/material.dart'; -import '../models/documents/attribute.dart'; -import '../models/documents/style.dart'; -import '../models/structs/vertical_spacing.dart'; -import '../utils/platform.dart'; -import 'style_widgets/checkbox_point.dart'; +import '../../models/documents/attribute.dart'; +import '../../models/documents/style.dart'; +import '../../models/structs/vertical_spacing.dart'; +import '../../utils/platform.dart'; +import '../style_widgets/checkbox_point.dart'; class QuillStyles extends InheritedWidget { const QuillStyles({ diff --git a/lib/src/widgets/delegate.dart b/lib/src/widgets/others/delegate.dart similarity index 98% rename from lib/src/widgets/delegate.dart rename to lib/src/widgets/others/delegate.dart index 5d021606..dff3709a 100644 --- a/lib/src/widgets/delegate.dart +++ b/lib/src/widgets/others/delegate.dart @@ -3,10 +3,10 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; -import '../models/documents/attribute.dart'; -import '../models/documents/nodes/leaf.dart'; -import '../utils/platform.dart'; -import 'editor/editor.dart'; +import '../../models/documents/attribute.dart'; +import '../../models/documents/nodes/leaf.dart'; +import '../../utils/platform.dart'; +import '../editor/editor.dart'; import 'embeds.dart'; import 'text_selection.dart'; diff --git a/lib/src/widgets/embeds.dart b/lib/src/widgets/others/embeds.dart similarity index 77% rename from lib/src/widgets/embeds.dart rename to lib/src/widgets/others/embeds.dart index 87511204..9b828d1b 100644 --- a/lib/src/widgets/embeds.dart +++ b/lib/src/widgets/others/embeds.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import '../../extensions.dart'; -import '../models/documents/nodes/leaf.dart' as leaf; -import '../models/themes/quill_dialog_theme.dart'; -import '../models/themes/quill_icon_theme.dart'; +import '../../../extensions.dart'; +import '../../models/documents/nodes/leaf.dart' as leaf; +import '../../models/themes/quill_dialog_theme.dart'; +import '../../models/themes/quill_icon_theme.dart'; import 'controller.dart'; abstract class EmbedBuilder { diff --git a/lib/src/widgets/float_cursor.dart b/lib/src/widgets/others/float_cursor.dart similarity index 100% rename from lib/src/widgets/float_cursor.dart rename to lib/src/widgets/others/float_cursor.dart diff --git a/lib/src/widgets/keyboard_listener.dart b/lib/src/widgets/others/keyboard_listener.dart similarity index 100% rename from lib/src/widgets/keyboard_listener.dart rename to lib/src/widgets/others/keyboard_listener.dart diff --git a/lib/src/widgets/link.dart b/lib/src/widgets/others/link.dart similarity index 97% rename from lib/src/widgets/link.dart rename to lib/src/widgets/others/link.dart index 9e4ee354..93d8c685 100644 --- a/lib/src/widgets/link.dart +++ b/lib/src/widgets/others/link.dart @@ -2,9 +2,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import '../l10n/extensions/localizations.dart'; -import '../models/documents/attribute.dart'; -import '../models/documents/nodes/node.dart'; +import '../../l10n/extensions/localizations.dart'; +import '../../models/documents/attribute.dart'; +import '../../models/documents/nodes/node.dart'; const linkPrefixes = [ 'mailto:', // email diff --git a/lib/src/widgets/proxy.dart b/lib/src/widgets/others/proxy.dart similarity index 100% rename from lib/src/widgets/proxy.dart rename to lib/src/widgets/others/proxy.dart diff --git a/lib/src/widgets/text_block.dart b/lib/src/widgets/others/text_block.dart similarity index 97% rename from lib/src/widgets/text_block.dart rename to lib/src/widgets/others/text_block.dart index 1f70c9af..a52ba4db 100644 --- a/lib/src/widgets/text_block.dart +++ b/lib/src/widgets/others/text_block.dart @@ -1,22 +1,22 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import '../extensions/quill_provider.dart'; -import '../models/documents/attribute.dart'; -import '../models/documents/nodes/block.dart'; -import '../models/documents/nodes/line.dart'; -import '../models/structs/vertical_spacing.dart'; -import '../utils/delta.dart'; +import '../../extensions/quill_provider.dart'; +import '../../models/documents/attribute.dart'; +import '../../models/documents/nodes/block.dart'; +import '../../models/documents/nodes/line.dart'; +import '../../models/structs/vertical_spacing.dart'; +import '../../utils/delta.dart'; import 'box.dart'; import 'controller.dart'; import 'cursor.dart'; import 'default_styles.dart'; import 'delegate.dart'; -import 'editor/editor.dart'; +import '../editor/editor.dart'; import 'link.dart'; -import 'style_widgets/bullet_point.dart'; -import 'style_widgets/checkbox_point.dart'; -import 'style_widgets/number_point.dart'; +import '../style_widgets/bullet_point.dart'; +import '../style_widgets/checkbox_point.dart'; +import '../style_widgets/number_point.dart'; import 'text_line.dart'; import 'text_selection.dart'; diff --git a/lib/src/widgets/text_line.dart b/lib/src/widgets/others/text_line.dart similarity index 98% rename from lib/src/widgets/text_line.dart rename to lib/src/widgets/others/text_line.dart index c79e8da3..0067c958 100644 --- a/lib/src/widgets/text_line.dart +++ b/lib/src/widgets/others/text_line.dart @@ -8,18 +8,18 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:url_launcher/url_launcher.dart'; -import '../models/documents/attribute.dart'; -import '../models/documents/nodes/container.dart' as container_node; -import '../models/documents/nodes/embeddable.dart'; -import '../models/documents/nodes/leaf.dart'; -import '../models/documents/nodes/leaf.dart' as leaf; -import '../models/documents/nodes/line.dart'; -import '../models/documents/nodes/node.dart'; -import '../models/documents/style.dart'; -import '../models/structs/vertical_spacing.dart'; -import '../utils/color.dart'; -import '../utils/font.dart'; -import '../utils/platform.dart'; +import '../../models/documents/attribute.dart'; +import '../../models/documents/nodes/container.dart' as container_node; +import '../../models/documents/nodes/embeddable.dart'; +import '../../models/documents/nodes/leaf.dart'; +import '../../models/documents/nodes/leaf.dart' as leaf; +import '../../models/documents/nodes/line.dart'; +import '../../models/documents/nodes/node.dart'; +import '../../models/documents/style.dart'; +import '../../models/structs/vertical_spacing.dart'; +import '../../utils/color.dart'; +import '../../utils/font.dart'; +import '../../utils/platform.dart'; import 'box.dart'; import 'controller.dart'; import 'cursor.dart'; diff --git a/lib/src/widgets/text_selection.dart b/lib/src/widgets/others/text_selection.dart similarity index 99% rename from lib/src/widgets/text_selection.dart rename to lib/src/widgets/others/text_selection.dart index c51d414d..8016201f 100644 --- a/lib/src/widgets/text_selection.dart +++ b/lib/src/widgets/others/text_selection.dart @@ -6,8 +6,8 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; -import '../models/documents/nodes/node.dart'; -import 'editor/editor.dart'; +import '../../models/documents/nodes/node.dart'; +import '../editor/editor.dart'; TextSelection localSelection(Node node, TextSelection selection, fromParent) { final base = fromParent ? node.offset : node.documentOffset; diff --git a/lib/src/widgets/quill_single_child_scroll_view.dart b/lib/src/widgets/raw_editor/quill_single_child_scroll_view.dart similarity index 100% rename from lib/src/widgets/quill_single_child_scroll_view.dart rename to lib/src/widgets/raw_editor/quill_single_child_scroll_view.dart diff --git a/lib/src/widgets/raw_editor/raw_editor_render_object.dart b/lib/src/widgets/raw_editor/raw_editor_render_object.dart index 3338c1f2..fe61fd37 100644 --- a/lib/src/widgets/raw_editor/raw_editor_render_object.dart +++ b/lib/src/widgets/raw_editor/raw_editor_render_object.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart' show ViewportOffset; import '../../models/documents/document.dart'; -import '../cursor.dart'; +import '../others/cursor.dart'; import '../editor/editor.dart'; class QuilRawEditorMultiChildRenderObject extends MultiChildRenderObjectWidget { diff --git a/lib/src/widgets/raw_editor/raw_editor_state.dart b/lib/src/widgets/raw_editor/raw_editor_state.dart index ced4ab06..2eff5786 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state.dart @@ -33,17 +33,17 @@ import '../../utils/cast.dart'; import '../../utils/delta.dart'; import '../../utils/embeds.dart'; import '../../utils/platform.dart'; -import '../controller.dart'; -import '../cursor.dart'; -import '../default_styles.dart'; +import '../others/controller.dart'; +import '../others/cursor.dart'; +import '../others/default_styles.dart'; import '../editor/editor.dart'; -import '../keyboard_listener.dart'; -import '../link.dart'; -import '../proxy.dart'; -import '../quill_single_child_scroll_view.dart'; -import '../text_block.dart'; -import '../text_line.dart'; -import '../text_selection.dart'; +import '../others/keyboard_listener.dart'; +import '../others/link.dart'; +import '../others/proxy.dart'; +import 'quill_single_child_scroll_view.dart'; +import '../others/text_block.dart'; +import '../others/text_line.dart'; +import '../others/text_selection.dart'; import 'raw_editor.dart'; import 'raw_editor_actions.dart'; import 'raw_editor_render_object.dart'; diff --git a/lib/src/widgets/style_widgets/number_point.dart b/lib/src/widgets/style_widgets/number_point.dart index 30b5590e..9809f4ac 100644 --- a/lib/src/widgets/style_widgets/number_point.dart +++ b/lib/src/widgets/style_widgets/number_point.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import '../../models/documents/attribute.dart'; -import '../text_block.dart'; +import '../others/text_block.dart'; class QuillEditorNumberPoint extends StatelessWidget { const QuillEditorNumberPoint({ diff --git a/lib/src/widgets/toolbar/base_toolbar.dart b/lib/src/widgets/toolbar/base_toolbar.dart index af412d35..59efda0c 100644 --- a/lib/src/widgets/toolbar/base_toolbar.dart +++ b/lib/src/widgets/toolbar/base_toolbar.dart @@ -3,11 +3,11 @@ import 'package:flutter/material.dart'; import '../../../flutter_quill.dart' show QuillBaseToolbarProvider, defaultToolbarSize; import '../../l10n/widgets/localizations.dart'; -import '../../models/config/toolbar/base_toolbar_configurations.dart'; +import '../../models/config/toolbar/toolbar_configurations.dart'; import 'buttons/arrow_indicated_list_button.dart'; export '../../models/config/toolbar/buttons/base.dart'; -export '../../models/config/toolbar/toolbar_configurations.dart'; +export '../../models/config/toolbar/simple_toolbar_configurations.dart'; export 'buttons/clear_format_button.dart'; export 'buttons/color/color_button.dart'; export 'buttons/custom_button_button.dart'; @@ -28,13 +28,13 @@ typedef QuillBaseToolbarChildrenBuilder = List Function( BuildContext context, ); -class QuillBaseToolbar extends StatelessWidget implements PreferredSizeWidget { - const QuillBaseToolbar({ +class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { + const QuillToolbar({ required this.configurations, super.key, }); - final QuillBaseToolbarConfigurations configurations; + final QuillToolbarConfigurations configurations; // We can't get the modified [toolbarSize] by the developer // but we tested the [QuillToolbar] on the [appBar] and I didn't notice @@ -90,7 +90,7 @@ class QuillBaseToolbar extends StatelessWidget implements PreferredSizeWidget { /// The divider which is used for separation of buttons in the toolbar. /// /// It can be used outside of this package, for example when user does not use -/// [QuillBaseToolbar.basic] and compose toolbar's children on its own. +/// [QuillToolbar.basic] and compose toolbar's children on its own. class QuillToolbarDivider extends StatelessWidget { const QuillToolbarDivider( this.axis, { diff --git a/lib/src/widgets/toolbar/buttons/clear_format_button.dart b/lib/src/widgets/toolbar/buttons/clear_format_button.dart index e25afa3d..d903aa77 100644 --- a/lib/src/widgets/toolbar/buttons/clear_format_button.dart +++ b/lib/src/widgets/toolbar/buttons/clear_format_button.dart @@ -4,7 +4,7 @@ import '../../../extensions/quill_provider.dart'; import '../../../l10n/extensions/localizations.dart'; import '../../../models/documents/attribute.dart'; import '../../../models/themes/quill_icon_theme.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; import '../base_toolbar.dart'; class QuillToolbarClearFormatButton extends StatelessWidget { diff --git a/lib/src/widgets/toolbar/buttons/color/color_button.dart b/lib/src/widgets/toolbar/buttons/color/color_button.dart index f5b2e032..2965f8b2 100644 --- a/lib/src/widgets/toolbar/buttons/color/color_button.dart +++ b/lib/src/widgets/toolbar/buttons/color/color_button.dart @@ -7,7 +7,7 @@ import '../../../../models/documents/attribute.dart'; import '../../../../models/documents/style.dart'; import '../../../../models/themes/quill_icon_theme.dart'; import '../../../../utils/color.dart'; -import '../../../controller.dart'; +import '../../../others/controller.dart'; import '../../base_toolbar.dart'; import 'color_dialog.dart'; diff --git a/lib/src/widgets/toolbar/buttons/custom_button_button.dart b/lib/src/widgets/toolbar/buttons/custom_button_button.dart index bbf6ad57..27c6cf14 100644 --- a/lib/src/widgets/toolbar/buttons/custom_button_button.dart +++ b/lib/src/widgets/toolbar/buttons/custom_button_button.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import '../../../extensions/quill_provider.dart'; import '../../../models/themes/quill_icon_theme.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; import '../base_toolbar.dart'; class QuillToolbarCustomButton extends StatelessWidget { diff --git a/lib/src/widgets/toolbar/buttons/font_family_button.dart b/lib/src/widgets/toolbar/buttons/font_family_button.dart index fbfa954e..40c62990 100644 --- a/lib/src/widgets/toolbar/buttons/font_family_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_family_button.dart @@ -7,7 +7,7 @@ import '../../../models/config/toolbar/buttons/font_family.dart'; import '../../../models/documents/attribute.dart'; import '../../../models/documents/style.dart'; import '../../../models/themes/quill_icon_theme.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; class QuillToolbarFontFamilyButton extends StatefulWidget { QuillToolbarFontFamilyButton({ diff --git a/lib/src/widgets/toolbar/buttons/font_size_button.dart b/lib/src/widgets/toolbar/buttons/font_size_button.dart index 621fc5c7..58dd04e9 100644 --- a/lib/src/widgets/toolbar/buttons/font_size_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_size_button.dart @@ -8,7 +8,7 @@ import '../../../models/documents/attribute.dart'; import '../../../models/documents/style.dart'; import '../../../models/themes/quill_icon_theme.dart'; import '../../../utils/font.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; class QuillToolbarFontSizeButton extends StatefulWidget { QuillToolbarFontSizeButton({ diff --git a/lib/src/widgets/toolbar/buttons/history_button.dart b/lib/src/widgets/toolbar/buttons/history_button.dart index 3a4cf3c1..c4ac883f 100644 --- a/lib/src/widgets/toolbar/buttons/history_button.dart +++ b/lib/src/widgets/toolbar/buttons/history_button.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import '../../../extensions/quill_provider.dart'; import '../../../l10n/extensions/localizations.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; import '../base_toolbar.dart'; class QuillToolbarHistoryButton extends StatefulWidget { diff --git a/lib/src/widgets/toolbar/buttons/indent_button.dart b/lib/src/widgets/toolbar/buttons/indent_button.dart index 793dd0fa..4d81b5c7 100644 --- a/lib/src/widgets/toolbar/buttons/indent_button.dart +++ b/lib/src/widgets/toolbar/buttons/indent_button.dart @@ -4,7 +4,7 @@ import '../../../extensions/quill_provider.dart'; import '../../../l10n/extensions/localizations.dart'; import '../../../models/config/toolbar/buttons/indent.dart'; import '../../../models/themes/quill_icon_theme.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; import '../base_toolbar.dart' show QuillToolbarBaseButtonOptions, QuillToolbarIconButton; diff --git a/lib/src/widgets/toolbar/buttons/link_style2_button.dart b/lib/src/widgets/toolbar/buttons/link_style2_button.dart index 86e25103..2eca0a81 100644 --- a/lib/src/widgets/toolbar/buttons/link_style2_button.dart +++ b/lib/src/widgets/toolbar/buttons/link_style2_button.dart @@ -10,8 +10,8 @@ import '../../../l10n/widgets/localizations.dart'; import '../../../models/documents/attribute.dart'; import '../../../models/themes/quill_dialog_theme.dart'; import '../../../models/themes/quill_icon_theme.dart'; -import '../../controller.dart'; -import '../../link.dart'; +import '../../others/controller.dart'; +import '../../others/link.dart'; import '../base_toolbar.dart'; /// Alternative version of [QuillToolbarLinkStyleButton]. This widget has more diff --git a/lib/src/widgets/toolbar/buttons/link_style_button.dart b/lib/src/widgets/toolbar/buttons/link_style_button.dart index b4aacadc..f08f3671 100644 --- a/lib/src/widgets/toolbar/buttons/link_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/link_style_button.dart @@ -8,8 +8,8 @@ import '../../../models/rules/insert.dart'; import '../../../models/structs/link_dialog_action.dart'; import '../../../models/themes/quill_dialog_theme.dart'; import '../../../models/themes/quill_icon_theme.dart'; -import '../../controller.dart'; -import '../../link.dart'; +import '../../others/controller.dart'; +import '../../others/link.dart'; import '../base_toolbar.dart'; class QuillToolbarLinkStyleButton extends StatefulWidget { diff --git a/lib/src/widgets/toolbar/buttons/search/search_button.dart b/lib/src/widgets/toolbar/buttons/search/search_button.dart index 8b568977..437ed791 100644 --- a/lib/src/widgets/toolbar/buttons/search/search_button.dart +++ b/lib/src/widgets/toolbar/buttons/search/search_button.dart @@ -5,7 +5,7 @@ import '../../../../l10n/extensions/localizations.dart'; import '../../../../l10n/widgets/localizations.dart'; import '../../../../models/themes/quill_dialog_theme.dart'; import '../../../../models/themes/quill_icon_theme.dart'; -import '../../../controller.dart'; +import '../../../others/controller.dart'; import '../../base_toolbar.dart'; class QuillToolbarSearchButton extends StatelessWidget { diff --git a/lib/src/widgets/toolbar/buttons/search/search_dialog.dart b/lib/src/widgets/toolbar/buttons/search/search_dialog.dart index 2aa268c5..65b2c4d4 100644 --- a/lib/src/widgets/toolbar/buttons/search/search_dialog.dart +++ b/lib/src/widgets/toolbar/buttons/search/search_dialog.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import '../../../../l10n/extensions/localizations.dart'; import '../../../../models/documents/document.dart'; import '../../../../models/themes/quill_dialog_theme.dart'; -import '../../../controller.dart'; +import '../../../others/controller.dart'; @immutable class QuillToolbarSearchDialogChildBuilderExtraOptions { diff --git a/lib/src/widgets/toolbar/buttons/select_alignment_button.dart b/lib/src/widgets/toolbar/buttons/select_alignment_button.dart index c81dc1e1..4d7f8bca 100644 --- a/lib/src/widgets/toolbar/buttons/select_alignment_button.dart +++ b/lib/src/widgets/toolbar/buttons/select_alignment_button.dart @@ -7,7 +7,7 @@ import '../../../models/documents/attribute.dart'; import '../../../models/documents/style.dart'; import '../../../models/themes/quill_icon_theme.dart'; import '../../../utils/widgets.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; import '../base_toolbar.dart'; class QuillToolbarSelectAlignmentButton extends StatefulWidget { diff --git a/lib/src/widgets/toolbar/buttons/select_header_style_button.dart b/lib/src/widgets/toolbar/buttons/select_header_style_button.dart index 0f913204..41dca31a 100644 --- a/lib/src/widgets/toolbar/buttons/select_header_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/select_header_style_button.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import '../../../../translations.dart'; import '../../../models/config/toolbar/buttons/select_header_style.dart'; import '../../../models/documents/attribute.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; enum QuillToolbarSelectHeaderStyleButtonOptions { normal, diff --git a/lib/src/widgets/toolbar/buttons/select_header_style_buttons.dart b/lib/src/widgets/toolbar/buttons/select_header_style_buttons.dart index 791b8132..5972baf2 100644 --- a/lib/src/widgets/toolbar/buttons/select_header_style_buttons.dart +++ b/lib/src/widgets/toolbar/buttons/select_header_style_buttons.dart @@ -7,7 +7,7 @@ import '../../../l10n/extensions/localizations.dart'; import '../../../models/documents/attribute.dart'; import '../../../models/documents/style.dart'; import '../../../models/themes/quill_icon_theme.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; import '../base_toolbar.dart'; class QuillToolbarSelectHeaderStyleButtons extends StatefulWidget { diff --git a/lib/src/widgets/toolbar/buttons/toggle_check_list_button.dart b/lib/src/widgets/toolbar/buttons/toggle_check_list_button.dart index 01ec7f92..db1980e5 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_check_list_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_check_list_button.dart @@ -8,7 +8,7 @@ import '../../../models/documents/attribute.dart'; import '../../../models/documents/style.dart'; import '../../../models/themes/quill_icon_theme.dart'; import '../../../utils/widgets.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; import 'toggle_style_button.dart'; class QuillToolbarToggleCheckListButton extends StatefulWidget { diff --git a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart index e2928ef3..67982e28 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart @@ -6,7 +6,7 @@ import '../../../models/documents/attribute.dart'; import '../../../models/documents/style.dart'; import '../../../models/themes/quill_icon_theme.dart'; import '../../../utils/widgets.dart'; -import '../../controller.dart'; +import '../../others/controller.dart'; import '../base_toolbar.dart'; typedef ToggleStyleButtonBuilder = Widget Function( diff --git a/lib/src/widgets/toolbar/toolbar.dart b/lib/src/widgets/toolbar/simple_toolbar.dart similarity index 98% rename from lib/src/widgets/toolbar/toolbar.dart rename to lib/src/widgets/toolbar/simple_toolbar.dart index b4c9a7d3..57644056 100644 --- a/lib/src/widgets/toolbar/toolbar.dart +++ b/lib/src/widgets/toolbar/simple_toolbar.dart @@ -2,20 +2,21 @@ import 'package:flutter/material.dart'; import '../../extensions/quill_provider.dart'; import '../../l10n/extensions/localizations.dart'; -import '../../models/config/toolbar/base_toolbar_configurations.dart'; +import '../../models/config/toolbar/toolbar_configurations.dart'; import '../../models/documents/attribute.dart'; import '../utils/provider.dart'; import 'base_toolbar.dart'; import 'buttons/select_header_style_button.dart'; -class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { - const QuillToolbar({ +class QuillSimpleToolbar extends StatelessWidget + implements PreferredSizeWidget { + const QuillSimpleToolbar({ required this.configurations, super.key, }); /// The configurations for the toolbar widget of flutter quill - final QuillToolbarConfigurations configurations; + final QuillSimpleToolbarConfigurations configurations; @override Widget build(BuildContext context) { @@ -50,8 +51,8 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { return QuillToolbarProvider( toolbarConfigurations: configurations, - child: QuillBaseToolbar( - configurations: QuillBaseToolbarConfigurations( + child: QuillToolbar( + configurations: QuillToolbarConfigurations( color: configurations.color, decoration: configurations.decoration, toolbarSectionSpacing: configurations.toolbarSectionSpacing, @@ -126,6 +127,36 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { ), spacerWidget, ], + if (configurations.showItalicButton) ...[ + QuillToolbarToggleStyleButton( + attribute: Attribute.italic, + options: toolbarConfigurations.buttonOptions.italic, + controller: + toolbarConfigurations.buttonOptions.italic.controller ?? + globalController, + ), + spacerWidget, + ], + if (configurations.showUnderLineButton) ...[ + QuillToolbarToggleStyleButton( + attribute: Attribute.underline, + options: toolbarConfigurations.buttonOptions.underLine, + controller: toolbarConfigurations + .buttonOptions.underLine.controller ?? + globalController, + ), + spacerWidget, + ], + if (configurations.showInlineCode) ...[ + QuillToolbarToggleStyleButton( + attribute: Attribute.inlineCode, + options: toolbarConfigurations.buttonOptions.inlineCode, + controller: toolbarConfigurations + .buttonOptions.inlineCode.controller ?? + globalController, + ), + spacerWidget, + ], if (configurations.showSubscript) ...[ QuillToolbarToggleStyleButton( attribute: Attribute.subscript, @@ -146,16 +177,6 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { ), spacerWidget, ], - if (configurations.showItalicButton) ...[ - QuillToolbarToggleStyleButton( - attribute: Attribute.italic, - options: toolbarConfigurations.buttonOptions.italic, - controller: - toolbarConfigurations.buttonOptions.italic.controller ?? - globalController, - ), - spacerWidget, - ], if (configurations.showSmallButton) ...[ QuillToolbarToggleStyleButton( attribute: Attribute.small, @@ -166,16 +187,6 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { ), spacerWidget, ], - if (configurations.showUnderLineButton) ...[ - QuillToolbarToggleStyleButton( - attribute: Attribute.underline, - options: toolbarConfigurations.buttonOptions.underLine, - controller: toolbarConfigurations - .buttonOptions.underLine.controller ?? - globalController, - ), - spacerWidget, - ], if (configurations.showStrikeThrough) ...[ QuillToolbarToggleStyleButton( attribute: Attribute.strikeThrough, @@ -186,16 +197,6 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { ), spacerWidget, ], - if (configurations.showInlineCode) ...[ - QuillToolbarToggleStyleButton( - attribute: Attribute.inlineCode, - options: toolbarConfigurations.buttonOptions.inlineCode, - controller: toolbarConfigurations - .buttonOptions.inlineCode.controller ?? - globalController, - ), - spacerWidget, - ], if (configurations.showColorButton) ...[ QuillToolbarColorButton( controller: diff --git a/lib/src/widgets/utils/provider.dart b/lib/src/widgets/utils/provider.dart index 773cbba3..4cd65636 100644 --- a/lib/src/widgets/utils/provider.dart +++ b/lib/src/widgets/utils/provider.dart @@ -3,7 +3,7 @@ import 'package:flutter/widgets.dart' show BuildContext, InheritedWidget, Widget; import '../../models/config/quill_configurations.dart'; -import '../../models/config/toolbar/base_toolbar_configurations.dart'; +import '../../models/config/toolbar/toolbar_configurations.dart'; class QuillProvider extends InheritedWidget { const QuillProvider({ @@ -72,7 +72,7 @@ class QuillToolbarProvider extends InheritedWidget { }); /// The configurations for the toolbar widget of flutter quill - final QuillToolbarConfigurations toolbarConfigurations; + final QuillSimpleToolbarConfigurations toolbarConfigurations; @override bool updateShouldNotify(covariant QuillToolbarProvider oldWidget) { @@ -130,7 +130,7 @@ class QuillBaseToolbarProvider extends InheritedWidget { }); /// The configurations for the toolbar widget of flutter quill - final QuillBaseToolbarConfigurations toolbarConfigurations; + final QuillToolbarConfigurations toolbarConfigurations; @override bool updateShouldNotify(covariant QuillBaseToolbarProvider oldWidget) { @@ -167,10 +167,10 @@ class QuillBaseToolbarProvider extends InheritedWidget { return provider; } - /// To pass the [QuillBaseToolbarConfigurations] instance as value + /// To pass the [QuillToolbarConfigurations] instance as value /// instead of creating new widget static QuillBaseToolbarProvider value({ - required QuillBaseToolbarConfigurations value, + required QuillToolbarConfigurations value, required Widget child, }) { return QuillBaseToolbarProvider( diff --git a/test/bug_fix_test.dart b/test/bug_fix_test.dart index 2b804bae..5867f67c 100644 --- a/test/bug_fix_test.dart +++ b/test/bug_fix_test.dart @@ -16,8 +16,8 @@ void main() { await tester.pumpWidget( MaterialApp( - home: QuillToolbar( - configurations: QuillToolbarConfigurations( + home: QuillSimpleToolbar( + configurations: QuillSimpleToolbarConfigurations( controller: controller, showRedo: false, customButtons: const [ @@ -40,7 +40,7 @@ void main() { // builtinFinder.evaluate().first.widget as QuillToolbarIconButton; final customFinder = find.descendant( - of: find.byType(QuillBaseToolbar), + of: find.byType(QuillToolbar), matching: find.byWidgetPredicate((widget) => widget is QuillToolbarIconButton && widget.tooltip == tooltip), matchRoot: true); diff --git a/version.dart b/version.dart index 24c648ad..a2833398 100644 --- a/version.dart +++ b/version.dart @@ -1 +1 @@ -const version = '9.0.0-dev-2'; +const version = '9.0.0-dev-3';