|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; |
|
|
|
|
import '../../models/documents/attribute.dart'; |
|
|
|
|
import '../../models/documents/style.dart'; |
|
|
|
|
import '../../models/themes/quill_icon_theme.dart'; |
|
|
|
|
import '../../utils/widgets.dart'; |
|
|
|
|
import '../controller.dart'; |
|
|
|
|
import '../toolbar.dart'; |
|
|
|
|
|
|
|
|
@ -17,6 +18,7 @@ class SelectAlignmentButton extends StatefulWidget { |
|
|
|
|
this.showRightAlignment, |
|
|
|
|
this.showJustifyAlignment, |
|
|
|
|
this.afterButtonPressed, |
|
|
|
|
this.tooltip, |
|
|
|
|
Key? key, |
|
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
|
|
@ -29,6 +31,7 @@ class SelectAlignmentButton extends StatefulWidget { |
|
|
|
|
final bool? showRightAlignment; |
|
|
|
|
final bool? showJustifyAlignment; |
|
|
|
|
final VoidCallback? afterButtonPressed; |
|
|
|
|
final String? tooltip; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
_SelectAlignmentButtonState createState() => _SelectAlignmentButtonState(); |
|
|
|
@ -93,40 +96,45 @@ class _SelectAlignmentButtonState extends State<SelectAlignmentButton> { |
|
|
|
|
width: widget.iconSize * kIconButtonFactor, |
|
|
|
|
height: widget.iconSize * kIconButtonFactor, |
|
|
|
|
), |
|
|
|
|
child: RawMaterialButton( |
|
|
|
|
hoverElevation: 0, |
|
|
|
|
highlightElevation: 0, |
|
|
|
|
elevation: 0, |
|
|
|
|
visualDensity: VisualDensity.compact, |
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
borderRadius: BorderRadius.circular( |
|
|
|
|
widget.iconTheme?.borderRadius ?? 2)), |
|
|
|
|
fillColor: _valueToText[_value] == _valueString[index] |
|
|
|
|
? (widget.iconTheme?.iconSelectedFillColor ?? |
|
|
|
|
Theme.of(context).primaryColor) |
|
|
|
|
: (widget.iconTheme?.iconUnselectedFillColor ?? |
|
|
|
|
theme.canvasColor), |
|
|
|
|
onPressed: () { |
|
|
|
|
_valueAttribute[index] == Attribute.leftAlignment |
|
|
|
|
? widget.controller |
|
|
|
|
.formatSelection(Attribute.clone(Attribute.align, null)) |
|
|
|
|
: widget.controller.formatSelection(_valueAttribute[index]); |
|
|
|
|
widget.afterButtonPressed?.call(); |
|
|
|
|
}, |
|
|
|
|
child: Icon( |
|
|
|
|
_valueString[index] == Attribute.leftAlignment.value |
|
|
|
|
? Icons.format_align_left |
|
|
|
|
: _valueString[index] == Attribute.centerAlignment.value |
|
|
|
|
? Icons.format_align_center |
|
|
|
|
: _valueString[index] == Attribute.rightAlignment.value |
|
|
|
|
? Icons.format_align_right |
|
|
|
|
: Icons.format_align_justify, |
|
|
|
|
size: widget.iconSize, |
|
|
|
|
color: _valueToText[_value] == _valueString[index] |
|
|
|
|
? (widget.iconTheme?.iconSelectedColor ?? |
|
|
|
|
theme.primaryIconTheme.color) |
|
|
|
|
: (widget.iconTheme?.iconUnselectedColor ?? |
|
|
|
|
theme.iconTheme.color), |
|
|
|
|
child: UtilityWidgets.maybeTooltip( |
|
|
|
|
message: widget.tooltip, |
|
|
|
|
child: RawMaterialButton( |
|
|
|
|
hoverElevation: 0, |
|
|
|
|
highlightElevation: 0, |
|
|
|
|
elevation: 0, |
|
|
|
|
visualDensity: VisualDensity.compact, |
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
borderRadius: BorderRadius.circular( |
|
|
|
|
widget.iconTheme?.borderRadius ?? 2)), |
|
|
|
|
fillColor: _valueToText[_value] == _valueString[index] |
|
|
|
|
? (widget.iconTheme?.iconSelectedFillColor ?? |
|
|
|
|
Theme.of(context).primaryColor) |
|
|
|
|
: (widget.iconTheme?.iconUnselectedFillColor ?? |
|
|
|
|
theme.canvasColor), |
|
|
|
|
onPressed: () { |
|
|
|
|
_valueAttribute[index] == Attribute.leftAlignment |
|
|
|
|
? widget.controller.formatSelection( |
|
|
|
|
Attribute.clone(Attribute.align, null)) |
|
|
|
|
: widget.controller |
|
|
|
|
.formatSelection(_valueAttribute[index]); |
|
|
|
|
widget.afterButtonPressed?.call(); |
|
|
|
|
}, |
|
|
|
|
child: Icon( |
|
|
|
|
_valueString[index] == Attribute.leftAlignment.value |
|
|
|
|
? Icons.format_align_left |
|
|
|
|
: _valueString[index] == Attribute.centerAlignment.value |
|
|
|
|
? Icons.format_align_center |
|
|
|
|
: _valueString[index] == |
|
|
|
|
Attribute.rightAlignment.value |
|
|
|
|
? Icons.format_align_right |
|
|
|
|
: Icons.format_align_justify, |
|
|
|
|
size: widget.iconSize, |
|
|
|
|
color: _valueToText[_value] == _valueString[index] |
|
|
|
|
? (widget.iconTheme?.iconSelectedColor ?? |
|
|
|
|
theme.primaryIconTheme.color) |
|
|
|
|
: (widget.iconTheme?.iconUnselectedColor ?? |
|
|
|
|
theme.iconTheme.color), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|