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 '../../../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,
this.padding,
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 EdgeInsets? padding;
final bool isFilled;
@override
Widget build(BuildContext context) {
if (isFilled) {
return IconButton.filled(
padding: padding,
onPressed: onPressed,
icon: icon,
);
}
return IconButton(
padding: padding,
onPressed: () {
onPressed?.call();
afterPressed?.call();
},
icon: icon,
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,
),
),
);
}
}

@ -252,11 +252,22 @@ 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(
icon: Icon(icon, size: iconSize * iconButtonFactor, color: iconColor),
isFilled: isEnabled ? isToggled == true : false,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * iconButtonFactor,
icon: Icon(icon, size: iconSize, color: iconColor),
fillColor: fill,
onPressed: onPressed,
afterPressed: afterPressed,
padding: iconTheme?.padding,
borderRadius: iconTheme?.borderRadius ?? 2,
);
}

Loading…
Cancel
Save