浏览代码

transitions

/main
xingwei.zhu 6 年前
当前提交
adcf538a
共有 2 个文件被更改,包括 126 次插入1 次删除
  1. 2
      Runtime/widgets/basic.cs
  2. 125
      Runtime/widgets/transitions.cs

2
Runtime/widgets/basic.cs


top: rect.top, width: rect.width, height: rect.height);
}
public static Positioned fromRelativeRect(Rect rect, Widget child, Key key = null) {
public static Positioned fromRelativeRect(RelativeRect rect, Widget child, Key key = null) {
return new Positioned(child, key: key, left: rect.left,
top: rect.top, right: rect.right, bottom: rect.bottom);
}

125
Runtime/widgets/transitions.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.widgets {
public abstract class AnimatedWidget : StatefulWidget {

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Animation<float>>("opacity", this.opacity));
}
}
public class PositionedTransition : AnimatedWidget {
public PositionedTransition(
Key key = null,
Animation<RelativeRect> rect = null,
Widget child = null
) : base(key: key, listenable: rect) {
D.assert(rect != null);
D.assert(child != null);
this.child = child;
}
Animation<RelativeRect> rect {
get { return (Animation<RelativeRect>) this.listenable; }
}
public readonly Widget child;
protected internal override Widget build(BuildContext context) {
return Positioned.fromRelativeRect(
rect: this.rect.value,
child: this.child
);
}
}
public class RelativePositionedTransition : AnimatedWidget {
public RelativePositionedTransition(
Key key = null,
Animation<Rect> rect = null,
Size size = null,
Widget child = null
) : base(key: key, listenable: rect) {
D.assert(rect != null);
D.assert(size != null);
D.assert(child != null);
}
Animation<Rect> rect {
get { return (Animation<Rect>) this.listenable; }
}
public readonly Size size;
public readonly Widget child;
protected internal override Widget build(BuildContext context) {
RelativeRect offsets = RelativeRect.fromSize(this.rect.value, this.size);
return new Positioned(
top: offsets.top,
right: offsets.right,
bottom: offsets.bottom,
left: offsets.left,
child: this.child
);
}
}
public class DecoratedBoxTransition : AnimatedWidget {
public DecoratedBoxTransition(
Key key = null,
Animation<Decoration> decoration = null,
DecorationPosition position = DecorationPosition.background,
Widget child = null
) : base(key: key, listenable: decoration) {
D.assert(decoration != null);
D.assert(child != null);
this.decoration = decoration;
this.position = position;
this.child = child;
}
public readonly Animation<Decoration> decoration;
public readonly DecorationPosition position;
public readonly Widget child;
protected internal override Widget build(BuildContext context) {
return new DecoratedBox(
decoration: this.decoration.value,
position: this.position,
child: this.child
);
}
}
public class AlignTransition : AnimatedWidget {
public AlignTransition(
Key key = null,
Animation<Alignment> alignment = null,
Widget child = null,
float? widthFactor = null,
float? heightFactor = null
) : base(key: key, listenable: alignment) {
this.child = child;
this.widthFactor = widthFactor;
this.heightFactor = heightFactor;
}
Animation<Alignment> alignment {
get { return (Animation<Alignment>) this.listenable; }
}
public readonly float? widthFactor;
public readonly float? heightFactor;
public readonly Widget child;
protected internal override Widget build(BuildContext context) {
return new Align(
alignment: this.alignment.value,
widthFactor: this.widthFactor,
heightFactor: this.heightFactor,
child: this.child
);
}
}

正在加载...
取消
保存