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 {
|
class _BorderContainerState extends State<_BorderContainer> with TickerProviderStateMixin {
|
||||||
static const Duration _kFocusInDuration = Duration(milliseconds: 45);
|
static const Duration _kFocusInDuration = Duration(milliseconds: 45);
|
||||||
|
static const Duration _kFocusOutDuration = Duration(milliseconds: 15);
|
||||||
static const Duration _kHoverDuration = Duration(milliseconds: 15);
|
static const Duration _kHoverDuration = Duration(milliseconds: 15);
|
||||||
|
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
@ -183,7 +184,7 @@ class _BorderContainerState extends State<_BorderContainer> with TickerProviderS
|
|||||||
super.initState();
|
super.initState();
|
||||||
_focusColorController = AnimationController(
|
_focusColorController = AnimationController(
|
||||||
duration: _kFocusInDuration,
|
duration: _kFocusInDuration,
|
||||||
// TODO(gspencer): use reverseDuration set to 15ms, once available.
|
reverseDuration: _kFocusOutDuration,
|
||||||
value: widget.isFocused ? 1.0 : 0.0,
|
value: widget.isFocused ? 1.0 : 0.0,
|
||||||
vsync: this,
|
vsync: this,
|
||||||
);
|
);
|
||||||
|
@ -149,7 +149,11 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_mouseIsConnected = RendererBinding.instance.mouseTracker.mouseIsConnected;
|
_mouseIsConnected = RendererBinding.instance.mouseTracker.mouseIsConnected;
|
||||||
_controller = AnimationController(duration: _fadeInDuration, vsync: this)
|
_controller = AnimationController(
|
||||||
|
duration: _fadeInDuration,
|
||||||
|
reverseDuration: _fadeOutDuration,
|
||||||
|
vsync: this,
|
||||||
|
)
|
||||||
..addStatusListener(_handleStatusChanged);
|
..addStatusListener(_handleStatusChanged);
|
||||||
// Listen to see when a mouse is added.
|
// Listen to see when a mouse is added.
|
||||||
RendererBinding.instance.mouseTracker.addListener(_handleMouseTrackerChange);
|
RendererBinding.instance.mouseTracker.addListener(_handleMouseTrackerChange);
|
||||||
@ -226,7 +230,6 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
|
|||||||
void _createNewEntry() {
|
void _createNewEntry() {
|
||||||
final RenderBox box = context.findRenderObject();
|
final RenderBox box = context.findRenderObject();
|
||||||
final Offset target = box.localToGlobal(box.size.center(Offset.zero));
|
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
|
// 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
|
// 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(
|
animation: CurvedAnimation(
|
||||||
parent: _controller,
|
parent: _controller,
|
||||||
curve: Curves.fastOutSlowIn,
|
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,
|
target: target,
|
||||||
verticalOffset: widget.verticalOffset,
|
verticalOffset: widget.verticalOffset,
|
||||||
|
@ -2140,8 +2140,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(getContainerColor(tester), equals(focusColor));
|
expect(getContainerColor(tester), equals(focusColor));
|
||||||
// TODO(gspencer): convert this to 15ms once reverseDuration for AnimationController lands.
|
await tester.pump(const Duration(milliseconds: 15));
|
||||||
await tester.pump(const Duration(milliseconds: 45));
|
|
||||||
expect(getContainerColor(tester), equals(fillColor));
|
expect(getContainerColor(tester), equals(fillColor));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user