diff --git a/example/lib/screens/quill/my_quill_editor.dart b/example/lib/screens/quill/my_quill_editor.dart index f523edcd..e5f05981 100644 --- a/example/lib/screens/quill/my_quill_editor.dart +++ b/example/lib/screens/quill/my_quill_editor.dart @@ -37,9 +37,7 @@ class MyQuillEditor extends StatelessWidget { codeBlock: QuillEditorCodeBlockElementOptions( enableLineNumbers: true, ), - orderedList: QuillEditorOrderedListElementOptions( - customWidget: Icon(Icons.add), - ), + orderedList: QuillEditorOrderedListElementOptions(), unorderedList: QuillEditorUnOrderedListElementOptions( useTextColorForDot: true, ), diff --git a/flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart b/flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart index ed446cb6..590dac52 100644 --- a/flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart +++ b/flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart @@ -23,7 +23,7 @@ class QuillToolbarFormulaButton extends StatelessWidget { final baseIconFactor = baseButtonExtraOptions(context)?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? _afterButtonPressed(BuildContext context) { diff --git a/flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart b/flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart index 7b1fc0f8..fdf80035 100644 --- a/flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart +++ b/flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart @@ -32,7 +32,7 @@ class QuillToolbarImageButton extends StatelessWidget { final baseIconFactor = baseButtonExtraOptions(context)?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? _afterButtonPressed(BuildContext context) { diff --git a/flutter_quill_extensions/lib/embeds/image/toolbar/select_image_source.dart b/flutter_quill_extensions/lib/embeds/image/toolbar/select_image_source.dart index 40b8de5d..c3e3d286 100644 --- a/flutter_quill_extensions/lib/embeds/image/toolbar/select_image_source.dart +++ b/flutter_quill_extensions/lib/embeds/image/toolbar/select_image_source.dart @@ -9,8 +9,8 @@ class SelectImageSourceDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( - height: 230, + return Container( + constraints: const BoxConstraints(minHeight: 200), width: double.infinity, child: SingleChildScrollView( child: Column( diff --git a/flutter_quill_extensions/lib/embeds/others/camera_button/camera_button.dart b/flutter_quill_extensions/lib/embeds/others/camera_button/camera_button.dart index 0b4fc61a..2d50cd07 100644 --- a/flutter_quill_extensions/lib/embeds/others/camera_button/camera_button.dart +++ b/flutter_quill_extensions/lib/embeds/others/camera_button/camera_button.dart @@ -7,7 +7,7 @@ import 'package:flutter_quill/flutter_quill.dart' QuillToolbarBaseButtonOptions, QuillToolbarIconButton, kDefaultIconSize, - kIconButtonFactor; + kDefaultIconButtonFactor; import 'package:flutter_quill/translations.dart'; import '../../../models/config/camera/camera_configurations.dart'; @@ -36,7 +36,7 @@ class QuillToolbarCameraButton extends StatelessWidget { final baseIconFactor = baseButtonExtraOptions(context)?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? _afterButtonPressed(BuildContext context) { diff --git a/flutter_quill_extensions/lib/embeds/video/toolbar/select_video_source.dart b/flutter_quill_extensions/lib/embeds/video/toolbar/select_video_source.dart index d8ddb774..94af92d9 100644 --- a/flutter_quill_extensions/lib/embeds/video/toolbar/select_video_source.dart +++ b/flutter_quill_extensions/lib/embeds/video/toolbar/select_video_source.dart @@ -9,8 +9,8 @@ class SelectVideoSourceDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( - height: 230, + return Container( + constraints: const BoxConstraints(minHeight: 200), width: double.infinity, child: SingleChildScrollView( child: Column( diff --git a/flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart b/flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart index bb109997..7383ffca 100644 --- a/flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart +++ b/flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart @@ -30,7 +30,7 @@ class QuillToolbarVideoButton extends StatelessWidget { final baseIconFactor = baseButtonExtraOptions(context)?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? _afterButtonPressed(BuildContext context) { diff --git a/flutter_quill_extensions/lib/models/config/camera/camera_configurations.dart b/flutter_quill_extensions/lib/models/config/camera/camera_configurations.dart index fc2c8131..938fd702 100644 --- a/flutter_quill_extensions/lib/models/config/camera/camera_configurations.dart +++ b/flutter_quill_extensions/lib/models/config/camera/camera_configurations.dart @@ -16,8 +16,8 @@ class QuillToolbarCameraButtonOptions extends QuillToolbarBaseButtonOptions< QuillToolbarCameraButtonOptions, QuillToolbarCameraButtonExtraOptions> { const QuillToolbarCameraButtonOptions({ this.cameraConfigurations = const QuillToolbarCameraConfigurations(), - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, this.fillColor, super.iconData, super.afterButtonPressed, @@ -26,9 +26,6 @@ class QuillToolbarCameraButtonOptions extends QuillToolbarBaseButtonOptions< super.childBuilder, }); - final double? iconSize; - final double? iconButtonFactor; - final Color? fillColor; final QuillToolbarCameraConfigurations cameraConfigurations; diff --git a/flutter_quill_extensions/lib/models/config/formula/formula_configurations.dart b/flutter_quill_extensions/lib/models/config/formula/formula_configurations.dart index 638e794c..c8f87902 100644 --- a/flutter_quill_extensions/lib/models/config/formula/formula_configurations.dart +++ b/flutter_quill_extensions/lib/models/config/formula/formula_configurations.dart @@ -19,12 +19,9 @@ class QuillToolbarFormulaButtonOptions extends QuillToolbarBaseButtonOptions< super.afterButtonPressed, super.childBuilder, this.fillColor, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, }); final Color? fillColor; - - final double? iconSize; - final double? iconButtonFactor; } diff --git a/flutter_quill_extensions/lib/models/config/image/toolbar/image_configurations.dart b/flutter_quill_extensions/lib/models/config/image/toolbar/image_configurations.dart index 79ff1034..799285e1 100644 --- a/flutter_quill_extensions/lib/models/config/image/toolbar/image_configurations.dart +++ b/flutter_quill_extensions/lib/models/config/image/toolbar/image_configurations.dart @@ -18,8 +18,8 @@ class QuillToolbarImageButtonOptions extends QuillToolbarBaseButtonOptions< QuillToolbarImageButtonOptions, QuillToolbarImageButtonExtraOptions> { const QuillToolbarImageButtonOptions({ super.iconData, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, /// specifies the tooltip text for the image button. super.tooltip, @@ -32,8 +32,6 @@ class QuillToolbarImageButtonOptions extends QuillToolbarBaseButtonOptions< this.imageButtonConfigurations = const QuillToolbarImageConfigurations(), }); - final double? iconSize; - final double? iconButtonFactor; final Color? fillColor; final QuillDialogTheme? dialogTheme; diff --git a/flutter_quill_extensions/lib/models/config/media/media_button_configurations.dart b/flutter_quill_extensions/lib/models/config/media/media_button_configurations.dart index 95c0654f..9cefeaac 100644 --- a/flutter_quill_extensions/lib/models/config/media/media_button_configurations.dart +++ b/flutter_quill_extensions/lib/models/config/media/media_button_configurations.dart @@ -23,7 +23,7 @@ class QuillToolbarMediaButtonOptions extends QuillToolbarBaseButtonOptions< this.mediaFilePicker, this.childrenSpacing = 16.0, this.autovalidateMode = AutovalidateMode.disabled, - this.iconSize, + super.iconSize, this.fillColor, this.dialogTheme, this.labelText, @@ -40,7 +40,6 @@ class QuillToolbarMediaButtonOptions extends QuillToolbarBaseButtonOptions< super.childBuilder, }); - final double? iconSize; final Color? fillColor; final QuillMediaType type; final QuillDialogTheme? dialogTheme; diff --git a/flutter_quill_extensions/lib/models/config/video/toolbar/video_configurations.dart b/flutter_quill_extensions/lib/models/config/video/toolbar/video_configurations.dart index f7d5c7a7..b68b7729 100644 --- a/flutter_quill_extensions/lib/models/config/video/toolbar/video_configurations.dart +++ b/flutter_quill_extensions/lib/models/config/video/toolbar/video_configurations.dart @@ -18,8 +18,8 @@ class QuillToolbarVideoButtonOptions extends QuillToolbarBaseButtonOptions< this.linkRegExp, this.dialogTheme, this.fillColor, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, super.iconData, super.afterButtonPressed, super.tooltip, @@ -33,7 +33,4 @@ class QuillToolbarVideoButtonOptions extends QuillToolbarBaseButtonOptions< final QuillToolbarVideoConfigurations videoConfigurations; final Color? fillColor; - - final double? iconSize; - final double? iconButtonFactor; } diff --git a/lib/src/models/config/toolbar/base_button_configurations.dart b/lib/src/models/config/toolbar/base_button_configurations.dart index 05b43cef..37496c34 100644 --- a/lib/src/models/config/toolbar/base_button_configurations.dart +++ b/lib/src/models/config/toolbar/base_button_configurations.dart @@ -4,7 +4,8 @@ import 'package:flutter/widgets.dart' show BuildContext, IconData, Widget; import '../../../../flutter_quill.dart' show QuillController; import '../../themes/quill_icon_theme.dart' show QuillIconTheme; -import '../quill_configurations.dart' show kDefaultIconSize, kIconButtonFactor; +import '../quill_configurations.dart' + show kDefaultIconSize, kDefaultIconButtonFactor; class QuillToolbarBaseButtonExtraOptionsIsToggled extends Equatable { const QuillToolbarBaseButtonExtraOptionsIsToggled(this.isToggled); @@ -44,7 +45,9 @@ class QuillToolbarBaseButtonOptions extends Equatable { const QuillToolbarBaseButtonOptions({ this.iconData, this.globalIconSize = kDefaultIconSize, - this.globalIconButtonFactor = kIconButtonFactor, + this.iconSize, + this.iconButtonFactor, + this.globalIconButtonFactor = kDefaultIconButtonFactor, this.afterButtonPressed, this.tooltip, this.iconTheme, @@ -61,10 +64,14 @@ class QuillToolbarBaseButtonOptions extends Equatable { /// this will be used for all the buttons but you can override this final double globalIconSize; + final double? iconSize; + /// The factor of how much larger the button is in relation to the icon, - /// by default it will be [kIconButtonFactor]. + /// by default it will be [kDefaultIconButtonFactor]. final double globalIconButtonFactor; + final double? iconButtonFactor; + /// To do extra logic after pressing the button final VoidCallback? afterButtonPressed; diff --git a/lib/src/models/config/toolbar/buttons/clear_format_configurations.dart b/lib/src/models/config/toolbar/buttons/clear_format_configurations.dart index 04bb8b05..7c8e60e9 100644 --- a/lib/src/models/config/toolbar/buttons/clear_format_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/clear_format_configurations.dart @@ -18,10 +18,9 @@ class QuillToolbarClearFormatButtonOptions super.childBuilder, super.iconTheme, super.tooltip, - this.iconSize, + super.iconSize, this.iconButtonFactor, }); - final double? iconSize; final double? iconButtonFactor; } diff --git a/lib/src/models/config/toolbar/buttons/color_configurations.dart b/lib/src/models/config/toolbar/buttons/color_configurations.dart index eef8c88e..8361a0cc 100644 --- a/lib/src/models/config/toolbar/buttons/color_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/color_configurations.dart @@ -26,8 +26,8 @@ class QuillToolbarColorButtonOptions extends QuillToolbarBaseButtonOptions< QuillToolbarColorButtonOptions, QuillToolbarColorButtonExtraOptions> { const QuillToolbarColorButtonOptions({ this.dialogBarrierColor, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, super.iconData, super.afterButtonPressed, super.childBuilder, @@ -36,9 +36,6 @@ class QuillToolbarColorButtonOptions extends QuillToolbarBaseButtonOptions< this.customOnPressedCallback, }); - final double? iconSize; - final double? iconButtonFactor; - /// By default will use the default `dialogBarrierColor` from /// [QuillSharedConfigurations] final Color? dialogBarrierColor; diff --git a/lib/src/models/config/toolbar/buttons/custom_button_configurations.dart b/lib/src/models/config/toolbar/buttons/custom_button_configurations.dart index 44fc79fb..9d8b58f4 100644 --- a/lib/src/models/config/toolbar/buttons/custom_button_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/custom_button_configurations.dart @@ -15,8 +15,6 @@ class QuillToolbarCustomButtonOptions extends QuillToolbarBaseButtonOptions< QuillToolbarBaseButtonOptions, QuillToolbarCustomButtonExtraOptions> { const QuillToolbarCustomButtonOptions({ this.icon, - this.iconButtonFactor, - this.iconSize, super.afterButtonPressed, super.tooltip, super.iconTheme, @@ -24,8 +22,6 @@ class QuillToolbarCustomButtonOptions extends QuillToolbarBaseButtonOptions< this.onPressed, }); - final double? iconButtonFactor; - final double? iconSize; final VoidCallback? onPressed; final Widget? icon; } diff --git a/lib/src/models/config/toolbar/buttons/font_family_configurations.dart b/lib/src/models/config/toolbar/buttons/font_family_configurations.dart index 410636fe..10ef5efc 100644 --- a/lib/src/models/config/toolbar/buttons/font_family_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/font_family_configurations.dart @@ -49,8 +49,8 @@ class QuillToolbarFontFamilyButtonOptions extends QuillToolbarBaseButtonOptions< this.itemPadding, this.defaultItemColor = Colors.red, this.renderFontFamilies = true, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, this.defaultDisplayText, }); @@ -72,10 +72,6 @@ class QuillToolbarFontFamilyButtonOptions extends QuillToolbarBaseButtonOptions< final Color? defaultItemColor; final String? defaultDisplayText; - /// By default will use [globalIconSize] - final double? iconSize; - final double? iconButtonFactor; - QuillToolbarFontFamilyButtonOptions copyWith({ List>? items, Map? rawItemsMap, diff --git a/lib/src/models/config/toolbar/buttons/font_size_configurations.dart b/lib/src/models/config/toolbar/buttons/font_size_configurations.dart index 3fcf373c..e926e184 100644 --- a/lib/src/models/config/toolbar/buttons/font_size_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/font_size_configurations.dart @@ -33,8 +33,8 @@ class QuillToolbarFontSizeButtonExtraOptions class QuillToolbarFontSizeButtonOptions extends QuillToolbarBaseButtonOptions< QuillToolbarFontSizeButtonOptions, QuillToolbarFontSizeButtonExtraOptions> { const QuillToolbarFontSizeButtonOptions({ - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, this.rawItemsMap, this.onSelected, this.attribute = Attribute.size, @@ -53,9 +53,6 @@ class QuillToolbarFontSizeButtonOptions extends QuillToolbarBaseButtonOptions< this.defaultDisplayText, }); - final double? iconSize; - final double? iconButtonFactor; - final ButtonStyle? shape; /// By default it will be [fontSizesValues] from [QuillSimpleToolbarConfigurations] diff --git a/lib/src/models/config/toolbar/buttons/history_configurations.dart b/lib/src/models/config/toolbar/buttons/history_configurations.dart index 1a146679..000ccc86 100644 --- a/lib/src/models/config/toolbar/buttons/history_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/history_configurations.dart @@ -25,11 +25,7 @@ class QuillToolbarHistoryButtonOptions extends QuillToolbarBaseButtonOptions< super.afterButtonPressed, super.tooltip, super.childBuilder, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, }); - - /// By default will use [globalIconSize] - final double? iconSize; - final double? iconButtonFactor; } diff --git a/lib/src/models/config/toolbar/buttons/indent_configurations.dart b/lib/src/models/config/toolbar/buttons/indent_configurations.dart index d5e3ee99..70b98169 100644 --- a/lib/src/models/config/toolbar/buttons/indent_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/indent_configurations.dart @@ -20,10 +20,7 @@ class QuillToolbarIndentButtonOptions extends QuillToolbarBaseButtonOptions< super.childBuilder, super.iconTheme, super.tooltip, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, }); - - final double? iconSize; - final double? iconButtonFactor; } diff --git a/lib/src/models/config/toolbar/buttons/link_style2_configurations.dart b/lib/src/models/config/toolbar/buttons/link_style2_configurations.dart index 170369f0..0a00bd55 100644 --- a/lib/src/models/config/toolbar/buttons/link_style2_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/link_style2_configurations.dart @@ -16,8 +16,8 @@ class QuillToolbarLinkStyleButton2Options extends QuillToolbarBaseButtonOptions< QuillToolbarLinkStyleButton2Options, QuillToolbarLinkStyleButton2ExtraOptions> { const QuillToolbarLinkStyleButton2Options({ - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, this.dialogTheme, this.constraints, this.addLinkLabel, @@ -35,8 +35,6 @@ class QuillToolbarLinkStyleButton2Options extends QuillToolbarBaseButtonOptions< super.childBuilder, }); - final double? iconSize; - final double? iconButtonFactor; final QuillDialogTheme? dialogTheme; /// The constrains for dialog. diff --git a/lib/src/models/config/toolbar/buttons/link_style_configurations.dart b/lib/src/models/config/toolbar/buttons/link_style_configurations.dart index 4d5a2d39..bc8b2dc2 100644 --- a/lib/src/models/config/toolbar/buttons/link_style_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/link_style_configurations.dart @@ -21,8 +21,8 @@ class QuillToolbarLinkStyleButtonOptions extends QuillToolbarBaseButtonOptions< this.linkRegExp, this.linkDialogAction, this.dialogBarrierColor, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, super.iconData, super.globalIconSize, super.afterButtonPressed, @@ -31,8 +31,6 @@ class QuillToolbarLinkStyleButtonOptions extends QuillToolbarBaseButtonOptions< super.childBuilder, }); - final double? iconSize; - final double? iconButtonFactor; final QuillDialogTheme? dialogTheme; final RegExp? linkRegExp; final LinkDialogAction? linkDialogAction; diff --git a/lib/src/models/config/toolbar/buttons/search_configurations.dart b/lib/src/models/config/toolbar/buttons/search_configurations.dart index f6fad562..8851fe5f 100644 --- a/lib/src/models/config/toolbar/buttons/search_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/search_configurations.dart @@ -20,16 +20,14 @@ class QuillToolbarSearchButtonOptions extends QuillToolbarBaseButtonOptions< super.afterButtonPressed, super.iconTheme, this.dialogTheme, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, this.dialogBarrierColor, this.fillColor, this.customOnPressedCallback, }); final QuillDialogTheme? dialogTheme; - final double? iconSize; - final double? iconButtonFactor; /// By default will be [dialogBarrierColor] from [QuillSharedConfigurations] final Color? dialogBarrierColor; diff --git a/lib/src/models/config/toolbar/buttons/select_alignment_configurations.dart b/lib/src/models/config/toolbar/buttons/select_alignment_configurations.dart index b3919470..65b33395 100644 --- a/lib/src/models/config/toolbar/buttons/select_alignment_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/select_alignment_configurations.dart @@ -17,16 +17,14 @@ class QuillToolbarSelectAlignmentButtonOptions const QuillToolbarSelectAlignmentButtonOptions({ this.iconsData, this.tooltips, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, super.afterButtonPressed, /// This will called on every select alignment button super.childBuilder, super.iconTheme, }); - final double? iconSize; - final double? iconButtonFactor; /// Default to /// const QuillToolbarSelectAlignmentValues( diff --git a/lib/src/models/config/toolbar/buttons/select_header_style_buttons_configurations.dart b/lib/src/models/config/toolbar/buttons/select_header_style_buttons_configurations.dart index f640b614..da3d7e1c 100644 --- a/lib/src/models/config/toolbar/buttons/select_header_style_buttons_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/select_header_style_buttons_configurations.dart @@ -23,8 +23,8 @@ class QuillToolbarSelectHeaderStyleButtonsOptions super.tooltip, this.axis, this.attributes, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, }); /// Default value: @@ -41,6 +41,4 @@ class QuillToolbarSelectHeaderStyleButtonsOptions /// 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/buttons/select_header_style_dropdown_button_configurations.dart b/lib/src/models/config/toolbar/buttons/select_header_style_dropdown_button_configurations.dart index 6bf73db4..22df0a33 100644 --- a/lib/src/models/config/toolbar/buttons/select_header_style_dropdown_button_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/select_header_style_dropdown_button_configurations.dart @@ -25,8 +25,8 @@ class QuillToolbarSelectHeaderStyleDropdownButtonOptions super.childBuilder, super.iconTheme, super.tooltip, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, this.textStyle, super.iconData, this.attributes, @@ -34,9 +34,6 @@ class QuillToolbarSelectHeaderStyleDropdownButtonOptions this.width, }); - /// By default we will the toolbar axis from [QuillSimpleToolbarConfigurations] - final double? iconSize; - final double? iconButtonFactor; final TextStyle? textStyle; /// Header attributes, defaults to: diff --git a/lib/src/models/config/toolbar/buttons/toggle_check_list_configurations.dart b/lib/src/models/config/toolbar/buttons/toggle_check_list_configurations.dart index de9dfe65..de30d3b8 100644 --- a/lib/src/models/config/toolbar/buttons/toggle_check_list_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/toggle_check_list_configurations.dart @@ -21,8 +21,8 @@ class QuillToolbarToggleCheckListButtonOptions QuillToolbarToggleCheckListButtonOptions, QuillToolbarToggleCheckListButtonExtraOptions> { const QuillToolbarToggleCheckListButtonOptions({ - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, this.fillColor, this.attribute = Attribute.unchecked, this.isShouldRequestKeyboard = false, @@ -33,9 +33,6 @@ class QuillToolbarToggleCheckListButtonOptions super.childBuilder, }); - final double? iconSize; - final double? iconButtonFactor; - final Color? fillColor; final Attribute attribute; diff --git a/lib/src/models/config/toolbar/buttons/toggle_style_configurations.dart b/lib/src/models/config/toolbar/buttons/toggle_style_configurations.dart index d8d0e3e2..5caa1447 100644 --- a/lib/src/models/config/toolbar/buttons/toggle_style_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/toggle_style_configurations.dart @@ -24,8 +24,8 @@ class QuillToolbarToggleStyleButtonOptions QuillToolbarToggleStyleButtonExtraOptions> { const QuillToolbarToggleStyleButtonOptions({ super.iconData, - this.iconSize, - this.iconButtonFactor, + super.iconSize, + super.iconButtonFactor, this.fillColor, super.tooltip, super.afterButtonPressed, @@ -33,7 +33,5 @@ class QuillToolbarToggleStyleButtonOptions super.childBuilder, }); - final double? iconSize; - final double? iconButtonFactor; final Color? fillColor; } diff --git a/lib/src/models/config/toolbar/simple_toolbar_configurations.dart b/lib/src/models/config/toolbar/simple_toolbar_configurations.dart index 8156a144..c479db21 100644 --- a/lib/src/models/config/toolbar/simple_toolbar_configurations.dart +++ b/lib/src/models/config/toolbar/simple_toolbar_configurations.dart @@ -32,10 +32,10 @@ export 'simple_toolbar_button_options.dart'; const double kDefaultIconSize = 15; /// The default size for the toolbar (width, height) -const double defaultToolbarSize = kDefaultIconSize * 2; +const double kDefaultToolbarSize = kDefaultIconSize * 2; /// The factor of how much larger the button is in relation to the icon. -const double kIconButtonFactor = 1.6; +const double kDefaultIconButtonFactor = 1.6; /// The horizontal margin between the contents of each toolbar section. const double kToolbarSectionSpacing = 4; diff --git a/lib/src/widgets/toolbar/base_button/stateless_base_button.dart b/lib/src/widgets/toolbar/base_button/stateless_base_button.dart new file mode 100644 index 00000000..d0aa931d --- /dev/null +++ b/lib/src/widgets/toolbar/base_button/stateless_base_button.dart @@ -0,0 +1,76 @@ +import 'package:flutter/material.dart'; + +import '../../../extensions/quill_configurations_ext.dart'; +import '../../../models/themes/quill_icon_theme.dart'; +import '../../quill/quill_controller.dart'; +import '../base_toolbar.dart'; + +/// The [T] is the options for the button, usually should refresnce itself +/// it's used in [childBuilder] so the developer can custmize this when using it +/// The [I] is extra options for the button, usually for it's state +abstract class QuillToolbarBaseButton extends StatelessWidget { + const QuillToolbarBaseButton({ + required this.controller, + super.key, + this.options, + }); + + final QuillToolbarBaseButtonOptions? options; + + final QuillController controller; + + double iconSize(BuildContext context) { + final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize; + final iconSize = options?.iconSize; + return iconSize ?? baseFontSize ?? kDefaultIconSize; + } + + double iconButtonFactor(BuildContext context) { + final baseIconFactor = + baseButtonExtraOptions(context)?.globalIconButtonFactor; + final iconButtonFactor = options?.iconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; + } + + VoidCallback? afterButtonPressed(BuildContext context) { + return options?.afterButtonPressed ?? + baseButtonExtraOptions(context)?.afterButtonPressed; + } + + QuillIconTheme? iconTheme(BuildContext context) { + return options?.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme; + } + + QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) { + return context.quillToolbarBaseButtonOptions; + } + + IconData iconData(BuildContext context) { + return options?.iconData ?? + baseButtonExtraOptions(context)?.iconData ?? + getDefaultIconData(context); + } + + String tooltip(BuildContext context) { + return options?.tooltip ?? + baseButtonExtraOptions(context)?.tooltip ?? + getDefaultIconSize(context); + } + + abstract final IconData Function(BuildContext context) getDefaultIconData; + abstract final String Function(BuildContext context) getDefaultIconSize; + + Widget buildButton(BuildContext context); + Widget? buildCustomChildBuilder( + BuildContext context, + ); + + @override + Widget build(BuildContext context) { + final childBuilder = options?.childBuilder; + if (childBuilder != null) { + return buildCustomChildBuilder(context) ?? const SizedBox.shrink(); + } + return buildButton(context); + } +} diff --git a/lib/src/widgets/toolbar/base_toolbar.dart b/lib/src/widgets/toolbar/base_toolbar.dart index ab1b483e..114276ce 100644 --- a/lib/src/widgets/toolbar/base_toolbar.dart +++ b/lib/src/widgets/toolbar/base_toolbar.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import '../../../flutter_quill.dart' - show QuillToolbarProvider, defaultToolbarSize; + show QuillToolbarProvider, kDefaultToolbarSize; import '../../l10n/widgets/localizations.dart'; import '../../models/config/toolbar/simple_toolbar_configurations.dart'; import '../../models/config/toolbar/toolbar_configurations.dart'; @@ -53,8 +53,8 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { // default @override Size get preferredSize => configurations.axis == Axis.horizontal - ? const Size.fromHeight(defaultToolbarSize) - : const Size.fromWidth(defaultToolbarSize); + ? const Size.fromHeight(kDefaultToolbarSize) + : const Size.fromWidth(kDefaultToolbarSize); @override Widget build(BuildContext context) { diff --git a/lib/src/widgets/toolbar/buttons/clear_format_button.dart b/lib/src/widgets/toolbar/buttons/clear_format_button.dart index 41df3834..4a28dcf1 100644 --- a/lib/src/widgets/toolbar/buttons/clear_format_button.dart +++ b/lib/src/widgets/toolbar/buttons/clear_format_button.dart @@ -1,120 +1,64 @@ import 'package:flutter/material.dart'; -import '../../../extensions/quill_configurations_ext.dart'; import '../../../l10n/extensions/localizations.dart'; import '../../../models/documents/attribute.dart'; -import '../../../models/themes/quill_icon_theme.dart'; -import '../../quill/quill_controller.dart'; +import '../base_button/stateless_base_button.dart'; import '../base_toolbar.dart'; -class QuillToolbarClearFormatButton extends StatelessWidget { +class QuillToolbarClearFormatButton extends QuillToolbarBaseButton { const QuillToolbarClearFormatButton({ - required QuillController controller, - this.options = const QuillToolbarClearFormatButtonOptions(), + required super.controller, + super.options, super.key, - }) : _controller = controller; - - final QuillController _controller; - final QuillToolbarClearFormatButtonOptions options; - - QuillController get controller { - return _controller; - } - - double _iconSize(BuildContext context) { - final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize; - final iconSize = options.iconSize; - return iconSize ?? baseFontSize ?? kDefaultIconSize; - } - - double _iconButtonFactor(BuildContext context) { - final baseIconFactor = - baseButtonExtraOptions(context)?.globalIconButtonFactor; - final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; - } - - VoidCallback? _afterButtonPressed(BuildContext context) { - return options.afterButtonPressed ?? - baseButtonExtraOptions(context)?.afterButtonPressed; - } - - QuillIconTheme? _iconTheme(BuildContext context) { - return options.iconTheme ?? baseButtonExtraOptions(context)?.iconTheme; - } - - QuillToolbarBaseButtonOptions? baseButtonExtraOptions(BuildContext context) { - return context.quillToolbarBaseButtonOptions; - } - - IconData _iconData(BuildContext context) { - return options.iconData ?? - baseButtonExtraOptions(context)?.iconData ?? - Icons.format_clear; - } - - String _tooltip(BuildContext context) { - return options.tooltip ?? - baseButtonExtraOptions(context)?.tooltip ?? - (context.loc.clearFormat); - } + }); void _sharedOnPressed() { - final attrs = {}; + final attributes = {}; for (final style in controller.getAllSelectionStyles()) { for (final attr in style.attributes.values) { - attrs.add(attr); + attributes.add(attr); } } - for (final attr in attrs) { - controller.formatSelection(Attribute.clone(attr, null)); + for (final attribute in attributes) { + controller.formatSelection(Attribute.clone(attribute, null)); } } @override - Widget build(BuildContext context) { - final iconTheme = _iconTheme(context); - final tooltip = _tooltip(context); - final iconSize = _iconSize(context); - final iconButtonFactor = _iconButtonFactor(context); - final iconData = _iconData(context); - - final childBuilder = - options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder; - final afterButtonPressed = _afterButtonPressed(context); - - if (childBuilder != null) { - return childBuilder( - QuillToolbarClearFormatButtonOptions( - afterButtonPressed: afterButtonPressed, - iconData: iconData, - iconSize: iconSize, - iconButtonFactor: iconButtonFactor, - iconTheme: iconTheme, - tooltip: tooltip, - ), - QuillToolbarClearFormatButtonExtraOptions( - controller: controller, - context: context, - onPressed: () { - _sharedOnPressed(); - _afterButtonPressed(context)?.call(); - }, - ), - ); - } - + Widget buildButton(BuildContext context) { return QuillToolbarIconButton( - tooltip: tooltip, + tooltip: tooltip(context), icon: Icon( - iconData, - size: iconSize * iconButtonFactor, - // color: iconColor, + iconData(context), + size: iconSize(context) * iconButtonFactor(context), ), isSelected: false, onPressed: _sharedOnPressed, - afterPressed: afterButtonPressed, - iconTheme: iconTheme, + afterPressed: afterButtonPressed(context), + iconTheme: iconTheme(context), ); } + + @override + Widget? buildCustomChildBuilder(BuildContext context) { + return options?.childBuilder?.call( + options, + QuillToolbarClearFormatButtonExtraOptions( + controller: controller, + context: context, + onPressed: () { + _sharedOnPressed(); + afterButtonPressed(context)?.call(); + }, + ), + ); + } + + @override + IconData Function(BuildContext context) get getDefaultIconData => + (context) => Icons.format_clear; + + @override + String Function(BuildContext context) get getDefaultIconSize => + (context) => context.loc.clearFormat; } diff --git a/lib/src/widgets/toolbar/buttons/color/color_button.dart b/lib/src/widgets/toolbar/buttons/color/color_button.dart index eefcc8c8..8df6914c 100644 --- a/lib/src/widgets/toolbar/buttons/color/color_button.dart +++ b/lib/src/widgets/toolbar/buttons/color/color_button.dart @@ -112,7 +112,7 @@ class QuillToolbarColorButtonState extends State { double get iconButtonFactor { final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? get afterButtonPressed { @@ -165,16 +165,7 @@ class QuillToolbarColorButtonState extends State { options.childBuilder ?? baseButtonExtraOptions?.childBuilder; if (childBuilder != null) { return childBuilder( - QuillToolbarColorButtonOptions( - afterButtonPressed: afterButtonPressed, - dialogBarrierColor: options.dialogBarrierColor, - tooltip: tooltip, - iconTheme: iconTheme, - iconSize: iconSize, - iconData: iconData, - iconButtonFactor: iconButtonFactor, - customOnPressedCallback: options.customOnPressedCallback, - ), + options, QuillToolbarColorButtonExtraOptions( controller: controller, context: context, diff --git a/lib/src/widgets/toolbar/buttons/custom_button_button.dart b/lib/src/widgets/toolbar/buttons/custom_button_button.dart index 4f99aa9a..f2ec87ba 100644 --- a/lib/src/widgets/toolbar/buttons/custom_button_button.dart +++ b/lib/src/widgets/toolbar/buttons/custom_button_button.dart @@ -15,19 +15,6 @@ class QuillToolbarCustomButton extends StatelessWidget { final QuillController controller; final QuillToolbarCustomButtonOptions options; - double _iconSize(BuildContext context) { - final baseFontSize = baseButtonExtraOptions(context)?.globalIconSize; - final iconSize = options.iconSize; - return iconSize ?? baseFontSize ?? kDefaultIconSize; - } - - double _iconButtonFactor(BuildContext context) { - final baseIconFactor = - baseButtonExtraOptions(context)?.globalIconButtonFactor; - final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; - } - VoidCallback? _afterButtonPressed(BuildContext context) { return options.afterButtonPressed ?? baseButtonExtraOptions(context)?.afterButtonPressed; @@ -54,8 +41,6 @@ class QuillToolbarCustomButton extends StatelessWidget { Widget build(BuildContext context) { final iconTheme = _iconTheme(context); final tooltip = _tooltip(context); - final iconSize = _iconSize(context); - final iconButtonFactor = _iconButtonFactor(context); final childBuilder = options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder; @@ -63,14 +48,7 @@ class QuillToolbarCustomButton extends StatelessWidget { if (childBuilder != null) { return childBuilder( - QuillToolbarCustomButtonOptions( - iconButtonFactor: iconButtonFactor, - iconSize: iconSize, - afterButtonPressed: afterButtonPressed, - iconTheme: iconTheme, - tooltip: tooltip, - icon: options.icon, - ), + options, QuillToolbarCustomButtonExtraOptions( context: context, controller: controller, diff --git a/lib/src/widgets/toolbar/buttons/font_family_button.dart b/lib/src/widgets/toolbar/buttons/font_family_button.dart index 276b7391..f0dc38ee 100644 --- a/lib/src/widgets/toolbar/buttons/font_family_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_family_button.dart @@ -147,10 +147,16 @@ class QuillToolbarFontFamilyButtonState } void _onPressed() { - _showMenu(); + if (_menuController.isOpen) { + _menuController.close(); + } else { + _menuController.open(); + } options.afterButtonPressed?.call(); } + final _menuController = MenuController(); + @override Widget build(BuildContext context) { final baseButtonConfigurations = context.quillToolbarBaseButtonOptions; @@ -158,13 +164,7 @@ class QuillToolbarFontFamilyButtonState options.childBuilder ?? baseButtonConfigurations?.childBuilder; if (childBuilder != null) { return childBuilder( - options.copyWith( - iconSize: iconSize, - rawItemsMap: rawItemsMap, - iconTheme: iconTheme, - tooltip: tooltip, - afterButtonPressed: afterButtonPressed, - ), + options, QuillToolbarFontFamilyButtonExtraOptions( currentValue: _currentValue, defaultDisplayText: _defaultDisplayText, @@ -185,101 +185,79 @@ class QuillToolbarFontFamilyButtonState } return Tooltip(message: effectiveTooltip, child: child); }, - child: Builder( - builder: (context) { - final isMaterial3 = Theme.of(context).useMaterial3; - if (!isMaterial3) { - return RawMaterialButton( - onPressed: _onPressed, - child: _buildContent(context), - ); - } - return QuillToolbarIconButton( - isSelected: false, - iconTheme: iconTheme?.copyWith( - iconButtonSelectedData: const IconButtonData( - visualDensity: VisualDensity.compact, - ), - iconButtonUnselectedData: const IconButtonData( - visualDensity: VisualDensity.compact, - ), - ), - onPressed: _onPressed, - icon: _buildContent(context), - ); - }, - ), - ); - } + child: MenuAnchor( + controller: _menuController, + menuChildren: [ + for (final MapEntry fontFamily in rawItemsMap.entries) + MenuItemButton( + key: ValueKey(fontFamily.key), + // value: fontFamily.value, + // height: options.itemHeight ?? kMinInteractiveDimension, + // padding: options.itemPadding, + onPressed: () { + final newValue = fontFamily.value; + final keyName = _getKeyName(newValue); + setState(() { + if (keyName != 'Clear') { + _currentValue = keyName ?? _defaultDisplayText; + } else { + _currentValue = _defaultDisplayText; + } + if (keyName != null) { + controller.formatSelection( + Attribute.fromKeyValue( + Attribute.font.key, + newValue == 'Clear' ? null : newValue, + ), + ); + options.onSelected?.call(newValue); + } + }); - Future _showMenu() async { - final popupMenuTheme = PopupMenuTheme.of(context); - final button = context.findRenderObject() as RenderBox; - final overlay = Overlay.of(context).context.findRenderObject() as RenderBox; - final position = RelativeRect.fromRect( - Rect.fromPoints( - button.localToGlobal(Offset.zero, ancestor: overlay), - button.localToGlobal(button.size.bottomLeft(Offset.zero), - ancestor: overlay), - ), - Offset.zero & overlay.size, - ); - final newValue = await showMenu( - context: context, - elevation: 4, - items: [ - for (final MapEntry fontFamily in rawItemsMap.entries) - PopupMenuItem( - key: ValueKey(fontFamily.key), - value: fontFamily.value, - height: options.itemHeight ?? kMinInteractiveDimension, - padding: options.itemPadding, - onTap: () { - if (fontFamily.value == 'Clear') { - controller.selectFontFamily(null); - return; - } - controller.selectFontFamily(fontFamily.value); - }, - child: Text( - fontFamily.key.toString(), - style: TextStyle( - fontFamily: - options.renderFontFamilies ? fontFamily.value : null, - color: fontFamily.value == 'Clear' - ? options.defaultItemColor - : null, + if (fontFamily.value == 'Clear') { + controller.selectFontFamily(null); + return; + } + controller.selectFontFamily(fontFamily.value); + }, + child: Text( + fontFamily.key.toString(), + style: TextStyle( + fontFamily: + options.renderFontFamilies ? fontFamily.value : null, + color: fontFamily.value == 'Clear' + ? options.defaultItemColor + : null, + ), ), ), - ), - ], - position: position, - shape: popupMenuTheme.shape, - color: popupMenuTheme.color, + ], + child: Builder( + builder: (context) { + final isMaterial3 = Theme.of(context).useMaterial3; + if (!isMaterial3) { + return RawMaterialButton( + onPressed: _onPressed, + child: _buildContent(context), + ); + } + return QuillToolbarIconButton( + isSelected: false, + iconTheme: iconTheme?.copyWith( + iconButtonSelectedData: const IconButtonData( + visualDensity: VisualDensity.compact, + ), + iconButtonUnselectedData: const IconButtonData( + visualDensity: VisualDensity.compact, + ), + ), + onPressed: _onPressed, + icon: _buildContent(context), + ); + }, + ), + ), ); - if (!mounted) { - return; - } - if (newValue == null) { - return; - } - final keyName = _getKeyName(newValue); - setState(() { - if (keyName != 'Clear') { - _currentValue = keyName ?? _defaultDisplayText; - } else { - _currentValue = _defaultDisplayText; - } - if (keyName != null) { - controller.formatSelection( - Attribute.fromKeyValue( - Attribute.font.key, - newValue == 'Clear' ? null : newValue, - ), - ); - options.onSelected?.call(newValue); - } - }); } Widget _buildContent(BuildContext context) { diff --git a/lib/src/widgets/toolbar/buttons/font_size_button.dart b/lib/src/widgets/toolbar/buttons/font_size_button.dart index 92f7072d..061290d0 100644 --- a/lib/src/widgets/toolbar/buttons/font_size_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_size_button.dart @@ -106,7 +106,7 @@ class QuillToolbarFontSizeButtonState final baseIconFactor = context.quillToolbarBaseButtonOptions?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? get afterButtonPressed { @@ -141,12 +141,7 @@ class QuillToolbarFontSizeButtonState options.childBuilder ?? baseButtonConfigurations?.childBuilder; if (childBuilder != null) { return childBuilder( - options.copyWith( - tooltip: tooltip, - iconSize: iconSize, - iconButtonFactor: iconButtonFactor, - afterButtonPressed: afterButtonPressed, - ), + options, QuillToolbarFontSizeButtonExtraOptions( controller: controller, currentValue: _currentValue, diff --git a/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_buttons.dart b/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_buttons.dart index 57ff5d64..61f570cb 100644 --- a/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_buttons.dart +++ b/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_buttons.dart @@ -63,7 +63,7 @@ class QuillToolbarSelectHeaderStyleButtonsState double get iconButtonFactor { final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? get afterButtonPressed { diff --git a/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart b/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart index 09fa358f..ef2c9b24 100644 --- a/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart +++ b/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart @@ -99,7 +99,7 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState final baseIconFactor = context.quillToolbarBaseButtonOptions?.globalIconButtonFactor; final iconButtonFactor = widget.options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } QuillIconTheme? get iconTheme { @@ -113,9 +113,6 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState Attribute.h1, Attribute.h2, Attribute.h3, - Attribute.h4, - Attribute.h5, - Attribute.h6, Attribute.header, ]; } @@ -147,11 +144,7 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState widget.options.childBuilder ?? baseButtonConfigurations?.childBuilder; if (childBuilder != null) { return childBuilder( - widget.options.copyWith( - iconSize: iconSize, - iconTheme: iconTheme, - afterButtonPressed: afterButtonPressed, - ), + widget.options, QuillToolbarSelectHeaderStyleDropdownButtonExtraOptions( currentValue: _selectedItem, context: context, diff --git a/lib/src/widgets/toolbar/buttons/history_button.dart b/lib/src/widgets/toolbar/buttons/history_button.dart index 0527c3fa..5834b5fc 100644 --- a/lib/src/widgets/toolbar/buttons/history_button.dart +++ b/lib/src/widgets/toolbar/buttons/history_button.dart @@ -68,7 +68,7 @@ class QuillToolbarHistoryButtonState extends State { kDefaultIconSize; final iconButtonFactor = options.iconButtonFactor ?? baseButtonConfigurations?.globalIconButtonFactor ?? - kIconButtonFactor; + kDefaultIconButtonFactor; final iconTheme = options.iconTheme ?? baseButtonConfigurations?.iconTheme; final afterButtonPressed = options.afterButtonPressed ?? @@ -76,14 +76,7 @@ class QuillToolbarHistoryButtonState extends State { if (childBuilder != null) { return childBuilder( - QuillToolbarHistoryButtonOptions( - afterButtonPressed: afterButtonPressed, - iconData: iconData, - iconSize: iconSize, - iconButtonFactor: iconButtonFactor, - iconTheme: iconTheme, - tooltip: tooltip, - ), + options, QuillToolbarHistoryButtonExtraOptions( onPressed: () { _updateHistory(); diff --git a/lib/src/widgets/toolbar/buttons/indent_button.dart b/lib/src/widgets/toolbar/buttons/indent_button.dart index 2c96de42..c2319f7c 100644 --- a/lib/src/widgets/toolbar/buttons/indent_button.dart +++ b/lib/src/widgets/toolbar/buttons/indent_button.dart @@ -43,7 +43,7 @@ class QuillToolbarIndentButtonState extends State { double get iconButtonFactor { final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? get afterButtonPressed { @@ -86,14 +86,7 @@ class QuillToolbarIndentButtonState extends State { if (childBuilder != null) { return childBuilder( - QuillToolbarIndentButtonOptions( - afterButtonPressed: afterButtonPressed, - iconData: iconData, - iconSize: iconSize, - iconButtonFactor: iconButtonFactor, - iconTheme: iconTheme, - tooltip: tooltip, - ), + options, QuillToolbarIndentButtonExtraOptions( controller: controller, context: context, diff --git a/lib/src/widgets/toolbar/buttons/link_style2_button.dart b/lib/src/widgets/toolbar/buttons/link_style2_button.dart index 7f2a2658..d5d4532c 100644 --- a/lib/src/widgets/toolbar/buttons/link_style2_button.dart +++ b/lib/src/widgets/toolbar/buttons/link_style2_button.dart @@ -78,7 +78,7 @@ class _QuillToolbarLinkStyleButton2State double get iconButtonFactor { final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? get afterButtonPressed { @@ -116,24 +116,7 @@ class _QuillToolbarLinkStyleButton2State options.childBuilder ?? baseButtonExtraOptions?.childBuilder; if (childBuilder != null) { return childBuilder( - QuillToolbarLinkStyleButton2Options( - iconData: iconData, - addLinkLabel: options.addLinkLabel, - afterButtonPressed: options.afterButtonPressed, - autovalidateMode: options.autovalidateMode, - buttonSize: options.buttonSize, - childrenSpacing: options.childrenSpacing, - dialogBarrierColor: dialogBarrierColor, - dialogTheme: options.dialogTheme, - iconSize: iconSize, - iconButtonFactor: iconButtonFactor, - constraints: options.constraints, - tooltip: tooltip, - iconTheme: iconTheme, - editLinkLabel: options.editLinkLabel, - validationMessage: options.validationMessage, - linkColor: options.linkColor, - ), + options, QuillToolbarLinkStyleButton2ExtraOptions( controller: controller, context: context, diff --git a/lib/src/widgets/toolbar/buttons/link_style_button.dart b/lib/src/widgets/toolbar/buttons/link_style_button.dart index 2670ff6e..1504f1e2 100644 --- a/lib/src/widgets/toolbar/buttons/link_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/link_style_button.dart @@ -71,7 +71,7 @@ class QuillToolbarLinkStyleButtonState double get iconButtonFactor { final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? get afterButtonPressed { @@ -115,18 +115,7 @@ class QuillToolbarLinkStyleButtonState options.childBuilder ?? baseButtonExtraOptions?.childBuilder; if (childBuilder != null) { return childBuilder( - QuillToolbarLinkStyleButtonOptions( - afterButtonPressed: afterButtonPressed, - dialogBarrierColor: dialogBarrierColor, - dialogTheme: options.dialogTheme, - iconData: iconData, - iconSize: iconSize, - iconButtonFactor: iconButtonFactor, - tooltip: tooltip, - linkDialogAction: options.linkDialogAction, - linkRegExp: linkRegExp, - iconTheme: iconTheme, - ), + options, QuillToolbarLinkStyleButtonExtraOptions( context: context, controller: controller, diff --git a/lib/src/widgets/toolbar/buttons/search/search_button.dart b/lib/src/widgets/toolbar/buttons/search/search_button.dart index c98afe13..d3bf980d 100644 --- a/lib/src/widgets/toolbar/buttons/search/search_button.dart +++ b/lib/src/widgets/toolbar/buttons/search/search_button.dart @@ -32,7 +32,7 @@ class QuillToolbarSearchButton extends StatelessWidget { final baseIconFactor = baseButtonExtraOptions(context)?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? _afterButtonPressed(BuildContext context) { @@ -85,17 +85,7 @@ class QuillToolbarSearchButton extends StatelessWidget { if (childBuilder != null) { return childBuilder( - QuillToolbarSearchButtonOptions( - afterButtonPressed: afterButtonPressed, - dialogBarrierColor: _dialogBarrierColor(context), - dialogTheme: _dialogTheme(context), - fillColor: options.fillColor, - iconData: iconData, - iconSize: iconSize, - iconButtonFactor: iconButtonFactor, - tooltip: tooltip, - iconTheme: iconTheme, - ), + options, QuillToolbarSearchButtonExtraOptions( controller: controller, context: context, 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 06a991cc..1bbb4b83 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_check_list_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_check_list_button.dart @@ -94,7 +94,7 @@ class QuillToolbarToggleCheckListButtonState double get iconButtonFactor { final baseIconFactor = baseButtonExtraOptions?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? get afterButtonPressed { @@ -128,14 +128,7 @@ class QuillToolbarToggleCheckListButtonState options.childBuilder ?? baseButtonExtraOptions?.childBuilder; if (childBuilder != null) { return childBuilder( - QuillToolbarToggleCheckListButtonOptions( - afterButtonPressed: afterButtonPressed, - iconTheme: iconTheme, - iconSize: iconSize, - iconButtonFactor: iconButtonFactor, - tooltip: tooltip, - iconData: iconData, - ), + options, QuillToolbarToggleCheckListButtonExtraOptions( context: context, controller: controller, diff --git a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart index 46408b94..af150cef 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart @@ -71,7 +71,7 @@ class QuillToolbarToggleStyleButtonState final baseIconFactor = context.quillToolbarBaseButtonOptions?.globalIconButtonFactor; final iconButtonFactor = options.iconButtonFactor; - return iconButtonFactor ?? baseIconFactor ?? kIconButtonFactor; + return iconButtonFactor ?? baseIconFactor ?? kDefaultIconButtonFactor; } VoidCallback? get afterButtonPressed { @@ -157,15 +157,7 @@ class QuillToolbarToggleStyleButtonState context.quillToolbarBaseButtonOptions?.childBuilder; if (childBuilder != null) { return childBuilder( - QuillToolbarToggleStyleButtonOptions( - afterButtonPressed: options.afterButtonPressed, - fillColor: options.fillColor, - iconButtonFactor: options.iconButtonFactor, - iconData: iconData, - iconSize: iconSize, - tooltip: tooltip, - iconTheme: iconTheme, - ), + options, QuillToolbarToggleStyleButtonExtraOptions( context: context, controller: controller, @@ -244,7 +236,7 @@ Widget defaultToggleStyleButtonBuilder( VoidCallback? onPressed, VoidCallback? afterPressed, [ double iconSize = kDefaultIconSize, - double iconButtonFactor = kIconButtonFactor, + double iconButtonFactor = kDefaultIconButtonFactor, QuillIconTheme? iconTheme, ]) { final isEnabled = onPressed != null; diff --git a/lib/src/widgets/toolbar/simple_toolbar.dart b/lib/src/widgets/toolbar/simple_toolbar.dart index a9bea206..0b397b39 100644 --- a/lib/src/widgets/toolbar/simple_toolbar.dart +++ b/lib/src/widgets/toolbar/simple_toolbar.dart @@ -365,8 +365,8 @@ class QuillSimpleToolbar extends StatelessWidget @override Size get preferredSize => configurations.axis == Axis.horizontal - ? const Size.fromHeight(defaultToolbarSize) - : const Size.fromWidth(defaultToolbarSize); + ? const Size.fromHeight(kDefaultToolbarSize) + : const Size.fromWidth(kDefaultToolbarSize); } /// The divider which is used for separation of buttons in the toolbar.