Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Runtime/animation/tween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ public override int lerp(float t) {
}
}

public class NullableFloatTween : Tween<float?> {
public NullableFloatTween(float? begin = null, float? end = null) : base(begin: begin, end: end) {
}

public override float? lerp(float t) {
D.assert(this.begin != null);
D.assert(this.end != null);
return this.begin + (this.end - this.begin) * t;
}
}

public class FloatTween : Tween<float> {
public FloatTween(float begin, float end) : base(begin: begin, end: end) {
}
Expand Down
10 changes: 6 additions & 4 deletions Runtime/widgets/implicit_animations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,18 @@ public override void debugFillProperties(DiagnosticPropertiesBuilder properties)
}

class _AnimatedOpacityState : ImplicitlyAnimatedWidgetState<AnimatedOpacity> {
FloatTween _opacity;
NullableFloatTween _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));
this._opacity = (NullableFloatTween) visitor.visit(this, this._opacity, this.widget.opacity,
(float? value) => new NullableFloatTween(begin: value));
}

protected override void didUpdateTweens() {
this._opacityAnimation = this.animation.drive(this._opacity);
float? endValue = this._opacity.end ?? this._opacity.begin ?? null;
D.assert(endValue != null);
this._opacityAnimation = this.animation.drive(new FloatTween(begin: this._opacity.begin.Value, end: endValue.Value));
}

public override Widget build(BuildContext context) {
Expand Down
8 changes: 7 additions & 1 deletion Samples/UIWidgetSample/txt/TextFieldSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ public override Widget build(BuildContext context) {
),
body: new Padding(
padding: EdgeInsets.all(16.0f),
child: new TextField(controller: this.myController)
child: new TextField(
controller: this.myController,
autofocus: true,
decoration: new InputDecoration(
hintText: "hinthere",
labelText: "pwd",
prefixIcon: new Icon(Unity.UIWidgets.material.Icons.search)))
),
floatingActionButton: new FloatingActionButton(
// When the user presses the button, show an alert dialog with the
Expand Down