|
|
|
@ -6,12 +6,12 @@ import '../models/themes/quill_custom_button.dart'; |
|
|
|
|
import '../models/themes/quill_dialog_theme.dart'; |
|
|
|
|
import '../models/themes/quill_icon_theme.dart'; |
|
|
|
|
import '../translations/toolbar.i18n.dart'; |
|
|
|
|
import '../utils/font.dart'; |
|
|
|
|
import 'controller.dart'; |
|
|
|
|
import 'embeds.dart'; |
|
|
|
|
import 'toolbar/arrow_indicated_button_list.dart'; |
|
|
|
|
import 'toolbar/clear_format_button.dart'; |
|
|
|
|
import 'toolbar/color_button.dart'; |
|
|
|
|
import 'toolbar/enum.dart'; |
|
|
|
|
import 'toolbar/history_button.dart'; |
|
|
|
|
import 'toolbar/indent_button.dart'; |
|
|
|
|
import 'toolbar/link_style_button.dart'; |
|
|
|
@ -29,32 +29,39 @@ export 'toolbar/color_button.dart'; |
|
|
|
|
export 'toolbar/history_button.dart'; |
|
|
|
|
export 'toolbar/indent_button.dart'; |
|
|
|
|
export 'toolbar/link_style_button.dart'; |
|
|
|
|
export 'toolbar/quill_font_family_button.dart'; |
|
|
|
|
export 'toolbar/quill_font_size_button.dart'; |
|
|
|
|
export 'toolbar/quill_icon_button.dart'; |
|
|
|
|
export 'toolbar/search_button.dart'; |
|
|
|
|
export 'toolbar/select_alignment_button.dart'; |
|
|
|
|
export 'toolbar/select_header_style_button.dart'; |
|
|
|
|
export 'toolbar/toggle_check_list_button.dart'; |
|
|
|
|
export 'toolbar/toggle_style_button.dart'; |
|
|
|
|
|
|
|
|
|
// The default size of the icon of a button. |
|
|
|
|
/// The default size of the icon of a button. |
|
|
|
|
const double kDefaultIconSize = 18; |
|
|
|
|
|
|
|
|
|
// The factor of how much larger the button is in relation to the icon. |
|
|
|
|
/// The factor of how much larger the button is in relation to the icon. |
|
|
|
|
const double kIconButtonFactor = 1.77; |
|
|
|
|
|
|
|
|
|
/// The horizontal margin between the contents of each toolbar section. |
|
|
|
|
const double kToolbarSectionSpacing = 4; |
|
|
|
|
|
|
|
|
|
class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
const QuillToolbar({ |
|
|
|
|
required this.children, |
|
|
|
|
this.axis = Axis.horizontal, |
|
|
|
|
this.toolbarSize = 36, |
|
|
|
|
this.toolbarSize = kDefaultIconSize * 2, |
|
|
|
|
this.toolbarSectionSpacing = kToolbarSectionSpacing, |
|
|
|
|
this.toolbarIconAlignment = WrapAlignment.center, |
|
|
|
|
this.toolbarIconCrossAlignment = WrapCrossAlignment.center, |
|
|
|
|
this.toolbarSectionSpacing = 4, |
|
|
|
|
this.multiRowsDisplay = true, |
|
|
|
|
this.color, |
|
|
|
|
this.customButtons = const [], |
|
|
|
|
this.locale, |
|
|
|
|
VoidCallback? afterButtonPressed, |
|
|
|
|
this.sectionDividerColor, |
|
|
|
|
this.sectionDividerSpace, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
@ -62,9 +69,10 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
required QuillController controller, |
|
|
|
|
Axis axis = Axis.horizontal, |
|
|
|
|
double toolbarIconSize = kDefaultIconSize, |
|
|
|
|
double toolbarSectionSpacing = 4, |
|
|
|
|
double toolbarSectionSpacing = kToolbarSectionSpacing, |
|
|
|
|
WrapAlignment toolbarIconAlignment = WrapAlignment.center, |
|
|
|
|
WrapCrossAlignment toolbarIconCrossAlignment = WrapCrossAlignment.center, |
|
|
|
|
bool multiRowsDisplay = true, |
|
|
|
|
bool showDividers = true, |
|
|
|
|
bool showFontFamily = true, |
|
|
|
|
bool showFontSize = true, |
|
|
|
@ -92,7 +100,6 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
bool showLink = true, |
|
|
|
|
bool showUndo = true, |
|
|
|
|
bool showRedo = true, |
|
|
|
|
bool multiRowsDisplay = true, |
|
|
|
|
bool showDirection = false, |
|
|
|
|
bool showSearchButton = true, |
|
|
|
|
List<QuillCustomButton> customButtons = const [], |
|
|
|
@ -117,12 +124,32 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
/// Is called after whatever logic the button performs has run. |
|
|
|
|
VoidCallback? afterButtonPressed, |
|
|
|
|
|
|
|
|
|
///Map of tooltips for toolbar buttons |
|
|
|
|
/// |
|
|
|
|
///The example is: |
|
|
|
|
///```dart |
|
|
|
|
/// tooltips = <ToolbarButtons, String>{ |
|
|
|
|
/// ToolbarButtons.undo: 'Undo', |
|
|
|
|
/// ToolbarButtons.redo: 'Redo', |
|
|
|
|
/// } |
|
|
|
|
/// |
|
|
|
|
///``` |
|
|
|
|
/// |
|
|
|
|
/// To disable tooltips just pass empty map as well. |
|
|
|
|
Map<ToolbarButtons, String>? tooltips, |
|
|
|
|
|
|
|
|
|
/// The locale to use for the editor toolbar, defaults to system locale |
|
|
|
|
/// More at https://github.com/singerdmx/flutter-quill#translation |
|
|
|
|
Locale? locale, |
|
|
|
|
|
|
|
|
|
/// The color of the toolbar |
|
|
|
|
Color? color, |
|
|
|
|
|
|
|
|
|
/// The color of the toolbar section divider |
|
|
|
|
Color? sectionDividerColor, |
|
|
|
|
|
|
|
|
|
/// The space occupied by toolbar divider |
|
|
|
|
double? sectionDividerSpace, |
|
|
|
|
Key? key, |
|
|
|
|
}) { |
|
|
|
|
final isButtonGroupShown = [ |
|
|
|
@ -172,6 +199,39 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
'Clear'.i18n: 'Clear' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//default button tooltips |
|
|
|
|
final buttonTooltips = tooltips ?? |
|
|
|
|
<ToolbarButtons, String>{ |
|
|
|
|
ToolbarButtons.undo: 'Undo'.i18n, |
|
|
|
|
ToolbarButtons.redo: 'Redo'.i18n, |
|
|
|
|
ToolbarButtons.fontFamily: 'Font family'.i18n, |
|
|
|
|
ToolbarButtons.fontSize: 'Font size'.i18n, |
|
|
|
|
ToolbarButtons.bold: 'Bold'.i18n, |
|
|
|
|
ToolbarButtons.italic: 'Italic'.i18n, |
|
|
|
|
ToolbarButtons.small: 'Small'.i18n, |
|
|
|
|
ToolbarButtons.underline: 'Underline'.i18n, |
|
|
|
|
ToolbarButtons.strikeThrough: 'Strike through'.i18n, |
|
|
|
|
ToolbarButtons.inlineCode: 'Inline code'.i18n, |
|
|
|
|
ToolbarButtons.color: 'Font color'.i18n, |
|
|
|
|
ToolbarButtons.backgroundColor: 'Background color'.i18n, |
|
|
|
|
ToolbarButtons.clearFormat: 'Clear format'.i18n, |
|
|
|
|
ToolbarButtons.leftAlignment: 'Align left'.i18n, |
|
|
|
|
ToolbarButtons.centerAlignment: 'Align center'.i18n, |
|
|
|
|
ToolbarButtons.rightAlignment: 'Align right'.i18n, |
|
|
|
|
ToolbarButtons.justifyAlignment: 'Justify win width'.i18n, |
|
|
|
|
ToolbarButtons.direction: 'Text direction'.i18n, |
|
|
|
|
ToolbarButtons.headerStyle: 'Header style'.i18n, |
|
|
|
|
ToolbarButtons.listNumbers: 'Numbered list'.i18n, |
|
|
|
|
ToolbarButtons.listBullets: 'Bullet list'.i18n, |
|
|
|
|
ToolbarButtons.listChecks: 'Checked list'.i18n, |
|
|
|
|
ToolbarButtons.codeBlock: 'Code block'.i18n, |
|
|
|
|
ToolbarButtons.quote: 'Quote'.i18n, |
|
|
|
|
ToolbarButtons.indentIncrease: 'Increase indent'.i18n, |
|
|
|
|
ToolbarButtons.indentDecrease: 'Decrease indent'.i18n, |
|
|
|
|
ToolbarButtons.link: 'Insert URL'.i18n, |
|
|
|
|
ToolbarButtons.search: 'Search'.i18n, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return QuillToolbar( |
|
|
|
|
key: key, |
|
|
|
|
axis: axis, |
|
|
|
@ -189,6 +249,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
HistoryButton( |
|
|
|
|
icon: Icons.undo_outlined, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.undo], |
|
|
|
|
controller: controller, |
|
|
|
|
undo: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -198,6 +259,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
HistoryButton( |
|
|
|
|
icon: Icons.redo_outlined, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.redo], |
|
|
|
|
controller: controller, |
|
|
|
|
undo: false, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -207,23 +269,9 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
QuillFontFamilyButton( |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.fontFamily], |
|
|
|
|
attribute: Attribute.font, |
|
|
|
|
controller: controller, |
|
|
|
|
items: [ |
|
|
|
|
for (MapEntry<String, String> fontFamily in fontFamilies.entries) |
|
|
|
|
PopupMenuItem<String>( |
|
|
|
|
key: ValueKey(fontFamily.key), |
|
|
|
|
value: fontFamily.value, |
|
|
|
|
child: Text(fontFamily.key.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: |
|
|
|
|
fontFamily.value == 'Clear' ? Colors.red : null)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
onSelected: (newFont) { |
|
|
|
|
controller.formatSelection(Attribute.fromKeyValue( |
|
|
|
|
'font', newFont == 'Clear' ? null : newFont)); |
|
|
|
|
}, |
|
|
|
|
rawItemsMap: fontFamilies, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
|
), |
|
|
|
@ -231,22 +279,9 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
QuillFontSizeButton( |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.fontSize], |
|
|
|
|
attribute: Attribute.size, |
|
|
|
|
controller: controller, |
|
|
|
|
items: [ |
|
|
|
|
for (MapEntry<String, String> fontSize in fontSizes.entries) |
|
|
|
|
PopupMenuItem<String>( |
|
|
|
|
key: ValueKey(fontSize.key), |
|
|
|
|
value: fontSize.value, |
|
|
|
|
child: Text(fontSize.key.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: fontSize.value == '0' ? Colors.red : null)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
onSelected: (newSize) { |
|
|
|
|
controller.formatSelection(Attribute.fromKeyValue( |
|
|
|
|
'size', newSize == '0' ? null : getFontSize(newSize))); |
|
|
|
|
}, |
|
|
|
|
rawItemsMap: fontSizes, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
|
), |
|
|
|
@ -255,6 +290,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.bold, |
|
|
|
|
icon: Icons.format_bold, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.bold], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -264,6 +300,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.italic, |
|
|
|
|
icon: Icons.format_italic, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.italic], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -273,6 +310,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.small, |
|
|
|
|
icon: Icons.format_size, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.small], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -282,6 +320,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.underline, |
|
|
|
|
icon: Icons.format_underline, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.underline], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -291,6 +330,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.strikeThrough, |
|
|
|
|
icon: Icons.format_strikethrough, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.strikeThrough], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -300,6 +340,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
attribute: Attribute.inlineCode, |
|
|
|
|
icon: Icons.code, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.inlineCode], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -308,6 +349,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ColorButton( |
|
|
|
|
icon: Icons.color_lens, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.color], |
|
|
|
|
controller: controller, |
|
|
|
|
background: false, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -317,6 +359,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ColorButton( |
|
|
|
|
icon: Icons.format_color_fill, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.backgroundColor], |
|
|
|
|
controller: controller, |
|
|
|
|
background: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -326,6 +369,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
ClearFormatButton( |
|
|
|
|
icon: Icons.format_clear, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.clearFormat], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
@ -340,10 +384,18 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
isButtonGroupShown[3] || |
|
|
|
|
isButtonGroupShown[4] || |
|
|
|
|
isButtonGroupShown[5])) |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
AxisDivider(axis, |
|
|
|
|
color: sectionDividerColor, space: sectionDividerSpace), |
|
|
|
|
if (showAlignmentButtons) |
|
|
|
|
SelectAlignmentButton( |
|
|
|
|
controller: controller, |
|
|
|
|
tooltips: Map.of(buttonTooltips) |
|
|
|
|
..removeWhere((key, value) => ![ |
|
|
|
|
ToolbarButtons.leftAlignment, |
|
|
|
|
ToolbarButtons.centerAlignment, |
|
|
|
|
ToolbarButtons.rightAlignment, |
|
|
|
|
ToolbarButtons.justifyAlignment, |
|
|
|
|
].contains(key)), |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
showLeftAlignment: showLeftAlignment, |
|
|
|
@ -355,6 +407,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showDirection) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.rtl, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.direction], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_textdirection_r_to_l, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -367,9 +420,11 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
isButtonGroupShown[3] || |
|
|
|
|
isButtonGroupShown[4] || |
|
|
|
|
isButtonGroupShown[5])) |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
AxisDivider(axis, |
|
|
|
|
color: sectionDividerColor, space: sectionDividerSpace), |
|
|
|
|
if (showHeaderStyle) |
|
|
|
|
SelectHeaderStyleButton( |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.headerStyle], |
|
|
|
|
controller: controller, |
|
|
|
|
axis: axis, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -382,10 +437,12 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
(isButtonGroupShown[3] || |
|
|
|
|
isButtonGroupShown[4] || |
|
|
|
|
isButtonGroupShown[5])) |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
AxisDivider(axis, |
|
|
|
|
color: sectionDividerColor, space: sectionDividerSpace), |
|
|
|
|
if (showListNumbers) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.ol, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listNumbers], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_list_numbered, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -395,6 +452,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showListBullets) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.ul, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listBullets], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_list_bulleted, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -404,6 +462,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showListCheck) |
|
|
|
|
ToggleCheckListButton( |
|
|
|
|
attribute: Attribute.unchecked, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.listChecks], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.check_box, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -413,6 +472,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showCodeBlock) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.codeBlock, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.codeBlock], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.code, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -422,10 +482,12 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
if (showDividers && |
|
|
|
|
isButtonGroupShown[3] && |
|
|
|
|
(isButtonGroupShown[4] || isButtonGroupShown[5])) |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
AxisDivider(axis, |
|
|
|
|
color: sectionDividerColor, space: sectionDividerSpace), |
|
|
|
|
if (showQuote) |
|
|
|
|
ToggleStyleButton( |
|
|
|
|
attribute: Attribute.blockQuote, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.quote], |
|
|
|
|
controller: controller, |
|
|
|
|
icon: Icons.format_quote, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
@ -436,6 +498,7 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
IndentButton( |
|
|
|
|
icon: Icons.format_indent_increase, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.indentIncrease], |
|
|
|
|
controller: controller, |
|
|
|
|
isIncrease: true, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -445,15 +508,18 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
IndentButton( |
|
|
|
|
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]) |
|
|
|
|
_dividerOnAxis(axis), |
|
|
|
|
AxisDivider(axis, |
|
|
|
|
color: sectionDividerColor, space: sectionDividerSpace), |
|
|
|
|
if (showLink) |
|
|
|
|
LinkStyleButton( |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.link], |
|
|
|
|
controller: controller, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
@ -464,19 +530,23 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
SearchButton( |
|
|
|
|
icon: Icons.search, |
|
|
|
|
iconSize: toolbarIconSize, |
|
|
|
|
tooltip: buttonTooltips[ToolbarButtons.search], |
|
|
|
|
controller: controller, |
|
|
|
|
iconTheme: iconTheme, |
|
|
|
|
dialogTheme: dialogTheme, |
|
|
|
|
afterButtonPressed: afterButtonPressed, |
|
|
|
|
), |
|
|
|
|
if (customButtons.isNotEmpty) |
|
|
|
|
if (showDividers) _dividerOnAxis(axis), |
|
|
|
|
if (showDividers) |
|
|
|
|
AxisDivider(axis, |
|
|
|
|
color: sectionDividerColor, space: sectionDividerSpace), |
|
|
|
|
for (var customButton in customButtons) |
|
|
|
|
QuillIconButton( |
|
|
|
|
highlightElevation: 0, |
|
|
|
|
hoverElevation: 0, |
|
|
|
|
size: toolbarIconSize * kIconButtonFactor, |
|
|
|
|
icon: Icon(customButton.icon, size: toolbarIconSize), |
|
|
|
|
tooltip: customButton.tooltip, |
|
|
|
|
borderRadius: iconTheme?.borderRadius ?? 2, |
|
|
|
|
onPressed: customButton.onTap, |
|
|
|
|
afterPressed: afterButtonPressed, |
|
|
|
@ -485,22 +555,6 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Widget _dividerOnAxis(Axis axis) { |
|
|
|
|
if (axis == Axis.horizontal) { |
|
|
|
|
return const VerticalDivider( |
|
|
|
|
indent: 12, |
|
|
|
|
endIndent: 12, |
|
|
|
|
color: Colors.grey, |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
return const Divider( |
|
|
|
|
indent: 12, |
|
|
|
|
endIndent: 12, |
|
|
|
|
color: Colors.grey, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final List<Widget> children; |
|
|
|
|
final Axis axis; |
|
|
|
|
final double toolbarSize; |
|
|
|
@ -522,6 +576,15 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
/// List of custom buttons |
|
|
|
|
final List<QuillCustomButton> customButtons; |
|
|
|
|
|
|
|
|
|
/// The color to use when painting the toolbar section divider. |
|
|
|
|
/// |
|
|
|
|
/// If this is null, then the [DividerThemeData.color] is used. If that is |
|
|
|
|
/// also null, then [ThemeData.dividerColor] is used. |
|
|
|
|
final Color? sectionDividerColor; |
|
|
|
|
|
|
|
|
|
/// The space occupied by toolbar section divider. |
|
|
|
|
final double? sectionDividerSpace; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Size get preferredSize => axis == Axis.horizontal |
|
|
|
|
? Size.fromHeight(toolbarSize) |
|
|
|
@ -554,3 +617,39 @@ class QuillToolbar extends StatelessWidget implements PreferredSizeWidget { |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class AxisDivider extends StatelessWidget { |
|
|
|
|
const AxisDivider( |
|
|
|
|
this.axis, { |
|
|
|
|
Key? key, |
|
|
|
|
this.color, |
|
|
|
|
this.space, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
|
const AxisDivider.horizontal({Color? color, double? space}) |
|
|
|
|
: this(Axis.horizontal, color: color, space: space); |
|
|
|
|
|
|
|
|
|
const AxisDivider.vertical({Color? color, double? space}) |
|
|
|
|
: this(Axis.vertical, color: color, space: space); |
|
|
|
|
|
|
|
|
|
final Axis axis; |
|
|
|
|
final Color? color; |
|
|
|
|
final double? space; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return axis == Axis.horizontal |
|
|
|
|
? Divider( |
|
|
|
|
height: space, |
|
|
|
|
color: color, |
|
|
|
|
indent: 12, |
|
|
|
|
endIndent: 12, |
|
|
|
|
) |
|
|
|
|
: VerticalDivider( |
|
|
|
|
width: space, |
|
|
|
|
color: color, |
|
|
|
|
indent: 12, |
|
|
|
|
endIndent: 12, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|