From 33df05bfcc80a6e10cca0274fee09d09b12acc1d Mon Sep 17 00:00:00 2001 From: Ellet Date: Wed, 20 Dec 2023 13:37:46 +0300 Subject: [PATCH] Bug fixes --- CHANGELOG.md | 3 ++ .../presentation/quill/my_quill_toolbar.dart | 15 +------ .../toolbar/buttons/color_configurations.dart | 4 +- .../toolbar/buttons/color/color_button.dart | 40 +++++++++---------- .../select_header_style_dropdown_button.dart | 1 + .../toolbar/buttons/history_button.dart | 8 ++-- .../toolbar/buttons/toggle_style_button.dart | 6 ++- 7 files changed, 35 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fc00e67..d89e6f5b 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.1 +* Bug fixes in the simple toolbar buttons + ## 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()` diff --git a/example/lib/presentation/quill/my_quill_toolbar.dart b/example/lib/presentation/quill/my_quill_toolbar.dart index a88a41a4..bc0a413b 100644 --- a/example/lib/presentation/quill/my_quill_toolbar.dart +++ b/example/lib/presentation/quill/my_quill_toolbar.dart @@ -201,25 +201,12 @@ class MyQuillToolbar extends StatelessWidget { configurations: QuillSimpleToolbarConfigurations( controller: controller, showAlignmentButtons: true, + multiRowsDisplay: false, buttonOptions: QuillSimpleToolbarButtonOptions( base: QuillToolbarBaseButtonOptions( // 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, - ), ), ), customButtons: [ diff --git a/lib/src/models/config/toolbar/buttons/color_configurations.dart b/lib/src/models/config/toolbar/buttons/color_configurations.dart index 5a00e0e5..eef8c88e 100644 --- a/lib/src/models/config/toolbar/buttons/color_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/color_configurations.dart @@ -18,8 +18,8 @@ class QuillToolbarColorButtonExtraOptions final Color? iconColor; final Color? iconColorBackground; - final Color fillColor; - final Color fillColorBackground; + final Color? fillColor; + final Color? fillColorBackground; } class QuillToolbarColorButtonOptions extends QuillToolbarBaseButtonOptions< diff --git a/lib/src/widgets/toolbar/buttons/color/color_button.dart b/lib/src/widgets/toolbar/buttons/color/color_button.dart index 23ebdc97..fe4e093c 100644 --- a/lib/src/widgets/toolbar/buttons/color/color_button.dart +++ b/lib/src/widgets/toolbar/buttons/color/color_button.dart @@ -145,22 +145,22 @@ class QuillToolbarColorButtonState extends State { @override Widget build(BuildContext context) { - // 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 iconColor = _isToggledColor && !widget.isBackground && !_isWhite + ? stringToColor(_selectionStyle.attributes['color']!.value) + : null; + + final iconColorBackground = + _isToggledBackground && widget.isBackground && !_isWhiteBackground + ? stringToColor(_selectionStyle.attributes['background']!.value) + : null; + + final fillColor = _isToggledColor && !widget.isBackground && _isWhite + ? stringToColor('#ffffff') + : null; + final fillColorBackground = + _isToggledBackground && widget.isBackground && _isWhiteBackground + ? stringToColor('#ffffff') + : null; final childBuilder = options.childBuilder ?? baseButtonExtraOptions?.childBuilder; @@ -186,9 +186,9 @@ class QuillToolbarColorButtonState extends State { afterButtonPressed?.call(); }, iconColor: null, - iconColorBackground: Colors.red, - fillColor: Colors.red, - fillColorBackground: Colors.red, + iconColorBackground: iconColorBackground, + fillColor: fillColor, + fillColorBackground: fillColorBackground, ), ); } @@ -198,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/hearder_style/select_header_style_dropdown_button.dart b/lib/src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart index 0f58991b..75945d3e 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 @@ -173,6 +173,7 @@ class _QuillToolbarSelectHeaderStyleDropdownButtonState final isMaterial3 = Theme.of(context).useMaterial3; final child = Row( mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( _label(_selectedItem), diff --git a/lib/src/widgets/toolbar/buttons/history_button.dart b/lib/src/widgets/toolbar/buttons/history_button.dart index 6c490a49..b9d4c504 100644 --- a/lib/src/widgets/toolbar/buttons/history_button.dart +++ b/lib/src/widgets/toolbar/buttons/history_button.dart @@ -102,12 +102,10 @@ class QuillToolbarHistoryButtonState extends State { icon: Icon( iconData, size: iconSize * iconButtonFactor, - // TODO: HEeeerre - // color: _canPressed - // ? iconTheme?.iconUnselectedColor ?? theme.iconTheme.color - // : iconTheme?.disabledIconColor ?? theme.disabledColor, ), - isSelected: false, + isSelected: _canPressed, + iconSelectedStyle: iconTheme?.iconButtonSelectedStyle, + iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle, onPressed: _updateHistory, 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 2c88695f..41c503fd 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart @@ -119,7 +119,11 @@ class QuillToolbarToggleStyleButtonState 'left' => (context.loc.alignLeft, Icons.format_align_left), 'right' => (context.loc.alignRight, Icons.format_align_right), 'center' => (context.loc.alignCenter, Icons.format_align_center), - Object() => (context.loc.alignCenter, Icons.format_align_center), + 'justify' => ( + context.loc.justifyWinWidth, + Icons.format_align_justify + ), + Object() => throw ArgumentError(widget.attribute.value), null => (context.loc.alignCenter, Icons.format_align_center), }; default: