Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to this project will be documented in this file.

## 9.1.0
* Fix the simple toolbar by add properties of `IconButton` and fix some buttons

## 9.1.0-dev.2
* Fix the history buttons

Expand Down
18 changes: 18 additions & 0 deletions example/lib/presentation/quill/my_quill_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,24 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller,
showAlignmentButtons: true,
multiRowsDisplay: true,
buttonOptions: QuillSimpleToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
afterButtonPressed: focusNode.requestFocus
// globalIconSize: 20,
// iconTheme: QuillIconTheme(
// iconButtonSelectedData: IconButtonData(
// style: IconButton.styleFrom(
// foregroundColor: Colors.amberAccent,
// ),
// ),
// iconButtonUnselectedData: IconButtonData(
// style: IconButton.styleFrom(
// foregroundColor: Colors.amberAccent,
// ),
// ),
// ),
),
),
customButtons: [
QuillToolbarCustomButtonOptions(
icon: const Icon(Icons.add_alarm_rounded),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class QuillToolbarFormulaButton extends StatelessWidget {
tooltip: tooltip,
onPressed: () => _sharedOnPressed(context),
isSelected: false,
iconTheme: iconTheme,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class QuillToolbarImageButton extends StatelessWidget {
tooltip: tooltip,
isSelected: false,
onPressed: () => _sharedOnPressed(context),
iconSelectedStyle: _iconTheme(context)?.iconButtonSelectedStyle,
iconUnselectedStyle: _iconTheme(context)?.iconButtonUnselectedStyle,
iconTheme: _iconTheme(context),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ class QuillToolbarCameraButton extends StatelessWidget {
isSelected: false,
// isDesktop(supportWeb: false) ? null :
onPressed: () => _sharedOnPressed(context),
iconSelectedStyle: iconTheme?.iconButtonSelectedStyle,
iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle,
iconTheme: iconTheme,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ class QuillToolbarVideoButton extends StatelessWidget {
tooltip: tooltip,
isSelected: false,
onPressed: () => _sharedOnPressed(context),
iconSelectedStyle: _iconTheme(context)?.iconButtonSelectedStyle,
iconUnselectedStyle: _iconTheme(context)?.iconButtonUnselectedStyle,
iconTheme: _iconTheme(context),
);
}

Expand Down
114 changes: 107 additions & 7 deletions lib/src/models/themes/quill_icon_theme.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,121 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter/material.dart';

@immutable
class QuillIconTheme {
const QuillIconTheme({
this.padding,
this.iconButtonSelectedStyle,
this.iconButtonUnselectedStyle,
// this.iconSelectedFillColor,
// this.iconUnselectedFillColor,
this.iconButtonSelectedData,
this.iconButtonUnselectedData,
});

@Deprecated('Please use iconButtonUnselectedData instead')
final ButtonStyle? iconButtonUnselectedStyle;
@Deprecated('Please use iconButtonSelectedData instead')
final ButtonStyle? iconButtonSelectedStyle;

// final Color? iconSelectedFillColor;
// final Color? iconUnselectedFillColor;
final IconButtonData? iconButtonUnselectedData;
final IconButtonData? iconButtonSelectedData;

QuillIconTheme copyWith({
IconButtonData? iconButtonUnselectedData,
IconButtonData? iconButtonSelectedData,
}) {
return QuillIconTheme(
iconButtonUnselectedData:
iconButtonUnselectedData ?? this.iconButtonUnselectedData,
iconButtonSelectedData:
iconButtonSelectedData ?? this.iconButtonSelectedData,
);
}
}

@immutable
class IconButtonData {
const IconButtonData({
this.iconSize,
this.visualDensity,
this.padding,
this.alignment,
this.splashRadius,
this.color,
this.focusColor,
this.hoverColor,
this.highlightColor,
this.splashColor,
this.disabledColor,
this.mouseCursor,
this.autofocus = false,
this.tooltip,
this.enableFeedback,
this.constraints,
this.style,
this.isSelected,
this.selectedIcon,
});

final double? iconSize;
final VisualDensity? visualDensity;
final EdgeInsetsGeometry? padding;
final AlignmentGeometry? alignment;
final double? splashRadius;
final Color? color;
final Color? focusColor;
final Color? hoverColor;
final Color? highlightColor;
final Color? splashColor;
final Color? disabledColor;
final MouseCursor? mouseCursor;
final bool autofocus;
final String? tooltip;
final bool? enableFeedback;
final BoxConstraints? constraints;
final ButtonStyle? style;
final bool? isSelected;
final Widget? selectedIcon;

///The padding for icons
final EdgeInsets? padding;
IconButtonData copyWith({
double? iconSize,
VisualDensity? visualDensity,
EdgeInsetsGeometry? padding,
AlignmentGeometry? alignment,
double? splashRadius,
Color? color,
Color? focusColor,
Color? hoverColor,
Color? highlightColor,
Color? splashColor,
Color? disabledColor,
MouseCursor? mouseCursor,
bool? autofocus,
String? tooltip,
bool? enableFeedback,
BoxConstraints? constraints,
ButtonStyle? style,
bool? isSelected,
Widget? selectedIcon,
}) {
return IconButtonData(
iconSize: iconSize ?? this.iconSize,
visualDensity: visualDensity ?? this.visualDensity,
padding: padding ?? this.padding,
alignment: alignment ?? this.alignment,
splashRadius: splashRadius ?? this.splashRadius,
color: color ?? this.color,
focusColor: focusColor ?? this.focusColor,
hoverColor: hoverColor ?? this.hoverColor,
highlightColor: highlightColor ?? this.highlightColor,
splashColor: splashColor ?? this.splashColor,
disabledColor: disabledColor ?? this.disabledColor,
mouseCursor: mouseCursor ?? this.mouseCursor,
autofocus: autofocus ?? this.autofocus,
tooltip: tooltip ?? this.tooltip,
enableFeedback: enableFeedback ?? this.enableFeedback,
constraints: constraints ?? this.constraints,
style: style ?? this.style,
isSelected: isSelected ?? this.isSelected,
selectedIcon: selectedIcon ?? this.selectedIcon,
);
}
}
2 changes: 1 addition & 1 deletion lib/src/widgets/toolbar/buttons/clear_format_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class QuillToolbarClearFormatButton extends StatelessWidget {
isSelected: false,
onPressed: _sharedOnPressed,
afterPressed: afterButtonPressed,
iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle,
iconTheme: iconTheme,
);
}
}
6 changes: 4 additions & 2 deletions lib/src/widgets/toolbar/buttons/color/color_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,14 @@ class QuillToolbarColorButtonState extends State<QuillToolbarColorButton> {
);
}

return IconButton(
return QuillToolbarIconButton(
tooltip: tooltip,
iconSize: iconSize * iconButtonFactor,
isSelected: false,
iconTheme: iconTheme,
icon: Icon(
iconData,
color: widget.isBackground ? iconColorBackground : iconColor,
size: iconSize * iconButtonFactor,
),
onPressed: _showColorPicker,
);
Expand Down
1 change: 1 addition & 0 deletions lib/src/widgets/toolbar/buttons/custom_button_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class QuillToolbarCustomButton extends StatelessWidget {
tooltip: tooltip,
onPressed: () => _onPressed(context),
afterPressed: afterButtonPressed,
iconTheme: iconTheme,
);
}
}
14 changes: 10 additions & 4 deletions lib/src/widgets/toolbar/buttons/font_family_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,16 @@ class QuillToolbarFontFamilyButtonState
child: _buildContent(context),
);
}
return IconButton(
// tooltip: , // TODO: Use this here
visualDensity: VisualDensity.compact,
style: iconTheme?.iconButtonUnselectedStyle,
return QuillToolbarIconButton(
isSelected: false,
iconTheme: iconTheme?.copyWith(
iconButtonSelectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
),
iconButtonUnselectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
),
),
onPressed: _onPressed,
icon: _buildContent(context),
);
Expand Down
16 changes: 12 additions & 4 deletions lib/src/widgets/toolbar/buttons/font_size_button.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'package:flutter/material.dart';

import '../../../../extensions.dart';

import '../../../extensions/quill_configurations_ext.dart';
import '../../../l10n/extensions/localizations.dart';
import '../../../models/config/quill_configurations.dart';
import '../../../models/documents/attribute.dart';
import '../../../models/themes/quill_icon_theme.dart';
import '../../../utils/font.dart';
import '../../quill/quill_controller.dart';
import '../base_toolbar.dart';

class QuillToolbarFontSizeButton extends StatefulWidget {
QuillToolbarFontSizeButton({
Expand Down Expand Up @@ -150,10 +151,17 @@ class QuillToolbarFontSizeButtonState
child: _buildContent(context),
);
}
return IconButton(
return QuillToolbarIconButton(
tooltip: tooltip,
visualDensity: VisualDensity.compact,
style: iconTheme?.iconButtonUnselectedStyle,
isSelected: false,
iconTheme: iconTheme?.copyWith(
iconButtonSelectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
),
iconButtonUnselectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
),
),
onPressed: _onPressed,
icon: _buildContent(context),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,17 @@ class QuillToolbarSelectHeaderStyleButtonsState
width: iconSize * iconButtonFactor,
height: iconSize * iconButtonFactor,
),
child: IconButton(
child: QuillToolbarIconButton(
tooltip: tooltip,
visualDensity: VisualDensity.compact,
style: isSelected
? iconTheme?.iconButtonSelectedStyle
: iconTheme?.iconButtonUnselectedStyle,
iconTheme: iconTheme?.copyWith(
iconButtonSelectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
),
iconButtonUnselectedData: const IconButtonData(
visualDensity: VisualDensity.compact,
),
),
isSelected: isSelected,
onPressed: () => _sharedOnPressed(attribute),
icon: Text(
_valueToText[attribute] ??
Expand Down
3 changes: 1 addition & 2 deletions lib/src/widgets/toolbar/buttons/history_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class QuillToolbarHistoryButtonState extends State<QuillToolbarHistoryButton> {
size: iconSize * iconButtonFactor,
),
isSelected: false,
iconSelectedStyle: iconTheme?.iconButtonSelectedStyle,
iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle,
iconTheme: iconTheme,
onPressed: _canPressed ? _updateHistory : null,
afterPressed: afterButtonPressed,
);
Expand Down
3 changes: 1 addition & 2 deletions lib/src/widgets/toolbar/buttons/indent_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> {
isSelected: false,
onPressed: _sharedOnPressed,
afterPressed: afterButtonPressed,
iconSelectedStyle: iconTheme?.iconButtonSelectedStyle,
iconUnselectedStyle: iconTheme?.iconButtonUnselectedStyle,
iconTheme: iconTheme,
);
}
}
1 change: 1 addition & 0 deletions lib/src/widgets/toolbar/buttons/link_style2_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class _QuillToolbarLinkStyleButton2State
),
isSelected: isToggled,
onPressed: _openLinkDialog,
iconTheme: iconTheme,
afterPressed: afterButtonPressed,
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/widgets/toolbar/buttons/link_style_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class QuillToolbarLinkStyleButtonState
isSelected: isToggled,
onPressed: () => _openLinkDialog(context),
afterPressed: afterButtonPressed,
iconTheme: iconTheme,
);
}

Expand Down
Loading