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.
120 lines
3.3 KiB
120 lines
3.3 KiB
4 years ago
|
import 'package:flutter/material.dart';
|
||
|
|
||
1 year ago
|
import '../../../extensions/quill_provider.dart';
|
||
1 year ago
|
import '../../../l10n/extensions/localizations.dart';
|
||
2 years ago
|
import '../../../models/config/toolbar/buttons/indent.dart';
|
||
2 years ago
|
import '../../../models/themes/quill_icon_theme.dart';
|
||
|
import '../../controller.dart';
|
||
2 years ago
|
import '../base_toolbar.dart'
|
||
1 year ago
|
show QuillToolbarBaseButtonOptions, QuillToolbarIconButton;
|
||
4 years ago
|
|
||
2 years ago
|
class QuillToolbarIndentButton extends StatefulWidget {
|
||
|
const QuillToolbarIndentButton({
|
||
4 years ago
|
required this.controller,
|
||
|
required this.isIncrease,
|
||
2 years ago
|
required this.options,
|
||
|
super.key,
|
||
|
});
|
||
|
|
||
4 years ago
|
final QuillController controller;
|
||
|
final bool isIncrease;
|
||
2 years ago
|
final QuillToolbarIndentButtonOptions options;
|
||
4 years ago
|
|
||
4 years ago
|
@override
|
||
1 year ago
|
QuillToolbarIndentButtonState createState() =>
|
||
|
QuillToolbarIndentButtonState();
|
||
4 years ago
|
}
|
||
|
|
||
1 year ago
|
class QuillToolbarIndentButtonState extends State<QuillToolbarIndentButton> {
|
||
2 years ago
|
QuillToolbarIndentButtonOptions get options {
|
||
|
return widget.options;
|
||
|
}
|
||
|
|
||
|
QuillController get controller {
|
||
2 years ago
|
return widget.controller;
|
||
2 years ago
|
}
|
||
|
|
||
|
double get iconSize {
|
||
|
final baseFontSize = baseButtonExtraOptions.globalIconSize;
|
||
|
final iconSize = options.iconSize;
|
||
|
return iconSize ?? baseFontSize;
|
||
|
}
|
||
|
|
||
1 year ago
|
double get iconButtonFactor {
|
||
1 year ago
|
final baseIconFactor = baseButtonExtraOptions.globalIconButtonFactor;
|
||
1 year ago
|
final iconButtonFactor = options.iconButtonFactor;
|
||
|
return iconButtonFactor ?? baseIconFactor;
|
||
|
}
|
||
|
|
||
2 years ago
|
VoidCallback? get afterButtonPressed {
|
||
|
return options.afterButtonPressed ??
|
||
|
baseButtonExtraOptions.afterButtonPressed;
|
||
|
}
|
||
|
|
||
|
QuillIconTheme? get iconTheme {
|
||
|
return options.iconTheme ?? baseButtonExtraOptions.iconTheme;
|
||
|
}
|
||
|
|
||
|
QuillToolbarBaseButtonOptions get baseButtonExtraOptions {
|
||
|
return context.requireQuillToolbarBaseButtonOptions;
|
||
|
}
|
||
|
|
||
|
IconData get iconData {
|
||
|
return options.iconData ??
|
||
|
baseButtonExtraOptions.iconData ??
|
||
|
(widget.isIncrease
|
||
|
? Icons.format_indent_increase
|
||
|
: Icons.format_indent_decrease);
|
||
|
}
|
||
|
|
||
|
String get tooltip {
|
||
|
return options.tooltip ??
|
||
|
baseButtonExtraOptions.tooltip ??
|
||
1 year ago
|
(widget.isIncrease
|
||
|
? context.loc.increaseIndent
|
||
|
: context.loc.decreaseIndent);
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
void _sharedOnPressed() {
|
||
|
widget.controller.indentSelection(widget.isIncrease);
|
||
|
}
|
||
|
|
||
4 years ago
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
2 years ago
|
final childBuilder =
|
||
|
options.childBuilder ?? baseButtonExtraOptions.childBuilder;
|
||
|
|
||
|
if (childBuilder != null) {
|
||
|
return childBuilder(
|
||
|
QuillToolbarIndentButtonOptions(
|
||
|
afterButtonPressed: afterButtonPressed,
|
||
|
iconData: iconData,
|
||
|
iconSize: iconSize,
|
||
1 year ago
|
iconButtonFactor: iconButtonFactor,
|
||
2 years ago
|
iconTheme: iconTheme,
|
||
|
tooltip: tooltip,
|
||
|
),
|
||
|
QuillToolbarIndentButtonExtraOptions(
|
||
|
controller: controller,
|
||
|
context: context,
|
||
|
onPressed: () {
|
||
|
_sharedOnPressed();
|
||
|
afterButtonPressed?.call();
|
||
|
},
|
||
|
),
|
||
|
);
|
||
|
}
|
||
4 years ago
|
final theme = Theme.of(context);
|
||
4 years ago
|
|
||
2 years ago
|
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color;
|
||
2 years ago
|
return QuillToolbarIconButton(
|
||
2 years ago
|
tooltip: tooltip,
|
||
1 year ago
|
size: iconSize * iconButtonFactor,
|
||
2 years ago
|
icon: Icon(iconData, size: iconSize, color: iconColor),
|
||
1 year ago
|
isFilled: false,
|
||
2 years ago
|
onPressed: _sharedOnPressed,
|
||
2 years ago
|
afterPressed: afterButtonPressed,
|
||
4 years ago
|
);
|
||
|
}
|
||
|
}
|