From fd9693e0eefcf1fb4c4bfae41d7543aea36e8f44 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 11 Jan 2024 15:54:55 +0000 Subject: [PATCH] quill refactor part 2 --- .github/workflows/pr.yml | 2 +- example/.gitignore | 1 - example/web/index.html | 4 + .../flutter/generated_plugin_registrant.cc | 3 - .../windows/flutter/generated_plugins.cmake | 1 - .../quill_editor/quill_editor_page.dart | 33 +- .../organisms/quill_editor/quill_toolbar.dart | 933 ++++++++++-------- 7 files changed, 536 insertions(+), 441 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6854f68..ba43168 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -46,7 +46,7 @@ jobs: ref: ${{ github.head_ref }} - uses: subosito/flutter-action@v2 with: - flutter-version: "3.13.x" + flutter-version: "3.16.x" channel: "stable" - name: Setup flutter run: flutter pub get diff --git a/example/.gitignore b/example/.gitignore index a8e938c..1eab1a2 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -33,7 +33,6 @@ migrate_working_dir/ /build/ # Web related -lib/generated_plugin_registrant.dart # Symbolication related app.*.symbols diff --git a/example/web/index.html b/example/web/index.html index 6a1b80b..4774245 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -13,6 +13,8 @@ * https://developer.mozilla.org/en-US/doc/Web/HTML/Element/base --> + @@ -31,6 +33,8 @@ + diff --git a/example/windows/flutter/generated_plugin_registrant.cc b/example/windows/flutter/generated_plugin_registrant.cc index 6c8aac7..3c20f2a 100644 --- a/example/windows/flutter/generated_plugin_registrant.cc +++ b/example/windows/flutter/generated_plugin_registrant.cc @@ -8,7 +8,6 @@ #include #include -#include #include #include @@ -17,8 +16,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("FileSelectorWindows")); IrondashEngineContextPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("IrondashEngineContextPluginCApi")); - PermissionHandlerWindowsPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); SuperNativeExtensionsPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("SuperNativeExtensionsPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake index 2187214..1e71556 100644 --- a/example/windows/flutter/generated_plugins.cmake +++ b/example/windows/flutter/generated_plugins.cmake @@ -5,7 +5,6 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_windows irondash_engine_context - permission_handler_windows super_native_extensions url_launcher_windows ) diff --git a/lib/src/components/organisms/quill_editor/quill_editor_page.dart b/lib/src/components/organisms/quill_editor/quill_editor_page.dart index 01147f2..bbc2e2d 100644 --- a/lib/src/components/organisms/quill_editor/quill_editor_page.dart +++ b/lib/src/components/organisms/quill_editor/quill_editor_page.dart @@ -9,6 +9,13 @@ import 'package:flutter_quill/quill_delta.dart'; import '../../../../zds_flutter.dart'; import 'quill_toolbar.dart'; +/// Default options for ZDS Quill Toolbar +final zdsQuillToolbarOptions = QuillToolbarOption.values.toSet() + ..remove(QuillToolbarOption.redo) + ..remove(QuillToolbarOption.undo) + ..remove(QuillToolbarOption.fontFamily) + ..remove(QuillToolbarOption.fontSize); + /// Represents a Quill editor page. class ZdsQuillEditorPage extends StatefulWidget { /// Constructs a [ZdsQuillEditorPage] with private constructor. @@ -20,7 +27,7 @@ class ZdsQuillEditorPage extends StatefulWidget { required this.readOnly, required this.showClearFormatAsFloating, this.quillToolbarPosition, - this.toolbarIconSize = 24, + this.toolbarIconSize = kDefaultIconSize, this.langCode, this.charLimit = 10000, this.placeholder = '', @@ -70,7 +77,7 @@ class ZdsQuillEditorPage extends StatefulWidget { int charLimit = 10000, bool readOnly = false, ZdsQuillDelta? initialDelta, - double toolbarIconSize = 24, + double toolbarIconSize = kDefaultIconSize, bool fullscreenDialog = true, bool showClearFormatAsFloating = true, Set? toolbarOptions, @@ -88,7 +95,7 @@ class ZdsQuillEditorPage extends StatefulWidget { toolbarIconSize: toolbarIconSize, quillToolbarPosition: quillToolbarPosition, showClearFormatAsFloating: showClearFormatAsFloating, - toolbarOptions: toolbarOptions ?? QuillToolbarOption.values.toSet(), + toolbarOptions: toolbarOptions ?? zdsQuillToolbarOptions, langCode: langCode ?? ComponentStrings.of(context).locale.toString(), initialDelta: initialDelta?.copyWith(document: initialDelta.document), ); @@ -376,9 +383,7 @@ class _ZdsQuillEditorState extends State with FrameCallbackM toolbarIconSize: widget.toolbarIconSize, quillToolbarPosition: widget.quillToolbarPosition, toolbarColor: Theme.of(context).colorScheme.surface, - toolbarOptions: {...widget.toolbarOptions} - ..remove(QuillToolbarOption.redo) - ..remove(QuillToolbarOption.undo), + toolbarOptions: {...widget.toolbarOptions}, ); } @@ -544,24 +549,14 @@ class _HistoryButtonState extends State<_HistoryButton> { widget.controller.changes.listen((quill.DocChange event) async { _setIconColor(); }); + return quill.QuillToolbarIconButton( - onPressed: _changeHistory, - icon: Icon( - widget.icon, - size: widget.iconSize * kIconButtonFactor, - color: _iconColor, - ), isSelected: false, iconTheme: const quill.QuillIconTheme(), + icon: Icon(widget.icon, size: widget.iconSize, color: _iconColor), + onPressed: _changeHistory, afterPressed: widget.afterPressed, ); - // return quill.QuillToolbarHistoryButton(controller: controller, isUndo: isUndo) - - // return quill.QuillIconButton( - // highlightElevation: 0, - // hoverElevation: 0, - // fillColor: Colors.transparent, - // ); } void _setIconColor() { diff --git a/lib/src/components/organisms/quill_editor/quill_toolbar.dart b/lib/src/components/organisms/quill_editor/quill_toolbar.dart index cf81b25..ad220e5 100644 --- a/lib/src/components/organisms/quill_editor/quill_toolbar.dart +++ b/lib/src/components/organisms/quill_editor/quill_toolbar.dart @@ -1,6 +1,12 @@ +// ignore_for_file: implementation_imports, public_member_api_docs + import 'package:flutter/material.dart'; import 'package:flutter_quill/flutter_quill.dart'; +import 'package:flutter_quill/src/widgets/toolbar/buttons/alignment/select_alignment_buttons.dart'; +import 'package:flutter_quill/src/widgets/toolbar/buttons/arrow_indicated_list_button.dart'; +import 'package:flutter_quill/translations.dart'; + /// enum for toolbar position /// /// above or below editor @@ -81,6 +87,40 @@ enum QuillToolbarOption { link, } +/// Options for Toolbar buttons +enum ToolbarButtons { + undo, + redo, + fontFamily, + fontSize, + bold, + subscript, + superscript, + italic, + small, + underline, + strikeThrough, + inlineCode, + color, + backgroundColor, + clearFormat, + centerAlignment, + leftAlignment, + rightAlignment, + justifyAlignment, + direction, + headerStyle, + listNumbers, + listBullets, + listChecks, + codeBlock, + quote, + indentIncrease, + indentDecrease, + link, + search, +} + /// The default size of the icon of a button. const double kDefaultIconSize = 18; @@ -98,21 +138,6 @@ class ZdsQuillToolbar extends QuillToolbar { super.configurations, required super.child, super.key, - // super.children = const [], - // super.axis, - // super.toolbarSize, - // super.toolbarSectionSpacing, - // super.toolbarIconAlignment, - // super.toolbarIconCrossAlignment, - // super.multiRowsDisplay, - // super.color, - // super.customButtons, - // super.locale, - // super.afterButtonPressed, - // super.sectionDividerColor, - // super.sectionDividerSpace, - // super.linkDialogAction, - // super.key, }) : super(); /// Custom constructor for [ZdsQuillToolbar] @@ -126,7 +151,7 @@ class ZdsQuillToolbar extends QuillToolbar { }) { final ColorScheme theme = Theme.of(context).colorScheme; return ZdsQuillToolbar.basic( - toolbarIconSize: toolbarIconSize ?? 24, + toolbarIconSize: toolbarIconSize ?? kDefaultIconSize, controller: controller, color: color, locale: (langCode?.isNotEmpty ?? false) ? Locale(langCode!.substring(0, 2)) : null, @@ -156,12 +181,29 @@ class ZdsQuillToolbar extends QuillToolbar { showSuperscript: false, showSearchButton: false, multiRowsDisplay: false, - iconTheme: const QuillIconTheme( - // size: widget.iconSize * kIconButtonFactor, - // iconSelectedFillColor: theme.secondary, - // iconUnselectedFillColor: theme.surface, - // iconUnselectedColor: theme.onSurface, + iconTheme: QuillIconTheme( + iconButtonUnselectedData: IconButtonData( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.resolveWith((states) { + return theme.surface; + }), + foregroundColor: MaterialStateProperty.resolveWith((states) { + return theme.onSurface; + }), ), + ), + iconButtonSelectedData: IconButtonData( + style: ButtonStyle( + iconSize: MaterialStateProperty.resolveWith((states) => toolbarIconSize), + backgroundColor: MaterialStateProperty.resolveWith((states) { + return theme.secondary; + }), + foregroundColor: MaterialStateProperty.resolveWith((states) { + return theme.onSecondary; + }), + ), + ), + ), ); } @@ -233,7 +275,7 @@ class ZdsQuillToolbar extends QuillToolbar { ///``` /// /// To disable tooltips just pass empty map as well. - Map? tooltips, + Map? tooltips, /// The locale to use for the editor toolbar, defaults to system locale /// More at https://github.com/singerdmx/flutter-quill#translation @@ -273,405 +315,464 @@ class ZdsQuillToolbar extends QuillToolbar { showLink || showSearchButton, ]; - // //default font size values - // final fontSizes = - // fontSizeValues ?? {'Small'.i18n: 'small', 'Large'.i18n: 'large', 'Huge'.i18n: 'huge', 'Clear'.i18n: '0'}; - // - // //default font family values - // final fontFamilies = fontFamilyValues ?? - // { - // 'Sans Serif': 'sans-serif', - // 'Serif': 'serif', - // 'Monospace': 'monospace', - // 'Ibarra Real Nova': 'ibarra-real-nova', - // 'SquarePeg': 'square-peg', - // 'Nunito': 'nunito', - // 'Pacifico': 'pacifico', - // 'Roboto Mono': 'roboto-mono', - // 'Clear'.i18n: 'Clear', - // }; - - //default button tooltips - // final Map buttonTooltips = tooltips ?? - // { - // QuillToolbarOption.undo: 'Undo'.i18n, - // QuillToolbarOption.redo: 'Redo'.i18n, - // QuillToolbarOption.fontFamily: 'Font family'.i18n, - // QuillToolbarOption.fontSize: 'Font size'.i18n, - // QuillToolbarOption.bold: 'Bold'.i18n, - // QuillToolbarOption.subscript: 'Subscript'.i18n, - // QuillToolbarOption.superscript: 'Superscript'.i18n, - // QuillToolbarOption.italic: 'Italic'.i18n, - // QuillToolbarOption.small: 'Small'.i18n, - // QuillToolbarOption.underline: 'Underline'.i18n, - // QuillToolbarOption.strikeThrough: 'Strike through'.i18n, - // QuillToolbarOption.inlineCode: 'Inline code'.i18n, - // QuillToolbarOption.color: 'Font color'.i18n, - // QuillToolbarOption.backgroundColor: 'Background color'.i18n, - // QuillToolbarOption.clearFormat: 'Clear format'.i18n, - // QuillToolbarOption.leftAlignment: 'Align left'.i18n, - // QuillToolbarOption.centerAlignment: 'Align center'.i18n, - // QuillToolbarOption.rightAlignment: 'Align right'.i18n, - // QuillToolbarOption.justifyAlignment: 'Justify win width'.i18n, - // QuillToolbarOption.direction: 'Text direction'.i18n, - // QuillToolbarOption.headerStyle: 'Header style'.i18n, - // QuillToolbarOption.listNumbers: 'Numbered list'.i18n, - // QuillToolbarOption.listBullets: 'Bullet list'.i18n, - // QuillToolbarOption.listChecks: 'Checked list'.i18n, - // QuillToolbarOption.codeBlock: 'Code block'.i18n, - // QuillToolbarOption.quote: 'Quote'.i18n, - // QuillToolbarOption.indentIncrease: 'Increase indent'.i18n, - // QuillToolbarOption.indentDecrease: 'Decrease indent'.i18n, - // QuillToolbarOption.link: 'Insert URL'.i18n, - // QuillToolbarOption.search: 'Search'.i18n, - // }; + final configurations = QuillSimpleToolbarConfigurations( + controller: controller, + axis: axis, + toolbarSize: toolbarIconSize * 3, + color: color, + toolbarSectionSpacing: toolbarSectionSpacing, + toolbarIconAlignment: toolbarIconAlignment, + toolbarIconCrossAlignment: toolbarIconCrossAlignment, + multiRowsDisplay: multiRowsDisplay, + ); + iconTheme ??= QuillIconTheme( + iconButtonSelectedData: IconButtonData( + iconSize: toolbarIconSize, + alignment: Alignment.topCenter, + ), + iconButtonUnselectedData: IconButtonData(iconSize: toolbarIconSize), + ); return ZdsQuillToolbar( + configurations: QuillToolbarConfigurations( + sharedConfigurations: QuillSharedConfigurations( + locale: locale, + ), + ), key: key, - // axis: axis, - // color: color, - // toolbarSize: toolbarIconSize * 2, - // toolbarSectionSpacing: toolbarSectionSpacing, - // toolbarIconAlignment: toolbarIconAlignment, - // toolbarIconCrossAlignment: toolbarIconCrossAlignment, - // multiRowsDisplay: multiRowsDisplay, - // customButtons: customButtons, - // locale: locale, - // afterButtonPressed: afterButtonPressed, - child: Row( - children: [ - if (showUndo) - QuillToolbarHistoryButton( - // icon: Icons.undo_outlined, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.undo], - controller: controller, - isUndo: true, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showRedo) ...[ - QuillToolbarHistoryButton( - // icon: Icons.redo_outlined, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.redo], - controller: controller, - isUndo: false, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showDividers) QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - ], - if (showHeaderStyle) ...[ - QuillToolbarSelectHeaderStyleButtons( - controller: controller, - // tooltip: buttonTooltips[ToolbarButtons.headerStyle], - // axis: axis, - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showDividers) QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - ], - if (showBoldButton) - QuillToolbarToggleStyleButton( - attribute: Attribute.bold, - // icon: Icons.format_bold, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.bold], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showSubscript) - QuillToolbarToggleStyleButton( - attribute: Attribute.subscript, - // icon: Icons.subscript, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.subscript], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showSuperscript) - QuillToolbarToggleStyleButton( - attribute: Attribute.superscript, - // icon: Icons.superscript, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.superscript], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showItalicButton) - QuillToolbarToggleStyleButton( - attribute: Attribute.italic, - // icon: Icons.format_italic, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.italic], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showUnderLineButton) - QuillToolbarToggleStyleButton( - attribute: Attribute.underline, - // icon: Icons.format_underline, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.underline], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showStrikeThrough) - QuillToolbarToggleStyleButton( - attribute: Attribute.strikeThrough, - // icon: Icons.format_strikethrough, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.strikeThrough], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showSmallButton) - QuillToolbarToggleStyleButton( - attribute: Attribute.small, - // icon: Icons.format_size, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.small], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showInlineCode) - QuillToolbarToggleStyleButton( - attribute: Attribute.inlineCode, - // icon: Icons.code, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.inlineCode], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showDividers) QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - if (showColorButton) - QuillToolbarColorButton( - // icon: Icons.color_lens, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.color], - controller: controller, - isBackground: false, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showBackgroundColorButton) - QuillToolbarColorButton( - // icon: Icons.format_color_fill, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.backgroundColor], - controller: controller, - isBackground: true, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showClearFormat) - QuillToolbarClearFormatButton( - // icon: Icons.format_clear, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.clearFormat], - controller: controller, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, + child: Builder( + builder: (context) { + // default button tooltips + final buttonTooltips = tooltips ?? + { + ToolbarButtons.undo: context.loc.undo, // 'Undo'.i18n, + ToolbarButtons.redo: context.loc.redo, + ToolbarButtons.fontFamily: context.loc.fontFamily, + ToolbarButtons.fontSize: context.loc.fontSize, + ToolbarButtons.bold: context.loc.bold, + ToolbarButtons.subscript: context.loc.subscript, + ToolbarButtons.superscript: context.loc.superscript, + ToolbarButtons.italic: context.loc.italic, + ToolbarButtons.small: context.loc.small, + ToolbarButtons.underline: context.loc.underline, + ToolbarButtons.strikeThrough: context.loc.strikeThrough, + ToolbarButtons.inlineCode: context.loc.inlineCode, + ToolbarButtons.color: context.loc.fontColor, + ToolbarButtons.backgroundColor: context.loc.backgroundColor, + ToolbarButtons.clearFormat: context.loc.clearFormat, + ToolbarButtons.leftAlignment: context.loc.alignLeft, + ToolbarButtons.centerAlignment: context.loc.alignCenter, + ToolbarButtons.rightAlignment: context.loc.alignRight, + ToolbarButtons.justifyAlignment: context.loc.justifyWinWidth, + ToolbarButtons.direction: context.loc.textDirection, + ToolbarButtons.headerStyle: context.loc.headerStyle, + ToolbarButtons.listNumbers: context.loc.numberedList, + ToolbarButtons.listBullets: context.loc.bulletList, + ToolbarButtons.listChecks: context.loc.checkedList, + ToolbarButtons.codeBlock: context.loc.codeBlock, + ToolbarButtons.quote: context.loc.quote, + ToolbarButtons.indentIncrease: context.loc.increaseIndent, + ToolbarButtons.indentDecrease: context.loc.decreaseIndent, + ToolbarButtons.link: context.loc.link, + ToolbarButtons.search: context.loc.search, + }; + return Container( + decoration: configurations.decoration ?? BoxDecoration(color: configurations.color), + constraints: BoxConstraints.tightFor( + height: configurations.axis == Axis.horizontal ? configurations.toolbarSize : null, + width: configurations.axis == Axis.vertical ? configurations.toolbarSize : null, ), - if (embedButtons != null) - for (final EmbedButtonBuilder builder in embedButtons) - builder(controller, toolbarIconSize, iconTheme, dialogTheme), - if (showDividers && - isButtonGroupShown[0] && - (isButtonGroupShown[1] || - isButtonGroupShown[2] || - isButtonGroupShown[3] || - isButtonGroupShown[4] || - isButtonGroupShown[5])) - QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - if (showAlignmentButtons) - QuillToolbarSelectAlignmentButton( - controller: controller, - // tooltips: Map.of(buttonTooltips) - // ..removeWhere( - // (ToolbarButtons key, String value) => ![ - // ToolbarButtons.leftAlignment, - // ToolbarButtons.centerAlignment, - // ToolbarButtons.rightAlignment, - // ToolbarButtons.justifyAlignment, - // ].contains(key), - // ), - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // showLeftAlignment: showLeftAlignment, - // showCenterAlignment: showCenterAlignment, - // showRightAlignment: showRightAlignment, - // showJustifyAlignment: showJustifyAlignment, - // afterButtonPressed: afterButtonPressed, - ), - if (showDirection) - QuillToolbarToggleStyleButton( - attribute: Attribute.rtl, - // tooltip: buttonTooltips[ToolbarButtons.direction], - controller: controller, - // icon: Icons.format_textdirection_r_to_l, - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showDividers && - isButtonGroupShown[1] && - (isButtonGroupShown[2] || isButtonGroupShown[3] || isButtonGroupShown[4] || isButtonGroupShown[5])) - QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - if (showDividers && - showHeaderStyle && - isButtonGroupShown[2] && - (isButtonGroupShown[3] || isButtonGroupShown[4] || isButtonGroupShown[5])) - QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - if (showListNumbers) - QuillToolbarToggleStyleButton( - attribute: Attribute.ol, - // tooltip: buttonTooltips[ToolbarButtons.listNumbers], - controller: controller, - // icon: Icons.format_list_numbered, - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showListBullets) - QuillToolbarToggleStyleButton( - attribute: Attribute.ul, - // tooltip: buttonTooltips[ToolbarButtons.listBullets], - controller: controller, - // icon: Icons.format_list_bulleted, - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showListCheck) - QuillToolbarToggleCheckListButton( - // attribute: Attribute.unchecked, - // tooltip: buttonTooltips[ToolbarButtons.listChecks], - controller: controller, - // icon: Icons.check_box, - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showCodeBlock) - QuillToolbarToggleStyleButton( - attribute: Attribute.codeBlock, - // tooltip: buttonTooltips[ToolbarButtons.codeBlock], - controller: controller, - // icon: Icons.code_off, - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showDividers && isButtonGroupShown[3] && (isButtonGroupShown[4] || isButtonGroupShown[5])) - QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - if (showQuote) - QuillToolbarToggleStyleButton( - attribute: Attribute.blockQuote, - // tooltip: buttonTooltips[ToolbarButtons.quote], - controller: controller, - // icon: Icons.format_quote, - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showIndent) - QuillToolbarIndentButton( - // icon: Icons.format_indent_increase, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.indentIncrease], - controller: controller, - isIncrease: true, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showIndent) - QuillToolbarIndentButton( - // icon: Icons.format_indent_decrease, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.indentDecrease], - controller: controller, - isIncrease: false, - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - ), - if (showDividers && isButtonGroupShown[4] && isButtonGroupShown[5]) - QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - if (showLink) - QuillToolbarLinkStyleButton( - // tooltip: buttonTooltips[ToolbarButtons.link], - controller: controller, - // iconSize: toolbarIconSize, - // iconTheme: iconTheme, - // dialogTheme: dialogTheme, - // afterButtonPressed: afterButtonPressed, - // linkRegExp: linkRegExp, - // linkDialogAction: linkDialogAction, - ), - if (showSearchButton) - QuillToolbarSearchButton( - // icon: Icons.search, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.search], - controller: controller, - // iconTheme: iconTheme, - // dialogTheme: dialogTheme, - // afterButtonPressed: afterButtonPressed, - ), - // if (showFontFamily) - // QuillFontFamilyButton( - // iconTheme: iconTheme, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.fontFamily], - // attribute: Attribute.font, - // controller: controller, - // rawItemsMap: fontFamilies, - // afterButtonPressed: afterButtonPressed, - // ), - // if (showFontSize) - // QuillFontSizeButton( - // iconTheme: iconTheme, - // iconSize: toolbarIconSize, - // tooltip: buttonTooltips[ToolbarButtons.fontSize], - // attribute: Attribute.size, - // controller: controller, - // rawItemsMap: fontSizes, - // afterButtonPressed: afterButtonPressed, - // ), - if (customButtons.isNotEmpty) - if (showDividers) QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), - for (final QuillToolbarCustomButton customButton in customButtons) - if (customButton != null) ...[ - InkWell( - // onTap: customButton.onTap, - // child: customButton.child, + child: QuillToolbarArrowIndicatedButtonList( + axis: Axis.horizontal, + buttons: [ + if (showUndo) + QuillToolbarHistoryButton( + controller: controller, + isUndo: true, + options: QuillToolbarHistoryButtonOptions( + iconButtonFactor: toolbarSectionSpacing, + iconData: Icons.undo_outlined, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.undo], + ), + ), + if (showRedo) ...[ + QuillToolbarHistoryButton( + controller: controller, + isUndo: false, + options: QuillToolbarHistoryButtonOptions( + iconData: Icons.redo_outlined, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.redo], + ), + ), + if (showDividers) QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + ], + if (showHeaderStyle) ...[ + QuillToolbarSelectHeaderStyleButtons( + controller: controller, + options: QuillToolbarSelectHeaderStyleButtonsOptions( + tooltip: buttonTooltips[ToolbarButtons.headerStyle], + axis: axis, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + ), + ), + if (showDividers) QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + ], + if (showBoldButton) + QuillToolbarToggleStyleButton( + attribute: Attribute.bold, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_bold, + iconSize: toolbarIconSize, + tooltip: buttonTooltips[ToolbarButtons.bold], + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + ), + ), + if (showSubscript) + QuillToolbarToggleStyleButton( + attribute: Attribute.subscript, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.subscript, + iconSize: toolbarIconSize, + tooltip: buttonTooltips[ToolbarButtons.subscript], + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + ), + ), + if (showSuperscript) + QuillToolbarToggleStyleButton( + attribute: Attribute.superscript, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.superscript, + iconSize: toolbarIconSize, + tooltip: buttonTooltips[ToolbarButtons.superscript], + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + ), + ), + if (showItalicButton) + QuillToolbarToggleStyleButton( + attribute: Attribute.italic, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_italic, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + tooltip: buttonTooltips[ToolbarButtons.italic], + afterButtonPressed: afterButtonPressed, + ), + ), + if (showUnderLineButton) + QuillToolbarToggleStyleButton( + attribute: Attribute.underline, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_underline, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + // tooltip: buttonTooltips[ToolbarButtons.underline], + ), + ), + if (showStrikeThrough) + QuillToolbarToggleStyleButton( + attribute: Attribute.strikeThrough, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_strikethrough, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.strikeThrough], + ), ), - ] else ...[ - QuillToolbarCustomButton( - controller: controller, - // options: QuillToolbarCustomButtonOptions( - // onPressed: customButton.onTap, - // icon: customButton.icon, - // // iconColor: customButton.iconColor, - // // iconSize: toolbarIconSize, - - // iconTheme: iconTheme, - // afterButtonPressed: afterButtonPressed, - // tooltip: customButton.tooltip, - // ), - ), - ], - ], + if (showSmallButton) + QuillToolbarToggleStyleButton( + attribute: Attribute.small, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_size, + iconSize: toolbarIconSize, + tooltip: buttonTooltips[ToolbarButtons.small], + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + ), + ), + if (showInlineCode) + QuillToolbarToggleStyleButton( + attribute: Attribute.inlineCode, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.code, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.inlineCode], + ), + ), + if (showDividers) QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + if (showColorButton) + QuillToolbarColorButton( + controller: controller, + isBackground: false, + options: QuillToolbarColorButtonOptions( + iconData: Icons.color_lens, + iconSize: toolbarIconSize, + tooltip: buttonTooltips[ToolbarButtons.color], + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + ), + ), + if (showBackgroundColorButton) + QuillToolbarColorButton( + controller: controller, + isBackground: true, + options: QuillToolbarColorButtonOptions( + iconData: Icons.format_color_fill, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.backgroundColor], + ), + ), + if (showClearFormat) + QuillToolbarClearFormatButton( + controller: controller, + options: QuillToolbarBaseButtonOptions( + iconData: Icons.format_clear, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.clearFormat], + ), + ), + if (embedButtons != null) + for (final EmbedButtonBuilder builder in embedButtons) + builder(controller, toolbarIconSize, iconTheme, dialogTheme), + if (showDividers && + isButtonGroupShown[0] && + (isButtonGroupShown[1] || + isButtonGroupShown[2] || + isButtonGroupShown[3] || + isButtonGroupShown[4] || + isButtonGroupShown[5])) + QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + if (showAlignmentButtons) + QuillToolbarSelectAlignmentButtons( + controller: controller, + options: QuillToolbarSelectAlignmentButtonOptions( + // tooltips: Map.of(buttonTooltips) + // ..removeWhere( + // (ToolbarButtons key, String value) => ![ + // ToolbarButtons.leftAlignment, + // ToolbarButtons.centerAlignment, + // ToolbarButtons.rightAlignment, + // ToolbarButtons.justifyAlignment, + // ].contains(key), + // ), + iconSize: toolbarIconSize, + iconTheme: iconTheme, + showLeftAlignment: showLeftAlignment, + showCenterAlignment: showCenterAlignment, + showRightAlignment: showRightAlignment, + showJustifyAlignment: showJustifyAlignment, + afterButtonPressed: afterButtonPressed, + ), + ), + if (showDirection) + QuillToolbarToggleStyleButton( + attribute: Attribute.rtl, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_textdirection_r_to_l, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.direction], + ), + ), + if (showDividers && + isButtonGroupShown[1] && + (isButtonGroupShown[2] || isButtonGroupShown[3] || isButtonGroupShown[4] || isButtonGroupShown[5])) + QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + if (showDividers && + showHeaderStyle && + isButtonGroupShown[2] && + (isButtonGroupShown[3] || isButtonGroupShown[4] || isButtonGroupShown[5])) + QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + if (showListNumbers) + QuillToolbarToggleStyleButton( + attribute: Attribute.ol, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_list_numbered, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.listNumbers], + ), + ), + if (showListBullets) + QuillToolbarToggleStyleButton( + attribute: Attribute.ul, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_list_bulleted, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.listBullets], + ), + ), + if (showListCheck) + QuillToolbarToggleCheckListButton( + controller: controller, + options: QuillToolbarToggleCheckListButtonOptions( + iconData: Icons.check_box, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.listChecks], + ), + ), + if (showCodeBlock) + QuillToolbarToggleStyleButton( + attribute: Attribute.codeBlock, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.code_off, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.codeBlock], + ), + ), + if (showDividers && isButtonGroupShown[3] && (isButtonGroupShown[4] || isButtonGroupShown[5])) + QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + if (showQuote) + QuillToolbarToggleStyleButton( + attribute: Attribute.blockQuote, + controller: controller, + options: QuillToolbarToggleStyleButtonOptions( + iconData: Icons.format_quote, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.quote], + ), + ), + if (showIndent) + QuillToolbarIndentButton( + controller: controller, + isIncrease: true, + options: QuillToolbarIndentButtonOptions( + iconData: Icons.format_indent_increase, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.indentIncrease], + ), + ), + if (showIndent) + QuillToolbarIndentButton( + controller: controller, + isIncrease: false, + options: QuillToolbarIndentButtonOptions( + iconData: Icons.format_indent_decrease, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.indentDecrease], + ), + ), + if (showDividers && isButtonGroupShown[4] && isButtonGroupShown[5]) + QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + if (showLink) + QuillToolbarLinkStyleButton( + controller: controller, + options: QuillToolbarLinkStyleButtonOptions( + iconSize: toolbarIconSize, + iconTheme: iconTheme, + dialogTheme: dialogTheme, + afterButtonPressed: afterButtonPressed, + linkRegExp: linkRegExp, + linkDialogAction: linkDialogAction, + tooltip: buttonTooltips[ToolbarButtons.link], + ), + ), + if (showSearchButton) + QuillToolbarSearchButton( + controller: controller, + options: QuillToolbarSearchButtonOptions( + iconData: Icons.search, + iconSize: toolbarIconSize, + iconTheme: iconTheme, + dialogTheme: dialogTheme, + afterButtonPressed: afterButtonPressed, + tooltip: buttonTooltips[ToolbarButtons.search], + ), + ), + if (showFontFamily) + QuillToolbarFontFamilyButton( + controller: controller, + options: QuillToolbarFontFamilyButtonOptions( + iconTheme: iconTheme, + iconSize: toolbarIconSize, + afterButtonPressed: afterButtonPressed, + // rawItemsMap: fontFamilies,TODO: + ), + ), + if (showFontSize) + QuillToolbarFontSizeButton( + controller: controller, + options: QuillToolbarFontSizeButtonOptions( + iconSize: toolbarIconSize, + afterButtonPressed: afterButtonPressed, + // iconTheme: iconTheme, + // rawItemsMap: fontSizes,TODO: + tooltip: buttonTooltips[ToolbarButtons.fontSize], + ), + ), + if (customButtons.isNotEmpty) + if (showDividers) QuillToolbarDivider(axis, color: sectionDividerColor, space: sectionDividerSpace), + for (final QuillToolbarCustomButton? customButton in customButtons) + if (customButton != null) ...[ + InkWell( + // onTap: customButton.onTap, + // child: customButton.child, + ), + ] else ...[ + // QuillToolbarCustomButton( + // controller: controller, + // options: customButton!.options, + + // // options: QuillToolbarCustomButtonOptions( + // // onPressed: customButton.onTap, + // // icon: customButton.icon, + // // // iconColor: customButton.iconColor, + // // // iconSize: toolbarIconSize, + + // // iconTheme: iconTheme, + // // afterButtonPressed: afterButtonPressed, + // // tooltip: customButton.tooltip, + // // ), + // ), + ], + ], + ), + ); + }, ), ); }