From 4f5fa325418ebd92b082bd26df575ed109339757 Mon Sep 17 00:00:00 2001 From: Adil Hanney Date: Thu, 9 Nov 2023 03:30:14 +0000 Subject: [PATCH] fix: pass iconButtonFactor to childBuilder --- .../embeds/toolbar/camera_button/camera_button.dart | 1 + .../lib/presentation/embeds/toolbar/formula_button.dart | 9 +++++++++ .../embeds/toolbar/image_button/image_button.dart | 9 +++++++++ .../embeds/toolbar/media_button/media_button.dart | 1 + .../embeds/toolbar/video_button/video_button.dart | 1 + .../models/config/toolbar/buttons/camera.dart | 2 ++ .../models/config/toolbar/buttons/formula.dart | 2 ++ .../models/config/toolbar/buttons/image.dart | 2 ++ .../models/config/toolbar/buttons/video.dart | 2 ++ flutter_quill_extensions/pubspec.yaml | 2 +- lib/src/models/config/toolbar/buttons/font_family.dart | 4 ++++ lib/src/models/config/toolbar/buttons/font_size.dart | 4 ++++ lib/src/widgets/toolbar/buttons/clear_format.dart | 1 + lib/src/widgets/toolbar/buttons/font_size.dart | 8 ++++++++ lib/src/widgets/toolbar/buttons/history.dart | 1 + lib/src/widgets/toolbar/buttons/indent.dart | 1 + lib/src/widgets/toolbar/buttons/link_style.dart | 1 + lib/src/widgets/toolbar/buttons/link_style2.dart | 1 + lib/src/widgets/toolbar/buttons/search/search.dart | 9 +++++---- lib/src/widgets/toolbar/buttons/select_alignment.dart | 1 + lib/src/widgets/toolbar/buttons/select_header_style.dart | 1 + lib/src/widgets/toolbar/buttons/toggle_check_list.dart | 1 + 22 files changed, 59 insertions(+), 5 deletions(-) diff --git a/flutter_quill_extensions/lib/presentation/embeds/toolbar/camera_button/camera_button.dart b/flutter_quill_extensions/lib/presentation/embeds/toolbar/camera_button/camera_button.dart index 43d74f04..be7d7a14 100644 --- a/flutter_quill_extensions/lib/presentation/embeds/toolbar/camera_button/camera_button.dart +++ b/flutter_quill_extensions/lib/presentation/embeds/toolbar/camera_button/camera_button.dart @@ -77,6 +77,7 @@ class QuillToolbarCameraButton extends StatelessWidget { iconData: options.iconData, fillColor: options.fillColor, iconSize: options.iconSize, + iconButtonFactor: options.iconButtonFactor, iconTheme: options.iconTheme, tooltip: options.tooltip, cameraConfigurations: options.cameraConfigurations, diff --git a/flutter_quill_extensions/lib/presentation/embeds/toolbar/formula_button.dart b/flutter_quill_extensions/lib/presentation/embeds/toolbar/formula_button.dart index 4a0341d4..e821d689 100644 --- a/flutter_quill_extensions/lib/presentation/embeds/toolbar/formula_button.dart +++ b/flutter_quill_extensions/lib/presentation/embeds/toolbar/formula_button.dart @@ -19,6 +19,13 @@ class QuillToolbarFormulaButton extends StatelessWidget { return iconSize ?? baseFontSize; } + double _iconButtonFactor(BuildContext context) { + final baseIconFactor = + baseButtonExtraOptions(context).globalIconButtonFactor; + final iconButtonFactor = options.iconButtonFactor; + return iconButtonFactor ?? baseIconFactor; + } + VoidCallback? _afterButtonPressed(BuildContext context) { return options.afterButtonPressed ?? baseButtonExtraOptions(context).afterButtonPressed; @@ -58,6 +65,7 @@ class QuillToolbarFormulaButton extends StatelessWidget { final tooltip = _tooltip(context); final iconSize = _iconSize(context); + final iconButtonFactor = _iconButtonFactor(context); final iconData = _iconData(context); final childBuilder = options.childBuilder ?? baseButtonExtraOptions(context).childBuilder; @@ -73,6 +81,7 @@ class QuillToolbarFormulaButton extends StatelessWidget { fillColor: iconFillColor, iconData: iconData, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, iconTheme: iconTheme, tooltip: tooltip, ), diff --git a/flutter_quill_extensions/lib/presentation/embeds/toolbar/image_button/image_button.dart b/flutter_quill_extensions/lib/presentation/embeds/toolbar/image_button/image_button.dart index 8c27c1e3..cba66090 100644 --- a/flutter_quill_extensions/lib/presentation/embeds/toolbar/image_button/image_button.dart +++ b/flutter_quill_extensions/lib/presentation/embeds/toolbar/image_button/image_button.dart @@ -27,6 +27,13 @@ class QuillToolbarImageButton extends StatelessWidget { return iconSize ?? baseFontSize; } + double _iconButtonFactor(BuildContext context) { + final baseIconFactor = + baseButtonExtraOptions(context).globalIconButtonFactor; + final iconButtonFactor = options.iconButtonFactor; + return iconButtonFactor ?? baseIconFactor; + } + VoidCallback? _afterButtonPressed(BuildContext context) { return options.afterButtonPressed ?? baseButtonExtraOptions(context).afterButtonPressed; @@ -62,6 +69,7 @@ class QuillToolbarImageButton extends StatelessWidget { Widget build(BuildContext context) { final tooltip = _tooltip(context); final iconSize = _iconSize(context); + final iconButtonFactor = _iconButtonFactor(context); final iconData = _iconData(context); final childBuilder = options.childBuilder ?? baseButtonExtraOptions(context).childBuilder; @@ -72,6 +80,7 @@ class QuillToolbarImageButton extends StatelessWidget { afterButtonPressed: _afterButtonPressed(context), iconData: iconData, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, dialogTheme: options.dialogTheme, fillColor: options.fillColor, iconTheme: options.iconTheme, diff --git a/flutter_quill_extensions/lib/presentation/embeds/toolbar/media_button/media_button.dart b/flutter_quill_extensions/lib/presentation/embeds/toolbar/media_button/media_button.dart index fdebb485..5246e838 100644 --- a/flutter_quill_extensions/lib/presentation/embeds/toolbar/media_button/media_button.dart +++ b/flutter_quill_extensions/lib/presentation/embeds/toolbar/media_button/media_button.dart @@ -102,6 +102,7 @@ // galleryButtonText: options.galleryButtonText, // iconTheme: iconTheme, // iconSize: iconSize, +// iconButtonFactor: iconButtonFactor, // hintText: options.hintText, // labelText: options.labelText, // submitButtonSize: options.submitButtonSize, diff --git a/flutter_quill_extensions/lib/presentation/embeds/toolbar/video_button/video_button.dart b/flutter_quill_extensions/lib/presentation/embeds/toolbar/video_button/video_button.dart index 76b5a4d0..32b660f4 100644 --- a/flutter_quill_extensions/lib/presentation/embeds/toolbar/video_button/video_button.dart +++ b/flutter_quill_extensions/lib/presentation/embeds/toolbar/video_button/video_button.dart @@ -82,6 +82,7 @@ class QuillToolbarVideoButton extends StatelessWidget { dialogTheme: options.dialogTheme, fillColor: iconFillColor, iconSize: options.iconSize, + iconButtonFactor: options.iconButtonFactor, linkRegExp: options.linkRegExp, tooltip: options.tooltip, iconTheme: options.iconTheme, diff --git a/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/camera.dart b/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/camera.dart index 3c4c21cb..dafdf1ab 100644 --- a/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/camera.dart +++ b/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/camera.dart @@ -17,6 +17,7 @@ class QuillToolbarCameraButtonOptions extends QuillToolbarBaseButtonOptions< const QuillToolbarCameraButtonOptions({ this.cameraConfigurations = const QuillToolbarCameraConfigurations(), this.iconSize, + this.iconButtonFactor, this.fillColor, super.iconData, super.afterButtonPressed, @@ -27,6 +28,7 @@ class QuillToolbarCameraButtonOptions extends QuillToolbarBaseButtonOptions< }); final double? iconSize; + final double? iconButtonFactor; final Color? fillColor; diff --git a/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/formula.dart b/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/formula.dart index 7d716251..638e794c 100644 --- a/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/formula.dart +++ b/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/formula.dart @@ -20,9 +20,11 @@ class QuillToolbarFormulaButtonOptions extends QuillToolbarBaseButtonOptions< super.childBuilder, this.fillColor, this.iconSize, + this.iconButtonFactor, }); final Color? fillColor; final double? iconSize; + final double? iconButtonFactor; } diff --git a/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/image.dart b/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/image.dart index b0084eeb..d1e5efbd 100644 --- a/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/image.dart +++ b/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/image.dart @@ -20,6 +20,7 @@ class QuillToolbarImageButtonOptions extends QuillToolbarBaseButtonOptions< super.iconData, super.controller, this.iconSize, + this.iconButtonFactor, /// specifies the tooltip text for the image button. super.tooltip, @@ -33,6 +34,7 @@ class QuillToolbarImageButtonOptions extends QuillToolbarBaseButtonOptions< }); final double? iconSize; + final double? iconButtonFactor; final Color? fillColor; final QuillDialogTheme? dialogTheme; diff --git a/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/video.dart b/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/video.dart index 17f80453..e7efba51 100644 --- a/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/video.dart +++ b/flutter_quill_extensions/lib/presentation/models/config/toolbar/buttons/video.dart @@ -19,6 +19,7 @@ class QuillToolbarVideoButtonOptions extends QuillToolbarBaseButtonOptions< this.dialogTheme, this.fillColor, this.iconSize, + this.iconButtonFactor, super.iconData, super.afterButtonPressed, super.tooltip, @@ -35,4 +36,5 @@ class QuillToolbarVideoButtonOptions extends QuillToolbarBaseButtonOptions< final Color? fillColor; final double? iconSize; + final double? iconButtonFactor; } diff --git a/flutter_quill_extensions/pubspec.yaml b/flutter_quill_extensions/pubspec.yaml index 04fce298..97cd2782 100644 --- a/flutter_quill_extensions/pubspec.yaml +++ b/flutter_quill_extensions/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: flutter: sdk: flutter - flutter_quill: ^8.2.5 + flutter_quill: ^8.3.0 http: ^1.1.0 photo_view: ^0.14.0 diff --git a/lib/src/models/config/toolbar/buttons/font_family.dart b/lib/src/models/config/toolbar/buttons/font_family.dart index 6b79685f..17d75c9c 100644 --- a/lib/src/models/config/toolbar/buttons/font_family.dart +++ b/lib/src/models/config/toolbar/buttons/font_family.dart @@ -55,6 +55,7 @@ class QuillToolbarFontFamilyButtonOptions extends QuillToolbarBaseButtonOptions< this.hoverElevation = 1, this.fillColor, this.iconSize, + this.iconButtonFactor, }); final Color? fillColor; @@ -82,6 +83,7 @@ class QuillToolbarFontFamilyButtonOptions extends QuillToolbarBaseButtonOptions< /// By default will use [globalIconSize] final double? iconSize; + final double? iconButtonFactor; QuillToolbarFontFamilyButtonOptions copyWith({ Color? fillColor, @@ -102,6 +104,7 @@ class QuillToolbarFontFamilyButtonOptions extends QuillToolbarBaseButtonOptions< EdgeInsets? itemPadding, Color? defaultItemColor, double? iconSize, + double? iconButtonFactor, // Add properties to override inherited properties QuillController? controller, IconData? iconData, @@ -130,6 +133,7 @@ class QuillToolbarFontFamilyButtonOptions extends QuillToolbarBaseButtonOptions< itemPadding: itemPadding ?? this.itemPadding, defaultItemColor: defaultItemColor ?? this.defaultItemColor, iconSize: iconSize ?? this.iconSize, + iconButtonFactor: iconButtonFactor ?? this.iconButtonFactor, fillColor: fillColor ?? this.fillColor, hoverElevation: hoverElevation ?? this.hoverElevation, highlightElevation: highlightElevation ?? this.highlightElevation, diff --git a/lib/src/models/config/toolbar/buttons/font_size.dart b/lib/src/models/config/toolbar/buttons/font_size.dart index e9d4d5e7..651ad350 100644 --- a/lib/src/models/config/toolbar/buttons/font_size.dart +++ b/lib/src/models/config/toolbar/buttons/font_size.dart @@ -30,6 +30,7 @@ class QuillToolbarFontSizeButtonOptions extends QuillToolbarBaseButtonOptions< QuillToolbarFontSizeButtonOptions, QuillToolbarFontSizeButtonExtraOptions> { const QuillToolbarFontSizeButtonOptions({ this.iconSize, + this.iconButtonFactor, this.fillColor, this.hoverElevation = 1, this.highlightElevation = 1, @@ -53,6 +54,7 @@ class QuillToolbarFontSizeButtonOptions extends QuillToolbarBaseButtonOptions< }); final double? iconSize; + final double? iconButtonFactor; final Color? fillColor; final double hoverElevation; final double highlightElevation; @@ -75,6 +77,7 @@ class QuillToolbarFontSizeButtonOptions extends QuillToolbarBaseButtonOptions< QuillToolbarFontSizeButtonOptions copyWith({ double? iconSize, + double? iconButtonFactor, Color? fillColor, double? hoverElevation, double? highlightElevation, @@ -97,6 +100,7 @@ class QuillToolbarFontSizeButtonOptions extends QuillToolbarBaseButtonOptions< }) { return QuillToolbarFontSizeButtonOptions( iconSize: iconSize ?? this.iconSize, + iconButtonFactor: iconButtonFactor ?? this.iconButtonFactor, fillColor: fillColor ?? this.fillColor, hoverElevation: hoverElevation ?? this.hoverElevation, highlightElevation: highlightElevation ?? this.highlightElevation, diff --git a/lib/src/widgets/toolbar/buttons/clear_format.dart b/lib/src/widgets/toolbar/buttons/clear_format.dart index 9e1b27c7..65f4d9dd 100644 --- a/lib/src/widgets/toolbar/buttons/clear_format.dart +++ b/lib/src/widgets/toolbar/buttons/clear_format.dart @@ -90,6 +90,7 @@ class QuillToolbarClearFormatButton extends StatelessWidget { controller: controller, iconData: iconData, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, iconTheme: iconTheme, tooltip: tooltip, ), diff --git a/lib/src/widgets/toolbar/buttons/font_size.dart b/lib/src/widgets/toolbar/buttons/font_size.dart index a6ddf7e8..e58340d0 100644 --- a/lib/src/widgets/toolbar/buttons/font_size.dart +++ b/lib/src/widgets/toolbar/buttons/font_size.dart @@ -110,6 +110,13 @@ class QuillToolbarFontSizeButtonState return iconSize ?? baseFontSize; } + double get iconButtonFactor { + final baseIconFactor = + context.requireQuillToolbarBaseButtonOptions.globalIconButtonFactor; + final iconButtonFactor = options.iconButtonFactor; + return iconButtonFactor ?? baseIconFactor; + } + VoidCallback? get afterButtonPressed { return options.afterButtonPressed ?? context.requireQuillToolbarBaseButtonOptions.afterButtonPressed; @@ -142,6 +149,7 @@ class QuillToolbarFontSizeButtonState options.copyWith( tooltip: tooltip, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, iconTheme: iconTheme, afterButtonPressed: afterButtonPressed, controller: controller, diff --git a/lib/src/widgets/toolbar/buttons/history.dart b/lib/src/widgets/toolbar/buttons/history.dart index e0c3f7cf..e12b3f1b 100644 --- a/lib/src/widgets/toolbar/buttons/history.dart +++ b/lib/src/widgets/toolbar/buttons/history.dart @@ -76,6 +76,7 @@ class QuillToolbarHistoryButtonState extends State { controller: controller, iconData: iconData, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, iconTheme: iconTheme, tooltip: tooltip, ), diff --git a/lib/src/widgets/toolbar/buttons/indent.dart b/lib/src/widgets/toolbar/buttons/indent.dart index 9f3de303..e28b4239 100644 --- a/lib/src/widgets/toolbar/buttons/indent.dart +++ b/lib/src/widgets/toolbar/buttons/indent.dart @@ -88,6 +88,7 @@ class QuillToolbarIndentButtonState extends State { afterButtonPressed: afterButtonPressed, iconData: iconData, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, iconTheme: iconTheme, tooltip: tooltip, ), diff --git a/lib/src/widgets/toolbar/buttons/link_style.dart b/lib/src/widgets/toolbar/buttons/link_style.dart index e96aabb8..db41dc53 100644 --- a/lib/src/widgets/toolbar/buttons/link_style.dart +++ b/lib/src/widgets/toolbar/buttons/link_style.dart @@ -120,6 +120,7 @@ class QuillToolbarLinkStyleButtonState dialogTheme: options.dialogTheme, iconData: iconData, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, tooltip: tooltip, linkDialogAction: options.linkDialogAction, linkRegExp: linkRegExp, diff --git a/lib/src/widgets/toolbar/buttons/link_style2.dart b/lib/src/widgets/toolbar/buttons/link_style2.dart index 0ddf8f2f..fd5e2422 100644 --- a/lib/src/widgets/toolbar/buttons/link_style2.dart +++ b/lib/src/widgets/toolbar/buttons/link_style2.dart @@ -125,6 +125,7 @@ class _QuillToolbarLinkStyleButton2State dialogBarrierColor: dialogBarrierColor, dialogTheme: options.dialogTheme, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, constraints: options.constraints, tooltip: tooltip, iconTheme: iconTheme, diff --git a/lib/src/widgets/toolbar/buttons/search/search.dart b/lib/src/widgets/toolbar/buttons/search/search.dart index 2bfaeb38..500e56f5 100644 --- a/lib/src/widgets/toolbar/buttons/search/search.dart +++ b/lib/src/widgets/toolbar/buttons/search/search.dart @@ -89,10 +89,11 @@ class QuillToolbarSearchButton extends StatelessWidget { dialogBarrierColor: _dialogBarrierColor(context), dialogTheme: _dialogTheme(context), fillColor: options.fillColor, - iconData: _iconData(context), - iconSize: _iconSize(context), - tooltip: _tooltip(context), - iconTheme: _iconTheme(context), + iconData: iconData, + iconSize: iconSize, + iconButtonFactor: iconButtonFactor, + tooltip: tooltip, + iconTheme: iconTheme, ), QuillToolbarSearchButtonExtraOptions( controller: controller, diff --git a/lib/src/widgets/toolbar/buttons/select_alignment.dart b/lib/src/widgets/toolbar/buttons/select_alignment.dart index 6104f9a1..3418aeb4 100644 --- a/lib/src/widgets/toolbar/buttons/select_alignment.dart +++ b/lib/src/widgets/toolbar/buttons/select_alignment.dart @@ -214,6 +214,7 @@ class QuillToolbarSelectAlignmentButtonState QuillToolbarSelectAlignmentButtonOptions( afterButtonPressed: _afterButtonPressed, iconSize: _iconSize, + iconButtonFactor: _iconButtonFactor, iconTheme: _iconTheme, tooltips: _tooltips, iconsData: _iconsData, diff --git a/lib/src/widgets/toolbar/buttons/select_header_style.dart b/lib/src/widgets/toolbar/buttons/select_header_style.dart index 3795d1dd..865a619d 100644 --- a/lib/src/widgets/toolbar/buttons/select_header_style.dart +++ b/lib/src/widgets/toolbar/buttons/select_header_style.dart @@ -132,6 +132,7 @@ class QuillToolbarSelectHeaderStyleButtonsState attributes: _attrbuites, axis: axis, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, iconTheme: iconTheme, tooltip: tooltip, ), diff --git a/lib/src/widgets/toolbar/buttons/toggle_check_list.dart b/lib/src/widgets/toolbar/buttons/toggle_check_list.dart index 18a65aea..b1555877 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_check_list.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_check_list.dart @@ -135,6 +135,7 @@ class QuillToolbarToggleCheckListButtonState iconTheme: iconTheme, controller: controller, iconSize: iconSize, + iconButtonFactor: iconButtonFactor, tooltip: tooltip, iconData: iconData, ),