pull/1566/head
Ellet 1 year ago
parent b513bf21b1
commit b07448420f
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 8
      flutter_quill_extensions/lib/embeds/formula/toolbar/formula_button.dart
  2. 7
      flutter_quill_extensions/lib/embeds/image/toolbar/image_button.dart
  3. 7
      flutter_quill_extensions/lib/embeds/others/camera_button/camera_button.dart
  4. 5
      flutter_quill_extensions/lib/embeds/video/toolbar/video_button.dart
  5. 6
      lib/src/widgets/toolbar/buttons/clear_format.dart
  6. 6
      lib/src/widgets/toolbar/buttons/color/color.dart
  7. 6
      lib/src/widgets/toolbar/buttons/custom_button.dart
  8. 7
      lib/src/widgets/toolbar/buttons/history.dart
  9. 7
      lib/src/widgets/toolbar/buttons/indent.dart
  10. 7
      lib/src/widgets/toolbar/buttons/link_style.dart
  11. 7
      lib/src/widgets/toolbar/buttons/link_style2.dart
  12. 42
      lib/src/widgets/toolbar/buttons/quill_icon.dart
  13. 7
      lib/src/widgets/toolbar/buttons/search/search.dart
  14. 13
      lib/src/widgets/toolbar/buttons/toggle_style.dart
  15. 10
      test/bug_fix_test.dart

@ -71,14 +71,11 @@ class QuillToolbarFormulaButton extends StatelessWidget {
options.childBuilder ?? baseButtonExtraOptions(context).childBuilder;
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
final iconFillColor = iconTheme?.iconUnselectedFillColor ??
(options.fillColor ?? theme.canvasColor);
if (childBuilder != null) {
return childBuilder(
QuillToolbarFormulaButtonOptions(
afterButtonPressed: _afterButtonPressed(context),
fillColor: iconFillColor,
iconData: iconData,
iconSize: iconSize,
iconButtonFactor: iconButtonFactor,
@ -96,12 +93,9 @@ class QuillToolbarFormulaButton extends StatelessWidget {
return QuillToolbarIconButton(
icon: Icon(iconData, size: iconSize, color: iconColor),
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * 1.77,
fillColor: iconFillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
onPressed: () => _sharedOnPressed(context),
isFilled: false,
);
}

@ -101,8 +101,6 @@ class QuillToolbarImageButton extends StatelessWidget {
final iconTheme = _iconTheme(context);
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
final iconFillColor = iconTheme?.iconUnselectedFillColor ??
(options.fillColor ?? theme.canvasColor);
return QuillToolbarIconButton(
icon: Icon(
@ -111,11 +109,8 @@ class QuillToolbarImageButton extends StatelessWidget {
color: iconColor,
),
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * 1.77,
fillColor: iconFillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: false,
onPressed: () => _sharedOnPressed(context),
);
}

@ -96,17 +96,12 @@ class QuillToolbarCameraButton extends StatelessWidget {
final theme = Theme.of(context);
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
final iconFillColor = iconTheme?.iconUnselectedFillColor ??
(options.fillColor ?? theme.canvasColor);
return QuillToolbarIconButton(
icon: Icon(iconData, size: iconSize, color: iconColor),
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * 1.77,
fillColor: iconFillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: false,
// isDesktop(supportWeb: false) ? null :
onPressed: () => _sharedOnPressed(context),
);

@ -100,11 +100,8 @@ class QuillToolbarVideoButton extends StatelessWidget {
return QuillToolbarIconButton(
icon: Icon(iconData, size: iconSize, color: iconColor),
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * 1.77,
fillColor: iconFillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: false,
onPressed: () => _sharedOnPressed(context),
);
}

@ -108,16 +108,12 @@ class QuillToolbarClearFormatButton extends StatelessWidget {
final theme = Theme.of(context);
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
final fillColor = iconTheme?.iconUnselectedFillColor ?? theme.canvasColor;
return QuillToolbarIconButton(
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * iconButtonFactor,
icon: Icon(iconData, size: iconSize, color: iconColor),
fillColor: fillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: false,
onPressed: _sharedOnPressed,
afterPressed: afterButtonPressed,
);

@ -195,14 +195,12 @@ class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
return QuillToolbarIconButton(
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * iconButtonFactor,
icon: Icon(iconData,
size: iconSize,
color: widget.isBackground ? iconColorBackground : iconColor),
fillColor: widget.isBackground ? fillColorBackground : fillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
// fillColor: widget.isBackground ? fillColorBackground : fillColor,
isFilled: false,
onPressed: _showColorPicker,
afterPressed: afterButtonPressed,
);

@ -80,15 +80,13 @@ class QuillToolbarCustomButton extends StatelessWidget {
);
}
final theme = Theme.of(context);
return QuillToolbarIconButton(
size: iconSize * iconButtonFactor,
icon: options.icon,
icon: options.icon ?? const SizedBox.shrink(),
isFilled: false,
tooltip: tooltip,
borderRadius: iconTheme?.borderRadius ?? 2,
onPressed: () => _onPressed(context),
afterPressed: afterButtonPressed,
fillColor: iconTheme?.iconUnselectedFillColor ?? theme.canvasColor,
);
}
}

@ -93,12 +93,8 @@ class QuillToolbarHistoryButtonState extends State<QuillToolbarHistoryButton> {
}
theme = Theme.of(context);
final fillColor = iconTheme?.iconUnselectedFillColor ?? theme.canvasColor;
return QuillToolbarIconButton(
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * iconButtonFactor,
icon: Icon(
iconData,
@ -107,8 +103,7 @@ class QuillToolbarHistoryButtonState extends State<QuillToolbarHistoryButton> {
? iconTheme?.iconUnselectedColor ?? theme.iconTheme.color
: iconTheme?.disabledIconColor ?? theme.disabledColor,
),
fillColor: fillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: false,
onPressed: _updateHistory,
afterPressed: afterButtonPressed,
);

@ -107,16 +107,11 @@ class QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> {
final theme = Theme.of(context);
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
final iconFillColor =
iconTheme?.iconUnselectedFillColor ?? theme.canvasColor;
return QuillToolbarIconButton(
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * iconButtonFactor,
icon: Icon(iconData, size: iconSize, color: iconColor),
fillColor: iconFillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: false,
onPressed: _sharedOnPressed,
afterPressed: afterButtonPressed,
);

@ -141,8 +141,6 @@ class QuillToolbarLinkStyleButtonState
final theme = Theme.of(context);
return QuillToolbarIconButton(
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * iconButtonFactor,
icon: Icon(
iconData,
@ -151,10 +149,7 @@ class QuillToolbarLinkStyleButtonState
? (iconTheme?.iconSelectedColor ?? theme.primaryIconTheme.color)
: (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color),
),
fillColor: isToggled
? (iconTheme?.iconSelectedFillColor ?? theme.primaryColor)
: (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor),
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: isToggled,
onPressed: () => _openLinkDialog(context),
afterPressed: afterButtonPressed,
);

@ -148,8 +148,6 @@ class _QuillToolbarLinkStyleButton2State
final isToggled = _getLinkAttributeValue() != null;
return QuillToolbarIconButton(
tooltip: tooltip,
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * iconButtonFactor,
icon: Icon(
iconData,
@ -158,10 +156,7 @@ class _QuillToolbarLinkStyleButton2State
? (iconTheme?.iconSelectedColor ?? theme.primaryIconTheme.color)
: (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color),
),
fillColor: isToggled
? (iconTheme?.iconSelectedFillColor ?? theme.primaryColor)
: (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor),
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: isToggled,
onPressed: _openLinkDialog,
afterPressed: afterButtonPressed,
);

@ -1,54 +1,32 @@
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,
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 bool isFilled;
@override
Widget build(BuildContext context) {
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,
),
),
if (isFilled) {
return IconButton.filled(onPressed: onPressed, icon: icon);
}
return IconButton(
onPressed: onPressed,
icon: icon,
);
}
}

@ -111,8 +111,6 @@ class QuillToolbarSearchButton extends StatelessWidget {
final theme = Theme.of(context);
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
final iconFillColor = iconTheme?.iconUnselectedFillColor ??
(options.fillColor ?? theme.canvasColor);
return QuillToolbarIconButton(
tooltip: tooltip,
@ -121,11 +119,8 @@ class QuillToolbarSearchButton extends StatelessWidget {
size: iconSize,
color: iconColor,
),
highlightElevation: 0,
hoverElevation: 0,
size: iconSize * iconButtonFactor,
fillColor: iconFillColor,
borderRadius: iconTheme?.borderRadius ?? 2,
isFilled: false,
onPressed: () => _sharedOnPressed(context),
afterPressed: afterButtonPressed,
);

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

@ -36,8 +36,8 @@ void main() {
matchRoot: true,
);
expect(builtinFinder, findsOneWidget);
final builtinButton =
builtinFinder.evaluate().first.widget as QuillToolbarIconButton;
// final builtinButton =
// builtinFinder.evaluate().first.widget as QuillToolbarIconButton;
final customFinder = find.descendant(
of: find.byType(QuillBaseToolbar),
@ -45,10 +45,10 @@ void main() {
widget is QuillToolbarIconButton && widget.tooltip == tooltip),
matchRoot: true);
expect(customFinder, findsOneWidget);
final customButton =
customFinder.evaluate().first.widget as QuillToolbarIconButton;
// final customButton =
// customFinder.evaluate().first.widget as QuillToolbarIconButton;
expect(customButton.fillColor, equals(builtinButton.fillColor));
// expect(customButton.fillColor, equals(builtinButton.fillColor));
});
});

Loading…
Cancel
Save