stargazing-dino / just_the_tooltip

A directional tooltip for flutter projects
https://pub.dev/packages/just_the_tooltip
MIT License
56 stars 54 forks source link

Some problems with all the durations #26

Closed sgehrman closed 3 years ago

sgehrman commented 3 years ago

I don't know exactly what's going on, but setting these durations is near impossible to get right.

Most of the time the tooltip doesn't show up. It must be hiding the tooltip in timers that get fired at the wrong time.

Very confusing to set this up.

sgehrman commented 3 years ago

maybe false alarm, I'm seeing weird build problems with flutter, going to keep trying to reproduce it.

I think it might have something to do with this: (I'm on desktop linux)

final isConnected = RendererBinding.instance!.mouseTracker.mouseIsConnected;

if (isConnected != _mouseIsConnected) {
  setState(() {
    _mouseIsConnected = isConnected;
    print('mouse is connected');
  });
}
stargazing-dino commented 3 years ago

No, I think you're right. I just ran the demo and tried changing

showDuration: const Duration(seconds: 5),

and it looks like it has no effect. I should also clarify by asking you do mean these fields right showDuration and hideDuration? Those are the ones I assume you mean. It looks like I'm just not respecting them and waiting the duration it takes for longPress to be hit which isn't right.

sgehrman commented 3 years ago

I tried everything, all the durations. I got the code and trying to debug on my end.

Thanks for looking at it.

stargazing-dino commented 3 years ago

Yeah, so fadeInDuration and fadeOutDuration look like they work and I think I have a test setup for them but not showDuration which I'll set up once I find the issue. Those are specific to the amount of time it takes to fully show or hide the tooltip.

Another thing is that I'm not seeing is documentation on JustTheTooltip parameters which is weird because I inherit from a class that has the full docs for every class field. Can you confirm that and I'll make it a separate issue?

sgehrman commented 3 years ago

I did notice that issue with the docs. I only found the docks when I forked and looked at the code.

I normally just right click and go to definition and it wasn't going to your interface file, so maybe that's related?

stargazing-dino commented 3 years ago

Very silly mistake with docs. My mistake. Fixed with 43887ef8f12dcfe9c8e73928f06c0ac27bf142f2 and available in 0.0.7+3

Will move back to duration stuff but that might take a bit longer.

sgehrman commented 3 years ago

Thanks! I really appreciate the fast response. Code looks really nice.

stargazing-dino commented 3 years ago

So I think you're going to have to narrow down the question. It looks like everything works so far as I understand the problem.

https://user-images.githubusercontent.com/29642168/131937398-d70afa82-94d4-4b0b-a043-349a958cf54d.mov

The confusion might possibly be that you're trying on mobile and mobile does not support hover (from the official Tooltip design) so those fields are largely ignored. I'm honestly not sure so it might be that I'm missing something important. Please let me know if that is the case

sgehrman commented 3 years ago

I still can't figure out what is happening. It seems random. I'll build it with your package and it won't work, then I downloaded the code and put in some print statements and it worked. I keep trying things back and forth and I'm not sure if Dart is not compiling things correctly or what. Your package is a package included in another one of my packages, so maybe there is something too that. Very weird, but I'll keep trying to reproduce it.

sgehrman commented 3 years ago

Hey, I think I reproduced it!!

This was one test, so maybe a fluke. Open the app and don't move the mouse at all. Then move the mouse and it seems to work.

Next try moving the mouse back and forth over the page as it loads. _mouseIsConnected never gets set to true.

I've also seen cases where one view works, and the other doesn't work. And it's random.

See if you can reproduce that, I'll keep trying. I'm testing in a web page if that matters, on linux.

sgehrman commented 3 years ago

This code doesn't look wrong, but it looks kind of weird:

void initState() { if (!widget.isModal) { _hasBindingListeners = true; <== setting this to true here _addBindingListeners(); } else {

void _addBindingListeners() { if (!_hasBindingListeners) _hasBindingListeners = true; <== why have the if statement? it's not returning if already set.

should it be something like if (_hasBindingListeners) return;

?

sgehrman commented 3 years ago

If I move the mouse as it's loading, _handleMouseTrackerChange never gets called

Very weird. But I can reproduce it consistently.

RendererBinding.instance!.mouseTracker
    .addListener(_handleMouseTrackerChange);
sgehrman commented 3 years ago

I googled a bit and it looks like you copied some of the code from Flutter's tooltip.

That code has this in initState _mouseIsConnected = RendererBinding.instance!.mouseTracker.mouseIsConnected;

So, maybe they had the same issue? I added that and it works. I'm making a PR, you can see what I changed.