docs: Update the custom toolbar example

pull/1564/head
Ellet 1 year ago
parent 6830f8c661
commit aabd9f2fa5
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 28
      example/lib/presentation/quill/quill_toolbar.dart
  2. 20
      lib/src/models/config/toolbar/buttons/base.dart
  3. 1
      lib/src/models/config/toolbar/buttons/toggle_style.dart
  4. 11
      lib/src/widgets/toolbar/buttons/toggle_style.dart

@ -102,6 +102,11 @@ class MyQuillToolbar extends StatelessWidget {
configurations: QuillBaseToolbarConfigurations( configurations: QuillBaseToolbarConfigurations(
toolbarSize: 15 * 2, toolbarSize: 15 * 2,
multiRowsDisplay: false, multiRowsDisplay: false,
buttonOptions: const QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
globalIconSize: 30,
),
),
childrenBuilder: (context) { childrenBuilder: (context) {
final controller = context.requireQuillController; final controller = context.requireQuillController;
return [ return [
@ -122,9 +127,19 @@ class MyQuillToolbar extends StatelessWidget {
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
attribute: Attribute.bold, attribute: Attribute.bold,
controller: controller, controller: controller,
options: const QuillToolbarToggleStyleButtonOptions( options: QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_bold, childBuilder: (options, extraOptions) {
iconSize: 20, if (extraOptions.isToggled) {
return IconButton.filled(
onPressed: extraOptions.onPressed,
icon: Icon(options.iconData),
);
}
return IconButton(
onPressed: extraOptions.onPressed,
icon: Icon(options.iconData),
);
},
), ),
), ),
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
@ -132,7 +147,6 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller, controller: controller,
options: const QuillToolbarToggleStyleButtonOptions( options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_italic, iconData: Icons.format_italic,
iconSize: 20,
), ),
), ),
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
@ -147,7 +161,6 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller, controller: controller,
options: const QuillToolbarClearFormatButtonOptions( options: const QuillToolbarClearFormatButtonOptions(
iconData: Icons.format_clear, iconData: Icons.format_clear,
iconSize: 20,
), ),
), ),
VerticalDivider( VerticalDivider(
@ -166,7 +179,7 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller, controller: controller,
options: const QuillToolbarToggleStyleButtonOptions( options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_list_numbered, iconData: Icons.format_list_numbered,
iconSize: 20, iconSize: 39,
), ),
), ),
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
@ -174,7 +187,6 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller, controller: controller,
options: const QuillToolbarToggleStyleButtonOptions( options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_list_bulleted, iconData: Icons.format_list_bulleted,
iconSize: 20,
), ),
), ),
QuillToolbarToggleStyleButton( QuillToolbarToggleStyleButton(
@ -182,7 +194,7 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller, controller: controller,
options: const QuillToolbarToggleStyleButtonOptions( options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_quote, iconData: Icons.format_quote,
iconSize: 20, iconSize: 15,
), ),
), ),
VerticalDivider( VerticalDivider(

@ -90,26 +90,6 @@ class QuillToolbarBaseButtonOptions<T, I> extends Equatable {
childBuilder, childBuilder,
controller, 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( typedef QuillToolbarButtonOptionsChildBuilder<T, I> = Widget Function(

@ -1,3 +1,4 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter/foundation.dart' show immutable; import 'package:flutter/foundation.dart' show immutable;
import 'package:flutter/widgets.dart' show Color; import 'package:flutter/widgets.dart' show Color;

@ -146,7 +146,16 @@ class QuillToolbarToggleStyleButtonState
context.requireQuillToolbarBaseButtonOptions.childBuilder; context.requireQuillToolbarBaseButtonOptions.childBuilder;
if (childBuilder != null) { if (childBuilder != null) {
return childBuilder( return childBuilder(
options, QuillToolbarToggleStyleButtonOptions(
afterButtonPressed: options.afterButtonPressed,
controller: controller,
fillColor: options.fillColor,
iconButtonFactor: options.iconButtonFactor,
iconData: iconData,
iconSize: iconSize,
tooltip: tooltip,
iconTheme: iconTheme,
),
QuillToolbarToggleStyleButtonExtraOptions( QuillToolbarToggleStyleButtonExtraOptions(
context: context, context: context,
controller: controller, controller: controller,

Loading…
Cancel
Save