File refactoring

pull/1575/head
Aleksei 1 year ago
parent 7f605048d1
commit 8bba105170
  1. 116
      lib/src/models/config/toolbar/buttons/dropdown_header_style.dart
  2. 20
      lib/src/models/config/toolbar/toolbar_configurations.dart
  3. 110
      lib/src/widgets/toolbar/buttons/dropdown_header_style.dart

@ -0,0 +1,116 @@
import 'package:flutter/material.dart';
import '../../../../widgets/controller.dart';
import '../../../documents/attribute.dart';
import '../../../themes/quill_icon_theme.dart';
import '../../quill_configurations.dart';
class QuillToolbarSelectHeaderStyleDropdownButtonExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarSelectHeaderStyleDropdownButtonExtraOptions({
required this.currentValue,
required super.controller,
required super.context,
required super.onPressed,
});
final Attribute currentValue;
}
class QuillToolbarSelectHeaderStyleDropdownButtonOptions
extends QuillToolbarBaseButtonOptions<
QuillToolbarSelectHeaderStyleDropdownButtonOptions,
QuillToolbarSelectHeaderStyleDropdownButtonExtraOptions> {
const QuillToolbarSelectHeaderStyleDropdownButtonOptions({
super.controller,
super.iconData,
super.afterButtonPressed,
super.tooltip,
super.iconTheme,
super.childBuilder,
this.iconSize,
this.iconButtonFactor,
this.fillColor,
this.hoverElevation = 1,
this.highlightElevation = 1,
this.rawItemsMap,
this.onSelected,
this.attributes,
this.padding,
this.style,
this.width,
this.initialValue,
this.labelOverflow = TextOverflow.visible,
this.itemHeight,
this.itemPadding,
this.defaultItemColor,
});
final double? iconSize;
final double? iconButtonFactor;
final Color? fillColor;
final double hoverElevation;
final double highlightElevation;
final Map<String, String>? rawItemsMap;
final ValueChanged<String>? onSelected;
final List<Attribute>? attributes;
final EdgeInsetsGeometry? padding;
final TextStyle? style;
final double? width;
final String? initialValue;
final TextOverflow labelOverflow;
final double? itemHeight;
final EdgeInsets? itemPadding;
final Color? defaultItemColor;
QuillToolbarSelectHeaderStyleDropdownButtonOptions copyWith({
Color? fillColor,
double? hoverElevation,
double? highlightElevation,
List<PopupMenuEntry<String>>? items,
Map<String, String>? rawItemsMap,
ValueChanged<String>? onSelected,
List<Attribute>? attributes,
EdgeInsetsGeometry? padding,
TextStyle? style,
double? width,
String? initialValue,
TextOverflow? labelOverflow,
bool? renderFontFamilies,
bool? overrideTooltipByFontFamily,
double? itemHeight,
EdgeInsets? itemPadding,
Color? defaultItemColor,
double? iconSize,
double? iconButtonFactor,
// Add properties to override inherited properties
QuillController? controller,
IconData? iconData,
VoidCallback? afterButtonPressed,
String? tooltip,
QuillIconTheme? iconTheme,
}) {
return QuillToolbarSelectHeaderStyleDropdownButtonOptions(
attributes: attributes ?? this.attributes,
rawItemsMap: rawItemsMap ?? this.rawItemsMap,
controller: controller ?? this.controller,
iconData: iconData ?? this.iconData,
afterButtonPressed: afterButtonPressed ?? this.afterButtonPressed,
tooltip: tooltip ?? this.tooltip,
iconTheme: iconTheme ?? this.iconTheme,
onSelected: onSelected ?? this.onSelected,
padding: padding ?? this.padding,
style: style ?? this.style,
width: width ?? this.width,
initialValue: initialValue ?? this.initialValue,
labelOverflow: labelOverflow ?? this.labelOverflow,
itemHeight: itemHeight ?? this.itemHeight,
itemPadding: itemPadding ?? this.itemPadding,
defaultItemColor: defaultItemColor ?? this.defaultItemColor,
iconSize: iconSize ?? this.iconSize,
iconButtonFactor: iconButtonFactor ?? this.iconButtonFactor,
fillColor: fillColor ?? this.fillColor,
hoverElevation: hoverElevation ?? this.hoverElevation,
highlightElevation: highlightElevation ?? this.highlightElevation,
);
}
}

@ -10,6 +10,7 @@ import 'buttons/base.dart';
import 'buttons/clear_format.dart';
import 'buttons/color.dart';
import 'buttons/custom_button.dart';
import 'buttons/dropdown_header_style.dart';
import 'buttons/font_family.dart';
import 'buttons/font_size.dart';
import 'buttons/history.dart';
@ -37,6 +38,7 @@ export './buttons/link_style2.dart';
export './buttons/search.dart';
export './buttons/select_alignment.dart';
export './buttons/select_header_style.dart';
export './buttons/dropdown_header_style.dart';
export './buttons/toggle_check_list.dart';
export './buttons/toggle_style.dart';
@ -63,6 +65,17 @@ enum LinkStyleType {
bool get isAlternative => this == LinkStyleType.alternative;
}
enum HeaderStyleType {
/// Defines the original [QuillToolbarSelectHeaderStyleButtons].
original,
/// Defines the alternative [QuillToolbarSelectHeaderStyleDropdownButton].
dropdown;
bool get isOriginal => this == HeaderStyleType.original;
bool get isDropdown => this == HeaderStyleType.dropdown;
}
/// The configurations for the toolbar widget of flutter quill
@immutable
class QuillToolbarConfigurations extends QuillSharedToolbarProperties {
@ -105,6 +118,7 @@ class QuillToolbarConfigurations extends QuillSharedToolbarProperties {
this.showSubscript = true,
this.showSuperscript = true,
this.linkStyleType = LinkStyleType.original,
this.headerStyleType = HeaderStyleType.original,
super.customButtons = const [],
/// The decoration to use for the toolbar.
@ -208,6 +222,9 @@ class QuillToolbarConfigurations extends QuillSharedToolbarProperties {
/// Defines which dialog is used for applying link attribute.
final LinkStyleType linkStyleType;
/// Defines which dialog is used for applying header attribute.
final HeaderStyleType headerStyleType;
@override
List<Object?> get props => [
buttonOptions,
@ -255,6 +272,8 @@ class QuillToolbarButtonOptions extends Equatable {
this.search = const QuillToolbarSearchButtonOptions(),
this.selectHeaderStyleButtons =
const QuillToolbarSelectHeaderStyleButtonsOptions(),
this.headerStyleButton =
const QuillToolbarSelectHeaderStyleDropdownButtonOptions(),
this.linkStyle = const QuillToolbarLinkStyleButtonOptions(),
this.linkStyle2 = const QuillToolbarLinkStyleButton2Options(),
this.customButtons = const QuillToolbarCustomButtonOptions(),
@ -300,6 +319,7 @@ class QuillToolbarButtonOptions extends Equatable {
/// for all the header style buttons and not just one, you still
/// can customize it and you also have child builder
final QuillToolbarSelectHeaderStyleButtonsOptions selectHeaderStyleButtons;
final QuillToolbarSelectHeaderStyleDropdownButtonOptions headerStyleButton;
final QuillToolbarLinkStyleButtonOptions linkStyle;
final QuillToolbarLinkStyleButton2Options linkStyle2;

@ -4,116 +4,6 @@ import '../../../../flutter_quill.dart';
import '../../../../translations.dart';
import '../../../utils/widgets.dart';
class QuillToolbarSelectHeaderStyleDropdownButtonExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarSelectHeaderStyleDropdownButtonExtraOptions({
required this.currentValue,
required super.controller,
required super.context,
required super.onPressed,
});
final Attribute currentValue;
}
class QuillToolbarSelectHeaderStyleDropdownButtonOptions
extends QuillToolbarBaseButtonOptions<
QuillToolbarSelectHeaderStyleDropdownButtonOptions,
QuillToolbarSelectHeaderStyleDropdownButtonExtraOptions> {
const QuillToolbarSelectHeaderStyleDropdownButtonOptions({
super.controller,
super.iconData,
super.afterButtonPressed,
super.tooltip,
super.iconTheme,
super.childBuilder,
this.iconSize,
this.iconButtonFactor,
this.fillColor,
this.hoverElevation = 1,
this.highlightElevation = 1,
this.rawItemsMap,
this.onSelected,
this.attributes,
this.padding,
this.style,
this.width,
this.initialValue,
this.labelOverflow = TextOverflow.visible,
this.itemHeight,
this.itemPadding,
this.defaultItemColor,
});
final double? iconSize;
final double? iconButtonFactor;
final Color? fillColor;
final double hoverElevation;
final double highlightElevation;
final Map<String, String>? rawItemsMap;
final ValueChanged<String>? onSelected;
final List<Attribute>? attributes;
final EdgeInsetsGeometry? padding;
final TextStyle? style;
final double? width;
final String? initialValue;
final TextOverflow labelOverflow;
final double? itemHeight;
final EdgeInsets? itemPadding;
final Color? defaultItemColor;
QuillToolbarSelectHeaderStyleDropdownButtonOptions copyWith({
Color? fillColor,
double? hoverElevation,
double? highlightElevation,
List<PopupMenuEntry<String>>? items,
Map<String, String>? rawItemsMap,
ValueChanged<String>? onSelected,
List<Attribute>? attributes,
EdgeInsetsGeometry? padding,
TextStyle? style,
double? width,
String? initialValue,
TextOverflow? labelOverflow,
bool? renderFontFamilies,
bool? overrideTooltipByFontFamily,
double? itemHeight,
EdgeInsets? itemPadding,
Color? defaultItemColor,
double? iconSize,
double? iconButtonFactor,
// Add properties to override inherited properties
QuillController? controller,
IconData? iconData,
VoidCallback? afterButtonPressed,
String? tooltip,
QuillIconTheme? iconTheme,
}) {
return QuillToolbarSelectHeaderStyleDropdownButtonOptions(
attributes: attributes ?? this.attributes,
rawItemsMap: rawItemsMap ?? this.rawItemsMap,
controller: controller ?? this.controller,
iconData: iconData ?? this.iconData,
afterButtonPressed: afterButtonPressed ?? this.afterButtonPressed,
tooltip: tooltip ?? this.tooltip,
iconTheme: iconTheme ?? this.iconTheme,
onSelected: onSelected ?? this.onSelected,
padding: padding ?? this.padding,
style: style ?? this.style,
width: width ?? this.width,
initialValue: initialValue ?? this.initialValue,
labelOverflow: labelOverflow ?? this.labelOverflow,
itemHeight: itemHeight ?? this.itemHeight,
itemPadding: itemPadding ?? this.itemPadding,
defaultItemColor: defaultItemColor ?? this.defaultItemColor,
iconSize: iconSize ?? this.iconSize,
iconButtonFactor: iconButtonFactor ?? this.iconButtonFactor,
fillColor: fillColor ?? this.fillColor,
hoverElevation: hoverElevation ?? this.hoverElevation,
highlightElevation: highlightElevation ?? this.highlightElevation,
);
}
}
class QuillToolbarSelectHeaderStyleDropdownButton extends StatefulWidget {
const QuillToolbarSelectHeaderStyleDropdownButton({
required this.controller,

Loading…
Cancel
Save