Fix the QuillIconTheme by replacing all the properties with two properties of type ButtonStyle, use IconButton.styleFrom()

pull/1634/head
Ellet 1 year ago
parent 6a4a893454
commit 8dc1ff79d5
  1. 3
      CHANGELOG.md
  2. 11
      example/lib/presentation/quill/my_quill_toolbar.dart
  3. 11
      flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart
  4. 9
      flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart
  5. 11
      flutter_quill_extensions/lib/embeds/others/camera_button/camera_button.dart
  6. 21
      flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart
  7. 34
      lib/src/models/themes/quill_icon_theme.dart
  8. 13
      lib/src/widgets/toolbar/buttons/clear_format_button.dart
  9. 41
      lib/src/widgets/toolbar/buttons/color/color_button.dart
  10. 2
      lib/src/widgets/toolbar/buttons/custom_button_button.dart
  11. 16
      lib/src/widgets/toolbar/buttons/font_family_button.dart
  12. 15
      lib/src/widgets/toolbar/buttons/font_size_button.dart
  13. 49
      lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_buttons.dart
  14. 9
      lib/src/widgets/toolbar/buttons/history_button.dart
  15. 13
      lib/src/widgets/toolbar/buttons/indent_button.dart
  16. 9
      lib/src/widgets/toolbar/buttons/link_style2_button.dart
  17. 9
      lib/src/widgets/toolbar/buttons/link_style_button.dart
  18. 18
      lib/src/widgets/toolbar/buttons/quill_icon_button.dart
  19. 9
      lib/src/widgets/toolbar/buttons/search/search_button.dart
  20. 17
      lib/src/widgets/toolbar/buttons/toggle_style_button.dart

@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file. 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 ## 9.0.6
* Fix bug in QuillToolbarSelectAlignmentButtons * Fix bug in QuillToolbarSelectAlignmentButtons

@ -206,15 +206,20 @@ class MyQuillToolbar extends StatelessWidget {
// Request editor focus when any button is pressed // Request editor focus when any button is pressed
afterButtonPressed: focusNode.requestFocus, afterButtonPressed: focusNode.requestFocus,
// globalIconSize: 18, // globalIconSize: 18,
iconTheme: QuillIconTheme(
iconButtonUnselectedStyle: IconButton.styleFrom(
backgroundColor: Colors.green,
),
iconButtonSelectedStyle: IconButton.styleFrom(
backgroundColor: Colors.red,
),
),
), ),
selectHeaderStyleDropdownButton: selectHeaderStyleDropdownButton:
const QuillToolbarSelectHeaderStyleDropdownButtonOptions( const QuillToolbarSelectHeaderStyleDropdownButtonOptions(
textStyle: TextStyle( textStyle: TextStyle(
fontSize: 20, fontSize: 20,
), ),
iconTheme: QuillIconTheme(
iconSelectedColor: Colors.red,
),
), ),
), ),
customButtons: [ customButtons: [

@ -59,8 +59,6 @@ class QuillToolbarFormulaButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context);
final iconTheme = _iconTheme(context); final iconTheme = _iconTheme(context);
final tooltip = _tooltip(context); final tooltip = _tooltip(context);
@ -70,8 +68,6 @@ class QuillToolbarFormulaButton extends StatelessWidget {
final childBuilder = final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder; options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
if (childBuilder != null) { if (childBuilder != null) {
return childBuilder( return childBuilder(
QuillToolbarFormulaButtonOptions( QuillToolbarFormulaButtonOptions(
@ -91,10 +87,13 @@ class QuillToolbarFormulaButton extends StatelessWidget {
} }
return QuillToolbarIconButton( return QuillToolbarIconButton(
icon: Icon(iconData, size: iconSize * iconButtonFactor, color: iconColor), icon: Icon(
iconData,
size: iconSize * iconButtonFactor,
),
tooltip: tooltip, tooltip: tooltip,
onPressed: () => _sharedOnPressed(context), onPressed: () => _sharedOnPressed(context),
isFilled: false, isSelected: false,
); );
} }

@ -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( return QuillToolbarIconButton(
icon: Icon( icon: Icon(
iconData, iconData,
size: iconButtonFactor * iconSize, size: iconButtonFactor * iconSize,
color: iconColor,
), ),
tooltip: tooltip, tooltip: tooltip,
isFilled: false, isSelected: false,
onPressed: () => _sharedOnPressed(context), onPressed: () => _sharedOnPressed(context),
); );
} }

@ -103,14 +103,13 @@ class QuillToolbarCameraButton extends StatelessWidget {
); );
} }
final theme = Theme.of(context);
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
return QuillToolbarIconButton( return QuillToolbarIconButton(
icon: Icon(iconData, size: iconButtonFactor * iconSize, color: iconColor), icon: Icon(
iconData,
size: iconButtonFactor * iconSize,
),
tooltip: tooltip, tooltip: tooltip,
isFilled: false, isSelected: false,
// isDesktop(supportWeb: false) ? null : // isDesktop(supportWeb: false) ? null :
onPressed: () => _sharedOnPressed(context), onPressed: () => _sharedOnPressed(context),
); );

@ -68,10 +68,6 @@ class QuillToolbarVideoButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context);
final iconTheme = _iconTheme(context);
final tooltip = _tooltip(context); final tooltip = _tooltip(context);
final iconSize = _iconSize(context); final iconSize = _iconSize(context);
final iconButtonFactor = _iconButtonFactor(context); final iconButtonFactor = _iconButtonFactor(context);
@ -79,9 +75,10 @@ class QuillToolbarVideoButton extends StatelessWidget {
final childBuilder = final childBuilder =
options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder; options.childBuilder ?? baseButtonExtraOptions(context)?.childBuilder;
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; // final iconColor =
final iconFillColor = iconTheme?.iconUnselectedFillColor ?? // iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color;
(options.fillColor ?? theme.canvasColor); // final iconFillColor = iconTheme?.iconUnselectedFillColor ??
// (options.fillColor ?? theme.canvasColor);
if (childBuilder != null) { if (childBuilder != null) {
return childBuilder( return childBuilder(
@ -89,7 +86,7 @@ class QuillToolbarVideoButton extends StatelessWidget {
afterButtonPressed: _afterButtonPressed(context), afterButtonPressed: _afterButtonPressed(context),
iconData: iconData, iconData: iconData,
dialogTheme: options.dialogTheme, dialogTheme: options.dialogTheme,
fillColor: iconFillColor, // fillColor: iconFillColor,
iconSize: options.iconSize, iconSize: options.iconSize,
iconButtonFactor: iconButtonFactor, iconButtonFactor: iconButtonFactor,
linkRegExp: options.linkRegExp, linkRegExp: options.linkRegExp,
@ -106,9 +103,13 @@ class QuillToolbarVideoButton extends StatelessWidget {
} }
return QuillToolbarIconButton( return QuillToolbarIconButton(
icon: Icon(iconData, size: iconSize * iconButtonFactor, color: iconColor), icon: Icon(
iconData,
size: iconSize * iconButtonFactor,
// color: iconColor,
),
tooltip: tooltip, tooltip: tooltip,
isFilled: false, isSelected: false,
onPressed: () => _sharedOnPressed(context), onPressed: () => _sharedOnPressed(context),
); );
} }

@ -3,36 +3,18 @@ import 'package:flutter/material.dart';
@immutable @immutable
class QuillIconTheme { class QuillIconTheme {
const QuillIconTheme({ const QuillIconTheme({
this.iconSelectedColor,
this.iconUnselectedColor,
this.iconSelectedFillColor,
this.iconUnselectedFillColor,
this.disabledIconColor,
this.disabledIconFillColor,
this.borderRadius,
this.padding, this.padding,
this.iconButtonSelectedStyle,
this.iconButtonUnselectedStyle,
// this.iconSelectedFillColor,
// this.iconUnselectedFillColor,
}); });
///The color to use for selected icons in the toolbar final ButtonStyle? iconButtonUnselectedStyle;
final Color? iconSelectedColor; final ButtonStyle? iconButtonSelectedStyle;
///The color to use for unselected icons in the toolbar // final Color? iconSelectedFillColor;
final Color? iconUnselectedColor; // final Color? iconUnselectedFillColor;
///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;
///The padding for icons ///The padding for icons
final EdgeInsets? padding; final EdgeInsets? padding;

@ -104,16 +104,17 @@ class QuillToolbarClearFormatButton extends StatelessWidget {
); );
} }
final theme = Theme.of(context);
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
return QuillToolbarIconButton( return QuillToolbarIconButton(
tooltip: tooltip, tooltip: tooltip,
icon: Icon(iconData, size: iconSize * iconButtonFactor, color: iconColor), icon: Icon(
isFilled: false, iconData,
size: iconSize * iconButtonFactor,
// color: iconColor,
),
isSelected: false,
onPressed: _sharedOnPressed, onPressed: _sharedOnPressed,
afterPressed: afterButtonPressed, afterPressed: afterButtonPressed,
iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle,
); );
} }
} }

@ -145,23 +145,22 @@ class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); // final iconColor = _isToggledColor && !widget.isBackground && !_isWhite
final iconColor = _isToggledColor && !widget.isBackground && !_isWhite // ? stringToColor(_selectionStyle.attributes['color']!.value)
? stringToColor(_selectionStyle.attributes['color']!.value) // : (iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color);
: (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color);
// final iconColorBackground =
final iconColorBackground = // _isToggledBackground && widget.isBackground && !_isWhiteBackground
_isToggledBackground && widget.isBackground && !_isWhiteBackground // ? stringToColor(_selectionStyle.attributes['background']!.value)
? stringToColor(_selectionStyle.attributes['background']!.value) // : (iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color);
: (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color);
// final fillColor = _isToggledColor && !widget.isBackground && _isWhite
final fillColor = _isToggledColor && !widget.isBackground && _isWhite // ? stringToColor('#ffffff')
? stringToColor('#ffffff') // : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor);
: (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor); // final fillColorBackground =
final fillColorBackground = // _isToggledBackground && widget.isBackground && _isWhiteBackground
_isToggledBackground && widget.isBackground && _isWhiteBackground // ? stringToColor('#ffffff')
? stringToColor('#ffffff') // : (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor);
: (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor);
final childBuilder = final childBuilder =
options.childBuilder ?? baseButtonExtraOptions?.childBuilder; options.childBuilder ?? baseButtonExtraOptions?.childBuilder;
@ -187,9 +186,9 @@ class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
afterButtonPressed?.call(); afterButtonPressed?.call();
}, },
iconColor: null, iconColor: null,
iconColorBackground: iconColorBackground, iconColorBackground: Colors.red,
fillColor: fillColor, fillColor: Colors.red,
fillColorBackground: fillColorBackground, fillColorBackground: Colors.red,
), ),
); );
} }
@ -199,7 +198,7 @@ class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
iconSize: iconSize * iconButtonFactor, iconSize: iconSize * iconButtonFactor,
icon: Icon( icon: Icon(
iconData, iconData,
color: widget.isBackground ? iconColorBackground : iconColor, // color: widget.isBackground ? iconColorBackground : iconColor,
), ),
onPressed: _showColorPicker, onPressed: _showColorPicker,
); );

@ -81,7 +81,7 @@ class QuillToolbarCustomButton extends StatelessWidget {
return QuillToolbarIconButton( return QuillToolbarIconButton(
icon: options.icon ?? const SizedBox.shrink(), icon: options.icon ?? const SizedBox.shrink(),
isFilled: false, isSelected: false,
tooltip: tooltip, tooltip: tooltip,
onPressed: () => _onPressed(context), onPressed: () => _onPressed(context),
afterPressed: afterButtonPressed, afterPressed: afterButtonPressed,

@ -193,14 +193,7 @@ class QuillToolbarFontFamilyButtonState
return IconButton( return IconButton(
// tooltip: , // TODO: Use this here // tooltip: , // TODO: Use this here
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
style: IconButton.styleFrom( style: iconTheme?.iconButtonUnselectedStyle,
shape: iconTheme?.borderRadius != null
? RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
iconTheme?.borderRadius ?? -1),
)
: null,
),
onPressed: _onPressed, onPressed: _onPressed,
icon: _buildContent(context), icon: _buildContent(context),
); );
@ -281,7 +274,6 @@ class QuillToolbarFontFamilyButtonState
} }
Widget _buildContent(BuildContext context) { Widget _buildContent(BuildContext context) {
final theme = Theme.of(context);
final hasFinalWidth = options.width != null; final hasFinalWidth = options.width != null;
return Padding( return Padding(
padding: options.padding ?? const EdgeInsets.fromLTRB(10, 0, 0, 0), padding: options.padding ?? const EdgeInsets.fromLTRB(10, 0, 0, 0),
@ -299,8 +291,8 @@ class QuillToolbarFontFamilyButtonState
style: options.style ?? style: options.style ??
TextStyle( TextStyle(
fontSize: iconSize / 1.15, fontSize: iconSize / 1.15,
color: // color: iconTheme?.iconUnselectedFillColor ??
iconTheme?.iconUnselectedColor ?? theme.iconTheme.color, // theme.iconTheme.color,
), ),
), ),
), ),
@ -308,7 +300,7 @@ class QuillToolbarFontFamilyButtonState
Icon( Icon(
Icons.arrow_drop_down, Icons.arrow_drop_down,
size: iconSize / 1.15, size: iconSize / 1.15,
color: iconTheme?.iconUnselectedColor ?? theme.iconTheme.color, // color: iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color,
) )
], ],
), ),

@ -153,14 +153,7 @@ class QuillToolbarFontSizeButtonState
return IconButton( return IconButton(
tooltip: tooltip, tooltip: tooltip,
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
style: IconButton.styleFrom( style: iconTheme?.iconButtonUnselectedStyle,
shape: iconTheme?.borderRadius != null
? RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(iconTheme?.borderRadius ?? -1),
)
: null,
),
onPressed: _onPressed, onPressed: _onPressed,
icon: _buildContent(context), icon: _buildContent(context),
); );
@ -251,8 +244,8 @@ class QuillToolbarFontSizeButtonState
style: options.style ?? style: options.style ??
TextStyle( TextStyle(
fontSize: iconSize / 1.15, fontSize: iconSize / 1.15,
color: // color: iconTheme?.iconUnselectedFillColor ??
iconTheme?.iconUnselectedColor ?? theme.iconTheme.color, // theme.iconTheme.color,
), ),
), ),
), ),
@ -260,7 +253,7 @@ class QuillToolbarFontSizeButtonState
Icon( Icon(
Icons.arrow_drop_down, Icons.arrow_drop_down,
size: iconSize / 1.15, size: iconSize / 1.15,
color: iconTheme?.iconUnselectedColor ?? theme.iconTheme.color, // color: iconTheme?.iconUnselectedFillColor ?? theme.iconTheme.color,
) )
], ],
), ),

@ -1,7 +1,6 @@
import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../../extensions.dart';
import '../../../../extensions/quill_configurations_ext.dart'; import '../../../../extensions/quill_configurations_ext.dart';
import '../../../../l10n/extensions/localizations.dart'; import '../../../../l10n/extensions/localizations.dart';
import '../../../../models/documents/attribute.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; final isSelected = _selectedAttribute == attribute;
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: !kIsWeb ? 1.0 : 5.0), padding: const EdgeInsets.symmetric(horizontal: !kIsWeb ? 1.0 : 5.0),
@ -156,33 +155,25 @@ class QuillToolbarSelectHeaderStyleButtonsState
width: iconSize * iconButtonFactor, width: iconSize * iconButtonFactor,
height: iconSize * iconButtonFactor, height: iconSize * iconButtonFactor,
), ),
child: UtilityWidgets.maybeTooltip( child: IconButton(
message: tooltip, tooltip: tooltip,
child: RawMaterialButton( visualDensity: VisualDensity.compact,
hoverElevation: 0, style: isSelected
highlightElevation: 0, ? iconTheme?.iconButtonSelectedStyle
elevation: 0, : iconTheme?.iconButtonUnselectedStyle,
visualDensity: VisualDensity.compact, onPressed: () => _sharedOnPressed(attribute),
shape: RoundedRectangleBorder( icon: Text(
borderRadius: _valueToText[attribute] ??
BorderRadius.circular(iconTheme?.borderRadius ?? 2)), (throw ArgumentError.notNull(
fillColor: isSelected 'attrbuite',
? (iconTheme?.iconSelectedFillColor ?? theme.primaryColor) )),
: (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor), style: style.copyWith(
onPressed: () => _sharedOnPressed(attribute), // color: isSelected
child: Text( // ? (iconTheme?.iconSelectedFillColor ??
_valueToText[attribute] ?? // theme.primaryIconTheme.color)
(throw ArgumentError.notNull( // : (iconTheme?.iconUnselectedFillColor ??
'attrbuite', // theme.iconTheme.color),
)), ),
style: style.copyWith(
color: isSelected
? (iconTheme?.iconSelectedColor ??
theme.primaryIconTheme.color)
: (iconTheme?.iconUnselectedColor ??
theme.iconTheme.color),
),
),
), ),
), ),
), ),

@ -102,11 +102,12 @@ class QuillToolbarHistoryButtonState extends State<QuillToolbarHistoryButton> {
icon: Icon( icon: Icon(
iconData, iconData,
size: iconSize * iconButtonFactor, size: iconSize * iconButtonFactor,
color: _canPressed // TODO: HEeeerre
? iconTheme?.iconUnselectedColor ?? theme.iconTheme.color // color: _canPressed
: iconTheme?.disabledIconColor ?? theme.disabledColor, // ? iconTheme?.iconUnselectedColor ?? theme.iconTheme.color
// : iconTheme?.disabledIconColor ?? theme.disabledColor,
), ),
isFilled: false, isSelected: false,
onPressed: _updateHistory, onPressed: _updateHistory,
afterPressed: afterButtonPressed, afterPressed: afterButtonPressed,
); );

@ -104,15 +104,20 @@ class QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> {
), ),
); );
} }
final theme = Theme.of(context);
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; // final iconColor = iconTheme?.iconUnselectedFillColor;
return QuillToolbarIconButton( return QuillToolbarIconButton(
tooltip: tooltip, tooltip: tooltip,
icon: Icon(iconData, size: iconSize * iconButtonFactor, color: iconColor), icon: Icon(
isFilled: false, iconData,
size: iconSize * iconButtonFactor,
// color: iconColor,
),
isSelected: false,
onPressed: _sharedOnPressed, onPressed: _sharedOnPressed,
afterPressed: afterButtonPressed, afterPressed: afterButtonPressed,
iconSelectedStyle: iconTheme?.iconButtonSelectedStyle,
iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle,
); );
} }
} }

@ -144,18 +144,17 @@ class _QuillToolbarLinkStyleButton2State
), ),
); );
} }
final theme = Theme.of(context);
final isToggled = _getLinkAttributeValue() != null; final isToggled = _getLinkAttributeValue() != null;
return QuillToolbarIconButton( return QuillToolbarIconButton(
tooltip: tooltip, tooltip: tooltip,
icon: Icon( icon: Icon(
iconData, iconData,
size: iconSize * iconButtonFactor, size: iconSize * iconButtonFactor,
color: isToggled // color: isToggled
? (iconTheme?.iconSelectedColor ?? theme.primaryIconTheme.color) // ? iconTheme?.iconSelectedFillColor
: (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color), // : iconTheme?.iconUnselectedFillColor,
), ),
isFilled: isToggled, isSelected: isToggled,
onPressed: _openLinkDialog, onPressed: _openLinkDialog,
afterPressed: afterButtonPressed, afterPressed: afterButtonPressed,
); );

@ -137,17 +137,16 @@ class QuillToolbarLinkStyleButtonState
), ),
); );
} }
final theme = Theme.of(context);
return QuillToolbarIconButton( return QuillToolbarIconButton(
tooltip: tooltip, tooltip: tooltip,
icon: Icon( icon: Icon(
iconData, iconData,
size: iconSize * iconButtonFactor, size: iconSize * iconButtonFactor,
color: isToggled // color: isToggled
? (iconTheme?.iconSelectedColor ?? theme.primaryIconTheme.color) // ? iconTheme?.iconSelectedFillColor
: (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color), // : iconTheme?.iconUnselectedFillColor,
), ),
isFilled: isToggled, isSelected: isToggled,
onPressed: () => _openLinkDialog(context), onPressed: () => _openLinkDialog(context),
afterPressed: afterButtonPressed, afterPressed: afterButtonPressed,
); );

@ -4,13 +4,13 @@ class QuillToolbarIconButton extends StatelessWidget {
const QuillToolbarIconButton({ const QuillToolbarIconButton({
required this.onPressed, required this.onPressed,
required this.icon, required this.icon,
required this.isFilled, required this.isSelected,
this.afterPressed, this.afterPressed,
this.tooltip, this.tooltip,
this.padding, this.padding,
super.key, super.key,
this.iconFilledStyle, this.iconSelectedStyle,
this.iconStyle, this.iconUnselectedStyle,
}); });
final VoidCallback? onPressed; final VoidCallback? onPressed;
@ -19,18 +19,18 @@ class QuillToolbarIconButton extends StatelessWidget {
final String? tooltip; final String? tooltip;
final EdgeInsets? padding; final EdgeInsets? padding;
final bool isFilled; final bool isSelected;
final ButtonStyle? iconStyle; final ButtonStyle? iconUnselectedStyle;
final ButtonStyle? iconFilledStyle; final ButtonStyle? iconSelectedStyle;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (isFilled) { if (isSelected) {
return IconButton.filled( return IconButton.filled(
padding: padding, padding: padding,
onPressed: onPressed, onPressed: onPressed,
icon: icon, icon: icon,
style: iconStyle, style: iconSelectedStyle,
); );
} }
return IconButton( return IconButton(
@ -40,7 +40,7 @@ class QuillToolbarIconButton extends StatelessWidget {
afterPressed?.call(); afterPressed?.call();
}, },
icon: icon, icon: icon,
style: iconFilledStyle, style: iconUnselectedStyle,
); );
} }
} }

@ -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( return QuillToolbarIconButton(
tooltip: tooltip, tooltip: tooltip,
icon: Icon( icon: Icon(
iconData, iconData,
size: iconSize * iconButtonFactor, size: iconSize * iconButtonFactor,
color: iconColor, // color: iconColor,
), ),
isFilled: false, isSelected: false,
onPressed: () => _sharedOnPressed(context), onPressed: () => _sharedOnPressed(context),
afterPressed: afterButtonPressed, afterPressed: afterButtonPressed,
); );

@ -243,20 +243,17 @@ Widget defaultToggleStyleButtonBuilder(
double iconButtonFactor = kIconButtonFactor, double iconButtonFactor = kIconButtonFactor,
QuillIconTheme? iconTheme, QuillIconTheme? iconTheme,
]) { ]) {
final theme = Theme.of(context);
final isEnabled = onPressed != null; 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( return QuillToolbarIconButton(
icon: Icon(icon, size: iconSize * iconButtonFactor, color: iconColor), icon: Icon(
isFilled: isEnabled ? isToggled == true : false, icon,
size: iconSize * iconButtonFactor,
),
isSelected: isEnabled ? isToggled == true : false,
onPressed: onPressed, onPressed: onPressed,
afterPressed: afterPressed, afterPressed: afterPressed,
padding: iconTheme?.padding, padding: iconTheme?.padding,
iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle,
iconSelectedStyle: iconTheme?.iconButtonSelectedStyle,
); );
} }

Loading…
Cancel
Save