浏览代码

Finish dropdown.

/main
Yuncong Zhang 6 年前
当前提交
7dddd74d
共有 5 个文件被更改,包括 643 次插入470 次删除
  1. 962
      Runtime/material/dropdown.cs
  2. 6
      Runtime/material/input_decorator.cs
  3. 65
      Runtime/rendering/stack.cs
  4. 31
      Runtime/widgets/basic.cs
  5. 49
      Runtime/widgets/implicit_animations.cs

962
Runtime/material/dropdown.cs
文件差异内容过多而无法显示
查看文件

6
Runtime/material/input_decorator.cs


child: new AnimatedOpacity(
duration: InputDecoratorConstants._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve,
opacity: this.labelIsFloating ? 1.0f : 0.0,
opacity: this.labelIsFloating ? 1.0f : 0.0f,
child: this.child ?? new Text(this.text, style: this.style)
)
);

Widget hint = this.decoration.hintText == null
? null
: new AnimatedOpacity(
opacity: (this.isEmpty && !this._hasInlineLabel) ? 1.0f : 0.0,
opacity: (this.isEmpty && !this._hasInlineLabel) ? 1.0f : 0.0f,
duration: InputDecoratorConstants._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve,
child: new Text(this.decoration.hintText,

child: new AnimatedOpacity(
duration: InputDecoratorConstants._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve,
opacity: this._shouldShowLabel ? 1.0f : 0.0,
opacity: this._shouldShowLabel ? 1.0f : 0.0f,
child: new AnimatedDefaultTextStyle(
duration: InputDecoratorConstants._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve,

65
Runtime/rendering/stack.cs


return this.defaultHitTestChildren(result, position: position);
}
public void paintStack(PaintingContext context, Offset offset) {
public virtual void paintStack(PaintingContext context, Offset offset) {
this.defaultPaint(context, offset);
}

properties.add(new DiagnosticsProperty<Alignment>("alignment", this.alignment));
properties.add(new EnumProperty<StackFit>("fit", this.fit));
properties.add(new EnumProperty<Overflow>("overflow", this.overflow));
}
}
class RenderIndexedStack : RenderStack {
public RenderIndexedStack(
List<RenderBox> children = null,
Alignment alignment = null,
int? index = 0
) : base(fit: null, overflow: null, children: children, alignment: alignment ?? Alignment.topLeft) {
this._index = index;
}
public int? index {
get { return this._index; }
set {
if (this._index != value) {
this._index = value;
this.markNeedsLayout();
}
}
}
int? _index;
RenderBox _childAtIndex() {
D.assert(this.index != null);
RenderBox child = this.firstChild;
int i = 0;
while (child != null && i < this.index) {
StackParentData childParentData = (StackParentData) child.parentData;
child = childParentData.nextSibling;
i += 1;
}
D.assert(i == this.index);
D.assert(child != null);
return child;
}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
if (this.firstChild == null || this.index == null) {
return false;
}
D.assert(position != null);
RenderBox child = this._childAtIndex();
StackParentData childParentData = (StackParentData) child.parentData;
return child.hitTest(result, position: position - childParentData.offset);
}
public override void paintStack(PaintingContext context, Offset offset) {
if (this.firstChild == null || this.index == null) {
return;
}
RenderBox child = this._childAtIndex();
StackParentData childParentData = (StackParentData) child.parentData;
context.paintChild(child, childParentData.offset + offset);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new IntProperty("index", this.index));
}
}
}

31
Runtime/widgets/basic.cs


}
}
class IndexedStack : Stack {
public IndexedStack(
Key key = null,
Alignment alignment = null,
StackFit sizing = StackFit.loose,
int index = 0,
List<Widget> children = null
) : base(key: key, alignment: alignment ?? Alignment.topLeft, fit: sizing, children: children) {
this.index = index;
}
public readonly int index;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderIndexedStack(
index: this.index,
alignment: this.alignment
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
RenderIndexedStack renderIndexedStack = renderObject as RenderIndexedStack;
renderIndexedStack.index = this.index;
renderIndexedStack.alignment = this.alignment;
}
}
public class Positioned : ParentDataWidget<Stack> {
public Positioned(Widget child, Key key = null, float? left = null, float? top = null,
float? right = null, float? bottom = null, float? width = null, float? height = null) :

public static List<Widget> ensureUniqueKeysForList(IEnumerable<Widget> items, int baseIndex = 0) {
if (items == null) {
return null;
itemsWithUniqueKeys.Add(KeyedSubtree.wrap(item, itemIndex));
itemsWithUniqueKeys.Add(wrap(item, itemIndex));
itemIndex += 1;
}

49
Runtime/widgets/implicit_animations.cs


}
}
public class AnimatedOpacity : ImplicitlyAnimatedWidget {
public AnimatedOpacity(
Key key = null,
Widget child = null,
float? opacity = null,
Curve curve = null,
TimeSpan? duration = null
) :
base(key: key, curve: curve ?? Curves.linear, duration: duration) {
D.assert(opacity != null && opacity >= 0.0 && opacity <= 1.0);
this.child = child;
this.opacity = opacity ?? 1.0f;
}
public readonly Widget child;
public readonly float opacity;
public override State createState() {
return new _AnimatedOpacityState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("opacity", this.opacity));
}
}
class _AnimatedOpacityState : ImplicitlyAnimatedWidgetState<AnimatedOpacity> {
FloatTween _opacity;
Animation<float> _opacityAnimation;
protected override void forEachTween(TweenVisitor visitor) {
this._opacity = (FloatTween) visitor.visit(this, this._opacity, this.widget.opacity,
(float value) => new FloatTween(begin: value, end: 1.0f));
}
protected override void didUpdateTweens() {
this._opacityAnimation = this.animation.drive(this._opacity);
}
public override Widget build(BuildContext context) {
return new FadeTransition(
opacity: this._opacityAnimation,
child: this.widget.child
);
}
}
public class AnimatedDefaultTextStyle : ImplicitlyAnimatedWidget {
public AnimatedDefaultTextStyle(
Key key = null,

正在加载...
取消
保存