Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 6776893

Browse files
authored
Merge pull request #170 from UnityTech/slider
Slider
2 parents 832300b + a02cd3e commit 6776893

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

Runtime/animation/tween.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ public override int lerp(float t) {
186186
}
187187
}
188188

189+
public class NullableFloatTween : Tween<float?> {
190+
public NullableFloatTween(float? begin = null, float? end = null) : base(begin: begin, end: end) {
191+
}
192+
193+
public override float? lerp(float t) {
194+
D.assert(this.begin != null);
195+
D.assert(this.end != null);
196+
return this.begin + (this.end - this.begin) * t;
197+
}
198+
}
199+
189200
public class FloatTween : Tween<float> {
190201
public FloatTween(float begin, float end) : base(begin: begin, end: end) {
191202
}

Runtime/widgets/implicit_animations.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,16 +466,18 @@ public override void debugFillProperties(DiagnosticPropertiesBuilder properties)
466466
}
467467

468468
class _AnimatedOpacityState : ImplicitlyAnimatedWidgetState<AnimatedOpacity> {
469-
FloatTween _opacity;
469+
NullableFloatTween _opacity;
470470
Animation<float> _opacityAnimation;
471471

472472
protected override void forEachTween(TweenVisitor visitor) {
473-
this._opacity = (FloatTween) visitor.visit(this, this._opacity, this.widget.opacity,
474-
(float value) => new FloatTween(begin: value, end: 1.0f));
473+
this._opacity = (NullableFloatTween) visitor.visit(this, this._opacity, this.widget.opacity,
474+
(float? value) => new NullableFloatTween(begin: value));
475475
}
476476

477477
protected override void didUpdateTweens() {
478-
this._opacityAnimation = this.animation.drive(this._opacity);
478+
float? endValue = this._opacity.end ?? this._opacity.begin ?? null;
479+
D.assert(endValue != null);
480+
this._opacityAnimation = this.animation.drive(new FloatTween(begin: this._opacity.begin.Value, end: endValue.Value));
479481
}
480482

481483
public override Widget build(BuildContext context) {

Samples/UIWidgetSample/txt/TextFieldSample.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ public override Widget build(BuildContext context) {
4141
),
4242
body: new Padding(
4343
padding: EdgeInsets.all(16.0f),
44-
child: new TextField(controller: this.myController)
44+
child: new TextField(
45+
controller: this.myController,
46+
autofocus: true,
47+
decoration: new InputDecoration(
48+
hintText: "hinthere",
49+
labelText: "pwd",
50+
prefixIcon: new Icon(Unity.UIWidgets.material.Icons.search)))
4551
),
4652
floatingActionButton: new FloatingActionButton(
4753
// When the user presses the button, show an alert dialog with the

0 commit comments

Comments
 (0)