Added Formula Button (for maths support) (#900)
* added basic math keyboard * added formula to sample data! * created new variable for showFormulaButtonpull/901/head
parent
ac1cf592c3
commit
a707918f7f
6 changed files with 113 additions and 1 deletions
@ -0,0 +1,69 @@ |
|||||||
|
import 'package:flutter/material.dart'; |
||||||
|
import 'package:image_picker/image_picker.dart'; |
||||||
|
|
||||||
|
import '../../models/documents/nodes/embeddable.dart'; |
||||||
|
import '../../models/themes/quill_dialog_theme.dart'; |
||||||
|
import '../../models/themes/quill_icon_theme.dart'; |
||||||
|
import '../controller.dart'; |
||||||
|
import '../toolbar.dart'; |
||||||
|
|
||||||
|
class FormulaButton extends StatelessWidget { |
||||||
|
const FormulaButton({ |
||||||
|
required this.icon, |
||||||
|
required this.controller, |
||||||
|
this.iconSize = kDefaultIconSize, |
||||||
|
this.onImagePickCallback, |
||||||
|
this.fillColor, |
||||||
|
this.filePickImpl, |
||||||
|
this.webImagePickImpl, |
||||||
|
this.mediaPickSettingSelector, |
||||||
|
this.iconTheme, |
||||||
|
this.dialogTheme, |
||||||
|
Key? key, |
||||||
|
}) : super(key: key); |
||||||
|
|
||||||
|
final IconData icon; |
||||||
|
final double iconSize; |
||||||
|
|
||||||
|
final Color? fillColor; |
||||||
|
|
||||||
|
final QuillController controller; |
||||||
|
|
||||||
|
final OnImagePickCallback? onImagePickCallback; |
||||||
|
|
||||||
|
final WebImagePickImpl? webImagePickImpl; |
||||||
|
|
||||||
|
final FilePickImpl? filePickImpl; |
||||||
|
|
||||||
|
final MediaPickSettingSelector? mediaPickSettingSelector; |
||||||
|
|
||||||
|
final QuillIconTheme? iconTheme; |
||||||
|
|
||||||
|
final QuillDialogTheme? dialogTheme; |
||||||
|
|
||||||
|
@override |
||||||
|
Widget build(BuildContext context) { |
||||||
|
final theme = Theme.of(context); |
||||||
|
|
||||||
|
final iconColor = iconTheme?.iconUnselectedColor ?? theme.iconTheme.color; |
||||||
|
final iconFillColor = |
||||||
|
iconTheme?.iconUnselectedFillColor ?? (fillColor ?? theme.canvasColor); |
||||||
|
|
||||||
|
return QuillIconButton( |
||||||
|
icon: Icon(icon, size: iconSize, color: iconColor), |
||||||
|
highlightElevation: 0, |
||||||
|
hoverElevation: 0, |
||||||
|
size: iconSize * 1.77, |
||||||
|
fillColor: iconFillColor, |
||||||
|
borderRadius: iconTheme?.borderRadius ?? 2, |
||||||
|
onPressed: () => _onPressedHandler(context), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
Future<void> _onPressedHandler(BuildContext context) async { |
||||||
|
final index = controller.selection.baseOffset; |
||||||
|
final length = controller.selection.extentOffset - index; |
||||||
|
|
||||||
|
controller.replaceText(index, length, BlockEmbed.formula(''), null); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue