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(
toolbarSize: 15 * 2,
multiRowsDisplay: false,
buttonOptions: const QuillToolbarButtonOptions(
base: QuillToolbarBaseButtonOptions(
globalIconSize: 30,
),
),
childrenBuilder: (context) {
final controller = context.requireQuillController;
return [
@ -122,9 +127,19 @@ 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(
@ -132,7 +147,6 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_italic,
iconSize: 20,
),
),
QuillToolbarToggleStyleButton(
@ -147,7 +161,6 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller,
options: const QuillToolbarClearFormatButtonOptions(
iconData: Icons.format_clear,
iconSize: 20,
),
),
VerticalDivider(
@ -166,7 +179,7 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_list_numbered,
iconSize: 20,
iconSize: 39,
),
),
QuillToolbarToggleStyleButton(
@ -174,7 +187,6 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_list_bulleted,
iconSize: 20,
),
),
QuillToolbarToggleStyleButton(
@ -182,7 +194,7 @@ class MyQuillToolbar extends StatelessWidget {
controller: controller,
options: const QuillToolbarToggleStyleButtonOptions(
iconData: Icons.format_quote,
iconSize: 20,
iconSize: 15,
),
),
VerticalDivider(

@ -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(

@ -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;

@ -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,

Loading…
Cancel
Save