|
|
|
@ -9,11 +9,11 @@ import '../controller.dart'; |
|
|
|
|
|
|
|
|
|
class QuillFontFamilyButton extends StatefulWidget { |
|
|
|
|
const QuillFontFamilyButton({ |
|
|
|
|
required this.items, |
|
|
|
|
required this.rawItemsMap, |
|
|
|
|
required this.attribute, |
|
|
|
|
required this.controller, |
|
|
|
|
required this.onSelected, |
|
|
|
|
@Deprecated('It is not required because of `rawItemsMap`') this.items, |
|
|
|
|
this.onSelected, |
|
|
|
|
this.iconSize = 40, |
|
|
|
|
this.fillColor, |
|
|
|
|
this.hoverElevation = 1, |
|
|
|
@ -23,6 +23,8 @@ class QuillFontFamilyButton extends StatefulWidget { |
|
|
|
|
this.tooltip, |
|
|
|
|
this.padding, |
|
|
|
|
this.style, |
|
|
|
|
this.width, |
|
|
|
|
this.renderFontFamilies = true, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
@ -30,9 +32,10 @@ class QuillFontFamilyButton extends StatefulWidget { |
|
|
|
|
final Color? fillColor; |
|
|
|
|
final double hoverElevation; |
|
|
|
|
final double highlightElevation; |
|
|
|
|
final List<PopupMenuEntry<String>> items; |
|
|
|
|
@Deprecated('It is not required because of `rawItemsMap`') |
|
|
|
|
final List<PopupMenuEntry<String>>? items; |
|
|
|
|
final Map<String, String> rawItemsMap; |
|
|
|
|
final ValueChanged<String> onSelected; |
|
|
|
|
final ValueChanged<String>? onSelected; |
|
|
|
|
final QuillIconTheme? iconTheme; |
|
|
|
|
final Attribute attribute; |
|
|
|
|
final QuillController controller; |
|
|
|
@ -40,6 +43,8 @@ class QuillFontFamilyButton extends StatefulWidget { |
|
|
|
|
final String? tooltip; |
|
|
|
|
final EdgeInsetsGeometry? padding; |
|
|
|
|
final TextStyle? style; |
|
|
|
|
final double? width; |
|
|
|
|
final bool renderFontFamilies; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
_QuillFontFamilyButtonState createState() => _QuillFontFamilyButtonState(); |
|
|
|
@ -94,7 +99,10 @@ class _QuillFontFamilyButtonState extends State<QuillFontFamilyButton> { |
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return ConstrainedBox( |
|
|
|
|
constraints: BoxConstraints.tightFor(height: widget.iconSize * 1.81), |
|
|
|
|
constraints: BoxConstraints.tightFor( |
|
|
|
|
height: widget.iconSize * 1.81, |
|
|
|
|
width: widget.width ?? 120, |
|
|
|
|
), |
|
|
|
|
child: UtilityWidgets.maybeTooltip( |
|
|
|
|
message: widget.tooltip, |
|
|
|
|
child: RawMaterialButton( |
|
|
|
@ -131,7 +139,20 @@ class _QuillFontFamilyButtonState extends State<QuillFontFamilyButton> { |
|
|
|
|
showMenu<String>( |
|
|
|
|
context: context, |
|
|
|
|
elevation: 4, |
|
|
|
|
items: widget.items, |
|
|
|
|
items: [ |
|
|
|
|
for (MapEntry<String, String> fontFamily in widget.rawItemsMap.entries) |
|
|
|
|
PopupMenuItem<String>( |
|
|
|
|
key: ValueKey(fontFamily.key), |
|
|
|
|
value: fontFamily.value, |
|
|
|
|
child: Text( |
|
|
|
|
fontFamily.key.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontFamily: |
|
|
|
|
widget.renderFontFamilies ? fontFamily.value : null, |
|
|
|
|
color: fontFamily.value == 'Clear' ? Colors.red : null), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
position: position, |
|
|
|
|
shape: popupMenuTheme.shape, |
|
|
|
|
color: popupMenuTheme.color, |
|
|
|
@ -144,7 +165,9 @@ class _QuillFontFamilyButtonState extends State<QuillFontFamilyButton> { |
|
|
|
|
setState(() { |
|
|
|
|
_currentValue = keyName ?? _defaultDisplayText; |
|
|
|
|
if (keyName != null) { |
|
|
|
|
widget.onSelected(newValue); |
|
|
|
|
widget.controller.formatSelection(Attribute.fromKeyValue( |
|
|
|
|
'font', newValue == 'Clear' ? null : newValue)); |
|
|
|
|
widget.onSelected?.call(newValue); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|