diff --git a/Runtime/animation/tween.cs b/Runtime/animation/tween.cs index 09f8a49e..14453689 100644 --- a/Runtime/animation/tween.cs +++ b/Runtime/animation/tween.cs @@ -186,6 +186,17 @@ public override int lerp(float t) { } } + public class NullableFloatTween : Tween { + 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 { public FloatTween(float begin, float end) : base(begin: begin, end: end) { } diff --git a/Runtime/widgets/implicit_animations.cs b/Runtime/widgets/implicit_animations.cs index a6050ad1..82c8caee 100644 --- a/Runtime/widgets/implicit_animations.cs +++ b/Runtime/widgets/implicit_animations.cs @@ -466,16 +466,18 @@ public override void debugFillProperties(DiagnosticPropertiesBuilder properties) } class _AnimatedOpacityState : ImplicitlyAnimatedWidgetState { - FloatTween _opacity; + NullableFloatTween _opacity; Animation _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) { diff --git a/Samples/UIWidgetSample/txt/TextFieldSample.cs b/Samples/UIWidgetSample/txt/TextFieldSample.cs index 44a35577..dd386a24 100644 --- a/Samples/UIWidgetSample/txt/TextFieldSample.cs +++ b/Samples/UIWidgetSample/txt/TextFieldSample.cs @@ -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