Commit 715af6eb authored by Adam Barth's avatar Adam Barth

Port Tooltip to AnimationController

parent 6cea5dc8
...@@ -71,13 +71,13 @@ class Tooltip extends StatefulComponent { ...@@ -71,13 +71,13 @@ class Tooltip extends StatefulComponent {
class _TooltipState extends State<Tooltip> { class _TooltipState extends State<Tooltip> {
Performance _performance; AnimationController _controller;
OverlayEntry _entry; OverlayEntry _entry;
Timer _timer; Timer _timer;
void initState() { void initState() {
super.initState(); super.initState();
_performance = new Performance(duration: config.fadeDuration) _controller = new AnimationController(duration: config.fadeDuration)
..addStatusListener((PerformanceStatus status) { ..addStatusListener((PerformanceStatus status) {
switch (status) { switch (status) {
case PerformanceStatus.completed: case PerformanceStatus.completed:
...@@ -100,7 +100,7 @@ class _TooltipState extends State<Tooltip> { ...@@ -100,7 +100,7 @@ class _TooltipState extends State<Tooltip> {
void didUpdateConfig(Tooltip oldConfig) { void didUpdateConfig(Tooltip oldConfig) {
super.didUpdateConfig(oldConfig); super.didUpdateConfig(oldConfig);
if (config.fadeDuration != oldConfig.fadeDuration) if (config.fadeDuration != oldConfig.fadeDuration)
_performance.duration = config.fadeDuration; _controller.duration = config.fadeDuration;
if (_entry != null && if (_entry != null &&
(config.message != oldConfig.message || (config.message != oldConfig.message ||
config.backgroundColor != oldConfig.backgroundColor || config.backgroundColor != oldConfig.backgroundColor ||
...@@ -117,7 +117,7 @@ class _TooltipState extends State<Tooltip> { ...@@ -117,7 +117,7 @@ class _TooltipState extends State<Tooltip> {
} }
void resetShowTimer() { void resetShowTimer() {
assert(_performance.status == PerformanceStatus.completed); assert(_controller.status == PerformanceStatus.completed);
assert(_entry != null); assert(_entry != null);
_timer = new Timer(config.showDuration, hideTooltip); _timer = new Timer(config.showDuration, hideTooltip);
} }
...@@ -136,7 +136,10 @@ class _TooltipState extends State<Tooltip> { ...@@ -136,7 +136,10 @@ class _TooltipState extends State<Tooltip> {
height: config.height, height: config.height,
padding: config.padding, padding: config.padding,
opacity: config.opacity, opacity: config.opacity,
performance: _performance, animation: new CurvedAnimation(
parent: _controller,
curve: Curves.ease
),
target: target, target: target,
verticalOffset: config.verticalOffset, verticalOffset: config.verticalOffset,
screenEdgeMargin: config.screenEdgeMargin, screenEdgeMargin: config.screenEdgeMargin,
...@@ -146,9 +149,9 @@ class _TooltipState extends State<Tooltip> { ...@@ -146,9 +149,9 @@ class _TooltipState extends State<Tooltip> {
Overlay.of(context).insert(_entry); Overlay.of(context).insert(_entry);
} }
_timer?.cancel(); _timer?.cancel();
if (_performance.status != PerformanceStatus.completed) { if (_controller.status != PerformanceStatus.completed) {
_timer = null; _timer = null;
_performance.forward(); _controller.forward();
} else { } else {
resetShowTimer(); resetShowTimer();
} }
...@@ -158,7 +161,7 @@ class _TooltipState extends State<Tooltip> { ...@@ -158,7 +161,7 @@ class _TooltipState extends State<Tooltip> {
assert(_entry != null); assert(_entry != null);
_timer?.cancel(); _timer?.cancel();
_timer = null; _timer = null;
_performance.reverse(); _controller.reverse();
} }
void deactivate() { void deactivate() {
...@@ -232,7 +235,7 @@ class _TooltipOverlay extends StatelessComponent { ...@@ -232,7 +235,7 @@ class _TooltipOverlay extends StatelessComponent {
this.height, this.height,
this.padding, this.padding,
this.opacity, this.opacity,
this.performance, this.animation,
this.target, this.target,
this.verticalOffset, this.verticalOffset,
this.screenEdgeMargin, this.screenEdgeMargin,
...@@ -246,7 +249,7 @@ class _TooltipOverlay extends StatelessComponent { ...@@ -246,7 +249,7 @@ class _TooltipOverlay extends StatelessComponent {
final double borderRadius; final double borderRadius;
final double height; final double height;
final EdgeDims padding; final EdgeDims padding;
final PerformanceView performance; final Animated<double> animation;
final Point target; final Point target;
final double verticalOffset; final double verticalOffset;
final EdgeDims screenEdgeMargin; final EdgeDims screenEdgeMargin;
...@@ -266,9 +269,8 @@ class _TooltipOverlay extends StatelessComponent { ...@@ -266,9 +269,8 @@ class _TooltipOverlay extends StatelessComponent {
screenEdgeMargin: screenEdgeMargin, screenEdgeMargin: screenEdgeMargin,
preferBelow: preferBelow preferBelow: preferBelow
), ),
child: new OldFadeTransition( child: new FadeTransition(
performance: performance, opacity: animation,
opacity: new AnimatedValue<double>(0.0, end: 1.0, curve: Curves.ease),
child: new Opacity( child: new Opacity(
opacity: opacity, opacity: opacity,
child: new Container( child: new Container(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment