From b07448420fb2645fad4e34a5bda8e2060f0ba575 Mon Sep 17 00:00:00 2001 From: Ellet Date: Tue, 5 Dec 2023 10:18:57 +0300 Subject: [PATCH] 3 --- .../formula/toolbar/formula_button.dart | 8 +--- .../embeds/image/toolbar/image_button.dart | 7 +--- .../others/camera_button/camera_button.dart | 7 +--- .../embeds/video/toolbar/video_button.dart | 5 +-- .../widgets/toolbar/buttons/clear_format.dart | 6 +-- .../widgets/toolbar/buttons/color/color.dart | 6 +-- .../toolbar/buttons/custom_button.dart | 6 +-- lib/src/widgets/toolbar/buttons/history.dart | 7 +--- lib/src/widgets/toolbar/buttons/indent.dart | 7 +--- .../widgets/toolbar/buttons/link_style.dart | 7 +--- .../widgets/toolbar/buttons/link_style2.dart | 7 +--- .../widgets/toolbar/buttons/quill_icon.dart | 42 +++++-------------- .../toolbar/buttons/search/search.dart | 7 +--- .../widgets/toolbar/buttons/toggle_style.dart | 13 +----- test/bug_fix_test.dart | 10 ++--- 15 files changed, 30 insertions(+), 115 deletions(-) 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 935389f6b..8b642ed11 100644 --- a/flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart +++ b/flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart @@ -71,14 +71,11 @@ class QuillToolbarFormulaButton extends StatelessWidget { options.childBuilder ?? baseButtonExtraOptions(context).childBuilder; final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - final iconFillColor = iconTheme?.iconUnselectedFillColor ?? - (options.fillColor ?? theme.canvasColor); if (childBuilder != null) { return childBuilder( QuillToolbarFormulaButtonOptions( afterButtonPressed: _afterButtonPressed(context), - fillColor: iconFillColor, iconData: iconData, iconSize: iconSize, iconButtonFactor: iconButtonFactor, @@ -96,12 +93,9 @@ class QuillToolbarFormulaButton extends StatelessWidget { return QuillToolbarIconButton( icon: Icon(iconData, size: iconSize, color: iconColor), tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * 1.77, - fillColor: iconFillColor, - borderRadius: iconTheme?.borderRadius ?? 2, onPressed: () => _sharedOnPressed(context), + isFilled: false, ); } 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 06dcf805a..9f9bcc1a2 100644 --- a/flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart +++ b/flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart @@ -101,8 +101,6 @@ class QuillToolbarImageButton extends StatelessWidget { final iconTheme = _iconTheme(context); final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - final iconFillColor = iconTheme?.iconUnselectedFillColor ?? - (options.fillColor ?? theme.canvasColor); return QuillToolbarIconButton( icon: Icon( @@ -111,11 +109,8 @@ class QuillToolbarImageButton extends StatelessWidget { color: iconColor, ), tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * 1.77, - fillColor: iconFillColor, - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: false, onPressed: () => _sharedOnPressed(context), ); } 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 c62976cb4..f96f59af1 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 @@ -96,17 +96,12 @@ class QuillToolbarCameraButton extends StatelessWidget { final theme = Theme.of(context); final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - final iconFillColor = iconTheme?.iconUnselectedFillColor ?? - (options.fillColor ?? theme.canvasColor); return QuillToolbarIconButton( icon: Icon(iconData, size: iconSize, color: iconColor), tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * 1.77, - fillColor: iconFillColor, - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: false, // isDesktop(supportWeb: false) ? null : onPressed: () => _sharedOnPressed(context), ); 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 780112396..56e047696 100644 --- a/flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart +++ b/flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart @@ -100,11 +100,8 @@ class QuillToolbarVideoButton extends StatelessWidget { return QuillToolbarIconButton( icon: Icon(iconData, size: iconSize, color: iconColor), tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * 1.77, - fillColor: iconFillColor, - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: false, onPressed: () => _sharedOnPressed(context), ); } diff --git a/lib/src/widgets/toolbar/buttons/clear_format.dart b/lib/src/widgets/toolbar/buttons/clear_format.dart index e5f4afc7a..e25afa3d1 100644 --- a/lib/src/widgets/toolbar/buttons/clear_format.dart +++ b/lib/src/widgets/toolbar/buttons/clear_format.dart @@ -108,16 +108,12 @@ class QuillToolbarClearFormatButton extends StatelessWidget { final theme = Theme.of(context); final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - final fillColor = iconTheme?.iconUnselectedFillColor ?? theme.canvasColor; return QuillToolbarIconButton( tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * iconButtonFactor, icon: Icon(iconData, size: iconSize, color: iconColor), - fillColor: fillColor, - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: false, onPressed: _sharedOnPressed, afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/color/color.dart b/lib/src/widgets/toolbar/buttons/color/color.dart index 1691d71cd..9f939f1d6 100644 --- a/lib/src/widgets/toolbar/buttons/color/color.dart +++ b/lib/src/widgets/toolbar/buttons/color/color.dart @@ -195,14 +195,12 @@ class QuillToolbarColorButtonState extends State { return QuillToolbarIconButton( tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * iconButtonFactor, icon: Icon(iconData, size: iconSize, color: widget.isBackground ? iconColorBackground : iconColor), - fillColor: widget.isBackground ? fillColorBackground : fillColor, - borderRadius: iconTheme?.borderRadius ?? 2, + // fillColor: widget.isBackground ? fillColorBackground : fillColor, + isFilled: false, onPressed: _showColorPicker, afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/custom_button.dart b/lib/src/widgets/toolbar/buttons/custom_button.dart index f306a440b..bbf6ad575 100644 --- a/lib/src/widgets/toolbar/buttons/custom_button.dart +++ b/lib/src/widgets/toolbar/buttons/custom_button.dart @@ -80,15 +80,13 @@ class QuillToolbarCustomButton extends StatelessWidget { ); } - final theme = Theme.of(context); return QuillToolbarIconButton( size: iconSize * iconButtonFactor, - icon: options.icon, + icon: options.icon ?? const SizedBox.shrink(), + isFilled: false, tooltip: tooltip, - borderRadius: iconTheme?.borderRadius ?? 2, onPressed: () => _onPressed(context), afterPressed: afterButtonPressed, - fillColor: iconTheme?.iconUnselectedFillColor ?? theme.canvasColor, ); } } diff --git a/lib/src/widgets/toolbar/buttons/history.dart b/lib/src/widgets/toolbar/buttons/history.dart index bbf7c54f8..3a4cf3c1b 100644 --- a/lib/src/widgets/toolbar/buttons/history.dart +++ b/lib/src/widgets/toolbar/buttons/history.dart @@ -93,12 +93,8 @@ class QuillToolbarHistoryButtonState extends State { } theme = Theme.of(context); - - final fillColor = iconTheme?.iconUnselectedFillColor ?? theme.canvasColor; return QuillToolbarIconButton( tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * iconButtonFactor, icon: Icon( iconData, @@ -107,8 +103,7 @@ class QuillToolbarHistoryButtonState extends State { ? iconTheme?.iconUnselectedColor ?? theme.iconTheme.color : iconTheme?.disabledIconColor ?? theme.disabledColor, ), - fillColor: fillColor, - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: false, onPressed: _updateHistory, afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/indent.dart b/lib/src/widgets/toolbar/buttons/indent.dart index 22c3eb29a..793dd0faa 100644 --- a/lib/src/widgets/toolbar/buttons/indent.dart +++ b/lib/src/widgets/toolbar/buttons/indent.dart @@ -107,16 +107,11 @@ class QuillToolbarIndentButtonState extends State { final theme = Theme.of(context); final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - final iconFillColor = - iconTheme?.iconUnselectedFillColor ?? theme.canvasColor; return QuillToolbarIconButton( tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * iconButtonFactor, icon: Icon(iconData, size: iconSize, color: iconColor), - fillColor: iconFillColor, - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: false, onPressed: _sharedOnPressed, afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/link_style.dart b/lib/src/widgets/toolbar/buttons/link_style.dart index 2bc54fead..b4aacadc9 100644 --- a/lib/src/widgets/toolbar/buttons/link_style.dart +++ b/lib/src/widgets/toolbar/buttons/link_style.dart @@ -141,8 +141,6 @@ class QuillToolbarLinkStyleButtonState final theme = Theme.of(context); return QuillToolbarIconButton( tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * iconButtonFactor, icon: Icon( iconData, @@ -151,10 +149,7 @@ class QuillToolbarLinkStyleButtonState ? (iconTheme?.iconSelectedColor ?? theme.primaryIconTheme.color) : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color), ), - fillColor: isToggled - ? (iconTheme?.iconSelectedFillColor ?? theme.primaryColor) - : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor), - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: isToggled, onPressed: () => _openLinkDialog(context), afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/link_style2.dart b/lib/src/widgets/toolbar/buttons/link_style2.dart index df834f23b..86e25103a 100644 --- a/lib/src/widgets/toolbar/buttons/link_style2.dart +++ b/lib/src/widgets/toolbar/buttons/link_style2.dart @@ -148,8 +148,6 @@ class _QuillToolbarLinkStyleButton2State final isToggled = _getLinkAttributeValue() != null; return QuillToolbarIconButton( tooltip: tooltip, - highlightElevation: 0, - hoverElevation: 0, size: iconSize * iconButtonFactor, icon: Icon( iconData, @@ -158,10 +156,7 @@ class _QuillToolbarLinkStyleButton2State ? (iconTheme?.iconSelectedColor ?? theme.primaryIconTheme.color) : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color), ), - fillColor: isToggled - ? (iconTheme?.iconSelectedFillColor ?? theme.primaryColor) - : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor), - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: isToggled, onPressed: _openLinkDialog, afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/quill_icon.dart b/lib/src/widgets/toolbar/buttons/quill_icon.dart index d78494d0f..3370792e5 100644 --- a/lib/src/widgets/toolbar/buttons/quill_icon.dart +++ b/lib/src/widgets/toolbar/buttons/quill_icon.dart @@ -1,54 +1,32 @@ import 'package:flutter/material.dart'; -import '../../../utils/widgets.dart'; - class QuillToolbarIconButton extends StatelessWidget { const QuillToolbarIconButton({ required this.onPressed, + required this.icon, + required this.isFilled, this.afterPressed, - this.icon, this.size = 40, - this.fillColor, - this.hoverElevation = 1, - this.highlightElevation = 1, - this.borderRadius = 2, this.tooltip, super.key, }); final VoidCallback? onPressed; final VoidCallback? afterPressed; - final Widget? icon; + final Widget icon; final double size; - final Color? fillColor; - final double hoverElevation; - final double highlightElevation; - final double borderRadius; final String? tooltip; + final bool isFilled; @override Widget build(BuildContext context) { - return ConstrainedBox( - constraints: BoxConstraints.tightFor(width: size, height: size), - child: UtilityWidgets.maybeTooltip( - message: tooltip, - child: RawMaterialButton( - visualDensity: VisualDensity.compact, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(borderRadius), - ), - fillColor: fillColor, - elevation: 0, - hoverElevation: hoverElevation, - highlightElevation: hoverElevation, - onPressed: () { - onPressed?.call(); - afterPressed?.call(); - }, - child: icon, - ), - ), + if (isFilled) { + return IconButton.filled(onPressed: onPressed, icon: icon); + } + return IconButton( + onPressed: onPressed, + icon: icon, ); } } diff --git a/lib/src/widgets/toolbar/buttons/search/search.dart b/lib/src/widgets/toolbar/buttons/search/search.dart index 91cb622bc..8b568977d 100644 --- a/lib/src/widgets/toolbar/buttons/search/search.dart +++ b/lib/src/widgets/toolbar/buttons/search/search.dart @@ -111,8 +111,6 @@ class QuillToolbarSearchButton extends StatelessWidget { final theme = Theme.of(context); final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - final iconFillColor = iconTheme?.iconUnselectedFillColor ?? - (options.fillColor ?? theme.canvasColor); return QuillToolbarIconButton( tooltip: tooltip, @@ -121,11 +119,8 @@ class QuillToolbarSearchButton extends StatelessWidget { size: iconSize, color: iconColor, ), - highlightElevation: 0, - hoverElevation: 0, size: iconSize * iconButtonFactor, - fillColor: iconFillColor, - borderRadius: iconTheme?.borderRadius ?? 2, + isFilled: false, onPressed: () => _sharedOnPressed(context), afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/toggle_style.dart b/lib/src/widgets/toolbar/buttons/toggle_style.dart index dabf225e0..e2928ef37 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_style.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_style.dart @@ -241,22 +241,11 @@ Widget defaultToggleStyleButtonBuilder( .primaryIconTheme.color) //You can specify your own icon color : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color) : (iconTheme?.disabledIconColor ?? theme.disabledColor); - final fill = isEnabled - ? isToggled == true - ? (iconTheme?.iconSelectedFillColor ?? - Theme.of(context).primaryColor) //Selected icon fill color - : (iconTheme?.iconUnselectedFillColor ?? - theme.canvasColor) //Unselected icon fill color : - : (iconTheme?.disabledIconFillColor ?? - (fillColor ?? theme.canvasColor)); //Disabled icon fill color return QuillToolbarIconButton( - highlightElevation: 0, - hoverElevation: 0, size: iconSize * iconButtonFactor, icon: Icon(icon, size: iconSize, color: iconColor), - fillColor: fill, + isFilled: isEnabled ? isToggled == true : false, onPressed: onPressed, afterPressed: afterPressed, - borderRadius: iconTheme?.borderRadius ?? 2, ); } diff --git a/test/bug_fix_test.dart b/test/bug_fix_test.dart index f6c2c4edc..2b804bae9 100644 --- a/test/bug_fix_test.dart +++ b/test/bug_fix_test.dart @@ -36,8 +36,8 @@ void main() { matchRoot: true, ); expect(builtinFinder, findsOneWidget); - final builtinButton = - builtinFinder.evaluate().first.widget as QuillToolbarIconButton; + // final builtinButton = + // builtinFinder.evaluate().first.widget as QuillToolbarIconButton; final customFinder = find.descendant( of: find.byType(QuillBaseToolbar), @@ -45,10 +45,10 @@ void main() { widget is QuillToolbarIconButton && widget.tooltip == tooltip), matchRoot: true); expect(customFinder, findsOneWidget); - final customButton = - customFinder.evaluate().first.widget as QuillToolbarIconButton; + // final customButton = + // customFinder.evaluate().first.widget as QuillToolbarIconButton; - expect(customButton.fillColor, equals(builtinButton.fillColor)); + // expect(customButton.fillColor, equals(builtinButton.fillColor)); }); });