Shiyun Wen
4 年前
当前提交
accf9eb4
共有 18 个文件被更改,包括 1522 次插入 和 622 次删除
-
2com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs
-
126com.unity.uiwidgets/Runtime/rendering/sliver.cs
-
126com.unity.uiwidgets/Runtime/rendering/sliver_fill.cs
-
2com.unity.uiwidgets/Runtime/rendering/sliver_grid.cs
-
16com.unity.uiwidgets/Runtime/rendering/sliver_list.cs
-
99com.unity.uiwidgets/Runtime/rendering/sliver_multi_box_adaptor.cs
-
409com.unity.uiwidgets/Runtime/rendering/sliver_padding.cs
-
90com.unity.uiwidgets/Runtime/rendering/sliver_persistent_header.cs
-
10com.unity.uiwidgets/Runtime/rendering/viewport.cs
-
12com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs
-
156com.unity.uiwidgets/Runtime/widgets/layout_builder.cs
-
493com.unity.uiwidgets/Runtime/widgets/sliver.cs
-
138com.unity.uiwidgets/Runtime/widgets/sliver_persistent_header.cs
-
56com.unity.uiwidgets/Runtime/widgets/table.cs
-
4com.unity.uiwidgets/Runtime/widgets/texture.cs
-
209com.unity.uiwidgets/Runtime/widgets/sliver_fill.cs
-
140com.unity.uiwidgets/Runtime/widgets/sliver_prototype_extent_list.cs
-
56com.unity.uiwidgets/Runtime/widgets/status_transitions.cs
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
public class SliverFillViewport : StatelessWidget { |
|||
public SliverFillViewport( |
|||
Key key = null, |
|||
SliverChildDelegate _delegate = null, |
|||
float viewportFraction = 1.0f, |
|||
bool padEnds = true |
|||
) : base(key: key) { |
|||
D.assert(viewportFraction != null); |
|||
D.assert(viewportFraction > 0.0); |
|||
D.assert(padEnds != null); |
|||
this._delegate = _delegate; |
|||
this.viewportFraction = viewportFraction; |
|||
this.padEnds = padEnds; |
|||
} |
|||
|
|||
public readonly float viewportFraction; |
|||
public readonly bool padEnds; |
|||
public readonly SliverChildDelegate _delegate; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new _SliverFractionalPadding( |
|||
viewportFraction: padEnds ? ((int)(1 - viewportFraction).clamp(0f, 1f) / 2) : 0, |
|||
sliver: new _SliverFillViewportRenderObjectWidget( |
|||
viewportFraction: viewportFraction, |
|||
_delegate: _delegate |
|||
) |
|||
); |
|||
} |
|||
} |
|||
public class _SliverFillViewportRenderObjectWidget : SliverMultiBoxAdaptorWidget { |
|||
public _SliverFillViewportRenderObjectWidget( |
|||
Key key = null, |
|||
SliverChildDelegate _delegate = null, |
|||
float viewportFraction = 1.0f |
|||
) :base(key: key, del: _delegate) { |
|||
D.assert(viewportFraction != null); |
|||
D.assert(viewportFraction > 0.0); |
|||
this.viewportFraction = viewportFraction; |
|||
|
|||
} |
|||
|
|||
public readonly float viewportFraction; |
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
SliverMultiBoxAdaptorElement element = context as SliverMultiBoxAdaptorElement; |
|||
return new RenderSliverFillViewport(childManager: element, viewportFraction: viewportFraction); |
|||
} |
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
renderObject = (RenderSliverFillViewport) renderObject; |
|||
((RenderSliverFillViewport)renderObject).viewportFraction = viewportFraction; |
|||
} |
|||
} |
|||
public class _SliverFractionalPadding : SingleChildRenderObjectWidget { |
|||
public _SliverFractionalPadding( |
|||
int viewportFraction = 0, |
|||
Widget sliver = null |
|||
) : base(child: sliver) { |
|||
D.assert(viewportFraction != null); |
|||
D.assert(viewportFraction >= 0); |
|||
D.assert(viewportFraction <= 0.5); |
|||
this.viewportFraction = viewportFraction; |
|||
} |
|||
|
|||
public readonly float viewportFraction; |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new _RenderSliverFractionalPadding(viewportFraction: viewportFraction); |
|||
} |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
renderObject = (_RenderSliverFractionalPadding) renderObject; |
|||
((_RenderSliverFractionalPadding)renderObject).viewportFraction = viewportFraction; |
|||
} |
|||
} |
|||
public class _RenderSliverFractionalPadding : RenderSliverEdgeInsetsPadding { |
|||
public _RenderSliverFractionalPadding( |
|||
float viewportFraction = 0 |
|||
) { |
|||
D.assert(viewportFraction != null); |
|||
D.assert(viewportFraction <= 0.5); |
|||
D.assert(viewportFraction >= 0); |
|||
_viewportFraction = viewportFraction; |
|||
} |
|||
|
|||
SliverConstraints _lastResolvedConstraints; |
|||
|
|||
public float viewportFraction { |
|||
get {return _viewportFraction; } |
|||
set { |
|||
D.assert(value != null); |
|||
if (_viewportFraction == value) |
|||
return; |
|||
_viewportFraction = value; |
|||
_markNeedsResolution(); |
|||
} |
|||
} |
|||
float _viewportFraction; |
|||
|
|||
|
|||
public EdgeInsets resolvedPadding { |
|||
get { |
|||
return _resolvedPadding; |
|||
} |
|||
} |
|||
EdgeInsets _resolvedPadding; |
|||
void _markNeedsResolution() { |
|||
_resolvedPadding = null; |
|||
markNeedsLayout(); |
|||
} |
|||
void _resolve() { |
|||
if (_resolvedPadding != null && _lastResolvedConstraints == constraints) |
|||
return; |
|||
|
|||
D.assert(constraints.axis != null); |
|||
float paddingValue = constraints.viewportMainAxisExtent * viewportFraction; |
|||
_lastResolvedConstraints = constraints; |
|||
switch (constraints.axis) { |
|||
case Axis.horizontal: |
|||
_resolvedPadding = EdgeInsets.symmetric(horizontal: paddingValue); |
|||
break; |
|||
case Axis.vertical: |
|||
_resolvedPadding = EdgeInsets.symmetric(vertical: paddingValue); |
|||
break; |
|||
} |
|||
|
|||
return; |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
_resolve(); |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
public class SliverFillRemaining : StatelessWidget { |
|||
public SliverFillRemaining( |
|||
Key key = null, |
|||
Widget child = null, |
|||
bool hasScrollBody = true, |
|||
bool fillOverscroll = false) : base(key: key) { |
|||
D.assert(hasScrollBody != null); |
|||
D.assert(fillOverscroll != null); |
|||
this.child = child; |
|||
this.hasScrollBody = hasScrollBody; |
|||
this.fillOverscroll = fillOverscroll; |
|||
} |
|||
public readonly Widget child; |
|||
public readonly bool hasScrollBody; |
|||
public readonly bool fillOverscroll; |
|||
public override Widget build(BuildContext context) { |
|||
if (hasScrollBody) |
|||
return new _SliverFillRemainingWithScrollable(child: child); |
|||
if (!fillOverscroll) |
|||
return new _SliverFillRemainingWithoutScrollable(child: child); |
|||
return new _SliverFillRemainingAndOverscroll(child: child); |
|||
} |
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); properties.add(new DiagnosticsProperty<Widget>("child", child)); |
|||
List<string> flags = new List<string>(); |
|||
if (hasScrollBody) |
|||
flags.Add("scrollable"); |
|||
if (fillOverscroll) |
|||
flags.Add("fillOverscroll"); |
|||
if (flags.isEmpty()) |
|||
flags.Add("nonscrollable"); |
|||
//properties.add(IterableProperty<string>("mode", flags));
|
|||
} |
|||
} |
|||
|
|||
public class _SliverFillRemainingWithScrollable : SingleChildRenderObjectWidget { |
|||
public _SliverFillRemainingWithScrollable( |
|||
Key key = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
} |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new RenderSliverFillRemainingWithScrollable(); |
|||
} |
|||
} |
|||
|
|||
class _SliverFillRemainingWithoutScrollable : SingleChildRenderObjectWidget { |
|||
public _SliverFillRemainingWithoutScrollable( |
|||
Key key = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
} |
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new RenderSliverFillRemaining(); |
|||
} |
|||
} |
|||
class _SliverFillRemainingAndOverscroll : SingleChildRenderObjectWidget { |
|||
public _SliverFillRemainingAndOverscroll( |
|||
Key key = null, |
|||
Widget child = null |
|||
) : base(key: key, child: child) { |
|||
|
|||
} |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new RenderSliverFillRemainingAndOverscroll(); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
public class SliverPrototypeExtentList : SliverMultiBoxAdaptorWidget { |
|||
public SliverPrototypeExtentList( |
|||
Key key = null, |
|||
SliverChildDelegate del = null, |
|||
Widget prototypeItem = null |
|||
) : base(key: key, del: del) { |
|||
this.prototypeItem = prototypeItem; |
|||
} |
|||
|
|||
|
|||
public readonly Widget prototypeItem; |
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
_SliverPrototypeExtentListElement element = context as _SliverPrototypeExtentListElement; |
|||
return new _RenderSliverPrototypeExtentList(childManager: element); |
|||
} |
|||
public override Element createElement() { |
|||
return new _SliverPrototypeExtentListElement(this); |
|||
} |
|||
} |
|||
public class _SliverPrototypeExtentListElement : SliverMultiBoxAdaptorElement { |
|||
public _SliverPrototypeExtentListElement(SliverPrototypeExtentList widget) : base(widget) { |
|||
} |
|||
|
|||
public new SliverPrototypeExtentList widget { |
|||
get { |
|||
return base.widget as SliverPrototypeExtentList; |
|||
} |
|||
} |
|||
public new _RenderSliverPrototypeExtentList renderObject { |
|||
get { return base.renderObject as _RenderSliverPrototypeExtentList;} |
|||
} |
|||
|
|||
Element _prototype; |
|||
public readonly static object _prototypeSlot = null; |
|||
|
|||
protected override void insertChildRenderObject(RenderObject child, object slot) { |
|||
if (slot == _prototypeSlot) { |
|||
D.assert(child is RenderBox); |
|||
renderObject.child = child as RenderBox; |
|||
} else { |
|||
base.insertChildRenderObject(child, (int)slot ); |
|||
} |
|||
} |
|||
public override void didAdoptChild(RenderBox child) { |
|||
if (child != renderObject.child) |
|||
base.didAdoptChild(child); |
|||
} |
|||
|
|||
protected override void moveChildRenderObject(RenderObject child, object slot) { |
|||
child = (RenderBox) child; |
|||
if (slot == _prototypeSlot) |
|||
D.assert(false); |
|||
else |
|||
base.moveChildRenderObject(child, (int)slot ); |
|||
} |
|||
|
|||
protected override void removeChildRenderObject(RenderObject child) { |
|||
child = (RenderBox) child; |
|||
if (renderObject.child == child) |
|||
renderObject.child = null; |
|||
else |
|||
base.removeChildRenderObject(child); |
|||
} |
|||
public override void visitChildren(ElementVisitor visitor) { |
|||
if (_prototype != null) |
|||
visitor(_prototype); |
|||
base.visitChildren(visitor); |
|||
} |
|||
public override void mount(Element parent, object newSlot) { |
|||
base.mount(parent, newSlot); |
|||
_prototype = updateChild(_prototype, widget.prototypeItem, _prototypeSlot); |
|||
} |
|||
public override void update(Widget newWidget) { |
|||
newWidget = (SliverPrototypeExtentList) newWidget; |
|||
base.update(newWidget); |
|||
D.assert(widget == newWidget); |
|||
_prototype = updateChild(_prototype, widget.prototypeItem, _prototypeSlot); |
|||
} |
|||
} |
|||
public class _RenderSliverPrototypeExtentList : RenderSliverFixedExtentBoxAdaptor { |
|||
public _RenderSliverPrototypeExtentList( |
|||
_SliverPrototypeExtentListElement childManager = null |
|||
) : base(childManager: childManager) { |
|||
} |
|||
|
|||
RenderBox _child; |
|||
|
|||
public RenderBox child { |
|||
get { return _child;} |
|||
set { |
|||
if (_child != null) |
|||
dropChild(_child); |
|||
_child = value; |
|||
if (_child != null) |
|||
adoptChild(_child); |
|||
markNeedsLayout(); |
|||
} |
|||
} |
|||
protected override void performLayout() { |
|||
child.layout(constraints.asBoxConstraints(), parentUsesSize: true); |
|||
base.performLayout(); |
|||
} |
|||
public override void attach(object owner) { |
|||
owner = (PipelineOwner) owner; |
|||
base.attach(owner); |
|||
if (_child != null) |
|||
_child.attach(owner); |
|||
} |
|||
public override void detach() { |
|||
base.detach(); |
|||
if (_child != null) |
|||
_child.detach(); |
|||
} |
|||
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 float itemExtent { |
|||
get { |
|||
D.assert(child != null && child.hasSize); |
|||
return constraints.axis == Axis.vertical ? child.size.height : child.size.width; |
|||
} |
|||
set { } |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
public abstract class StatusTransitionWidget : StatefulWidget { |
|||
public StatusTransitionWidget( |
|||
Animation<float> animation, |
|||
Key key = null |
|||
) : base(key: key) { |
|||
D.assert(animation != null); |
|||
this.animation = animation; |
|||
} |
|||
|
|||
public readonly Animation<float> animation; |
|||
|
|||
public abstract Widget build(BuildContext context); |
|||
public override State createState() => new _StatusTransitionState(); |
|||
} |
|||
public class _StatusTransitionState : State<StatusTransitionWidget> { |
|||
public override void initState() { |
|||
base.initState(); |
|||
widget.animation.addStatusListener(_animationStatusChanged); |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|||
oldWidget = (StatusTransitionWidget)oldWidget; |
|||
base.didUpdateWidget(oldWidget); |
|||
if (widget.animation != ((StatusTransitionWidget)oldWidget).animation) { |
|||
((StatusTransitionWidget)oldWidget).animation.removeStatusListener(_animationStatusChanged); |
|||
widget.animation.addStatusListener(_animationStatusChanged); |
|||
} |
|||
} |
|||
|
|||
public override void dispose() { |
|||
widget.animation.removeStatusListener(_animationStatusChanged); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _animationStatusChanged(AnimationStatus status) { |
|||
setState(() =>{ |
|||
// The animation's state is our build state, and it changed already.
|
|||
}); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return widget.build(context); |
|||
} |
|||
} |
|||
|
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue