Restore correct feel&look of `QuillToolbarIconButton`

pull/1621/head
Aleksei 1 year ago
parent a35c5cf93c
commit 9db3efc308
  1. 54
      lib/src/widgets/toolbar/buttons/quill_icon_button.dart
  2. 17
      lib/src/widgets/toolbar/buttons/toggle_style_button.dart

@ -1,40 +1,54 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../utils/widgets.dart';
class QuillToolbarIconButton extends StatelessWidget { class QuillToolbarIconButton extends StatelessWidget {
const QuillToolbarIconButton({ const QuillToolbarIconButton({
required this.onPressed, required this.onPressed,
required this.icon,
required this.isFilled,
this.afterPressed, this.afterPressed,
this.icon,
this.size = 40,
this.fillColor,
this.hoverElevation = 1,
this.highlightElevation = 1,
this.borderRadius = 2,
this.tooltip, this.tooltip,
this.padding,
super.key, super.key,
}); });
final VoidCallback? onPressed; final VoidCallback? onPressed;
final VoidCallback? afterPressed; 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 String? tooltip;
final EdgeInsets? padding;
final bool isFilled;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (isFilled) { return ConstrainedBox(
return IconButton.filled( constraints: BoxConstraints.tightFor(width: size, height: size),
padding: padding, child: UtilityWidgets.maybeTooltip(
onPressed: onPressed, message: tooltip,
icon: icon, child: RawMaterialButton(
); visualDensity: VisualDensity.compact,
} shape: RoundedRectangleBorder(
return IconButton( borderRadius: BorderRadius.circular(borderRadius),
padding: padding, ),
onPressed: () { fillColor: fillColor,
onPressed?.call(); elevation: 0,
afterPressed?.call(); hoverElevation: hoverElevation,
}, highlightElevation: hoverElevation,
icon: icon, onPressed: () {
onPressed?.call();
afterPressed?.call();
},
child: icon,
),
),
); );
} }
} }

@ -252,11 +252,22 @@ Widget defaultToggleStyleButtonBuilder(
.primaryIconTheme.color) //You can specify your own icon color .primaryIconTheme.color) //You can specify your own icon color
: (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color) : (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color)
: (iconTheme?.disabledIconColor ?? theme.disabledColor); : (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( return QuillToolbarIconButton(
icon: Icon(icon, size: iconSize * iconButtonFactor, color: iconColor), highlightElevation: 0,
isFilled: isEnabled ? isToggled == true : false, hoverElevation: 0,
size: iconSize * iconButtonFactor,
icon: Icon(icon, size: iconSize, color: iconColor),
fillColor: fill,
onPressed: onPressed, onPressed: onPressed,
afterPressed: afterPressed, afterPressed: afterPressed,
padding: iconTheme?.padding, borderRadius: iconTheme?.borderRadius ?? 2,
); );
} }

Loading…
Cancel
Save