Add QuillTheme class

pull/13/head
singerdmx 4 years ago
parent d9d1f6762c
commit c907f0cce4
  1. 26
      lib/widgets/default_styles.dart
  2. 70
      lib/widgets/editor.dart

@ -2,6 +2,32 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:tuple/tuple.dart';
class QuillTheme extends InheritedWidget {
final DefaultStyles data;
QuillTheme({
Key key,
@required this.data,
@required Widget child,
}) : assert(data != null),
assert(child != null),
super(key: key, child: child);
@override
bool updateShouldNotify(QuillTheme oldWidget) {
return data != oldWidget.data;
}
static DefaultStyles of(BuildContext context, nullOk) {
var widget = context.dependOnInheritedWidgetOfExactType<QuillTheme>();
if (widget == null && nullOk) {
return null;
}
assert(widget != null);
return widget.data;
}
}
class DefaultTextBlockStyle {
final TextStyle style;

@ -694,7 +694,10 @@ class RawEditorState extends EditorState
@override
Widget build(BuildContext context) {
// TODO: implement build
assert(debugCheckHasMediaQuery(context));
_focusAttachment.reparent();
super.build(context);
throw UnimplementedError();
}
@ -731,6 +734,17 @@ class RawEditorState extends EditorState
widget.focusNode.addListener(_handleFocusChanged);
}
@override
didChangeDependencies() {
// TODO
}
@override
void didUpdateWidget(RawEditor oldWidget) {
super.didUpdateWidget(oldWidget);
// TODO
}
handleDelete(bool forward) {
// TODO
}
@ -834,11 +848,40 @@ class RawEditorState extends EditorState
bool get wantKeepAlive => widget.focusNode.hasFocus;
}
typedef TextSelectionChangedHandler = void Function(
TextSelection selection, SelectionChangedCause cause);
class RenderEditor extends RenderEditableContainerBox
implements RenderAbstractEditor {
Document document;
TextSelection selection;
bool _hasFocus = false;
LayerLink _startHandleLayerLink;
LayerLink _endHandleLayerLink;
TextSelectionChangedHandler onSelectionChanged;
RenderEditor(
List<RenderEditableBox> children,
TextDirection textDirection,
hasFocus,
EdgeInsetsGeometry padding,
this.document,
this.selection,
this._hasFocus,
this.onSelectionChanged,
this._startHandleLayerLink,
this._endHandleLayerLink,
EdgeInsets floatingCursorAddedMargin)
: assert(document != null),
assert(textDirection != null),
assert(hasFocus != null),
assert(floatingCursorAddedMargin != null),
super(
children,
document.root,
textDirection,
padding,
);
setDocument(Document doc) {
assert(doc != null);
@ -866,6 +909,22 @@ class RenderEditor extends RenderEditableContainerBox
markNeedsPaint();
}
setStartHandleLayerLink(LayerLink value) {
if (_startHandleLayerLink == value) {
return;
}
_startHandleLayerLink = value;
markNeedsPaint();
}
setEndHandleLayerLink(LayerLink value) {
if (_endHandleLayerLink == value) {
return;
}
_endHandleLayerLink = value;
markNeedsPaint();
}
@override
List<TextSelectionPoint> getEndpointsForSelection(
TextSelection textSelection) {
@ -943,6 +1002,15 @@ class RenderEditableContainerBox extends RenderBox
EdgeInsetsGeometry _padding;
EdgeInsets _resolvedPadding;
RenderEditableContainerBox(List<RenderEditableBox> children, this._container,
this._textDirection, this._padding)
: assert(_container != null),
assert(_textDirection != null),
assert(_padding != null),
assert(_padding.isNonNegative) {
addAll(children);
}
setContainer(container.Container c) {
assert(c != null);
if (_container == c) {

Loading…
Cancel
Save