From 8dc1ff79d5d168452d7f14ffbcc201538dcf88c3 Mon Sep 17 00:00:00 2001 From: Ellet Date: Wed, 20 Dec 2023 13:05:55 +0300 Subject: [PATCH] Fix the QuillIconTheme by replacing all the properties with two properties of type ButtonStyle, use IconButton.styleFrom() --- CHANGELOG.md | 3 ++ .../presentation/quill/my_quill_toolbar.dart | 11 +++-- .../formula/toolbar/formula_button.dart | 11 ++--- .../embeds/image/toolbar/image_button.dart | 9 +--- .../others/camera_button/camera_button.dart | 11 ++--- .../embeds/video/toolbar/video_button.dart | 21 ++++---- lib/src/models/themes/quill_icon_theme.dart | 34 +++---------- .../toolbar/buttons/clear_format_button.dart | 13 ++--- .../toolbar/buttons/color/color_button.dart | 41 ++++++++-------- .../toolbar/buttons/custom_button_button.dart | 2 +- .../toolbar/buttons/font_family_button.dart | 16 ++---- .../toolbar/buttons/font_size_button.dart | 15 ++---- .../select_header_style_buttons.dart | 49 ++++++++----------- .../toolbar/buttons/history_button.dart | 9 ++-- .../toolbar/buttons/indent_button.dart | 13 +++-- .../toolbar/buttons/link_style2_button.dart | 9 ++-- .../toolbar/buttons/link_style_button.dart | 9 ++-- .../toolbar/buttons/quill_icon_button.dart | 18 +++---- .../toolbar/buttons/search/search_button.dart | 9 ++-- .../toolbar/buttons/toggle_style_button.dart | 17 +++---- 20 files changed, 140 insertions(+), 180 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d9b43bd..7fc00e67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## 9.1.0-dev +* **Breaking Change**: in the `QuillSimpleToolbar` Fix the `QuillIconTheme` by replacing all the properties with two properties of type `ButtonStyle`, use `IconButton.styleFrom()` + ## 9.0.6 * Fix bug in QuillToolbarSelectAlignmentButtons diff --git a/example/lib/presentation/quill/my_quill_toolbar.dart b/example/lib/presentation/quill/my_quill_toolbar.dart index 4a07cee0..a88a41a4 100644 --- a/example/lib/presentation/quill/my_quill_toolbar.dart +++ b/example/lib/presentation/quill/my_quill_toolbar.dart @@ -206,15 +206,20 @@ class MyQuillToolbar extends StatelessWidget { // Request editor focus when any button is pressed afterButtonPressed: focusNode.requestFocus, // globalIconSize: 18, + iconTheme: QuillIconTheme( + iconButtonUnselectedStyle: IconButton.styleFrom( + backgroundColor: Colors.green, + ), + iconButtonSelectedStyle: IconButton.styleFrom( + backgroundColor: Colors.red, + ), + ), ), selectHeaderStyleDropdownButton: const QuillToolbarSelectHeaderStyleDropdownButtonOptions( textStyle: TextStyle( fontSize: 20, ), - iconTheme: QuillIconTheme( - iconSelectedColor: Colors.red, - ), ), ), customButtons: [ 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 513a8b29..757df66e 100644 --- a/flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart +++ b/flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart @@ -59,8 +59,6 @@ class QuillToolbarFormulaButton extends StatelessWidget { @override Widget build(BuildContext context) { - final theme = Theme.of(context); - final iconTheme = _iconTheme(context); final tooltip = _tooltip(context); @@ -70,8 +68,6 @@ class QuillToolbarFormulaButton extends StatelessWidget { final childBuilder = options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder; - final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - if (childBuilder != null) { return childBuilder( QuillToolbarFormulaButtonOptions( @@ -91,10 +87,13 @@ class QuillToolbarFormulaButton extends StatelessWidget { } return QuillToolbarIconButton( - icon: Icon(iconData, size: iconSize * iconButtonFactor, color: iconColor), + icon: Icon( + iconData, + size: iconSize * iconButtonFactor, + ), tooltip: tooltip, onPressed: () => _sharedOnPressed(context), - isFilled: false, + isSelected: 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 2d756d72..4d52da63 100644 --- a/flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart +++ b/flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart @@ -96,20 +96,13 @@ class QuillToolbarImageButton extends StatelessWidget { ); } - final theme = Theme.of(context); - - final iconTheme = _iconTheme(context); - - final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - return QuillToolbarIconButton( icon: Icon( iconData, size: iconButtonFactor * iconSize, - color: iconColor, ), tooltip: tooltip, - isFilled: false, + isSelected: 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 2aee06fa..48c6737d 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 @@ -103,14 +103,13 @@ class QuillToolbarCameraButton extends StatelessWidget { ); } - final theme = Theme.of(context); - - final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - return QuillToolbarIconButton( - icon: Icon(iconData, size: iconButtonFactor * iconSize, color: iconColor), + icon: Icon( + iconData, + size: iconButtonFactor * iconSize, + ), tooltip: tooltip, - isFilled: false, + isSelected: 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 5bc7d06f..0d272c4b 100644 --- a/flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart +++ b/flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart @@ -68,10 +68,6 @@ class QuillToolbarVideoButton extends StatelessWidget { @override Widget build(BuildContext context) { - final theme = Theme.of(context); - - final iconTheme = _iconTheme(context); - final tooltip = _tooltip(context); final iconSize = _iconSize(context); final iconButtonFactor = _iconButtonFactor(context); @@ -79,9 +75,10 @@ class QuillToolbarVideoButton extends StatelessWidget { final childBuilder = options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder; - final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - final iconFillColor = iconTheme?.iconUnselectedFillColor ?? - (options.fillColor ?? theme.canvasColor); + // final iconColor = + // iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color; + // final iconFillColor = iconTheme?.iconUnselectedFillColor ?? + // (options.fillColor ?? theme.canvasColor); if (childBuilder != null) { return childBuilder( @@ -89,7 +86,7 @@ class QuillToolbarVideoButton extends StatelessWidget { afterButtonPressed: _afterButtonPressed(context), iconData: iconData, dialogTheme: options.dialogTheme, - fillColor: iconFillColor, + // fillColor: iconFillColor, iconSize: options.iconSize, iconButtonFactor: iconButtonFactor, linkRegExp: options.linkRegExp, @@ -106,9 +103,13 @@ class QuillToolbarVideoButton extends StatelessWidget { } return QuillToolbarIconButton( - icon: Icon(iconData, size: iconSize * iconButtonFactor, color: iconColor), + icon: Icon( + iconData, + size: iconSize * iconButtonFactor, + // color: iconColor, + ), tooltip: tooltip, - isFilled: false, + isSelected: false, onPressed: () => _sharedOnPressed(context), ); } diff --git a/lib/src/models/themes/quill_icon_theme.dart b/lib/src/models/themes/quill_icon_theme.dart index 8901e462..bcbc2b6e 100644 --- a/lib/src/models/themes/quill_icon_theme.dart +++ b/lib/src/models/themes/quill_icon_theme.dart @@ -3,36 +3,18 @@ import 'package:flutter/material.dart'; @immutable class QuillIconTheme { const QuillIconTheme({ - this.iconSelectedColor, - this.iconUnselectedColor, - this.iconSelectedFillColor, - this.iconUnselectedFillColor, - this.disabledIconColor, - this.disabledIconFillColor, - this.borderRadius, this.padding, + this.iconButtonSelectedStyle, + this.iconButtonUnselectedStyle, + // this.iconSelectedFillColor, + // this.iconUnselectedFillColor, }); - ///The color to use for selected icons in the toolbar - final Color? iconSelectedColor; + final ButtonStyle? iconButtonUnselectedStyle; + final ButtonStyle? iconButtonSelectedStyle; - ///The color to use for unselected icons in the toolbar - final Color? iconUnselectedColor; - - ///The fill color to use for the selected icons in the toolbar - final Color? iconSelectedFillColor; - - ///The fill color to use for the unselected icons in the toolbar - final Color? iconUnselectedFillColor; - - ///The color to use for disabled icons in the toolbar - final Color? disabledIconColor; - - ///The fill color to use for disabled icons in the toolbar - final Color? disabledIconFillColor; - - ///The borderRadius for icons - final double? borderRadius; + // final Color? iconSelectedFillColor; + // final Color? iconUnselectedFillColor; ///The padding for icons final EdgeInsets? padding; diff --git a/lib/src/widgets/toolbar/buttons/clear_format_button.dart b/lib/src/widgets/toolbar/buttons/clear_format_button.dart index 1e8d2b72..e718cd8e 100644 --- a/lib/src/widgets/toolbar/buttons/clear_format_button.dart +++ b/lib/src/widgets/toolbar/buttons/clear_format_button.dart @@ -104,16 +104,17 @@ class QuillToolbarClearFormatButton extends StatelessWidget { ); } - final theme = Theme.of(context); - - final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; - return QuillToolbarIconButton( tooltip: tooltip, - icon: Icon(iconData, size: iconSize * iconButtonFactor, color: iconColor), - isFilled: false, + icon: Icon( + iconData, + size: iconSize * iconButtonFactor, + // color: iconColor, + ), + isSelected: false, onPressed: _sharedOnPressed, afterPressed: afterButtonPressed, + iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle, ); } } diff --git a/lib/src/widgets/toolbar/buttons/color/color_button.dart b/lib/src/widgets/toolbar/buttons/color/color_button.dart index 2b20c5d3..23ebdc97 100644 --- a/lib/src/widgets/toolbar/buttons/color/color_button.dart +++ b/lib/src/widgets/toolbar/buttons/color/color_button.dart @@ -145,23 +145,22 @@ class QuillToolbarColorButtonState extends State { @override Widget build(BuildContext context) { - final theme = Theme.of(context); - final iconColor = _isToggledColor && !widget.isBackground && !_isWhite - ? stringToColor(_selectionStyle.attributes['color']!.value) - : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color); - - final iconColorBackground = - _isToggledBackground && widget.isBackground && !_isWhiteBackground - ? stringToColor(_selectionStyle.attributes['background']!.value) - : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color); - - final fillColor = _isToggledColor && !widget.isBackground && _isWhite - ? stringToColor('#ffffff') - : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor); - final fillColorBackground = - _isToggledBackground && widget.isBackground && _isWhiteBackground - ? stringToColor('#ffffff') - : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor); + // final iconColor = _isToggledColor && !widget.isBackground && !_isWhite + // ? stringToColor(_selectionStyle.attributes['color']!.value) + // : (iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color); + + // final iconColorBackground = + // _isToggledBackground && widget.isBackground && !_isWhiteBackground + // ? stringToColor(_selectionStyle.attributes['background']!.value) + // : (iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color); + + // final fillColor = _isToggledColor && !widget.isBackground && _isWhite + // ? stringToColor('#ffffff') + // : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor); + // final fillColorBackground = + // _isToggledBackground && widget.isBackground && _isWhiteBackground + // ? stringToColor('#ffffff') + // : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor); final childBuilder = options.childBuilder ?? baseButtonExtraOptions?.childBuilder; @@ -187,9 +186,9 @@ class QuillToolbarColorButtonState extends State { afterButtonPressed?.call(); }, iconColor: null, - iconColorBackground: iconColorBackground, - fillColor: fillColor, - fillColorBackground: fillColorBackground, + iconColorBackground: Colors.red, + fillColor: Colors.red, + fillColorBackground: Colors.red, ), ); } @@ -199,7 +198,7 @@ class QuillToolbarColorButtonState extends State { iconSize: iconSize * iconButtonFactor, icon: Icon( iconData, - color: widget.isBackground ? iconColorBackground : iconColor, + // color: widget.isBackground ? iconColorBackground : iconColor, ), onPressed: _showColorPicker, ); diff --git a/lib/src/widgets/toolbar/buttons/custom_button_button.dart b/lib/src/widgets/toolbar/buttons/custom_button_button.dart index 60209d01..3f83bf10 100644 --- a/lib/src/widgets/toolbar/buttons/custom_button_button.dart +++ b/lib/src/widgets/toolbar/buttons/custom_button_button.dart @@ -81,7 +81,7 @@ class QuillToolbarCustomButton extends StatelessWidget { return QuillToolbarIconButton( icon: options.icon ?? const SizedBox.shrink(), - isFilled: false, + isSelected: false, tooltip: tooltip, onPressed: () => _onPressed(context), afterPressed: afterButtonPressed, diff --git a/lib/src/widgets/toolbar/buttons/font_family_button.dart b/lib/src/widgets/toolbar/buttons/font_family_button.dart index 7153034d..a400c67a 100644 --- a/lib/src/widgets/toolbar/buttons/font_family_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_family_button.dart @@ -193,14 +193,7 @@ class QuillToolbarFontFamilyButtonState return IconButton( // tooltip: , // TODO: Use this here visualDensity: VisualDensity.compact, - style: IconButton.styleFrom( - shape: iconTheme?.borderRadius != null - ? RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - iconTheme?.borderRadius ?? -1), - ) - : null, - ), + style: iconTheme?.iconButtonUnselectedStyle, onPressed: _onPressed, icon: _buildContent(context), ); @@ -281,7 +274,6 @@ class QuillToolbarFontFamilyButtonState } Widget _buildContent(BuildContext context) { - final theme = Theme.of(context); final hasFinalWidth = options.width != null; return Padding( padding: options.padding ?? const EdgeInsets.fromLTRB(10, 0, 0, 0), @@ -299,8 +291,8 @@ class QuillToolbarFontFamilyButtonState style: options.style ?? TextStyle( fontSize: iconSize / 1.15, - color: - iconTheme?.iconUnselectedColor ?? theme.iconTheme.color, + // color: iconTheme?.iconUnselectedFillColor ?? + // theme.iconTheme.color, ), ), ), @@ -308,7 +300,7 @@ class QuillToolbarFontFamilyButtonState Icon( Icons.arrow_drop_down, size: iconSize / 1.15, - color: iconTheme?.iconUnselectedColor ?? theme.iconTheme.color, + // color: iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color, ) ], ), diff --git a/lib/src/widgets/toolbar/buttons/font_size_button.dart b/lib/src/widgets/toolbar/buttons/font_size_button.dart index 93062e84..5971ea4c 100644 --- a/lib/src/widgets/toolbar/buttons/font_size_button.dart +++ b/lib/src/widgets/toolbar/buttons/font_size_button.dart @@ -153,14 +153,7 @@ class QuillToolbarFontSizeButtonState return IconButton( tooltip: tooltip, visualDensity: VisualDensity.compact, - style: IconButton.styleFrom( - shape: iconTheme?.borderRadius != null - ? RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(iconTheme?.borderRadius ?? -1), - ) - : null, - ), + style: iconTheme?.iconButtonUnselectedStyle, onPressed: _onPressed, icon: _buildContent(context), ); @@ -251,8 +244,8 @@ class QuillToolbarFontSizeButtonState style: options.style ?? TextStyle( fontSize: iconSize / 1.15, - color: - iconTheme?.iconUnselectedColor ?? theme.iconTheme.color, + // color: iconTheme?.iconUnselectedFillColor ?? + // theme.iconTheme.color, ), ), ), @@ -260,7 +253,7 @@ class QuillToolbarFontSizeButtonState Icon( Icons.arrow_drop_down, size: iconSize / 1.15, - color: iconTheme?.iconUnselectedColor ?? theme.iconTheme.color, + // color: iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color, ) ], ), 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 8e069936..5268ddee 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 @@ -1,7 +1,6 @@ import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/material.dart'; -import '../../../../../extensions.dart'; import '../../../../extensions/quill_configurations_ext.dart'; import '../../../../l10n/extensions/localizations.dart'; import '../../../../models/documents/attribute.dart'; @@ -147,7 +146,7 @@ class QuillToolbarSelectHeaderStyleButtonsState ), ); } - final theme = Theme.of(context); + // final theme = Theme.of(context); final isSelected = _selectedAttribute == attribute; return Padding( padding: const EdgeInsets.symmetric(horizontal: !kIsWeb ? 1.0 : 5.0), @@ -156,33 +155,25 @@ class QuillToolbarSelectHeaderStyleButtonsState width: iconSize * iconButtonFactor, height: iconSize * iconButtonFactor, ), - child: UtilityWidgets.maybeTooltip( - message: tooltip, - child: RawMaterialButton( - hoverElevation: 0, - highlightElevation: 0, - elevation: 0, - visualDensity: VisualDensity.compact, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(iconTheme?.borderRadius ?? 2)), - fillColor: isSelected - ? (iconTheme?.iconSelectedFillColor ?? theme.primaryColor) - : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor), - onPressed: () => _sharedOnPressed(attribute), - child: Text( - _valueToText[attribute] ?? - (throw ArgumentError.notNull( - 'attrbuite', - )), - style: style.copyWith( - color: isSelected - ? (iconTheme?.iconSelectedColor ?? - theme.primaryIconTheme.color) - : (iconTheme?.iconUnselectedColor ?? - theme.iconTheme.color), - ), - ), + child: IconButton( + tooltip: tooltip, + visualDensity: VisualDensity.compact, + style: isSelected + ? iconTheme?.iconButtonSelectedStyle + : iconTheme?.iconButtonUnselectedStyle, + onPressed: () => _sharedOnPressed(attribute), + icon: Text( + _valueToText[attribute] ?? + (throw ArgumentError.notNull( + 'attrbuite', + )), + style: style.copyWith( + // color: isSelected + // ? (iconTheme?.iconSelectedFillColor ?? + // theme.primaryIconTheme.color) + // : (iconTheme?.iconUnselectedFillColor ?? + // theme.iconTheme.color), + ), ), ), ), diff --git a/lib/src/widgets/toolbar/buttons/history_button.dart b/lib/src/widgets/toolbar/buttons/history_button.dart index 1abc0ab8..6c490a49 100644 --- a/lib/src/widgets/toolbar/buttons/history_button.dart +++ b/lib/src/widgets/toolbar/buttons/history_button.dart @@ -102,11 +102,12 @@ class QuillToolbarHistoryButtonState extends State { icon: Icon( iconData, size: iconSize * iconButtonFactor, - color: _canPressed - ? iconTheme?.iconUnselectedColor ?? theme.iconTheme.color - : iconTheme?.disabledIconColor ?? theme.disabledColor, + // TODO: HEeeerre + // color: _canPressed + // ? iconTheme?.iconUnselectedColor ?? theme.iconTheme.color + // : iconTheme?.disabledIconColor ?? theme.disabledColor, ), - isFilled: false, + isSelected: false, onPressed: _updateHistory, afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/indent_button.dart b/lib/src/widgets/toolbar/buttons/indent_button.dart index 876f74c1..6778f790 100644 --- a/lib/src/widgets/toolbar/buttons/indent_button.dart +++ b/lib/src/widgets/toolbar/buttons/indent_button.dart @@ -104,15 +104,20 @@ class QuillToolbarIndentButtonState extends State { ), ); } - final theme = Theme.of(context); - final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; + // final iconColor = iconTheme?.iconUnselectedFillColor; return QuillToolbarIconButton( tooltip: tooltip, - icon: Icon(iconData, size: iconSize * iconButtonFactor, color: iconColor), - isFilled: false, + icon: Icon( + iconData, + size: iconSize * iconButtonFactor, + // color: iconColor, + ), + isSelected: false, onPressed: _sharedOnPressed, afterPressed: afterButtonPressed, + iconSelectedStyle: iconTheme?.iconButtonSelectedStyle, + iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle, ); } } diff --git a/lib/src/widgets/toolbar/buttons/link_style2_button.dart b/lib/src/widgets/toolbar/buttons/link_style2_button.dart index f1912a05..0c24d4ec 100644 --- a/lib/src/widgets/toolbar/buttons/link_style2_button.dart +++ b/lib/src/widgets/toolbar/buttons/link_style2_button.dart @@ -144,18 +144,17 @@ class _QuillToolbarLinkStyleButton2State ), ); } - final theme = Theme.of(context); final isToggled = _getLinkAttributeValue() != null; return QuillToolbarIconButton( tooltip: tooltip, icon: Icon( iconData, size: iconSize * iconButtonFactor, - color: isToggled - ? (iconTheme?.iconSelectedColor ?? theme.primaryIconTheme.color) - : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color), + // color: isToggled + // ? iconTheme?.iconSelectedFillColor + // : iconTheme?.iconUnselectedFillColor, ), - isFilled: isToggled, + isSelected: isToggled, onPressed: _openLinkDialog, afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/link_style_button.dart b/lib/src/widgets/toolbar/buttons/link_style_button.dart index 363ef45b..484ffc87 100644 --- a/lib/src/widgets/toolbar/buttons/link_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/link_style_button.dart @@ -137,17 +137,16 @@ class QuillToolbarLinkStyleButtonState ), ); } - final theme = Theme.of(context); return QuillToolbarIconButton( tooltip: tooltip, icon: Icon( iconData, size: iconSize * iconButtonFactor, - color: isToggled - ? (iconTheme?.iconSelectedColor ?? theme.primaryIconTheme.color) - : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color), + // color: isToggled + // ? iconTheme?.iconSelectedFillColor + // : iconTheme?.iconUnselectedFillColor, ), - isFilled: isToggled, + isSelected: isToggled, onPressed: () => _openLinkDialog(context), afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/quill_icon_button.dart b/lib/src/widgets/toolbar/buttons/quill_icon_button.dart index 3024133b..0ceeafff 100644 --- a/lib/src/widgets/toolbar/buttons/quill_icon_button.dart +++ b/lib/src/widgets/toolbar/buttons/quill_icon_button.dart @@ -4,13 +4,13 @@ class QuillToolbarIconButton extends StatelessWidget { const QuillToolbarIconButton({ required this.onPressed, required this.icon, - required this.isFilled, + required this.isSelected, this.afterPressed, this.tooltip, this.padding, super.key, - this.iconFilledStyle, - this.iconStyle, + this.iconSelectedStyle, + this.iconUnselectedStyle, }); final VoidCallback? onPressed; @@ -19,18 +19,18 @@ class QuillToolbarIconButton extends StatelessWidget { final String? tooltip; final EdgeInsets? padding; - final bool isFilled; + final bool isSelected; - final ButtonStyle? iconStyle; - final ButtonStyle? iconFilledStyle; + final ButtonStyle? iconUnselectedStyle; + final ButtonStyle? iconSelectedStyle; @override Widget build(BuildContext context) { - if (isFilled) { + if (isSelected) { return IconButton.filled( padding: padding, onPressed: onPressed, icon: icon, - style: iconStyle, + style: iconSelectedStyle, ); } return IconButton( @@ -40,7 +40,7 @@ class QuillToolbarIconButton extends StatelessWidget { afterPressed?.call(); }, icon: icon, - style: iconFilledStyle, + style: iconUnselectedStyle, ); } } diff --git a/lib/src/widgets/toolbar/buttons/search/search_button.dart b/lib/src/widgets/toolbar/buttons/search/search_button.dart index 3a2581aa..bba06036 100644 --- a/lib/src/widgets/toolbar/buttons/search/search_button.dart +++ b/lib/src/widgets/toolbar/buttons/search/search_button.dart @@ -107,18 +107,19 @@ class QuillToolbarSearchButton extends StatelessWidget { ); } - final theme = Theme.of(context); + // final theme = Theme.of(context); - final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; + // final iconColor = + // iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color; return QuillToolbarIconButton( tooltip: tooltip, icon: Icon( iconData, size: iconSize * iconButtonFactor, - color: iconColor, + // color: iconColor, ), - isFilled: false, + isSelected: false, onPressed: () => _sharedOnPressed(context), afterPressed: afterButtonPressed, ); diff --git a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart index 8e9ae3e9..2c88695f 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart @@ -243,20 +243,17 @@ Widget defaultToggleStyleButtonBuilder( double iconButtonFactor = kIconButtonFactor, QuillIconTheme? iconTheme, ]) { - final theme = Theme.of(context); final isEnabled = onPressed != null; - final iconColor = isEnabled - ? isToggled == true - ? (iconTheme?.iconSelectedColor ?? - theme - .primaryIconTheme.color) //You can specify your own icon color - : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color) - : (iconTheme?.disabledIconColor ?? theme.disabledColor); return QuillToolbarIconButton( - icon: Icon(icon, size: iconSize * iconButtonFactor, color: iconColor), - isFilled: isEnabled ? isToggled == true : false, + icon: Icon( + icon, + size: iconSize * iconButtonFactor, + ), + isSelected: isEnabled ? isToggled == true : false, onPressed: onPressed, afterPressed: afterPressed, padding: iconTheme?.padding, + iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle, + iconSelectedStyle: iconTheme?.iconButtonSelectedStyle, ); }