浏览代码

update

/main
fzhangtj 6 年前
当前提交
2f474e8b
共有 11 个文件被更改,包括 1906 次插入2 次删除
  1. 16
      Runtime/foundation/basic_types.cs
  2. 299
      Runtime/rendering/object.mixin.gen.cs
  3. 2
      Runtime/rendering/object.mixin.njk
  4. 34
      Runtime/rendering/proxy_box.cs
  5. 6
      Runtime/rendering/proxy_box.mixin.gen.cs
  6. 6
      Runtime/rendering/proxy_box.mixin.njk
  7. 30
      Runtime/widgets/basic.cs
  8. 1001
      Runtime/widgets/navigator.cs
  9. 11
      Runtime/widgets/navigator.cs.meta
  10. 492
      Runtime/widgets/overlay.cs
  11. 11
      Runtime/widgets/overlay.cs.meta

16
Runtime/foundation/basic_types.cs


it.TryGetValue(key, out v);
return v;
}
public static T first<T>(this IList<T> it) {
return it[0];
}
public static T last<T>(this IList<T> it) {
return it[it.Count - 1];
}
public static T removeLast<T>(this IList<T> it)
{
var lastIndex = it.Count - 1;
var result = it[lastIndex];
it.RemoveAt(lastIndex);
return result;
}
}
}

299
Runtime/rendering/object.mixin.gen.cs


}
public abstract class ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<ChildType, ParentDataType> : RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack, ContainerRenderObjectMixin
where ChildType : RenderObject
where ParentDataType : ParentData, ContainerParentDataMixin<ChildType> {
bool _debugUltimatePreviousSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.previousSibling != null) {
D.assert(childParentData.previousSibling != child);
child = childParentData.previousSibling;
childParentData = (ParentDataType) child.parentData;
}
return child == equals;
}
bool _debugUltimateNextSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.nextSibling != null) {
D.assert(childParentData.nextSibling != child);
child = childParentData.nextSibling;
childParentData = (ParentDataType) child.parentData;
}
return child == equals;
}
int _childCount = 0;
public int childCount {
get { return this._childCount; }
}
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {
throw new UIWidgetsError(
"A " + this.GetType() + " expected a child of type " + typeof(ChildType) + " but received a " +
"child of type " + child.GetType() + ".\n" +
"RenderObjects expect specific types of children because they " +
"coordinate with their children during layout and paint. For " +
"example, a RenderSliver cannot be the child of a RenderBox because " +
"a RenderSliver does not understand the RenderBox layout protocol.\n" +
"\n" +
"The " + this.GetType() + " that expected a $ChildType child was created by:\n" +
" " + this.debugCreator + "\n" +
"\n" +
"The " + child.GetType() + " that did not match the expected child type " +
"was created by:\n" +
" " + child.debugCreator + "\n"
);
}
return true;
});
return true;
}
ChildType _firstChild;
ChildType _lastChild;
void _insertIntoChildList(ChildType child, ChildType after = null) {
var childParentData = (ParentDataType) child.parentData;
D.assert(childParentData.nextSibling == null);
D.assert(childParentData.previousSibling == null);
this._childCount++;
D.assert(this._childCount > 0);
if (after == null) {
childParentData.nextSibling = this._firstChild;
if (this._firstChild != null) {
var firstChildParentData = (ParentDataType) this._firstChild.parentData;
firstChildParentData.previousSibling = child;
}
this._firstChild = child;
this._lastChild = this._lastChild ?? child;
} else {
D.assert(this._firstChild != null);
D.assert(this._lastChild != null);
D.assert(this._debugUltimatePreviousSiblingOf(after, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(after, equals: this._lastChild));
var afterParentData = (ParentDataType) after.parentData;
if (afterParentData.nextSibling == null) {
D.assert(after == this._lastChild);
childParentData.previousSibling = after;
afterParentData.nextSibling = child;
this._lastChild = child;
} else {
childParentData.nextSibling = afterParentData.nextSibling;
childParentData.previousSibling = after;
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;
var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childPreviousSiblingParentData.nextSibling = child;
childNextSiblingParentData.previousSibling = child;
D.assert(afterParentData.nextSibling == child);
}
}
}
public virtual void insert(ChildType child, ChildType after = null) {
D.assert(child != this, "A RenderObject cannot be inserted into itself.");
D.assert(after != this,
"A RenderObject cannot simultaneously be both the parent and the sibling of another RenderObject.");
D.assert(child != after, "A RenderObject cannot be inserted after itself.");
D.assert(child != this._firstChild);
D.assert(child != this._lastChild);
this.adoptChild(child);
this._insertIntoChildList(child, after);
}
public virtual void add(ChildType child) {
this.insert(child, this._lastChild);
}
public virtual void addAll(List<ChildType> children) {
if (children != null) {
children.ForEach(this.add);
}
}
public void _removeFromChildList(ChildType child) {
var childParentData = (ParentDataType) child.parentData;
D.assert(this._debugUltimatePreviousSiblingOf(child, equals: this._firstChild));
D.assert(this._debugUltimateNextSiblingOf(child, equals: this._lastChild));
D.assert(this._childCount >= 0);
if (childParentData.previousSibling == null) {
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;
childPreviousSiblingParentData.nextSibling = childParentData.nextSibling;
}
if (childParentData.nextSibling == null) {
D.assert(this._lastChild == child);
this._lastChild = childParentData.previousSibling;
} else {
var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childNextSiblingParentData.previousSibling = childParentData.previousSibling;
}
childParentData.previousSibling = null;
childParentData.nextSibling = null;
this._childCount--;
}
public virtual void remove(ChildType child) {
this._removeFromChildList(child);
this.dropChild(child);
}
public virtual void removeAll() {
ChildType child = this._firstChild;
while (child != null) {
var childParentData = (ParentDataType) child.parentData;
var next = childParentData.nextSibling;
childParentData.previousSibling = null;
childParentData.nextSibling = null;
this.dropChild(child);
child = next;
}
this._firstChild = null;
this._lastChild = null;
this._childCount = 0;
}
public void move(ChildType child, ChildType after = null) {
D.assert(child != this);
D.assert(after != this);
D.assert(child != after);
D.assert(child.parent == this);
var childParentData = (ParentDataType) child.parentData;
if (childParentData.previousSibling == after) {
return;
}
this._removeFromChildList(child);
this._insertIntoChildList(child, after);
this.markNeedsLayout();
}
public override void attach(object owner) {
base.attach(owner);
ChildType child = this._firstChild;
while (child != null) {
child.attach(owner);
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}
}
public override void detach() {
base.detach();
ChildType child = this._firstChild;
while (child != null) {
child.detach();
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}
}
public override void redepthChildren() {
ChildType child = this._firstChild;
while (child != null) {
this.redepthChild(child);
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}
}
public override void visitChildren(RenderObjectVisitor visitor) {
ChildType child = this._firstChild;
while (child != null) {
visitor(child);
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}
}
public ChildType firstChild {
get { return this._firstChild; }
}
public ChildType lastChild {
get { return this._lastChild; }
}
public ChildType childBefore(ChildType child) {
D.assert(child != null);
D.assert(child.parent == this);
var childParentData = (ParentDataType) child.parentData;
return childParentData.previousSibling;
}
public ChildType childAfter(ChildType child) {
D.assert(child != null);
D.assert(child.parent == this);
var childParentData = (ParentDataType) child.parentData;
return childParentData.nextSibling;
}
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
if (this.firstChild != null) {
ChildType child = this.firstChild;
int count = 1;
while (true) {
children.Add(child.toDiagnosticsNode(name: "child " + count));
if (child == this.lastChild) {
break;
}
count += 1;
var childParentData = (ParentDataType) child.parentData;
child = childParentData.nextSibling;
}
}
return children;
}
void ContainerRenderObjectMixin.insert(RenderObject child, RenderObject after) {
this.insert((ChildType) child, (ChildType) after);
}
void ContainerRenderObjectMixin.remove(RenderObject child) {
this.remove((ChildType) child);
}
void ContainerRenderObjectMixin.move(RenderObject child, RenderObject after) {
this.move((ChildType) child, (ChildType) after);
}
RenderObject ContainerRenderObjectMixin.firstChild {
get { return this.firstChild; }
}
RenderObject ContainerRenderObjectMixin.lastChild {
get { return this.lastChild; }
}
RenderObject ContainerRenderObjectMixin.childBefore(RenderObject child) {
return this.childBefore((ChildType) child);
}
RenderObject ContainerRenderObjectMixin.childAfter(RenderObject child) {
return this.childAfter((ChildType) child);
}
}
}

2
Runtime/rendering/object.mixin.njk


{{ ContainerRenderObjectMixin('RenderSliver') }}
{{ ContainerRenderObjectMixin('RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack') }}
}

34
Runtime/rendering/proxy_box.cs


properties.add(new DiagnosticsProperty<bool>("ignoring", this.ignoring));
}
}
public class RenderAbsorbPointer : RenderProxyBox {
public RenderAbsorbPointer(
RenderBox child = null,
bool absorbing = true
) : base(child)
{
_absorbing = absorbing;
}
public bool absorbing
{
get { return _absorbing; }
set
{
_absorbing = value;
}
}
bool _absorbing;
public override bool hitTest(HitTestResult result, Offset position) {
return absorbing
? size.contains(position)
: base.hitTest(result, position: position);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("absorbing", absorbing));
}
}
}

6
Runtime/rendering/proxy_box.mixin.gen.cs


}
}
public abstract class RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack:
RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<RenderStack> {
}
}

6
Runtime/rendering/proxy_box.mixin.njk


{{ RenderProxyBoxMixin('RenderObjectWithChildMixinRenderBox') }}
}
public abstract class RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack:
RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<RenderStack> {
}
}

30
Runtime/widgets/basic.cs


}
}
public class AbsorbPointer : SingleChildRenderObjectWidget {
public AbsorbPointer(
Key key = null,
bool absorbing = true,
Widget child = null
) : base(key: key, child: child) {
}
public readonly bool absorbing;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderAbsorbPointer(
absorbing: absorbing
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject)
{
((RenderAbsorbPointer) renderObject).absorbing = absorbing;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("absorbing", absorbing));
}
}
public class Builder : StatelessWidget {
public Builder(
Key key = null,

1001
Runtime/widgets/navigator.cs
文件差异内容过多而无法显示
查看文件

11
Runtime/widgets/navigator.cs.meta


fileFormatVersion: 2
guid: 78638000dd54446508ed86d5936a4493
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

492
Runtime/widgets/overlay.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
namespace Unity.UIWidgets.widgets
{
public class OverlayEntry
{
public OverlayEntry(WidgetBuilder builder = null, bool opaque = false, bool maintainState = false)
{
D.assert(builder != null);
_opaque = opaque;
_maintainState = maintainState;
}
public readonly WidgetBuilder builder;
bool _opaque;
public bool opaque
{
get { return _opaque; }
set
{
if (_opaque == value)
{
return;
}
_opaque = value;
D.assert(_overlay != null);
_overlay._didChangeEntryOpacity();
}
}
bool _maintainState;
public bool maintainState
{
get { return _maintainState; }
set
{
if (_maintainState == value)
{
return;
}
_maintainState = value;
D.assert(_overlay != null);
_overlay._didChangeEntryOpacity();
}
}
internal OverlayState _overlay;
internal readonly GlobalKey<_OverlayEntryState> _key = new LabeledGlobalKey<_OverlayEntryState>();
public void remove()
{
D.assert(_overlay != null);
OverlayState overlay = _overlay;
_overlay = null;
if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks)
{
SchedulerBinding.instance.addPostFrameCallback((duration) => { overlay._remove(this); });
}
else
{
overlay._remove(this);
}
}
public void markNeedsBuild()
{
_key.currentState?._markNeedsBuild();
}
public override string ToString()
{
return $"{Diagnostics.describeIdentity(this)}(opaque: {opaque}; maintainState: {maintainState})";
}
}
class _OverlayEntry : StatefulWidget
{
internal _OverlayEntry(OverlayEntry entry) : base(key: entry._key)
{
D.assert(entry != null);
}
public readonly OverlayEntry entry;
public override State createState()
{
return new _OverlayEntryState();
}
}
class _OverlayEntryState : State<_OverlayEntry>
{
public override Widget build(BuildContext context)
{
return widget.entry.builder(context);
}
internal void _markNeedsBuild()
{
setState(() =>
{
/* the state that changed is in the builder */
});
}
}
public class Overlay : StatefulWidget
{
public Overlay(Key key = null, List<OverlayEntry> initialEntries = null) : base(key)
{
D.assert(initialEntries != null);
this.initialEntries = initialEntries;
}
public readonly List<OverlayEntry> initialEntries;
public static OverlayState of(BuildContext context, Widget debugRequiredFor = null)
{
OverlayState result = (OverlayState) context.ancestorStateOfType(new TypeMatcher<OverlayState>());
D.assert(() =>
{
if (debugRequiredFor != null && result == null)
{
var additional = context.widget != debugRequiredFor
? $"\nThe context from which that widget was searching for an overlay was:\n {context}"
: "";
throw new UIWidgetsError(
"No Overlay widget found.\n" +
$"{debugRequiredFor.GetType()} widgets require an Overlay widget ancestor for correct operation.\n" +
"The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n" +
"The specific widget that failed to find an overlay was:\n" +
$" {debugRequiredFor}" +
$"{additional}"
);
}
return true;
});
return result;
}
public override State createState()
{
return new OverlayState();
}
}
public class OverlayState : TickerProviderStateMixin<Overlay>
{
readonly List<OverlayEntry> _entries = new List<OverlayEntry>();
public override void initState()
{
base.initState();
insertAll(widget.initialEntries);
}
public void insert(OverlayEntry entry, OverlayEntry above = null)
{
D.assert(entry._overlay == null);
D.assert(above == null || (above._overlay == this && _entries.Contains(above)));
entry._overlay = this;
setState(() =>
{
int index = above == null ? _entries.Count : _entries.IndexOf(above) + 1;
_entries.Insert(index, entry);
});
}
public void insertAll(ICollection<OverlayEntry> entries, OverlayEntry above = null)
{
D.assert(above == null || (above._overlay == this && _entries.Contains(above)));
if (entries.isEmpty())
return;
foreach (OverlayEntry entry in entries)
{
D.assert(entry._overlay == null);
entry._overlay = this;
}
setState(() =>
{
int index = above == null ? _entries.Count : _entries.IndexOf(above) + 1;
_entries.InsertRange(index, entries);
});
}
internal void _remove(OverlayEntry entry)
{
if (mounted)
{
_entries.Remove(entry);
setState(() =>
{
/* entry was removed */
});
}
}
public bool debugIsVisible(OverlayEntry entry)
{
bool result = false;
D.assert(_entries.Contains(entry));
D.assert(() =>
{
for (int i = _entries.Count - 1; i > 0; i -= 1)
{
// todo why not including 0?
OverlayEntry candidate = _entries[i];
if (candidate == entry)
{
result = true;
break;
}
if (candidate.opaque)
break;
}
return true;
});
return result;
}
internal void _didChangeEntryOpacity()
{
setState(() => { });
}
public override Widget build(BuildContext context)
{
var onstageChildren = new List<Widget>();
var offstageChildren = new List<Widget>();
var onstage = true;
for (var i = _entries.Count - 1; i >= 0; i -= 1)
{
var entry = _entries[i];
if (onstage)
{
onstageChildren.Add(new _OverlayEntry(entry));
if (entry.opaque)
{
onstage = false;
}
}
else if (entry.maintainState)
{
offstageChildren.Add(new TickerMode(enabled: false, child: new _OverlayEntry(entry)));
}
}
onstageChildren.Reverse();
return new _Theatre(
onstage: new Stack(
fit: StackFit.expand,
children: onstageChildren
),
offstage: offstageChildren
);
}
}
class _Theatre : RenderObjectWidget
{
internal _Theatre(Stack onstage = null, List<Widget> offstage = null)
{
D.assert(offstage != null);
D.assert(!offstage.Any((child) => child == null));
this.onstage = onstage;
this.offstage = offstage;
}
public readonly Stack onstage;
public readonly List<Widget> offstage;
public override Element createElement()
{
return new _TheatreElement(this);
}
public override RenderObject createRenderObject(BuildContext context)
{
return new _RenderTheatre();
}
}
class _TheatreElement : RenderObjectElement
{
public _TheatreElement(RenderObjectWidget widget) : base(widget)
{
D.assert(!WidgetsD.debugChildrenHaveDuplicateKeys(widget, ((_Theatre) widget).offstage));
}
public new _Theatre widget
{
get { return (_Theatre) base.widget; }
}
public new _RenderTheatre renderObject
{
get { return (_RenderTheatre) base.renderObject; }
}
Element _onstage;
static readonly object _onstageSlot = new object();
List<Element> _offstage;
readonly HashSet<Element> _forgottenOffstageChildren = new HashSet<Element>();
protected override void insertChildRenderObject(RenderObject child, object slot)
{
D.assert(renderObject.debugValidateChild(child));
if (slot == _onstageSlot)
{
D.assert(child is RenderStack);
renderObject.child = (RenderStack) child;
}
else
{
D.assert(slot == null || slot is Element);
renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
}
}
protected override void moveChildRenderObject(RenderObject child, object slot)
{
if (slot == _onstageSlot)
{
renderObject.remove((RenderBox) child);
D.assert(child is RenderStack);
renderObject.child = (RenderStack) child;
}
else
{
D.assert(slot == null || slot is Element);
if (renderObject.child == child)
{
renderObject.child = null;
renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
}
else
{
renderObject.move((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
}
}
}
protected override void removeChildRenderObject(RenderObject child)
{
if (renderObject.child == child)
{
renderObject.child = null;
}
else
{
renderObject.remove((RenderBox) child);
}
}
public override void visitChildren(ElementVisitor visitor)
{
if (_onstage != null)
visitor(_onstage);
foreach (var child in _offstage)
{
if (!_forgottenOffstageChildren.Contains(child))
visitor(child);
}
}
public override void debugVisitOnstageChildren(ElementVisitor visitor)
{
if (_onstage != null)
visitor(_onstage);
}
protected override void forgetChild(Element child)
{
if (child == _onstage)
{
_onstage = null;
}
else
{
D.assert(_offstage.Contains(child));
D.assert(!_forgottenOffstageChildren.Contains(child));
_forgottenOffstageChildren.Add(child);
}
}
public override void mount(Element parent, object newSlot)
{
base.mount(parent, newSlot);
_onstage = updateChild(_onstage, widget.onstage, _onstageSlot);
_offstage = new List<Element>(widget.offstage.Count);
Element previousChild = null;
for (int i = 0; i < _offstage.Count; i += 1)
{
var newChild = inflateWidget(widget.offstage[i], previousChild);
_offstage[i] = newChild;
previousChild = newChild;
}
}
public override void update(Widget newWidget)
{
base.update(newWidget);
D.assert(Equals(widget, newWidget));
_onstage = updateChild(_onstage, widget.onstage, _onstageSlot);
_offstage = updateChildren(_offstage, widget.offstage, forgottenChildren: _forgottenOffstageChildren);
_forgottenOffstageChildren.Clear();
}
}
class _RenderTheatre : ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<
RenderBox, StackParentData>
{
public override void setupParentData(RenderObject child)
{
if (!(child.parentData is StackParentData))
child.parentData = new StackParentData();
}
public override void redepthChildren()
{
if (child != null)
redepthChild(child);
base.redepthChildren();
}
public override void visitChildren(RenderObjectVisitor visitor)
{
if (child != null)
visitor(child);
base.visitChildren(visitor);
}
public override List<DiagnosticsNode> debugDescribeChildren()
{
var children = new List<DiagnosticsNode>();
if (child != null)
children.Add(child.toDiagnosticsNode(name: "onstage"));
if (firstChild != null)
{
var child = firstChild;
int count = 1;
while (true)
{
children.Add(
child.toDiagnosticsNode(
name: $"offstage {count}",
style: DiagnosticsTreeStyle.offstage
)
);
if (child == lastChild)
break;
var childParentData = (StackParentData) child.parentData;
child = childParentData.nextSibling;
count += 1;
}
}
else
{
children.Add(
DiagnosticsNode.message(
"no offstage children",
style: DiagnosticsTreeStyle.offstage
)
);
}
return children;
}
}
}

11
Runtime/widgets/overlay.cs.meta


fileFormatVersion: 2
guid: b92d0bc4e5fb643c1beee12417aec777
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存