-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Re-land: Add support for Tooltip hover #31699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2b02910 to
956c577
Compare
956c577 to
6de810d
Compare
c2b5a00 to
3ba2d9b
Compare
|
OK, @HansMuller, this is ready for another round. I've updated this with the code to not even wrap the Listener widget in the tooltip unless there is a mouse connected, and also changed the Listener to not add the layer unless a mouse is connected. |
ea3b74a to
c80d1b2
Compare
This is a re-land of flutter#31561, after fixing performance regressions.
c80d1b2 to
e935f49
Compare
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just some random comments to prove that I read through all of it.
| /// {@macro flutter.widgets.child} | ||
| final Widget child; | ||
|
|
||
| /// Specifies the decoration of the tooltip window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tooltip's shape and background color?
If I'm not mistaken, there's no window here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was in the everythings-a-window sense. :-)
No, no window. Fixed.
| /// Specifies the decoration of the tooltip window. | ||
| /// | ||
| /// If not specified, defaults to a rounded rectangle with a border radius of | ||
| /// 4.0, and a color derived from the text theme. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three text themes in ThemeData: textTheme, primaryTextTheme, accentTextTheme. Assuming that we're referring to the first one, then maybe mention [ThemeData.textTheme].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's theme.textTheme or theme.primaryTextTheme, depending upon whether it's a dark theme or not. I didn't change the logic, and I wanted to say loosely what it was based on, but without repeating the conditionals. Probably better to just be explicit, though.
| kind: kind, | ||
| pointer: pointer ?? _getNextPointer(), | ||
| ); | ||
| await gesture.addPointer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a non-trivial change. Should the doc for the method reflect it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I removed it and moved it into the test, since I think that the createGesture should probably not assume anything about the events a test might need. I may introduce a startHover method that will do it, but for now I'll just put the addPointer into the test.
| /// In a test, send a move event that moves the pointer by the given offset. | ||
| @visibleForTesting | ||
| Future<void> updateWithCustomEvent(PointerEvent event, { Duration timeStamp = Duration.zero }) { | ||
| Future<void> updateWithCustomEvent(PointerEvent event, {Duration timeStamp = Duration.zero}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ Duration timeStamp = Duration.zero } I think I mentioned this earlier. Flutter sources generally include the spaces before named parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is dartfmt really not helping me. Fixed everywhere in this file.
Description
This is a re-land of #31561, after fixing performance regressions.
Added change listening to the MouseTracker so that the Listener and tooltip can react to whether or not a mouse is connected at all. Added a change check to make sure
Listeneronly repaints when something changed.Here's a gist with the changes since the original change.
Fixes #22817