Skip to content

Commit

Permalink
docs: Update the custom toolbar example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellet committed Dec 2, 2023
1 parent 6830f8c commit aabd9f2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
28 changes: 20 additions & 8 deletions example/lib/presentation/quill/quill_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ class MyQuillToolbar extends StatelessWidget {
configurations: QuillBaseToolbarConfigurations(
toolbarSize: 15 * 2,
multiRowsDisplay: false,
buttonOptions: const QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
globalIconSize: 30,
),
),
childrenBuilder: (context) {
final controller = context.requireQuillController;
return [
Expand All @@ -122,17 +127,26 @@ class MyQuillToolbar extends StatelessWidget {
QuillToolbarToggleStyleButton(
attribute: Attribute.bold,
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_bold,
iconSize: 20,
options: QuillToolbarToggleStyleButtonOptions(
childBuilder: (options, extraOptions) {
if (extraOptions.isToggled) {
return IconButton.filled(
onPressed: extraOptions.onPressed,
icon: Icon(options.iconData),
);
}
return IconButton(
onPressed: extraOptions.onPressed,
icon: Icon(options.iconData),
);
},
),
),
QuillToolbarToggleStyleButton(
attribute: Attribute.italic,
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_italic,
iconSize: 20,
),
),
QuillToolbarToggleStyleButton(
Expand All @@ -147,7 +161,6 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller,
options: const QuillToolbarClearFormatButtonOptions(
iconData: Icons.format_clear,
iconSize: 20,
),
),
VerticalDivider(
Expand All @@ -166,23 +179,22 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_list_numbered,
iconSize: 20,
iconSize: 39,
),
),
QuillToolbarToggleStyleButton(
attribute: Attribute.ul,
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_list_bulleted,
iconSize: 20,
),
),
QuillToolbarToggleStyleButton(
attribute: Attribute.blockQuote,
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_quote,
iconSize: 20,
iconSize: 15,
),
),
VerticalDivider(
Expand Down
20 changes: 0 additions & 20 deletions lib/src/models/config/toolbar/buttons/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,6 @@ class QuillToolbarBaseButtonOptions<T, I> extends Equatable {
childBuilder,
controller,
];

// QuillToolbarBaseButtonOptions<T, I> copyWith({
// IconData? iconData,
// double? globalIconSize,
// VoidCallback? afterButtonPressed,
// String? tooltip,
// QuillIconTheme? iconTheme,
// Widget Function(T options, I extraOptions)? childBuilder,
// QuillController? controller,
// }) {
// return QuillToolbarBaseButtonOptions<T, I>(
// iconData: iconData ?? this.iconData,
// globalIconSize: globalIconSize ?? this.globalIconSize,
// afterButtonPressed: afterButtonPressed ?? this.afterButtonPressed,
// tooltip: tooltip ?? this.tooltip,
// iconTheme: iconTheme ?? this.iconTheme,
// childBuilder: childBuilder ?? this.childBuilder,
// controller: controller ?? this.controller,
// );
// }
}

typedef QuillToolbarButtonOptionsChildBuilder<T, I> = Widget Function(
Expand Down
1 change: 1 addition & 0 deletions lib/src/models/config/toolbar/buttons/toggle_style.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter/foundation.dart' show immutable;
import 'package:flutter/widgets.dart' show Color;

Expand Down
11 changes: 10 additions & 1 deletion lib/src/widgets/toolbar/buttons/toggle_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,16 @@ class QuillToolbarToggleStyleButtonState
context.requireQuillToolbarBaseButtonOptions.childBuilder;
if (childBuilder != null) {
return childBuilder(
options,
QuillToolbarToggleStyleButtonOptions(
afterButtonPressed: options.afterButtonPressed,
controller: controller,
fillColor: options.fillColor,
iconButtonFactor: options.iconButtonFactor,
iconData: iconData,
iconSize: iconSize,
tooltip: tooltip,
iconTheme: iconTheme,
),
QuillToolbarToggleStyleButtonExtraOptions(
context: context,
controller: controller,
Expand Down

0 comments on commit aabd9f2

Please sign in to comment.