// ignore_for_file: public_member_api_docs, sort_constructors_first import 'package:equatable/equatable.dart'; import 'package:flutter/foundation.dart' show immutable; import 'package:flutter/widgets.dart' show Axis, WrapAlignment, WrapCrossAlignment; import '../../../widgets/quill/embeds.dart'; import '../../../widgets/quill/quill_controller.dart'; import '../../themes/quill_dialog_theme.dart'; import '../../themes/quill_icon_theme.dart'; import 'base_button_configurations.dart'; import 'buttons/clear_format_configurations.dart'; import 'buttons/color_configurations.dart'; import 'buttons/custom_button_configurations.dart'; import 'buttons/font_family_configurations.dart'; import 'buttons/font_size_configurations.dart'; import 'buttons/history_configurations.dart'; import 'buttons/indent_configurations.dart'; import 'buttons/link_style2_configurations.dart'; import 'buttons/link_style_configurations.dart'; import 'buttons/search_configurations.dart'; import 'buttons/select_alignment_configurations.dart'; import 'buttons/select_header_style_button_configurations.dart'; import 'buttons/select_header_style_buttons_configurations.dart'; import 'buttons/toggle_check_list_configurations.dart'; import 'buttons/toggle_style_configurations.dart'; import 'toolbar_shared_configurations.dart'; export './../../../widgets/toolbar/buttons/search/search_dialog.dart'; export 'base_button_configurations.dart'; export 'buttons/clear_format_configurations.dart'; export 'buttons/color_configurations.dart'; export 'buttons/custom_button_configurations.dart'; export 'buttons/font_family_configurations.dart'; export 'buttons/font_size_configurations.dart'; export 'buttons/history_configurations.dart'; export 'buttons/indent_configurations.dart'; export 'buttons/link_style2_configurations.dart'; export 'buttons/link_style_configurations.dart'; export 'buttons/search_configurations.dart'; export 'buttons/select_alignment_configurations.dart'; export 'buttons/select_header_style_buttons_configurations.dart'; export 'buttons/toggle_check_list_configurations.dart'; export 'buttons/toggle_style_configurations.dart'; /// The default size of the icon of a button. const double kDefaultIconSize = 15; /// The default size for the toolbar (width, height) const double defaultToolbarSize = kDefaultIconSize * 2; /// The factor of how much larger the button is in relation to the icon. const double kIconButtonFactor = 1.6; /// The horizontal margin between the contents of each toolbar section. const double kToolbarSectionSpacing = 4; enum LinkStyleType { /// Defines the original [QuillToolbarLinkStyleButton]. original, /// Defines the alternative [QuillToolbarLinkStyleButton2]. alternative; bool get isOriginal => this == LinkStyleType.original; bool get isAlternative => this == LinkStyleType.alternative; } /// The configurations for the toolbar widget of flutter quill @immutable class QuillSimpleToolbarConfigurations extends QuillSharedToolbarProperties { const QuillSimpleToolbarConfigurations({ required this.controller, super.sharedConfigurations, super.toolbarSectionSpacing = kToolbarSectionSpacing, super.toolbarIconAlignment = WrapAlignment.center, super.toolbarIconCrossAlignment = WrapCrossAlignment.center, super.buttonOptions = const QuillToolbarButtonOptions(), this.customButtons = const [], this.fontFamilyValues, super.multiRowsDisplay = true, this.fontSizesValues, this.showDividers = true, this.showFontFamily = true, this.showFontSize = true, this.showBoldButton = true, this.showItalicButton = true, this.showSmallButton = false, this.showUnderLineButton = true, this.showStrikeThrough = true, this.showInlineCode = true, this.showColorButton = true, this.showBackgroundColorButton = true, this.showClearFormat = true, this.showAlignmentButtons = false, this.showLeftAlignment = true, this.showCenterAlignment = true, this.showRightAlignment = true, this.showJustifyAlignment = true, this.showHeaderStyle = true, this.showListNumbers = true, this.showListBullets = true, this.showListCheck = true, this.showCodeBlock = true, this.showQuote = true, this.showIndent = true, this.showLink = true, this.showUndo = true, this.showRedo = true, this.showDirection = false, this.showSearchButton = true, this.showSubscript = true, this.showSuperscript = true, this.linkStyleType = LinkStyleType.original, /// The decoration to use for the toolbar. super.decoration, /// Toolbar items to display for controls of embed blocks this.embedButtons, super.linkDialogAction, ///The theme to use for the icons in the toolbar, uses type [QuillIconTheme] // this.iconTheme, this.dialogTheme, super.axis = Axis.horizontal, super.color, super.sectionDividerColor, super.sectionDividerSpace, /// By default it will calculated based on the [globalIconSize] from /// [base] in [QuillToolbarButtonOptions] /// You can change it but the the change only apply if /// the [multiRowsDisplay] is false, if [multiRowsDisplay] then the value /// will be [kDefaultIconSize] * 2 super.toolbarSize, }) : _toolbarSize = toolbarSize; final double? _toolbarSize; /// The toolbar size, by default it will be `baseButtonOptions.iconSize * 2` @override double get toolbarSize { final alternativeToolbarSize = _toolbarSize; if (alternativeToolbarSize != null) { return alternativeToolbarSize; } return buttonOptions.base.globalIconSize * 2; } final Map? fontFamilyValues; final QuillController controller; /// By default it will be /// ``` /// { /// 'Small'.i18n: 'small', /// 'Large'.i18n: 'large', /// 'Huge'.i18n: 'huge', /// 'Clear'.loc: '0' /// } /// ``` final Map? fontSizesValues; /// List of custom buttons final List customButtons; final bool showDividers; final bool showFontFamily; final bool showFontSize; final bool showBoldButton; final bool showItalicButton; final bool showSmallButton; final bool showUnderLineButton; final bool showStrikeThrough; final bool showInlineCode; final bool showColorButton; final bool showBackgroundColorButton; final bool showClearFormat; final bool showAlignmentButtons; final bool showLeftAlignment; final bool showCenterAlignment; final bool showRightAlignment; final bool showJustifyAlignment; final bool showHeaderStyle; final bool showListNumbers; final bool showListBullets; final bool showListCheck; final bool showCodeBlock; final bool showQuote; final bool showIndent; final bool showLink; final bool showUndo; final bool showRedo; final bool showDirection; final bool showSearchButton; final bool showSubscript; final bool showSuperscript; /// Toolbar items to display for controls of embed blocks final List? embedButtons; // ///The theme to use for the icons in the toolbar, uses type [QuillIconTheme] // final QuillIconTheme? iconTheme; ///The theme to use for the theming of the [LinkDialog()], ///shown when embedding an image, for example final QuillDialogTheme? dialogTheme; /// Defines which dialog is used for applying link attribute. final LinkStyleType linkStyleType; @override List get props => [ buttonOptions, multiRowsDisplay, fontSizesValues, toolbarSize, axis, ]; } /// The configurations for the buttons of the toolbar widget of flutter quill @immutable class QuillToolbarButtonOptions extends Equatable { const QuillToolbarButtonOptions({ this.base = const QuillToolbarBaseButtonOptions(), this.undoHistory = const QuillToolbarHistoryButtonOptions(), this.redoHistory = const QuillToolbarHistoryButtonOptions(), this.fontFamily = const QuillToolbarFontFamilyButtonOptions(), this.fontSize = const QuillToolbarFontSizeButtonOptions(), this.bold = const QuillToolbarToggleStyleButtonOptions(), this.subscript = const QuillToolbarToggleStyleButtonOptions(), this.superscript = const QuillToolbarToggleStyleButtonOptions(), this.italic = const QuillToolbarToggleStyleButtonOptions(), this.small = const QuillToolbarToggleStyleButtonOptions(), this.underLine = const QuillToolbarToggleStyleButtonOptions(), this.strikeThrough = const QuillToolbarToggleStyleButtonOptions(), this.inlineCode = const QuillToolbarToggleStyleButtonOptions(), this.direction = const QuillToolbarToggleStyleButtonOptions(), this.listNumbers = const QuillToolbarToggleStyleButtonOptions(), this.listBullets = const QuillToolbarToggleStyleButtonOptions(), this.codeBlock = const QuillToolbarToggleStyleButtonOptions(), this.quote = const QuillToolbarToggleStyleButtonOptions(), this.toggleCheckList = const QuillToolbarToggleCheckListButtonOptions(), this.indentIncrease = const QuillToolbarIndentButtonOptions(), this.indentDecrease = const QuillToolbarIndentButtonOptions(), this.color = const QuillToolbarColorButtonOptions(), this.backgroundColor = const QuillToolbarColorButtonOptions(), this.clearFormat = const QuillToolbarClearFormatButtonOptions(), this.selectAlignmentButtons = const QuillToolbarSelectAlignmentButtonOptions(), this.search = const QuillToolbarSearchButtonOptions(), this.selectHeaderStyleButtons = const QuillToolbarSelectHeaderStyleButtonsOptions(), this.selectHeaderStyleButton = const QuillToolbarSelectHeaderStyleButtonOptions(), this.linkStyle = const QuillToolbarLinkStyleButtonOptions(), this.linkStyle2 = const QuillToolbarLinkStyleButton2Options(), this.customButtons = const QuillToolbarCustomButtonOptions(), }); /// The base configurations for all the buttons which will apply to all /// but if the options overrided in the spesefic button options /// then it will use that instead final QuillToolbarBaseButtonOptions base; final QuillToolbarHistoryButtonOptions undoHistory; final QuillToolbarHistoryButtonOptions redoHistory; final QuillToolbarFontFamilyButtonOptions fontFamily; final QuillToolbarFontSizeButtonOptions fontSize; final QuillToolbarToggleStyleButtonOptions bold; final QuillToolbarToggleStyleButtonOptions subscript; final QuillToolbarToggleStyleButtonOptions superscript; final QuillToolbarToggleStyleButtonOptions italic; final QuillToolbarToggleStyleButtonOptions small; final QuillToolbarToggleStyleButtonOptions underLine; final QuillToolbarToggleStyleButtonOptions strikeThrough; final QuillToolbarToggleStyleButtonOptions inlineCode; final QuillToolbarToggleStyleButtonOptions direction; final QuillToolbarToggleStyleButtonOptions listNumbers; final QuillToolbarToggleStyleButtonOptions listBullets; final QuillToolbarToggleStyleButtonOptions codeBlock; final QuillToolbarToggleStyleButtonOptions quote; final QuillToolbarToggleCheckListButtonOptions toggleCheckList; final QuillToolbarIndentButtonOptions indentIncrease; final QuillToolbarIndentButtonOptions indentDecrease; final QuillToolbarColorButtonOptions color; final QuillToolbarColorButtonOptions backgroundColor; final QuillToolbarClearFormatButtonOptions clearFormat; /// The reason we call this buttons in the end because this is responsible /// for all the alignment buttons and not just one, you still /// can customize the icons and tooltips /// and you have child builder final QuillToolbarSelectAlignmentButtonOptions selectAlignmentButtons; final QuillToolbarSearchButtonOptions search; /// The reason we call this buttons in the end because this is responsible /// for all the header style buttons and not just one, you still /// can customize it and you also have child builder final QuillToolbarSelectHeaderStyleButtonsOptions selectHeaderStyleButtons; /// The reason we call this buttons in the end because this is responsible /// for all the header style buttons and not just one, you still /// can customize it and you also have child builder final QuillToolbarSelectHeaderStyleButtonOptions selectHeaderStyleButton; final QuillToolbarLinkStyleButtonOptions linkStyle; final QuillToolbarLinkStyleButton2Options linkStyle2; final QuillToolbarCustomButtonOptions customButtons; @override List get props => [ base, ]; }