浏览代码

Merge branch 'shiyun/skia' of github.com:Unity-Technologies/com.unity.uiwidgets into shiyun/skia

/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
546670e8
共有 12 个文件被更改,包括 317 次插入191 次删除
  1. 12
      com.unity.uiwidgets/Runtime/rendering/tweens.cs
  2. 14
      com.unity.uiwidgets/Runtime/widgets/image_filter.cs
  3. 114
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  4. 2
      com.unity.uiwidgets/Runtime/widgets/inherited_theme.cs
  5. 148
      com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs
  6. 42
      com.unity.uiwidgets/Runtime/widgets/localizations.cs
  7. 22
      com.unity.uiwidgets/Runtime/widgets/media_query.cs
  8. 22
      com.unity.uiwidgets/Runtime/widgets/modal_barrier.cs
  9. 17
      com.unity.uiwidgets/Runtime/widgets/navigation_toolbar.cs
  10. 38
      com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs
  11. 24
      com.unity.uiwidgets/Runtime/widgets/overlay.cs
  12. 53
      com.unity.uiwidgets/Runtime/widgets/image_icon.cs

12
com.unity.uiwidgets/Runtime/rendering/tweens.cs


return Alignment.lerp(begin, end, t);
}
}
public class AlignmentGeometryTween : Tween<AlignmentGeometry> {
public AlignmentGeometryTween(
AlignmentGeometry begin = null,
AlignmentGeometry end = null
) : base(begin: begin, end: end) {
}
public override AlignmentGeometry lerp(float t) {
return AlignmentGeometry.lerp(begin, end, t);
}
}
}

14
com.unity.uiwidgets/Runtime/widgets/image_filter.cs


public class ImageFiltered : SingleChildRenderObjectWidget {
protected ImageFiltered(
Key key,
ImageFilter imageFilter,
Widget child
Key key = null,
ImageFilter imageFilter = null,
Widget child = null
this.imageFilter = imageFilter;
public override RenderObject createRenderObject(BuildContext context) => new _ImageFilterRenderObject(imageFilter);
public override RenderObject createRenderObject(BuildContext context) {
return new _ImageFilterRenderObject(imageFilter);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
((_ImageFilterRenderObject) renderObject).imageFilter = imageFilter;

}
}
}
ImageFilter _imageFilter;
protected override bool alwaysNeedsCompositing {

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


return EdgeInsets.lerp(begin, end, t);
}
}
public class EdgeInsetsGeometryTween : Tween<EdgeInsetsGeometry> {
public EdgeInsetsGeometryTween(
EdgeInsetsGeometry begin = null,
EdgeInsetsGeometry end = null) : base(begin: begin, end: end) {
}
public override EdgeInsetsGeometry lerp(float t) {
return EdgeInsetsGeometry.lerp(begin, end, t);
}
}
public class BorderRadiusTween : Tween<BorderRadius> {

protected AnimationController controller {
get { return _controller; }
}
Animation<float> _animation;
public override void initState() {

public class AnimatedContainer : ImplicitlyAnimatedWidget {
public AnimatedContainer(
Key key = null,
Alignment alignment = null,
AlignmentGeometry alignment = null,
EdgeInsets padding = null,
Color color = null,
Decoration decoration = null,

public readonly Widget child;
public readonly Alignment alignment;
public readonly AlignmentGeometry alignment;
public readonly EdgeInsets padding;

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Alignment>("alignment", alignment, showName: false,
properties.add(new DiagnosticsProperty<AlignmentGeometry>("alignment", alignment, showName: false,
defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", padding, defaultValue: null));
properties.add(new DiagnosticsProperty<Decoration>("bg", decoration, defaultValue: null));

}
class _AnimatedContainerState : AnimatedWidgetBaseState<AnimatedContainer> {
AlignmentTween _alignment;
AlignmentGeometryTween _alignment;
EdgeInsetsTween _padding;
DecorationTween _decoration;
DecorationTween _foregroundDecoration;

protected override void forEachTween(TweenVisitor visitor) {
_alignment = (AlignmentTween) visitor.visit(this, _alignment, widget.alignment,
(Alignment value) => new AlignmentTween(begin: value));
_alignment = (AlignmentGeometryTween) visitor.visit(this, _alignment, widget.alignment,
(AlignmentGeometry value) => new AlignmentGeometryTween(begin: value));
_padding = (EdgeInsetsTween) visitor.visit(this, _padding, widget.padding,
(EdgeInsets value) => new EdgeInsetsTween(begin: value));
_decoration = (DecorationTween) visitor.visit(this, _decoration, widget.decoration,

alignment: _alignment?.evaluate(animation),
padding: _padding?.evaluate(animation),
decoration: _decoration?.evaluate(animation),
forgroundDecoration: _foregroundDecoration?.evaluate(animation),
foregroundDecoration: _foregroundDecoration?.evaluate(animation),
transfrom: _transform?.evaluate(animation)
transform: _transform?.evaluate(animation)
);
}

description.add(new DiagnosticsProperty<AlignmentTween>("alignment", _alignment, showName: false,
description.add(new DiagnosticsProperty<AlignmentGeometryTween>("alignment", _alignment, showName: false,
defaultValue: null));
description.add(new DiagnosticsProperty<EdgeInsetsTween>("padding", _padding, defaultValue: null));
description.add(new DiagnosticsProperty<DecorationTween>("bg", _decoration, defaultValue: null));

public class AnimatedPadding : ImplicitlyAnimatedWidget {
public AnimatedPadding(
Key key = null,
EdgeInsets padding = null,
EdgeInsetsGeometry padding = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null,

this.child = child;
}
public readonly EdgeInsets padding;
public readonly EdgeInsetsGeometry padding;
public readonly Widget child;

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", padding));
properties.add(new DiagnosticsProperty<EdgeInsetsGeometry>("padding", padding));
EdgeInsetsTween _padding;
EdgeInsetsGeometryTween _padding;
_padding = (EdgeInsetsTween) visitor.visit(this, _padding, widget.padding,
(EdgeInsets value) => new EdgeInsetsTween(begin: value));
_padding = (EdgeInsetsGeometryTween) visitor.visit(this, _padding, widget.padding,
(EdgeInsetsGeometry value) => new EdgeInsetsGeometryTween(begin: value));
}
public override Widget build(BuildContext context) {

public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<EdgeInsetsTween>("padding", _padding,
description.add(new DiagnosticsProperty<EdgeInsetsGeometryTween>("padding", _padding,
defaultValue: foundation_.kNullDefaultValue));
}
}

Key key = null,
Alignment alignment = null,
AlignmentGeometry alignment = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null,

this.child = child;
}
public readonly Alignment alignment;
public readonly AlignmentGeometry alignment;
public readonly Widget child;

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties: properties);
properties.add(new DiagnosticsProperty<Alignment>("alignment", value: alignment));
properties.add(new DiagnosticsProperty<AlignmentGeometry>("alignment", value: alignment));
AlignmentTween _alignment;
AlignmentGeometryTween _alignment;
_alignment = (AlignmentTween) visitor.visit(this, tween: _alignment,
targetValue: widget.alignment, constructor: value => new AlignmentTween(begin: value));
_alignment = (AlignmentGeometryTween) visitor.visit(this, tween: _alignment,
targetValue: widget.alignment, constructor: value => new AlignmentGeometryTween(begin: value));
}
public override Widget build(BuildContext context) {

public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(properties: description);
description.add(new DiagnosticsProperty<AlignmentTween>("alignment", value: _alignment, defaultValue: null));
description.add(new DiagnosticsProperty<AlignmentGeometryTween>("alignment", value: _alignment, defaultValue: null));
}
}

Curve curve = null,
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve, duration: duration, onEnd: onEnd) {
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(start == null || end == null || width == null);
D.assert(top == null || bottom == null || height == null);
this.child = child;

base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
this.child = child;
this.opacity = opacity ?? 1.0f;
this.opacity = opacity;
public readonly float opacity;
public readonly float? opacity;
public override State createState() {
return new _AnimatedOpacityState();

protected SliverAnimatedOpacity(
Key key = null,
Widget sliver = null,
float opacity = default,
Curve curve = null,//Curve curve = Curve.linear
float? opacity = null,
Curve curve = null,
) : base(key: key, curve: curve, duration: duration, onEnd: onEnd) {
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
this.opacity = opacity;
this.sliver = sliver;
public readonly float opacity;
public readonly float? opacity;
public override State createState() {
return new _SliverAnimatedOpacityState();

Animation<float> _opacityAnimation;
protected override void forEachTween(TweenVisitor visitor) {
_opacity = (FloatTween) visitor.visit(this,_opacity, widget.opacity, (float value) => new FloatTween(begin: value, 0));
_opacity = (FloatTween) visitor.visit(this, _opacity, widget.opacity ?? 0.0f, (float value) => new FloatTween(begin: value, 0));
}
protected override void didUpdateTweens() {

bool softWrap = true,
TextOverflow? overflow = null,
int? maxLines = null,
TextWidthBasis textWidthBasis = TextWidthBasis.parent,
ui.TextHeightBehavior textHeightBehavior = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd) {
D.assert(overflow != null);
this.child = child;
this.style = style;
this.textAlign = textAlign;

this.textHeightBehavior = textHeightBehavior;
this.textWidthBasis = textWidthBasis;
}
public readonly Widget child;

public readonly bool softWrap;
public readonly TextAlign? textAlign;
public readonly ui.TextHeightBehavior textHeightBehavior;
public readonly TextWidthBasis textWidthBasis;
public readonly VoidCallback onEnd;
public override State createState() {
return new _AnimatedDefaultTextStyleState();

base.debugFillProperties(properties);
properties.add(new EnumProperty<TextAlign>("textAlign", textAlign ?? TextAlign.center,
defaultValue: null));
properties.add(new FlagProperty("softWrap", value: softWrap, ifTrue: "wrapping at box width",
ifFalse: "no wrapping except at line break characters", showName: true));
properties.add(new EnumProperty<TextAlign>("textAlign", textAlign ?? TextAlign.start, defaultValue: null));
properties.add(new FlagProperty("softWrap", value: softWrap, ifTrue: "wrapping at box width", ifFalse: "no wrapping except at line break characters", showName: true));
properties.add(new EnumProperty<TextWidthBasis>("textWidthBasis", textWidthBasis, defaultValue: TextWidthBasis.parent));
properties.add(new DiagnosticsProperty<ui.TextHeightBehavior>("textHeightBehavior", textHeightBehavior, defaultValue: null));
}
}

softWrap: widget.softWrap,
overflow: widget.overflow,
maxLines: widget.maxLines,
child: widget.child);
textWidthBasis: widget.textWidthBasis,
textHeightBehavior: widget.textHeightBehavior,
child: widget.child
);
}
}

Color shadowColor = null,
bool animateShadowColor = true,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration) {
TimeSpan? duration = null,
VoidCallback onEnd = null
) : base(key: key, curve: curve ?? Curves.linear, duration: duration,onEnd: onEnd) {
D.assert(duration != null);
this.child = child;
this.shape = shape ?? BoxShape.circle;
this.clipBehavior = clipBehavior;

properties.add(new DiagnosticsProperty<bool>("animateColor", animateColor));
properties.add(new DiagnosticsProperty<Color>("shadowColor", shadowColor));
properties.add(new DiagnosticsProperty<bool>("animateShadowColor", animateShadowColor));
}
}

2
com.unity.uiwidgets/Runtime/widgets/inherited_theme.cs


) : base(key: key) {
D.assert(themes != null);
D.assert(child != null);
this.child = child;
this.themes = themes;
}
public readonly List<InheritedTheme> themes;

148
com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs


using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;

class ListWheelScrollViewUtils {
public static int _getItemFromOffset(
float offset,
float itemExtent,
float minScrollExtent,
float maxScrollExtent
float? offset = null,
float? itemExtent = null,
float? minScrollExtent = null,
float? maxScrollExtent = null
return (_clipOffsetToScrollableRange(offset, minScrollExtent, maxScrollExtent) / itemExtent).round();
var _itemExtent = itemExtent ?? 1.0f;
return (_clipOffsetToScrollableRange(offset ?? 0.0f , minScrollExtent ?? 0.0f, maxScrollExtent ?? 0.0f) / _itemExtent).round();
public static float _clipOffsetToScrollableRange(
float offset,
float minScrollExtent,

public Future animateToItem(
int itemIndex,
TimeSpan duration,
Curve curve
) {///////
TimeSpan? duration = null,
Curve curve = null
) {
if (!hasClients) {
return null;
}

itemIndex * position.itemExtent,
duration: duration,
duration: duration ?? new TimeSpan(0,0,0,0,0),
curve: curve
));
}

}
}
public override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context,
public override ScrollPosition createScrollPosition(
ScrollPhysics physics,
ScrollContext context,
ScrollPosition oldPosition) {
return new _FixedExtentScrollPosition(
physics: physics,

public class FixedExtentMetrics : FixedScrollMetrics, IFixedExtentMetrics {
public FixedExtentMetrics(
int itemIndex,
float minScrollExtent = 0.0f,
float maxScrollExtent = 0.0f,
float pixels = 0.0f,
float viewportDimension = 0.0f,
AxisDirection axisDirection = AxisDirection.down
float? minScrollExtent = null,
float? maxScrollExtent = null,
float? pixels = null,
float? viewportDimension = null,
AxisDirection axisDirection = AxisDirection.down,
int? itemIndex = null
minScrollExtent: minScrollExtent,
maxScrollExtent: maxScrollExtent,
pixels: pixels,
viewportDimension: viewportDimension,
minScrollExtent: minScrollExtent ?? 0.0f,
maxScrollExtent: maxScrollExtent ?? 0.0f,
pixels: pixels ?? 0.0f,
viewportDimension: viewportDimension ?? 0.0f,
this.itemIndex = itemIndex;
this.itemIndex = itemIndex ?? 0;
}
public int itemIndex { get; set; }

itemIndex: itemIndex ?? this.itemIndex
);
}
ScrollPhysics physics,
ScrollContext context,
int initialItem,
ScrollPhysics physics = null,
ScrollContext context = null,
int? initialItem = null,
bool keepScrollOffset = true,
ScrollPosition oldPosition = null,
string debugLabel = null

static float _getItemExtentFromScrollContext(ScrollContext context) {
_FixedExtentScrollableState scrollable = (_FixedExtentScrollableState) context;
return scrollable.itemExtent;
return scrollable.itemExtent ?? 0.0f;
}
public float itemExtent {

class _FixedExtentScrollable : Scrollable {
public _FixedExtentScrollable(
float itemExtent,
ViewportBuilder viewportBuilder,
ScrollPhysics physics = null
ScrollPhysics physics = null,
float? itemExtent = null,
ViewportBuilder viewportBuilder = null
) : base(
key: key,
axisDirection: axisDirection,

this.itemExtent = itemExtent;
}
public readonly float itemExtent;
public readonly float? itemExtent;
public override State createState() {
return new _FixedExtentScrollableState();

class _FixedExtentScrollableState : ScrollableState {
public float itemExtent {
public float? itemExtent {
get {
_FixedExtentScrollable actualWidget = (_FixedExtentScrollable) widget;
return actualWidget.itemExtent;

}
if (settlingItemIndex == metrics.itemIndex) {
return new SpringSimulation(spring,
return new SpringSimulation(
spring,
metrics.pixels,
settlingPixels,
velocity,

return FrictionSimulation.through(
metrics.pixels,
settlingPixels,
velocity, tolerance.velocity * velocity.sign()
velocity,
tolerance.velocity * velocity.sign()
);
}
}

float itemExtent,
List<Widget> children = null,
Key key = null,
ScrollController controller = null,
ScrollPhysics physics = null,

bool useMagnifier = false,
float magnification = 1.0f,
float overAndUnderCenterOpacity = 1.0f,
float? itemExtent = null,
ListWheelChildDelegate childDelegate = null
List<Widget> children = null
) : base(key: key) {
D.assert(children != null || childDelegate != null);
D.assert(diameterRatio > 0.0, () => RenderListWheelViewport.diameterRatioZeroMessage);

D.assert(overAndUnderCenterOpacity != null);
D.assert(squeeze != null);
D.assert(squeeze > 0);
D.assert(
!renderChildrenOutsideViewport || !clipToSize,

this.childDelegate = childDelegate ?? new ListWheelChildListDelegate(children: children);
childDelegate = new ListWheelChildListDelegate(children: children);
this.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
this.itemExtent = itemExtent;
this.squeeze = squeeze;

}
public static ListWheelScrollView useDelegate(
float itemExtent,
float overAndUnderCenterOpacity = 1.0f,
float squeeze = 1.0f,
List<Widget> children = null,
ListWheelChildDelegate childDelegate = null,
Key key = null,
ScrollController controller = null,
ScrollPhysics physics = null,

bool useMagnifier = false,
float magnification = 1.0f,
float? itemExtent = null,
float squeeze = 1.0f,
float overAndUnderCenterOpacity = 1.0f,
bool renderChildrenOutsideViewport = false
bool renderChildrenOutsideViewport = false,
ListWheelChildDelegate childDelegate = null
return new ListWheelScrollView(
D.assert(childDelegate != null);
D.assert(diameterRatio > 0.0, ()=>RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(perspective > 0);
D.assert(perspective <= 0.01,()=> RenderListWheelViewport.perspectiveTooHighMessage);
D.assert(magnification > 0);
D.assert(overAndUnderCenterOpacity >= 0 && overAndUnderCenterOpacity <= 1);
D.assert(itemExtent != null);
D.assert(itemExtent > 0);
D.assert(squeeze > 0);
D.assert(
!renderChildrenOutsideViewport || !clipToSize,()=>
RenderListWheelViewport.clipToSizeAndRenderChildrenOutsideViewportConflict
);
var view = new ListWheelScrollView(
children: children,
childDelegate: childDelegate,
key: key,
controller: controller,
physics: physics,

clipToSize: clipToSize,
renderChildrenOutsideViewport: renderChildrenOutsideViewport
);
view.childDelegate = childDelegate;
return view;
}
public readonly ScrollController controller;

public readonly float offAxisFraction;
public readonly bool useMagnifier;
public readonly float magnification;
public readonly float itemExtent;
public readonly float? itemExtent;
public readonly ListWheelChildDelegate childDelegate;
public ListWheelChildDelegate childDelegate;
public override State createState() {
return new _ListWheelScrollViewState();

&& notification is ScrollUpdateNotification
&& notification.metrics is FixedExtentMetrics metrics) {
int currentItemIndex = metrics.itemIndex;
if (currentItemIndex != _lastReportedItemIndex) {
_lastReportedItemIndex = currentItemIndex;
int trueIndex = widget.childDelegate.trueIndexOf(currentItemIndex);

useMagnifier: widget.useMagnifier,
magnification: widget.magnification,
overAndUnderCenterOpacity: widget.overAndUnderCenterOpacity,
itemExtent: widget.itemExtent,
itemExtent: widget.itemExtent ?? 0.0f,
squeeze: widget.squeeze,
clipToSize: widget.clipToSize,
renderChildrenOutsideViewport: widget.renderChildrenOutsideViewport,

owner.buildScope(this, () => {
bool insertFirst = after == null;
D.assert(insertFirst || _childElements[index - 1] != null);
// Debug.Log($"{index}: {this._childElements.getOrDefault(index)}");
// Debug.Log(newChild);
if (newChild != null) {
_childElements[index] = newChild;
}

protected override void insertChildRenderObject(RenderObject child, object slot) {
RenderListWheelViewport renderObject = this.renderObject;
D.assert(renderObject.debugValidateChild(child));
renderObject.insert((RenderBox) child,
(RenderBox) _childElements.getOrDefault((int) slot - 1)?.renderObject);
// Debug.Log($"insert: {this._childElements.getOrDefault((int) slot - 1)}");
renderObject.insert(child as RenderBox, after: _childElements[(int)slot - 1]?.renderObject as RenderBox);
D.assert(renderObject == this.renderObject);
}

public class ListWheelViewport : RenderObjectWidget {
public ListWheelViewport(
float itemExtent,
ViewportOffset offset,
ListWheelChildDelegate childDelegate,
Key key = null,
float diameterRatio = RenderListWheelViewport.defaultDiameterRatio,
float perspective = RenderListWheelViewport.defaultPerspective,

float overAndUnderCenterOpacity = 1.0f,
float? itemExtent = null,
float squeeze = 1.0f,
float overAndUnderCenterOpacity = 1.0f,
float squeeze = 1.0f
ViewportOffset offset = null,
ListWheelChildDelegate childDelegate = null
) : base(key: key) {
D.assert(childDelegate != null);
D.assert(offset != null);

D.assert(overAndUnderCenterOpacity != null);
D.assert(itemExtent != null);
D.assert(itemExtent > 0);
D.assert(
!renderChildrenOutsideViewport || !clipToSize,

public readonly bool useMagnifier;
public readonly float magnification;
public readonly float overAndUnderCenterOpacity;
public readonly float itemExtent;
public readonly float? itemExtent;
public readonly float squeeze;
public readonly bool clipToSize;
public readonly bool renderChildrenOutsideViewport;

useMagnifier: useMagnifier,
magnification: magnification,
overAndUnderCenterOpacity: overAndUnderCenterOpacity,
itemExtent: itemExtent,
itemExtent: itemExtent ?? 0.0f,
squeeze: squeeze,
clipToSize: clipToSize,
renderChildrenOutsideViewport: renderChildrenOutsideViewport

viewport.useMagnifier = useMagnifier;
viewport.magnification = magnification;
viewport.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
viewport.itemExtent = itemExtent;
viewport.itemExtent = itemExtent ?? 0.0f;
viewport.squeeze = squeeze;
viewport.clipToSize = clipToSize;
viewport.renderChildrenOutsideViewport = renderChildrenOutsideViewport;

42
com.unity.uiwidgets/Runtime/widgets/localizations.cs


namespace Unity.UIWidgets.widgets {
class _Pending {
public _Pending(LocalizationsDelegate del, Future<object> futureValue) {
public _Pending(
LocalizationsDelegate del,
Future<object> futureValue) {
this.del = del;
this.futureValue = futureValue;
}

internal static Future<Dictionary<Type, object>> _loadAll(Locale locale,
internal static Future<Dictionary<Type, object>> _loadAll(
Locale locale,
IEnumerable<LocalizationsDelegate> allDelegates) {
Dictionary<Type, object> output = new Dictionary<Type, object>();
List<_Pending> pendingList = null;

}
foreach (LocalizationsDelegate del in delegates) {
//Future<WidgetsLocalizations> inputValue = del.load(locale);
/* Future<object> futureValue = inputValue.then_<object>(value => {
completedValue = value;
return FutureOr.value(completedValue);
})();*/
if (completedValue != null) {
Type type = del.type;
D.assert(!output.ContainsKey(type));

return Future.wait<object>(pendingList.Select(p => p.futureValue))
.then(values => {
//TODO : check values is list
var list = (List<object>)values;
D.assert(list.Count == pendingList.Count);
for (int i = 0; i < list.Count; i += 1) {

}
public abstract class LocalizationsDelegate<T> : LocalizationsDelegate {
//public abstract Future<T> load(Locale locale);
public override Type type {
get { return typeof(T); }
}

public TextDirection textDirection { get; }
static WidgetsLocalizations of(BuildContext context) {
return Localizations.of<WidgetsLocalizations>(context, typeof(WidgetsLocalizations));
}

class _LocalizationsScope : InheritedWidget {
public _LocalizationsScope(
Key key,
Locale locale,
_LocalizationsState localizationsState,
Dictionary<Type, object> typeToResources,
Widget child
Key key = null,
Locale locale = null,
_LocalizationsState localizationsState = null,
Dictionary<Type, object> typeToResources = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(locale != null);
D.assert(localizationsState != null);

public Locale locale {
get { return _locale; }
}
Locale _locale;
public override void initState() {

return resources;
}
TextDirection _textDirection {
get {
WidgetsLocalizations resources = (WidgetsLocalizations)_typeToResources.getOrDefault(typeof(WidgetsLocalizations)) ;
D.assert(resources != null);
return resources.textDirection;
}
}
public override Widget build(BuildContext context) {
if (_locale == null) {
return new Container();

locale: _locale,
localizationsState: this,
typeToResources: _typeToResources,
child: widget.child
child: new Directionality(
textDirection: _textDirection,
child: widget.child
)
);
}
}

22
com.unity.uiwidgets/Runtime/widgets/media_query.cs


size: window.physicalSize / window.devicePixelRatio,
devicePixelRatio: window.devicePixelRatio,
textScaleFactor: window.textScaleFactor,
//platformBrightness: window.platformBrightness, // TODO: remove comment when window.platformBrightness is ready
platformBrightness: window.platformBrightness, // TODO: remove comment when window.platformBrightness is ready
padding: EdgeInsets.fromWindowPadding(window.padding, window.devicePixelRatio),
viewPadding : EdgeInsets.fromWindowPadding(window.viewPadding, window.devicePixelRatio),
viewInsets: EdgeInsets.fromWindowPadding(window.viewInsets, window.devicePixelRatio),

float? physicalDepth = null,
bool? alwaysUse24HourFormat = null,
bool? accessibleNavigation = null,
bool? invertColors = null,
bool? invertColors = null,
bool? accessibleNavigation = null,
bool? boldText = null
) {
return new MediaQueryData(

bool removeRight = false,
bool removeBottom = false
) {
if (!(removeLeft || removeTop || removeRight || removeBottom)) {
if (!(removeLeft || removeTop || removeRight || removeBottom))
}
return new MediaQueryData(
size: size,
devicePixelRatio: devicePixelRatio,

left: removeLeft ? (float?) 0.0 : null,
top: removeTop ? (float?) 0.0 : null,
right: removeRight ? (float?) 0.0 : null,
bottom: removeBottom ? (float?) 0.0 : null
left: removeLeft ? (float?)0.0f : null,
top: removeTop ?(float?) 0.0f : null,
right: removeRight ? (float?)0.0f : null,
bottom: removeBottom ?(float?) 0.0f : null
),
viewPadding: viewPadding.copyWith(
left: removeLeft ? (float?)Mathf.Max(0.0f, viewPadding.left - padding.left) : null,

accessibleNavigation: accessibleNavigation,
boldText: boldText
);
}
public MediaQueryData removeViewInsets(

public static MediaQueryData of(BuildContext context, bool nullOk = false) {
D.assert(context != null);
//MediaQuery query = context.dependOnInheritedWidgetOfExactType<MediaQuery>();
MediaQuery query = (MediaQuery) context.dependOnInheritedWidgetOfExactType<MediaQuery>();
if (query != null) {
return query.data;

22
com.unity.uiwidgets/Runtime/widgets/modal_barrier.cs


public readonly Color color;
public readonly bool dismissible;
public ModalBarrier(Key key = null, Color color = null, bool dismissible = true) : base(key) {
public ModalBarrier(
Key key = null,
Color color = null,
bool dismissible = true) : base(key) {
this.color = color;
this.dismissible = dismissible;
}

public class AnimatedModalBarrier : AnimatedWidget {
public readonly bool dismissible;
public AnimatedModalBarrier(Key key = null, Animation<Color> color = null,
bool dismissible = true) : base(key, color) {
public AnimatedModalBarrier(
Key key = null,
Animation<Color> color = null,
bool dismissible = true
) : base(key, color) {
this.dismissible = dismissible;
}

protected internal override Widget build(BuildContext context) {
return new ModalBarrier(color: color?.value, dismissible: dismissible);
return new ModalBarrier(
color: color?.value,
dismissible: dismissible);
public _AnyTapGestureRecognizer( Object debugOwner = null) : base(debugOwner: debugOwner) {}
public _AnyTapGestureRecognizer( object debugOwner = null) : base(debugOwner: debugOwner) {}
protected override bool isPointerAllowed(PointerDownEvent _event) {
protected override bool isPointerAllowed(PointerDownEvent _event ) {
if (onAnyTapUp == null)
return false;
return base.isPointerAllowed(_event);

) : base(key: key) {
D.assert(child != null);
D.assert(onDismiss != null);
this.child = child;
this.onDismiss = onDismiss;
}
public readonly Widget child;

17
com.unity.uiwidgets/Runtime/widgets/navigation_toolbar.cs


namespace Unity.UIWidgets.widgets {
public class NavigationToolbar : StatelessWidget {
public NavigationToolbar(Key key = null, Widget leading = null, Widget middle = null,
Widget trailing = null, bool centerMiddle = true, float middleSpacing = kMiddleSpacing) : base(key) {
public NavigationToolbar(
Key key = null,
Widget leading = null,
Widget middle = null,
Widget trailing = null,
bool centerMiddle = true,
float middleSpacing = kMiddleSpacing
) : base(key) {
this.leading = leading;
this.middle = middle;
this.trailing = trailing;

class _ToolbarLayout : MultiChildLayoutDelegate {
public _ToolbarLayout(
bool? centerMiddle = true,
bool? centerMiddle = null,
float? middleSpacing = null,
TextDirection? textDirection = null
) {

this.middleSpacing = middleSpacing ?? 0.0f;
this.middleSpacing = middleSpacing ?? 0.0f;
this.textDirection = textDirection ?? TextDirection.ltr;
}

float middleStartMargin = leadingWidth + middleSpacing;
float middleStart = middleStartMargin;
float middleY = (size.height - middleSize.height) / 2.0f;
// If the centered middle will not fit between the leading and trailing
// widgets, then align its left or right edge with the adjacent boundary.
if (centerMiddle) {
middleStart = (size.width - middleSize.width) / 2.0f;
if (middleStart + middleSize.width > size.width - trailingWidth) {

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


reverse: widget.reverse,
physics: widget.physics != null
? widget.physics.applyTo(new ClampingScrollPhysics())
: new ClampingScrollPhysics(),
controller: _coordinator._outerController,
slivers: widget._buildSlivers(
_context, _coordinator._innerController, _lastHasScrolledBody
),
handle: _absorberHandle
);
: new ClampingScrollPhysics(),
controller: _coordinator._outerController,
slivers: widget._buildSlivers(
context,
_coordinator._innerController,
_lastHasScrolledBody
),
handle: _absorberHandle
);
}
)
);

class _NestedScrollViewCustomScrollView : CustomScrollView {
public _NestedScrollViewCustomScrollView(
Axis scrollDirection,
bool reverse,
Axis scrollDirection,
bool reverse ,
ScrollPhysics physics,
ScrollController controller,
List<Widget> slivers,

if (!_outerController.hasClients) {
return null;
}
return _outerController.nestedPositions.Single();
}
}

ScrollDirection _userScrollDirection = ScrollDirection.idle;
public void updateUserScrollDirection(ScrollDirection value) {
D.assert(value != null);
if (userScrollDirection == value) {
return;
}

}
public void goBallistic(float velocity) {
beginActivity(createOuterBallisticScrollActivity(velocity),
beginActivity(
createOuterBallisticScrollActivity(velocity),
(_NestedScrollPosition position) => createInnerBallisticScrollActivity(position, velocity)
);
}

_outerPosition.updateCanDrag(maxInnerExtent);
}
public Future animateTo(float to,
TimeSpan duration,
Curve curve
public Future animateTo(
float to,
TimeSpan? duration = null,
Curve curve = null
duration,
duration ?? new TimeSpan(0,0,0,0),
curve
);
List<Future> resultFutures = new List<Future> {outerActivity.done};

DrivenScrollActivity innerActivity = position.createDrivenScrollActivity(
nestOffset(to, position),
duration,
duration ?? new TimeSpan(0,0,0,0),
curve
);
resultFutures.Add(innerActivity.done);

}
public override string ToString() {
return "$GetType()(outer=$_outerController; inner=$_innerController)";
return $"{GetType()}(outer={_outerController}; inner={_innerController})";
}
}

24
com.unity.uiwidgets/Runtime/widgets/overlay.cs


namespace Unity.UIWidgets.widgets {
public class OverlayEntry {
public OverlayEntry(WidgetBuilder builder = null, bool opaque = false, bool maintainState = false) {
public OverlayEntry(
WidgetBuilder builder = null,
bool opaque = false,
bool maintainState = false) {
D.assert(builder != null);
_opaque = opaque;
_maintainState = maintainState;

_maintainState = value;
D.assert(_overlay != null);
_overlay._didChangeEntryOpacity();
_overlay?._didChangeEntryOpacity();
}
}

}
class _OverlayEntryWidgetState : State<_OverlayEntryWidget> {
public override Widget build(BuildContext context) {
public override Widget build(
BuildContext context) {
return new TickerMode(
enabled: widget.tickerEnabled,
child: widget.entry.builder(context)

class _RenderTheatre : ContainerRenderObjectMixinRenderBox<RenderBox, StackParentData> {
internal _RenderTheatre(
TextDirection textDirection,
TextDirection textDirection ,
List<RenderBox> children = null,
int skipCount = 0
) {

if (_resolvedAlignment != null) {
return;
}
//FIXME: wait for changes on painting/alignment.cs (by Siyao)
//then uncomment the line below and remove the switch clauses
//_resolvedAlignment = AlignmentDirectional.topStart.resolve(textDirection);
switch (textDirection) {
case TextDirection.rtl:
_resolvedAlignment = new Alignment(-1, -1);
break;
case TextDirection.ltr:
_resolvedAlignment = new Alignment(1, -1);
break;
}
_resolvedAlignment = AlignmentDirectional.topStart.resolve(textDirection);
}
void _markNeedResolution() {

53
com.unity.uiwidgets/Runtime/widgets/image_icon.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.painting;
namespace Unity.UIWidgets.widgets {
public class ImageIcon: StatelessWidget {
public ImageIcon(
ImageProvider image ,
Key key = null,
float? size = null,
Color color = null
) : base(key: key) {
this.image = image;
this.size = size;
this.color = color;
}
public readonly ImageProvider image;
public readonly float? size;
public readonly Color color;
public override Widget build(BuildContext context) {
IconThemeData iconTheme = IconTheme.of(context);
float? iconSize = size == null ? iconTheme.size : size;
if (image == null)
return new SizedBox(width: iconSize, height: iconSize);
float? iconOpacity = iconTheme.opacity;
Color iconColor = color ?? iconTheme.color;
if (iconOpacity != null && iconOpacity != 1.0)
iconColor = iconColor.withOpacity(iconColor.opacity * (iconOpacity ?? 1.0f));
return new Image(
image: image,
width: iconSize,
height: iconSize,
color: iconColor,
fit: BoxFit.scaleDown,
alignment: Alignment.center
//excludeFromSemantics: true
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ImageProvider>("image'", image, ifNull: "<empty>", showName: false));
properties.add(new FloatProperty("size", size, defaultValue: null));
properties.add(new ColorProperty("color", color, defaultValue: null));
}
}
}
正在加载...
取消
保存