浏览代码

Implement SizeTransition and SliverToBoxAdapter.

/main
Yuncong Zhang 6 年前
当前提交
c8c36dd5
共有 2 个文件被更改,包括 57 次插入0 次删除
  1. 12
      Runtime/widgets/basic.cs
  2. 45
      Runtime/widgets/transitions.cs

12
Runtime/widgets/basic.cs


}
}
public class SliverToBoxAdapter : SingleChildRenderObjectWidget {
public SliverToBoxAdapter(
Key key = null,
Widget child = null) : base(key: key, child: child) {
}
public override RenderObject createRenderObject(BuildContext context) {
return new RenderSliverToBoxAdapter();
}
}
public class Flex : MultiChildRenderObjectWidget {
public Flex(
Axis direction = Axis.vertical,

45
Runtime/widgets/transitions.cs


}
}
public class SizeTransition : AnimatedWidget {
public SizeTransition(
Key key = null,
Axis axis = Axis.vertical,
Animation<float> sizeFactor = null,
float axisAlignment = 0.0f,
Widget child = null) : base(key: key, listenable: sizeFactor) {
D.assert(axis != null);
D.assert(sizeFactor != null);
D.assert(axisAlignment != null);
this.axis = axis;
this.axisAlignment = axisAlignment;
this.child = child;
}
public readonly Axis axis;
public readonly float axisAlignment;
Animation<float> sizeFactor {
get { return (Animation<float>) this.listenable; }
}
public readonly Widget child;
protected internal override Widget build(BuildContext context) {
Alignment alignment;
if (this.axis == Axis.vertical) {
alignment = new Alignment(-1.0f, this.axisAlignment);
}
else {
alignment = new Alignment(this.axisAlignment, -1.0f);
}
return new ClipRect(
child: new Align(
alignment: alignment,
widthFactor: this.axis == Axis.horizontal ? (float?) Mathf.Max(this.sizeFactor.value, 0.0f) : null,
heightFactor: this.axis == Axis.vertical ? (float?) Mathf.Max(this.sizeFactor.value, 0.0f) : null,
child: this.child
)
);
}
}
public class FadeTransition : SingleChildRenderObjectWidget {
public FadeTransition(Key key = null, Animation<float> opacity = null,
Widget child = null) : base(key: key, child: child) {

正在加载...
取消
保存