From c40ccbe205884db3f3a11f7be960d26186410144 Mon Sep 17 00:00:00 2001 From: mark8044 <87546778+mark8044@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:17:02 -0800 Subject: [PATCH] Add padding control in for toolbar buttons (#1592) * Update quill_icon_button.dart Add padding property to icon buttons * Update quill_icon_theme.dart Add padding to IconTheme * Pass padding to the QuillToolbarIconButton * Update quill_icon_button.dart * CI fix for const * CI fix? --- lib/src/models/themes/quill_icon_theme.dart | 10 ++++++---- lib/src/widgets/toolbar/buttons/quill_icon_button.dart | 9 ++++++++- .../widgets/toolbar/buttons/toggle_style_button.dart | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/src/models/themes/quill_icon_theme.dart b/lib/src/models/themes/quill_icon_theme.dart index ca70b800..c93e3857 100644 --- a/lib/src/models/themes/quill_icon_theme.dart +++ b/lib/src/models/themes/quill_icon_theme.dart @@ -1,6 +1,4 @@ -import 'package:flutter/widgets.dart' show Color; - -import 'package:meta/meta.dart' show immutable; +import 'package:flutter/material.dart'; @immutable class QuillIconTheme { @@ -11,7 +9,8 @@ class QuillIconTheme { this.iconUnselectedFillColor, this.disabledIconColor, this.disabledIconFillColor, - this.borderRadius}); + this.borderRadius, + this.padding}); ///The color to use for selected icons in the toolbar final Color? iconSelectedColor; @@ -33,4 +32,7 @@ class QuillIconTheme { ///The borderRadius for icons final double? borderRadius; + + ///The padding for icons + final EdgeInsets? padding; } diff --git a/lib/src/widgets/toolbar/buttons/quill_icon_button.dart b/lib/src/widgets/toolbar/buttons/quill_icon_button.dart index 78c4eaf5..6b4d53d2 100644 --- a/lib/src/widgets/toolbar/buttons/quill_icon_button.dart +++ b/lib/src/widgets/toolbar/buttons/quill_icon_button.dart @@ -7,6 +7,7 @@ class QuillToolbarIconButton extends StatelessWidget { required this.isFilled, this.afterPressed, this.tooltip, + this.padding, super.key, }); @@ -15,14 +16,20 @@ class QuillToolbarIconButton extends StatelessWidget { final Widget icon; final String? tooltip; + final EdgeInsets? padding; final bool isFilled; @override Widget build(BuildContext context) { if (isFilled) { - return IconButton.filled(onPressed: onPressed, icon: icon); + return IconButton.filled( + padding: padding, + constraints: const BoxConstraints(), + onPressed: onPressed, icon: icon); } return IconButton( + padding: padding, + constraints: const BoxConstraints(), onPressed: () { onPressed?.call(); afterPressed?.call(); diff --git a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart index fd558ebb..a721f4b0 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart @@ -254,5 +254,6 @@ Widget defaultToggleStyleButtonBuilder( isFilled: isEnabled ? isToggled == true : false, onPressed: onPressed, afterPressed: afterPressed, + padding: iconTheme?.padding ); }