Skip to content

Commit b7063f0

Browse files
committed
toolbar button fillColor
1 parent e08009e commit b7063f0

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/widgets/toolbar.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ class InsertEmbedButton extends StatelessWidget {
2424
const InsertEmbedButton({
2525
required this.controller,
2626
required this.icon,
27+
this.fillColor,
2728
Key? key,
2829
}) : super(key: key);
2930

3031
final QuillController controller;
3132
final IconData icon;
33+
final Color? fillColor;
3234

3335
@override
3436
Widget build(BuildContext context) {
@@ -41,7 +43,7 @@ class InsertEmbedButton extends StatelessWidget {
4143
size: iconSize,
4244
color: Theme.of(context).iconTheme.color,
4345
),
44-
fillColor: Theme.of(context).canvasColor,
46+
fillColor: fillColor ?? Theme.of(context).canvasColor,
4547
onPressed: () {
4648
final index = controller.selection.baseOffset;
4749
final length = controller.selection.extentOffset - index;
@@ -169,6 +171,7 @@ typedef ToggleStyleButtonBuilder = Widget Function(
169171
BuildContext context,
170172
Attribute attribute,
171173
IconData icon,
174+
Color? fillColor,
172175
bool? isToggled,
173176
VoidCallback? onPressed,
174177
);
@@ -178,6 +181,7 @@ class ToggleStyleButton extends StatefulWidget {
178181
required this.attribute,
179182
required this.icon,
180183
required this.controller,
184+
this.fillColor,
181185
this.childBuilder = defaultToggleStyleButtonBuilder,
182186
Key? key,
183187
}) : super(key: key);
@@ -186,6 +190,8 @@ class ToggleStyleButton extends StatefulWidget {
186190

187191
final IconData icon;
188192

193+
final Color? fillColor;
194+
189195
final QuillController controller;
190196

191197
final ToggleStyleButtonBuilder childBuilder;
@@ -246,8 +252,7 @@ class _ToggleStyleButtonState extends State<ToggleStyleButton> {
246252
_selectionStyle.attributes.containsKey(Attribute.codeBlock.key);
247253
final isEnabled =
248254
!isInCodeBlock || widget.attribute.key == Attribute.codeBlock.key;
249-
return widget.childBuilder(context, widget.attribute, widget.icon,
250-
_isToggled, isEnabled ? _toggleAttribute : null);
255+
return widget.childBuilder(context, widget.attribute, widget.icon, widget.fillColor, _isToggled, isEnabled ? _toggleAttribute : null);
251256
}
252257

253258
void _toggleAttribute() {
@@ -262,12 +267,15 @@ class ToggleCheckListButton extends StatefulWidget {
262267
required this.icon,
263268
required this.controller,
264269
required this.attribute,
270+
this.fillColor,
265271
this.childBuilder = defaultToggleStyleButtonBuilder,
266272
Key? key,
267273
}) : super(key: key);
268274

269275
final IconData icon;
270276

277+
final Color? fillColor;
278+
271279
final QuillController controller;
272280

273281
final ToggleStyleButtonBuilder childBuilder;
@@ -331,8 +339,7 @@ class _ToggleCheckListButtonState extends State<ToggleCheckListButton> {
331339
_selectionStyle.attributes.containsKey(Attribute.codeBlock.key);
332340
final isEnabled =
333341
!isInCodeBlock || Attribute.list.key == Attribute.codeBlock.key;
334-
return widget.childBuilder(context, Attribute.unchecked, widget.icon,
335-
_isToggled, isEnabled ? _toggleAttribute : null);
342+
return widget.childBuilder(context, Attribute.unchecked, widget.icon, widget.fillColor, _isToggled, isEnabled ? _toggleAttribute : null);
336343
}
337344

338345
void _toggleAttribute() {
@@ -346,6 +353,7 @@ Widget defaultToggleStyleButtonBuilder(
346353
BuildContext context,
347354
Attribute attribute,
348355
IconData icon,
356+
Color? fillColor,
349357
bool? isToggled,
350358
VoidCallback? onPressed,
351359
) {
@@ -356,14 +364,14 @@ Widget defaultToggleStyleButtonBuilder(
356364
? theme.primaryIconTheme.color
357365
: theme.iconTheme.color
358366
: theme.disabledColor;
359-
final fillColor =
360-
isToggled == true ? theme.toggleableActiveColor : theme.canvasColor;
367+
final fill =
368+
isToggled == true ? theme.toggleableActiveColor : fillColor ?? theme.canvasColor;
361369
return QuillIconButton(
362370
highlightElevation: 0,
363371
hoverElevation: 0,
364372
size: iconSize * 1.77,
365373
icon: Icon(icon, size: iconSize, color: iconColor),
366-
fillColor: fillColor,
374+
fillColor: fill,
367375
onPressed: onPressed,
368376
);
369377
}

0 commit comments

Comments
 (0)