Use reverseDuration on Tooltip and InkWell. (#32904)
This puts the new AnimationController reverseDuration argument to use in two places: focus for InkWells and fade out for Tooltips.
This commit is contained in:
parent
71d370fd7b
commit
76dccbe2fb
@ -166,6 +166,7 @@ class _BorderContainer extends StatefulWidget {
|
||||
|
||||
class _BorderContainerState extends State<_BorderContainer> with TickerProviderStateMixin {
|
||||
static const Duration _kFocusInDuration = Duration(milliseconds: 45);
|
||||
static const Duration _kFocusOutDuration = Duration(milliseconds: 15);
|
||||
static const Duration _kHoverDuration = Duration(milliseconds: 15);
|
||||
|
||||
AnimationController _controller;
|
||||
@ -183,7 +184,7 @@ class _BorderContainerState extends State<_BorderContainer> with TickerProviderS
|
||||
super.initState();
|
||||
_focusColorController = AnimationController(
|
||||
duration: _kFocusInDuration,
|
||||
// TODO(gspencer): use reverseDuration set to 15ms, once available.
|
||||
reverseDuration: _kFocusOutDuration,
|
||||
value: widget.isFocused ? 1.0 : 0.0,
|
||||
vsync: this,
|
||||
);
|
||||
|
@ -149,7 +149,11 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_mouseIsConnected = RendererBinding.instance.mouseTracker.mouseIsConnected;
|
||||
_controller = AnimationController(duration: _fadeInDuration, vsync: this)
|
||||
_controller = AnimationController(
|
||||
duration: _fadeInDuration,
|
||||
reverseDuration: _fadeOutDuration,
|
||||
vsync: this,
|
||||
)
|
||||
..addStatusListener(_handleStatusChanged);
|
||||
// Listen to see when a mouse is added.
|
||||
RendererBinding.instance.mouseTracker.addListener(_handleMouseTrackerChange);
|
||||
@ -226,7 +230,6 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
|
||||
void _createNewEntry() {
|
||||
final RenderBox box = context.findRenderObject();
|
||||
final Offset target = box.localToGlobal(box.size.center(Offset.zero));
|
||||
assert(_fadeOutDuration < _fadeInDuration);
|
||||
|
||||
// We create this widget outside of the overlay entry's builder to prevent
|
||||
// updated values from happening to leak into the overlay when the overlay
|
||||
@ -239,14 +242,6 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
|
||||
animation: CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: Curves.fastOutSlowIn,
|
||||
// Add an interval here to make the fade out use a different (shorter)
|
||||
// duration than the fade in. If _kFadeOutDuration is made longer than
|
||||
// _kFadeInDuration, then the equation below will need to change.
|
||||
reverseCurve: Interval(
|
||||
0.0,
|
||||
_fadeOutDuration.inMilliseconds / _fadeInDuration.inMilliseconds,
|
||||
curve: Curves.fastOutSlowIn,
|
||||
),
|
||||
),
|
||||
target: target,
|
||||
verticalOffset: widget.verticalOffset,
|
||||
|
@ -2140,8 +2140,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(getContainerColor(tester), equals(focusColor));
|
||||
// TODO(gspencer): convert this to 15ms once reverseDuration for AnimationController lands.
|
||||
await tester.pump(const Duration(milliseconds: 45));
|
||||
await tester.pump(const Duration(milliseconds: 15));
|
||||
expect(getContainerColor(tester), equals(fillColor));
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user