浏览代码

fix T-W

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
b836738c
共有 23 个文件被更改,包括 1073 次插入185 次删除
  1. 39
      com.unity.uiwidgets/Runtime/painting/inline_span.cs
  2. 15
      com.unity.uiwidgets/Runtime/painting/placeholder_span.cs
  3. 125
      com.unity.uiwidgets/Runtime/painting/text_span.cs
  4. 48
      com.unity.uiwidgets/Runtime/rendering/object.cs
  5. 11
      com.unity.uiwidgets/Runtime/rendering/paragraph.cs
  6. 3
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  7. 60
      com.unity.uiwidgets/Runtime/rendering/viewport.cs
  8. 1
      com.unity.uiwidgets/Runtime/scheduler2/binding.cs
  9. 65
      com.unity.uiwidgets/Runtime/service/system_chrome.cs
  10. 2
      com.unity.uiwidgets/Runtime/ui2/painting.cs
  11. 3
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  12. 6
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  13. 109
      com.unity.uiwidgets/Runtime/widgets/sliver.cs
  14. 109
      com.unity.uiwidgets/Runtime/widgets/transitions.cs
  15. 7
      com.unity.uiwidgets/Runtime/widgets/value_listenable_builder.cs
  16. 25
      com.unity.uiwidgets/Runtime/widgets/viewport.cs
  17. 111
      com.unity.uiwidgets/Runtime/widgets/visibility.cs
  18. 4
      com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
  19. 62
      com.unity.uiwidgets/Runtime/widgets/widget_span.cs
  20. 333
      com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs
  21. 38
      com.unity.uiwidgets/Runtime/widgets/title.cs
  22. 61
      com.unity.uiwidgets/Runtime/widgets/tween_animation_builder.cs
  23. 21
      com.unity.uiwidgets/Runtime/widgets/unique_widget.cs

39
com.unity.uiwidgets/Runtime/painting/inline_span.cs


public abstract class InlineSpan : DiagnosticableTree, IEquatable<InlineSpan> {
public InlineSpan(
TextStyle style , HoverRecognizer hoverRecognizer
TextStyle style = null
this.hoverRecognizer = hoverRecognizer;
public readonly HoverRecognizer hoverRecognizer;
public bool hasHoverRecognizer {
get {
bool need = false;
visitChildren((text) => {
if (text.hoverRecognizer != null) {
need = true;
return false;
}
return true;
});
return need;
}
}
public abstract void build(ParagraphBuilder builder,
float textScaleFactor = 1, List<PlaceholderDimensions> dimensions = null
);

public InlineSpan getSpanForPosition(TextPosition position) {
public virtual InlineSpan getSpanForPosition(TextPosition position) {
D.assert(debugAssertIsValid());
Accumulator offset = new Accumulator();
InlineSpan result = null;

protected abstract InlineSpan getSpanForPositionVisitor(TextPosition position, Accumulator offset);
public string toPlainText(
bool includeSemanticsLabels = true, bool includePlaceholders = true) {
public virtual string toPlainText(
bool includeSemanticsLabels = true,
bool includePlaceholders = true)
{
StringBuilder buffer = new StringBuilder();
computeToPlainText(buffer, includeSemanticsLabels: includeSemanticsLabels,
includePlaceholders: includePlaceholders);

public abstract void computeSemanticsInformation(List<InlineSpanSemanticsInformation> collector);
public abstract void computeToPlainText(StringBuilder buffer,
bool includeSemanticsLabels = true, bool includePlaceholders = true);
public abstract void computeToPlainText(
StringBuilder buffer,
bool includeSemanticsLabels = true,
bool includePlaceholders = true);
public int? codeUnitAt(int index) {
if (index < 0)

protected abstract int? codeUnitAtVisitor(int index, Accumulator offset);
public bool debugAssertIsValid() => true;
public virtual bool debugAssertIsValid() => true;
public abstract RenderComparison compareTo(InlineSpan other);
void debugFillProperties(DiagnosticPropertiesBuilder properties) {

15
com.unity.uiwidgets/Runtime/painting/placeholder_span.cs


using System.Collections.Generic;
using System.Text;
using JetBrains.Annotations;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.ui;

public PlaceholderSpan(
TextBaseline baseline,
TextStyle style,
PlaceholderAlignment alignment = PlaceholderAlignment.bottom,
HoverRecognizer hoverRecognizer = null
) : base(style: style, hoverRecognizer: hoverRecognizer) {
TextBaseline? baseline = null,
TextStyle style = null,
PlaceholderAlignment alignment = PlaceholderAlignment.bottom
) : base(style: style) {
this.baseline = baseline;
this.alignment = alignment;
}

public TextBaseline baseline;
public TextBaseline? baseline;
public override void computeToPlainText(
StringBuilder buffer,

base.debugFillProperties(properties);
properties.add(new EnumProperty<PlaceholderAlignment>("alignment", alignment, defaultValue: null));
properties.add(new EnumProperty<TextBaseline>("baseline", baseline, defaultValue: null));
properties.add(new EnumProperty<TextBaseline>("baseline", (TextBaseline)baseline, defaultValue: null));
}
}
}

125
com.unity.uiwidgets/Runtime/painting/text_span.cs


public readonly string semanticsLabel;
public TextSpan(
string text = "",
string text = null,
HoverRecognizer hoverRecognizer = null,
string semanticsLabel = null) : base(style: style, hoverRecognizer: hoverRecognizer) {
string semanticsLabel = null
) : base(style: style) {
this.text = text;
this.children = children;
this.recognizer = recognizer;

public override void build(ParagraphBuilder builder, float textScaleFactor = 1.0f,
List<PlaceholderDimensions> dimensions = null) {
public override void build(
ParagraphBuilder builder,
float textScaleFactor = 1.0f,
List<PlaceholderDimensions> dimensions = null
) {
D.assert(debugAssertIsValid());
var hasStyle = style != null;

if (text != null)
builder.addText(text);
if (children != null) {

return null;
}
public override void computeToPlainText(StringBuilder buffer, bool includeSemanticsLabels = true,
bool includePlaceholders = true) {
public override void computeToPlainText(
StringBuilder buffer,
bool includeSemanticsLabels = true,
bool includePlaceholders = true
) {
D.assert(debugAssertIsValid());
if (semanticsLabel != null && includeSemanticsLabels) {
buffer.Append(semanticsLabel);

return null;
}
bool debugAssertIsValid() {
public override bool debugAssertIsValid() {
D.assert(() => {
if (children != null) {
foreach (InlineSpan child in children) {

return result;
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((TextSpan) obj);
}
unchecked {
unchecked
{
var hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (text != null ? text.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (children != null ? children.GetHashCode() : 0);

}
}
public bool Equals(InlineSpan otherInline) {
if (ReferenceEquals(null, otherInline)) {
return false;
}
if (ReferenceEquals(this, otherInline)) {
return true;
}
TextSpan other = otherInline as TextSpan;
return Equals(style, other.style) && string.Equals(text, other.text) &&
childEquals(children, other.children) && recognizer == other.recognizer;
}
public static bool operator ==(TextSpan left, TextSpan right) {
return Equals(left, right);
}

}
int childHash() {
unchecked {
var hashCode = 0;
if (children != null) {
foreach (var child in children) {
hashCode = (hashCode * 397) ^ (child != null ? child.GetHashCode() : 0);
}
}
return hashCode;
}
}
static bool childEquals(List<InlineSpan> left, List<InlineSpan> right) {
if (ReferenceEquals(left, right)) {
return true;

return left.SequenceEqual(right);
}
public override string toStringShort() {
return GetType().ToString();
}
properties.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace;
// Properties on style are added as if they were properties directly on
// this TextSpan.
if (style != null) {
style.debugFillProperties(properties);
}
properties.add(
new StringProperty(
"text",
text,
showName: false,
defaultValue: null
)
);
if (style == null && text == null && children == null)
properties.add(DiagnosticsNode.message("(empty)"));
description: recognizer == null ? "" : recognizer.GetType().FullName,
defaultValue: foundation_.kNullDefaultValue
description: recognizer?.GetType()?.ToString(),
defaultValue: null
properties.add(new StringProperty("text", text, showName: false,
defaultValue: foundation_.kNullDefaultValue));
if (style == null && text == null && children == null) {
properties.add(DiagnosticsNode.message("(empty)"));
if (semanticsLabel != null) {
properties.add(new StringProperty("semanticsLabel", semanticsLabel));
}
}

}).ToList();
}
public bool Equals(TextSpan other) {
public bool Equals(TextSpan other)
{
if (ReferenceEquals(null, other)) {
return false;
}

}
return base.Equals(other) && text == other.text && Equals(children, other.children) &&
Equals(recognizer, other.recognizer) && semanticsLabel == other.semanticsLabel;
return base.Equals(other) && text == other.text && Equals(children, other.children) && Equals(recognizer, other.recognizer) && semanticsLabel == other.semanticsLabel;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((TextSpan) obj);
}
}
}

48
com.unity.uiwidgets/Runtime/rendering/object.cs


public void pushOpacity(Offset offset, int alpha, PaintingContextCallback painter) {
pushLayer(new OpacityLayer(alpha: alpha), painter, offset);
}
public OpacityLayer pushOpacity(Offset offset, int alpha, PaintingContextCallback painter, OpacityLayer oldLayer = null) {
OpacityLayer layer = oldLayer ?? new OpacityLayer();
layer.alpha = alpha;
layer.offset = offset;
pushLayer(layer, painter, Offset.zero);
return layer;
}
public override string ToString() {
return

D.assert(node._relayoutBoundary == node);
return true;
}
// TODO
/*void markNeedsSemanticsUpdate() {
D.assert(!attached || !owner._debugDoingSemantics);
if (!attached || owner._semanticsOwner == null) {
_cachedSemanticsConfiguration = null;
return;
}
bool wasSemanticsBoundary = _semantics != null && _cachedSemanticsConfiguration?.isSemanticBoundary == true;
_cachedSemanticsConfiguration = null;
bool isEffectiveSemanticsBoundary = _semanticsConfiguration.isSemanticBoundary && wasSemanticsBoundary;
RenderObject node = this;
while (!isEffectiveSemanticsBoundary && node.parent is RenderObject) {
if (node != this && node._needsSemanticsUpdate)
break;
node._needsSemanticsUpdate = true;
node = node.parent as RenderObject;
isEffectiveSemanticsBoundary = node._semanticsConfiguration.isSemanticBoundary;
if (isEffectiveSemanticsBoundary && node._semantics == null) {
return;
}
}
if (node != this && _semantics != null && _needsSemanticsUpdate) {
owner._nodesNeedingSemantics.remove(this);
}
if (!node._needsSemanticsUpdate) {
node._needsSemanticsUpdate = true;
if (owner != null) {
D.assert(node._semanticsConfiguration.isSemanticBoundary || node.parent is! RenderObject);
owner._nodesNeedingSemantics.add(node);
owner.requestVisualUpdate();
}
}
}*/
public virtual void markNeedsLayout() {
D.assert(_debugCanPerformMutations);
if (_needsLayout) {

RenderObject child { get; set; }
}
public interface RenderObjectWithChildMixin<ChildType> : RenderObjectWithChildMixin
where ChildType : RenderObject {
new ChildType child { get; set; }
public interface RenderObjectWithChildMixin<ChildType> : RenderObjectWithChildMixin where ChildType : RenderObject {
ChildType child { get; set; }
}
public interface ContainerParentDataMixin<ChildType> where ChildType : RenderObject {

11
com.unity.uiwidgets/Runtime/rendering/paragraph.cs


public class RenderParagraph : RenderBox{
// ContainerRenderObjectMixin<RenderBox, TextParentData>,
//RenderBoxContainerDefaultsMixin<RenderBox, TextParentData>,
//RelayoutWhenSystemFontsChangeMixin
static readonly string _kEllipsis = "\u2026";
bool _softWrap;

_pointerHoverInside = true;
}
void _onPointerExit(PointerEvent evt) {
/*void _onPointerExit(PointerEvent evt) {
}
}*/
void _onPointerHover(PointerEvent evt) {
/*void _onPointerHover(PointerEvent evt) {
_layoutTextWithConstraints(constraints);
Offset offset = globalToLocal(evt.position);
TextPosition position = _textPainter.getPositionForOffset(offset);

(span as TextSpan)?.hoverRecognizer?.OnPointerEnter?.Invoke((PointerHoverEvent) evt);
_previousHoverSpan = span;
}
}
}*/
public override void handleEvent(PointerEvent evt, HitTestEntry entry) {
D.assert(debugHandleEvent(evt, entry));

3
com.unity.uiwidgets/Runtime/rendering/sliver.cs


_geometry = value;
}
}
SliverGeometry _geometry;
public override Rect paintBounds {

get { return 0.0f; }
}
public bool hitTest(SliverHitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
public virtual bool hitTest(SliverHitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
if (mainAxisPosition >= 0.0f && mainAxisPosition < geometry.hitTestExtent &&
crossAxisPosition >= 0.0f && crossAxisPosition < constraints.crossAxisExtent) {
if (hitTestChildren(result, mainAxisPosition: mainAxisPosition,

60
com.unity.uiwidgets/Runtime/rendering/viewport.cs


using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public enum CacheExtentStyle {
/// Treat the [Viewport.cacheExtent] as logical pixels.
pixel,
/// Treat the [Viewport.cacheExtent] as a multiplier of the main axis extent.
viewport,
}
public interface RenderAbstractViewport {
RevealedOffset getOffsetToReveal(RenderObject target, float alignment, Rect rect = null);
RenderObject parent { get; }

AxisDirection axisDirection = AxisDirection.down,
AxisDirection crossAxisDirection = AxisDirection.right,
ViewportOffset offset = null,
float cacheExtent = RenderViewportUtils.defaultCacheExtent
float cacheExtent = RenderViewportUtils.defaultCacheExtent,
CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel
D.assert(axisDirection != null);
D.assert(crossAxisDirection != null);
D.assert(cacheExtentStyle != null);
D.assert(cacheExtent != null || cacheExtentStyle == CacheExtentStyle.pixel);
_cacheExtentStyle = cacheExtentStyle;
}
public new RenderObject parent {

markNeedsLayout();
}
}
public float _calculatedCacheExtent;
public CacheExtentStyle cacheExtentStyle {
get {
return _cacheExtentStyle;
}
set {
D.assert(value != null);
if (value == _cacheExtentStyle) {
return;
}
_cacheExtentStyle = value;
markNeedsLayout();
}
}
CacheExtentStyle _cacheExtentStyle;
public override void attach(object owner) {
base.attach(owner);
_offset.addListener(markNeedsLayout);

float anchor = 0.0f,
List<RenderSliver> children = null,
RenderSliver center = null,
float cacheExtent = RenderViewportUtils.defaultCacheExtent
) : base(axisDirection, crossAxisDirection, offset, cacheExtent) {
float cacheExtent = RenderViewportUtils.defaultCacheExtent,
CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel
) : base(axisDirection, crossAxisDirection, offset, cacheExtent,cacheExtentStyle) {
D.assert(anchor != null);
D.assert(cacheExtentStyle != CacheExtentStyle.viewport || cacheExtent != null);
if (center == null && firstChild != null) {
_center = firstChild;
}

float reverseDirectionRemainingPaintExtent = centerOffset.clamp(0.0f, mainAxisExtent);
float forwardDirectionRemainingPaintExtent = (mainAxisExtent - centerOffset).clamp(0.0f, mainAxisExtent);
float fullCacheExtent = mainAxisExtent + 2 * cacheExtent;
float centerCacheOffset = centerOffset + cacheExtent;
switch (cacheExtentStyle) {
case CacheExtentStyle.pixel:
_calculatedCacheExtent = cacheExtent;
break;
case CacheExtentStyle.viewport:
_calculatedCacheExtent = mainAxisExtent * cacheExtent;
break;
}
float fullCacheExtent = mainAxisExtent + 2 * _calculatedCacheExtent;
float centerCacheOffset = centerOffset + _calculatedCacheExtent;
float reverseDirectionRemainingCacheExtent = centerCacheOffset.clamp(0.0f, fullCacheExtent);
float forwardDirectionRemainingCacheExtent =
(fullCacheExtent - centerCacheOffset).clamp(0.0f, fullCacheExtent);

growthDirection: GrowthDirection.reverse,
advance: childBefore,
remainingCacheExtent: reverseDirectionRemainingCacheExtent,
cacheOrigin: (mainAxisExtent - centerOffset).clamp(-cacheExtent, 0.0f)
cacheOrigin: (mainAxisExtent - centerOffset).clamp(-_calculatedCacheExtent, 0.0f)
);
if (result != 0.0f) {
return -result;

growthDirection: GrowthDirection.forward,
advance: childAfter,
remainingCacheExtent: forwardDirectionRemainingCacheExtent,
cacheOrigin: centerOffset.clamp(-cacheExtent, 0.0f)
cacheOrigin: centerOffset.clamp(-_calculatedCacheExtent, 0.0f)
);
}

1
com.unity.uiwidgets/Runtime/scheduler2/binding.cs


_ensureEventLoopCallback();
return entry.completer.future;
}
protected override void unlocked() {
base.unlocked();

65
com.unity.uiwidgets/Runtime/service/system_chrome.cs


using System;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.service {

return !Equals(left, right);
}
}
public class SystemChrome {
/*public static Future setPreferredOrientations(List<DeviceOrientation> orientations) {
return SystemChannels.platform.invokeMethod(
"SystemChrome.setPreferredOrientations",
_stringify(orientations)
);
}
public static Future setApplicationSwitcherDescription(ApplicationSwitcherDescription description){
return SystemChannels.platform.invokeMethod(
"SystemChrome.setApplicationSwitcherDescription",
new Dictionary<string, object>{
{"label",description.label},
{"primaryColor", description.primaryColor},
}
);
}
static Future setEnabledSystemUIOverlays(List<SystemUiOverlay> overlays) {
return SystemChannels.platform.invokeMethod(
"SystemChrome.setEnabledSystemUIOverlays",
_stringify(overlays)
);
}
public static Future restoreSystemUIOverlays() {
return SystemChannels.platform.invokeMethod(
"SystemChrome.restoreSystemUIOverlays",
null
);
}
public static void setSystemUIOverlayStyle(SystemUiOverlayStyle style) {
D.assert(style != null);
if (_pendingStyle != null) {
_pendingStyle = style;
return;
}
if (style == _latestStyle) {
return;
}
_pendingStyle = style;
scheduleMicrotask(()=> {
D.assert(_pendingStyle != null);
if (_pendingStyle != _latestStyle) {
return SystemChannels.platform.invokeMethod(
"SystemChrome.setSystemUIOverlayStyle",
_pendingStyle._toMap()
);
_latestStyle = _pendingStyle;
}
_pendingStyle = null;
});
}*/
public static SystemUiOverlayStyle _pendingStyle;
public static SystemUiOverlayStyle latestStyle {
get {
return _latestStyle;
}
}
static SystemUiOverlayStyle _latestStyle;
}
}

2
com.unity.uiwidgets/Runtime/ui2/painting.cs


}
}
static int getAlphaFromOpacity(float opacity) {
public static int getAlphaFromOpacity(float opacity) {
return (opacity.clamp(0.0f, 1.0f) * 255).round();
}

3
com.unity.uiwidgets/Runtime/widgets/basic.cs


}
public readonly bool ignoring;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderIgnorePointer(
ignoring: ignoring

6
com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs


public ImplicitlyAnimatedWidget(
Key key = null,
Curve curve = null,
TimeSpan? duration = null
TimeSpan? duration = null,
VoidCallback onEnd = null
this.onEnd = onEnd;
public readonly VoidCallback onEnd;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);

109
com.unity.uiwidgets/Runtime/widgets/sliver.cs


public abstract override RenderObject createRenderObject(BuildContext context);
}
public class SliverIgnorePointer : SingleChildRenderObjectWidget {
public SliverIgnorePointer(
Key key = null,
bool ignoring = true,
bool? ignoringSemantics = null,
Widget sliver = null
) : base(key: key, child: sliver) {
D.assert(ignoring != null);
this.ignoring = ignoring;
this.ignoringSemantics = ignoringSemantics;
}
public readonly bool ignoring;
public readonly bool? ignoringSemantics;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverIgnorePointer(
ignoring: ignoring,
ignoringSemantics: ignoringSemantics
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverIgnorePointer) renderObject;
((RenderSliverIgnorePointer)renderObject).ignoring = ignoring;
((RenderSliverIgnorePointer)renderObject).ignoringSemantics = ignoringSemantics;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("ignoring", ignoring));
properties.add(new DiagnosticsProperty<bool>("ignoringSemantics", (bool)ignoringSemantics, defaultValue: null));
}
}
public class SliverOffstage : SingleChildRenderObjectWidget {
public SliverOffstage(
Key key = null,
bool offstage = true,
Widget sliver = null) : base(key: key, child: sliver) {
D.assert(offstage != null);
this.offstage = offstage;
}
public readonly bool offstage;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverOffstage(offstage: offstage);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverOffstage) renderObject;
((RenderSliverOffstage)renderObject).offstage = offstage;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("offstage", offstage));
}
public override Element createElement() {
return new _SliverOffstageElement(this);
}
}
public abstract class SliverMultiBoxAdaptorWidget : SliverWithKeepAliveWidget {
protected SliverMultiBoxAdaptorWidget(

public override RenderObject createRenderObject(BuildContext context) {
SliverMultiBoxAdaptorElement element = (SliverMultiBoxAdaptorElement) context;
return new RenderSliverList(childManager: element);
}
}
public class SliverOpacity : SingleChildRenderObjectWidget {
public SliverOpacity(
Key key = null,
float opacity = 0f,
bool alwaysIncludeSemantics = false,
Widget sliver = null) : base(key: key, child: sliver) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
D.assert(alwaysIncludeSemantics != null);
this.opacity = opacity;
this.alwaysIncludeSemantics = alwaysIncludeSemantics;
}
public readonly float opacity;
public readonly bool alwaysIncludeSemantics;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverOpacity(
opacity: opacity,
alwaysIncludeSemantics: alwaysIncludeSemantics
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
renderObject = (RenderSliverOpacity) renderObject;
((RenderSliverOpacity) renderObject).opacity = opacity;
((RenderSliverOpacity) renderObject).alwaysIncludeSemantics = alwaysIncludeSemantics;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<float>("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
}
public class _SliverOffstageElement : SingleChildRenderObjectElement {
public _SliverOffstageElement(SliverOffstage widget) : base(widget) {
}
public SliverOffstage widget {
get { return base.widget as SliverOffstage; }
}
public override void debugVisitOnstageChildren(ElementVisitor visitor) {
if (!widget.offstage)
base.debugVisitOnstageChildren(visitor);
}
}

109
com.unity.uiwidgets/Runtime/widgets/transitions.cs


namespace Unity.UIWidgets.widgets {
public abstract class AnimatedWidget : StatefulWidget {
public readonly Listenable listenable;
protected AnimatedWidget(Key key = null, Listenable listenable = null) : base(key) {
protected AnimatedWidget(
Key key = null,
Listenable listenable = null
) : base(key) {
D.assert(listenable != null);
this.listenable = listenable;
}

}
public class SlideTransition : AnimatedWidget {
public SlideTransition(Key key = null,
public SlideTransition(
Key key = null,
Widget child = null) : base(key: key, listenable: position) {
Widget child = null
) : base(key: key, listenable: position) {
D.assert(position != null);
this.transformHitTests = transformHitTests;
this.textDirection = textDirection;

protected internal override Widget build(BuildContext context) {
float scaleValue = scale.value;
Matrix4 transform = Matrix4.diagonal3Values(scaleValue, scaleValue, 1);
Matrix4 transform = Matrix4.identity();
transform.scale(scaleValue, scaleValue, 1.0f);
return new Transform(
transform: transform,
alignment: alignment,

Key key = null,
Animation<float> turns = null,
Alignment alignment = null,
Widget child = null) : base(key: key, listenable: turns) {
Widget child = null) :
base(key: key, listenable: turns) {
D.assert(turns != null);
this.alignment = alignment ?? Alignment.center;
this.child = child;

Axis axis = Axis.vertical,
Animation<float> sizeFactor = null,
float axisAlignment = 0.0f,
Widget child = null) : base(key: key, listenable: sizeFactor) {
Widget child = null)
: base(key: key, listenable: sizeFactor) {
D.assert(sizeFactor != null);
this.axis = axis;
this.axisAlignment = axisAlignment;

}
public class FadeTransition : SingleChildRenderObjectWidget {
public FadeTransition(Key key = null, Animation<float> opacity = null,
Widget child = null) : base(key: key, child: child) {
public FadeTransition(
Key key = null,
Animation<float> opacity = null,
bool alwaysIncludeSemantics = false,
Widget child = null
) : base(key: key, child: child) {
this.alwaysIncludeSemantics = alwaysIncludeSemantics;
public readonly bool alwaysIncludeSemantics;
//alwaysIncludeSemantics: alwaysIncludeSemantics
//((RenderAnimatedOpacity) renderObject).alwaysIncludeSemantics = alwaysIncludeSemantics;
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
/*public class SliverFadeTransition : SingleChildRenderObjectWidget {
public SliverFadeTransition(
Animation<float> opacity ,
Key key = null,
bool alwaysIncludeSemantics = false,
Widget sliver = null
) : base(key: key, child: sliver) {
D.assert(opacity != null);
}
public readonly Animation<float> opacity;
public readonly bool alwaysIncludeSemantics;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverAnimatedOpacity(
opacity: opacity,
alwaysIncludeSemantics: alwaysIncludeSemantics
);
}
public override void updateRenderObject(BuildContext context, RenderSliverAnimatedOpacity renderObject) {
renderObject = (RenderSliverAnimatedOpacity) renderObject;
((RenderSliverAnimatedOpacity) renderObject).opacity = opacity;
((RenderSliverAnimatedOpacity) renderObject).alwaysIncludeSemantics = alwaysIncludeSemantics;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<float>>("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
}*/
public RelativeRectTween(RelativeRect begin = null, RelativeRect end = null) : base(begin: begin, end: end) {
public RelativeRectTween(
RelativeRect begin = null,
RelativeRect end = null) : base(begin: begin, end: end) {
}
public override RelativeRect lerp(float t) {

public class PositionedTransition : AnimatedWidget {
public PositionedTransition(
Animation<RelativeRect> rect ,
Animation<RelativeRect> rect = null,
D.assert(child != null);
this.child = child;
}

protected internal override Widget build(BuildContext context) {
return Positioned.fromRelativeRect(
rect: rect.value,

public class RelativePositionedTransition : AnimatedWidget {
public RelativePositionedTransition(
Key key = null,
Animation<Rect> rect = null,
Size size = null,
Widget child = null
Animation<Rect> rect,
Size size,
Widget child ,
Key key = null
) : base(key: key, listenable: rect) {
D.assert(rect != null);
D.assert(size != null);

public class DecoratedBoxTransition : AnimatedWidget {
public DecoratedBoxTransition(
Key key = null,
Animation<Decoration> decoration = null,
DecorationPosition position = DecorationPosition.background,
Widget child = null
Animation<Decoration> decoration ,
Widget child ,
Key key = null,
DecorationPosition position = DecorationPosition.background
) : base(key: key, listenable: decoration) {
D.assert(decoration != null);
D.assert(child != null);

public class AlignTransition : AnimatedWidget {
public AlignTransition(
Animation<Alignment> alignment,
Widget child,
Animation<Alignment> alignment = null,
Widget child = null,
float? widthFactor = null,
float? heightFactor = null
) : base(key: key, listenable: alignment) {

public class DefaultTextStyleTransition : AnimatedWidget {
public DefaultTextStyleTransition(
Animation<TextStyle> style,
Widget child,
Animation<TextStyle> style = null,
Widget child = null,
TextAlign? textAlign = null,
bool softWrap = true,
TextOverflow overflow = TextOverflow.clip,

public class AnimatedBuilder : AnimatedWidget {
public readonly TransitionBuilder builder;
public AnimatedBuilder(Key key = null, Listenable animation = null, TransitionBuilder builder = null,
Widget child = null) :
base(key, animation) {
public AnimatedBuilder(
Listenable animation,
TransitionBuilder builder,
Key key = null,
Widget child = null) : base(key, animation) {
D.assert(builder != null);
D.assert(animation != null);
this.builder = builder;

7
com.unity.uiwidgets/Runtime/widgets/value_listenable_builder.cs


public class ValueListenableBuilder<T> : StatefulWidget {
public ValueListenableBuilder(
ValueListenable<T> valueListenable,
ValueWidgetBuilder<T> builder,
ValueListenable<T> valueListenable ,
ValueWidgetBuilder<T> builder ,
Key key = null,
) {
) : base(key: key) {
D.assert(valueListenable != null);
D.assert(builder != null);
this.valueListenable = valueListenable;

25
com.unity.uiwidgets/Runtime/widgets/viewport.cs


ViewportOffset offset = null,
Key center = null,
float? cacheExtent = null,
CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel,
D.assert(center == null || children.Count(child => child.key == center) == 1);
D.assert(slivers != null);
D.assert(center == null || slivers.Where((Widget child) => child.key == center).Count() == 1);
D.assert(cacheExtentStyle != null);
D.assert(cacheExtentStyle != CacheExtentStyle.viewport || cacheExtent != null);
this.axisDirection = axisDirection;
this.crossAxisDirection = crossAxisDirection;
this.anchor = anchor;

this.cacheExtentStyle = cacheExtentStyle;
}
public readonly AxisDirection axisDirection;

public readonly Key center;
public readonly float? cacheExtent;
public readonly CacheExtentStyle cacheExtentStyle;
public static AxisDirection getDefaultCrossAxisDirection(BuildContext context, AxisDirection axisDirection) {
switch (axisDirection) {

public override RenderObject createRenderObject(BuildContext context) {
return new RenderViewport(
axisDirection: axisDirection,
crossAxisDirection: crossAxisDirection ??
getDefaultCrossAxisDirection(context, axisDirection),
crossAxisDirection: crossAxisDirection ?? getDefaultCrossAxisDirection(context, axisDirection),
cacheExtent: cacheExtent ?? RenderViewportUtils.defaultCacheExtent
);
cacheExtent: cacheExtent ?? RenderViewportUtils.defaultCacheExtent,
cacheExtentStyle: cacheExtentStyle);
renderObject.crossAxisDirection = crossAxisDirection ??
getDefaultCrossAxisDirection(context, axisDirection);
renderObject.crossAxisDirection = crossAxisDirection ?? getDefaultCrossAxisDirection(context, axisDirection);
renderObject.cacheExtentStyle = cacheExtentStyle;
}
public override Element createElement() {

else if (children.isNotEmpty() && children.First().key != null) {
properties.add(new DiagnosticsProperty<Key>("center", children.First().key, tooltip: "implicit"));
}
properties.add(new DiagnosticsProperty<float>("cacheExtent", (float)cacheExtent));
properties.add(new DiagnosticsProperty<CacheExtentStyle>("cacheExtentStyle", cacheExtentStyle));
}
}

ViewportOffset offset = null,
List<Widget> slivers = null
) : base(key: key, children: slivers) {
slivers = slivers ?? new List<Widget>();
this.axisDirection = axisDirection;
this.crossAxisDirection = crossAxisDirection;
this.offset = offset;

111
com.unity.uiwidgets/Runtime/widgets/visibility.cs


bool maintainState = false,
bool maintainAnimation = false,
bool maintainSize = false,
bool maintainSemantics = false,
D.assert(replacement != null);
D.assert(visible != null);
D.assert(maintainState != null);
D.assert(maintainAnimation != null);
D.assert(maintainSize != null);
D.assert(
maintainSize == true || maintainSemantics == false,
()=>"Cannot maintain semantics if size is not maintained."
);
D.assert(maintainSize == true || maintainInteractivity == false,
() => "Cannot maintain interactivity if size is not maintained.");
this.replacement = replacement ?? SizedBox.shrink();

this.maintainAnimation = maintainAnimation;
this.maintainSize = maintainSize;
this.maintainSemantics = maintainSemantics;
this.maintainInteractivity = maintainInteractivity;
}

public readonly bool maintainSize;
public readonly bool maintainSemantics;
public readonly bool maintainInteractivity;
public override Widget build(BuildContext context) {

result = new IgnorePointer(
child: child,
ignoring: !visible
//todo : ignoringSemantics: !visible && !maintainSemantics,
//alwaysIncludeSemantics: maintainSemantics,
D.assert(!maintainSemantics);
if (maintainState) {
Widget result = child;
if (!maintainAnimation) {

offstage: !visible
);
}
D.assert(!maintainAnimation);
D.assert(!maintainState);
return visible ? child : replacement;

properties.add(new FlagProperty("maintainAnimation", value: maintainAnimation,
ifFalse: "maintainAnimation"));
properties.add(new FlagProperty("maintainSize", value: maintainSize, ifFalse: "maintainSize"));
properties.add(new FlagProperty("maintainSemantics", value: maintainSemantics, ifFalse: "maintainSemantics"));
public class SliverVisibility : StatelessWidget {
public SliverVisibility(
Widget sliver,
Widget replacementSliver ,
Key key = null,
bool visible = true,
bool maintainState = false,
bool maintainAnimation = false,
bool maintainSize = false,
bool maintainSemantics = false,
bool maintainInteractivity = false) : base (key: key) {
replacementSliver = replacementSliver ?? new SliverToBoxAdapter();
D.assert(sliver != null);
D.assert(replacementSliver != null);
D.assert(visible != null);
D.assert(maintainState != null);
D.assert(maintainAnimation != null);
D.assert(maintainSize != null);
D.assert(maintainSemantics != null);
D.assert(maintainInteractivity != null);
D.assert(
maintainState == true || maintainAnimation == false,
()=>"Cannot maintain animations if the state is not also maintained."
);
D.assert(
maintainAnimation == true || maintainSize == false,
()=> "Cannot maintain size if animations are not maintained."
);
D.assert(
maintainSize == true || maintainSemantics == false,
()=> "Cannot maintain semantics if size is not maintained."
);
D.assert(
maintainSize == true || maintainInteractivity == false,
()=> "Cannot maintain interactivity if size is not maintained."
);
}
public readonly Widget sliver;
public readonly Widget replacementSliver;
public readonly bool visible;
public readonly bool maintainState;
public readonly bool maintainAnimation;
public readonly bool maintainSize;
public readonly bool maintainSemantics;
public readonly bool maintainInteractivity;
public override Widget build(BuildContext context) {
if (maintainSize) {
Widget result = sliver;
if (!maintainInteractivity) {
result = new SliverIgnorePointer(
sliver: sliver,
ignoring: !visible,
ignoringSemantics: !visible && !maintainSemantics
);
}
return new SliverOpacity(
opacity: visible ? 1.0f : 0.0f,
alwaysIncludeSemantics: maintainSemantics,
sliver: result
);
}
D.assert(!maintainInteractivity);
D.assert(!maintainSemantics);
D.assert(!maintainSize);
if (maintainState) {
Widget result = sliver;
if (!maintainAnimation)
result = new TickerMode(child: sliver, enabled: visible);
return new SliverOffstage(
sliver: result,
offstage: !visible
);
}
D.assert(!maintainAnimation);
D.assert(!maintainState);
return visible ? sliver : replacementSliver;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add( new FlagProperty("visible", value: visible, ifFalse: "hidden", ifTrue: "visible"));
properties.add( new FlagProperty("maintainState", value: maintainState, ifFalse: "maintainState"));
properties.add( new FlagProperty("maintainAnimation", value: maintainAnimation, ifFalse: "maintainAnimation"));
properties.add( new FlagProperty("maintainSize", value: maintainSize, ifFalse: "maintainSize"));
properties.add( new FlagProperty("maintainSemantics", value: maintainSemantics, ifFalse: "maintainSemantics"));
properties.add( new FlagProperty("maintainInteractivity", value: maintainInteractivity, ifFalse: "maintainInteractivity"));
}
}
}

4
com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs


}
class _InspectorOverlay : LeafRenderObjectWidget {
public _InspectorOverlay(Key key, InspectorSelection selection) : base(key) {
public _InspectorOverlay(
Key key = null,
InspectorSelection selection = null) : base(key) {
this.selection = selection;
}

62
com.unity.uiwidgets/Runtime/widgets/widget_span.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;

namespace Unity.UIWidgets.widgets {
class WidgetSpan : PlaceholderSpan {
class WidgetSpan : PlaceholderSpan,IEquatable<WidgetSpan> {
Widget child,
TextBaseline baseline,
TextStyle style,
Widget child ,
TextBaseline? baseline = null,
TextStyle style = null,
PlaceholderAlignment alignment = PlaceholderAlignment.bottom
) : base(
alignment: alignment,

public override RenderComparison compareTo(InlineSpan other) {
if (this == other)
return RenderComparison.identical;
if (style.GetType() == GetType())
return RenderComparison.layout;
if (child.Equals(typedOther.child) || alignment != typedOther.alignment) {
if (!child.Equals(typedOther.child) || alignment != typedOther.alignment) {
return RenderComparison.layout;
}

}
public override int GetHashCode() {
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (child.GetHashCode());
hashCode = (hashCode * 397) ^ (alignment.GetHashCode());
hashCode = (hashCode * 397) ^ (baseline.GetHashCode());
return hashCode;
unchecked
{
return (base.GetHashCode() * 397) ^ (child != null ? child.GetHashCode() : 0);
}
return true;
}
public bool Equals(WidgetSpan other)
{
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return base.Equals(other) && Equals(child, other.child);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((WidgetSpan) obj);
}
public static bool operator ==(WidgetSpan left, WidgetSpan right) {
return Equals(left, right);
}
public static bool operator !=(WidgetSpan left, WidgetSpan right) {
return !Equals(left, right);
}
public override bool debugAssertIsValid() {
return true;
}
}

333
com.unity.uiwidgets/Runtime/rendering/proxy_sliver.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.rendering {
public abstract class RenderProxySliver : RenderSliver , RenderObjectWithChildMixin<RenderSliver> {
public RenderProxySliver(RenderSliver child = null) {
this.child = child;
}
RenderSliver _child;
public RenderSliver child {
get { return _child; }
set {
if (_child != null)
dropChild(_child);
_child = value;
if (_child != null)
adoptChild(_child);
}
}
public override void setupParentData(RenderObject child) {
if (!(child.parentData is SliverPhysicalParentData))
child.parentData = new SliverPhysicalParentData();
}
protected override void performLayout() {
D.assert(child != null);
child.layout(constraints, parentUsesSize: true);
geometry = child.geometry;
}
public override void paint(PaintingContext context, Offset offset) {
if (child != null)
context.paintChild(child, offset);
}
protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
return child != null
&& child.geometry.hitTestExtent > 0
&& child.hitTest(
result,
mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition);
}
public override float childMainAxisPosition(RenderObject child) {
child = (RenderSliver)child;
D.assert(child != null);
D.assert(child == this.child);
return 0.0f;
}
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
childParentData.applyPaintTransform(transform);
}
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is RenderSliver)) {
string result = "";
result += new ErrorDescription(
$"A {GetType()} expected a child of type $ChildType but received a " +
$"child of type {child.GetType()}.");
result += new ErrorDescription(
"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."
);
result += new ErrorSpacer();
result += new DiagnosticsProperty<dynamic>(
$"The {GetType()} that expected a $ChildType child was created by",
debugCreator,
style: DiagnosticsTreeStyle.errorProperty
);
result += new ErrorSpacer();
result += new DiagnosticsProperty<dynamic>(
$"The {child.GetType()} that did not match the expected child type " +
"was created by",
child.debugCreator,
style: DiagnosticsTreeStyle.errorProperty
);
throw new UIWidgetsError(result);
}
return true;
});
return true;
}
RenderObject RenderObjectWithChildMixin.child {
get { return child; }
set { child = (RenderSliver) value; }
}
}
public class RenderSliverOpacity : RenderProxySliver {
public RenderSliverOpacity(
RenderSliver sliver = null,
float opacity = 1.0f,
bool alwaysIncludeSemantics = false
) : base( child:sliver) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
D.assert(alwaysIncludeSemantics != null);
_opacity = opacity;
_alwaysIncludeSemantics = alwaysIncludeSemantics;
_alpha = ui.Color.getAlphaFromOpacity(opacity);
child = sliver;
}
bool alwaysNeedsCompositing {
get { return child != null && (_alpha != 0 && _alpha != 255);}
}
int _alpha;
public float opacity {
get { return _opacity; }
set {
D.assert(value != null);
D.assert(value >= 0.0 && value <= 1.0);
if (_opacity == value)
return;
bool didNeedCompositing = alwaysNeedsCompositing;
bool wasVisible = _alpha != 0;
_opacity = value;
_alpha = ui.Color.getAlphaFromOpacity(_opacity);
if (didNeedCompositing != alwaysNeedsCompositing)
markNeedsCompositingBitsUpdate();
markNeedsPaint();
//if (wasVisible != (_alpha != 0) && !alwaysIncludeSemantics)
// markNeedsSemanticsUpdate();
}
}
float _opacity;
public bool alwaysIncludeSemantics {
get { return _alwaysIncludeSemantics;}
set {
if (value == _alwaysIncludeSemantics)
return;
_alwaysIncludeSemantics = value;
// markNeedsSemanticsUpdate();
}
}
bool _alwaysIncludeSemantics;
public override void paint(PaintingContext context, Offset offset) {
if (child != null && child.geometry.visible) {
if (_alpha == 0) {
setLayer(null);
return;
}
if (_alpha == 255) {
setLayer(null);
context.paintChild(child, offset);
return;
}
D.assert(needsCompositing);
var opacity = context.pushOpacity(
offset,
_alpha,
base.paint,
oldLayer: layer as OpacityLayer
);
setLayer(opacity);
}
}
/*public override void visitChildrenForSemantics(RenderObject visitor) {
visitor = (RenderObjectVisitor)visitor;
if (child != null && (_alpha != 0 || alwaysIncludeSemantics))
visitor(child);
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("opacity", opacity));
properties.add(new FlagProperty("alwaysIncludeSemantics", value: alwaysIncludeSemantics, ifTrue: "alwaysIncludeSemantics"));
}
}
public class RenderSliverIgnorePointer : RenderProxySliver {
public RenderSliverIgnorePointer(
RenderSliver sliver = null,
bool ignoring = true,
bool? ignoringSemantics = null
):base(child:sliver){
child = sliver;
D.assert(ignoring != null);
_ignoring = ignoring;
_ignoringSemantics = ignoringSemantics;
}
public bool ignoring {
get { return _ignoring; }
set {
D.assert(value != null);
if (value == _ignoring)
return;
_ignoring = value;
//if (_ignoringSemantics == null || !_ignoringSemantics)
// markNeedsSemanticsUpdate();
}
}
bool _ignoring;
public bool? ignoringSemantics {
get { return _ignoringSemantics; }
set {
if (value == _ignoringSemantics)
return ;
bool oldEffectiveValue = _effectiveIgnoringSemantics;
_ignoringSemantics = value;
//if (oldEffectiveValue != _effectiveIgnoringSemantics)
// markNeedsSemanticsUpdate();
}
}
bool? _ignoringSemantics;
bool _effectiveIgnoringSemantics {
get { return ignoringSemantics ?? ignoring; }
}
public override bool hitTest(SliverHitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
return !ignoring && base.hitTest(
result,
mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition
);
}
/*public override void visitChildrenForSemantics(RenderObjectVisitor visitor) {
if (child != null && !_effectiveIgnoringSemantics)
visitor(child);
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("ignoring", ignoring));
properties.add(new DiagnosticsProperty<bool>("ignoringSemantics", _effectiveIgnoringSemantics, description: ignoringSemantics == null ? $"implicitly {_effectiveIgnoringSemantics}" : null));
}
}
public class RenderSliverOffstage : RenderProxySliver {
public RenderSliverOffstage(
RenderSliver sliver = null,
bool offstage = true): base(child:sliver) {
D.assert(offstage != null);
_offstage = offstage;
child = sliver;
}
public bool offstage {
get { return _offstage; }
set {
D.assert(value != null);
if (value == _offstage)
return;
_offstage = value;
markNeedsLayoutForSizedByParentChange();
}
}
bool _offstage;
protected override void performLayout() {
D.assert(child != null);
child.layout(constraints, parentUsesSize: true);
if (!offstage)
geometry = child.geometry;
else
geometry = new SliverGeometry(
scrollExtent: 0.0f,
visible: false,
maxPaintExtent: 0.0f);
}
public override bool hitTest(SliverHitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
return !offstage && base.hitTest(result, mainAxisPosition: mainAxisPosition, crossAxisPosition: crossAxisPosition);
}
protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0, float crossAxisPosition = 0) {
return !offstage
&& child != null
&& child.geometry.hitTestExtent > 0
&& child.hitTest(
result,
mainAxisPosition: mainAxisPosition,
crossAxisPosition: crossAxisPosition
);
}
public override void paint(PaintingContext context, Offset offset) {
if (offstage)
return;
context.paintChild(child, offset);
}
/*public override void visitChildrenForSemantics(RenderObjectVisitor visitor) {
if (offstage)
return;
base.visitChildrenForSemantics(visitor);
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<bool>("offstage", offstage));
}
public override List<DiagnosticsNode> debugDescribeChildren() {
if (child == null)
return new List<DiagnosticsNode>();
return new List<DiagnosticsNode>{
child.toDiagnosticsNode(
name: "child",
style: offstage ? DiagnosticsTreeStyle.offstage : DiagnosticsTreeStyle.sparse
),
};
}
}
/*public class RenderSliverAnimatedOpacity : RenderProxySliver ,RenderAnimatedOpacityMixin<RenderSliver>{
public RenderSliverAnimatedOpacity(
Animation<double> opacity = null,
bool alwaysIncludeSemantics = false,
RenderSliver sliver = null
):base(sliver) {
D.assert(opacity != null);
D.assert(alwaysIncludeSemantics != null);
this.opacity = opacity;
this.alwaysIncludeSemantics = alwaysIncludeSemantics;
child = sliver;
}
}*/
}

38
com.unity.uiwidgets/Runtime/widgets/title.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.service;
namespace Unity.UIWidgets.widgets {
class Title : StatelessWidget {
public Title(
Color color,
Key key = null,
string title = "",
Widget child = null
) : base(key: key) {
D.assert(title != null);
D.assert(color != null && color.alpha == 0xFF);
}
public readonly String title;
public readonly Color color;
public readonly Widget child;
public override Widget build(BuildContext context) {
/*SystemChrome.setApplicationSwitcherDescription(
new ApplicationSwitcherDescription(
label: title,
primaryColor: (int)color.value
)
);*/
return child;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new StringProperty("title", title, defaultValue: ""));
//properties.add(new ColorProperty("color", color, defaultValue: null));
}
}
}

61
com.unity.uiwidgets/Runtime/widgets/tween_animation_builder.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public class TweenAnimationBuilder<T> : ImplicitlyAnimatedWidget {
public TweenAnimationBuilder(
Key key = null,
Tween<T> tween = null,
TimeSpan? duration = null,
Curve curve = null,
ValueWidgetBuilder<T> builder = null,
VoidCallback onEnd = null,
Widget child = null
) : base(key: key, duration: duration, curve: curve, onEnd: onEnd) {
curve = curve ?? Curves.linear;
D.assert(tween != null);
D.assert(curve != null);
D.assert(builder != null);
}
public readonly Tween<T> tween;
public readonly ValueWidgetBuilder<T> builder;
public readonly Widget child;
public override State createState() {
return new _TweenAnimationBuilderState<T>();
}
}
public class _TweenAnimationBuilderState<T> : AnimatedWidgetBaseState<TweenAnimationBuilder<T>> {
Tween<T> _currentTween;
public override void initState() {
_currentTween = widget.tween;
_currentTween.begin ??= _currentTween.end;
base.initState();
if (_currentTween.begin.Equals( _currentTween.end)) {
controller.forward();
}
}
protected override void forEachTween(TweenVisitor visitor) {
D.assert(
widget.tween.end != null,()=>
"Tween provided to TweenAnimationBuilder must have non-null Tween.end value.");
_currentTween = visitor.visit(
this,
_currentTween,
widget.tween.end,
(value) =>{
D.assert(false);
return null; }) as Tween<T>;
}
public override Widget build(BuildContext context) {
return widget.builder(context, _currentTween.evaluate(animation), widget.child);
}
}
}

21
com.unity.uiwidgets/Runtime/widgets/unique_widget.cs


using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.widgets {
public abstract class UniqueWidget<T> :StatefulWidget where T: State<StatefulWidget> {
public UniqueWidget(
GlobalKey<T> key
) : base(key: key) {
D.assert(key != null);
}
public abstract override State createState();
T currentState {
get {
GlobalKey<T> globalKey = key as GlobalKey<T>;
return globalKey.currentState;
}
}
}
}
正在加载...
取消
保存