dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1014 B
38 lines
1014 B
1 year ago
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
import '../../../../models/documents/attribute.dart';
|
||
|
import '../../../quill/quill_controller.dart';
|
||
|
|
||
|
enum _AlignmentOptions {
|
||
|
left(attribute: Attribute.leftAlignment),
|
||
|
center(attribute: Attribute.centerAlignment),
|
||
|
right(attribute: Attribute.rightAlignment),
|
||
|
justifyMinWidth(attribute: Attribute.justifyAlignment);
|
||
|
|
||
|
const _AlignmentOptions({required this.attribute});
|
||
|
|
||
|
final Attribute attribute;
|
||
|
}
|
||
|
|
||
|
class QuillToolbarSelectAlignmentButton extends StatelessWidget {
|
||
|
const QuillToolbarSelectAlignmentButton(
|
||
|
{required this.controller, super.key});
|
||
|
final QuillController controller;
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return MenuAnchor(
|
||
|
menuChildren: _AlignmentOptions.values
|
||
|
.map(
|
||
|
(e) => MenuItemButton(
|
||
|
child: Text(e.name),
|
||
|
onPressed: () {
|
||
|
controller.formatSelection(e.attribute);
|
||
|
},
|
||
|
),
|
||
|
)
|
||
|
.toList(),
|
||
|
);
|
||
|
}
|
||
|
}
|