From 715af6ebe82871bdb01501bfebcba982940b754a Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 19 Jan 2016 23:03:33 -0800 Subject: [PATCH] Port Tooltip to AnimationController --- .../flutter/lib/src/material/tooltip.dart | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index 60f27d3d86..a59a259dcd 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -71,13 +71,13 @@ class Tooltip extends StatefulComponent { class _TooltipState extends State { - Performance _performance; + AnimationController _controller; OverlayEntry _entry; Timer _timer; void initState() { super.initState(); - _performance = new Performance(duration: config.fadeDuration) + _controller = new AnimationController(duration: config.fadeDuration) ..addStatusListener((PerformanceStatus status) { switch (status) { case PerformanceStatus.completed: @@ -100,7 +100,7 @@ class _TooltipState extends State { void didUpdateConfig(Tooltip oldConfig) { super.didUpdateConfig(oldConfig); if (config.fadeDuration != oldConfig.fadeDuration) - _performance.duration = config.fadeDuration; + _controller.duration = config.fadeDuration; if (_entry != null && (config.message != oldConfig.message || config.backgroundColor != oldConfig.backgroundColor || @@ -117,7 +117,7 @@ class _TooltipState extends State { } void resetShowTimer() { - assert(_performance.status == PerformanceStatus.completed); + assert(_controller.status == PerformanceStatus.completed); assert(_entry != null); _timer = new Timer(config.showDuration, hideTooltip); } @@ -136,7 +136,10 @@ class _TooltipState extends State { height: config.height, padding: config.padding, opacity: config.opacity, - performance: _performance, + animation: new CurvedAnimation( + parent: _controller, + curve: Curves.ease + ), target: target, verticalOffset: config.verticalOffset, screenEdgeMargin: config.screenEdgeMargin, @@ -146,9 +149,9 @@ class _TooltipState extends State { Overlay.of(context).insert(_entry); } _timer?.cancel(); - if (_performance.status != PerformanceStatus.completed) { + if (_controller.status != PerformanceStatus.completed) { _timer = null; - _performance.forward(); + _controller.forward(); } else { resetShowTimer(); } @@ -158,7 +161,7 @@ class _TooltipState extends State { assert(_entry != null); _timer?.cancel(); _timer = null; - _performance.reverse(); + _controller.reverse(); } void deactivate() { @@ -232,7 +235,7 @@ class _TooltipOverlay extends StatelessComponent { this.height, this.padding, this.opacity, - this.performance, + this.animation, this.target, this.verticalOffset, this.screenEdgeMargin, @@ -246,7 +249,7 @@ class _TooltipOverlay extends StatelessComponent { final double borderRadius; final double height; final EdgeDims padding; - final PerformanceView performance; + final Animated animation; final Point target; final double verticalOffset; final EdgeDims screenEdgeMargin; @@ -266,9 +269,8 @@ class _TooltipOverlay extends StatelessComponent { screenEdgeMargin: screenEdgeMargin, preferBelow: preferBelow ), - child: new OldFadeTransition( - performance: performance, - opacity: new AnimatedValue(0.0, end: 1.0, curve: Curves.ease), + child: new FadeTransition( + opacity: animation, child: new Opacity( opacity: opacity, child: new Container(