GithubHelp home page GithubHelp logo

Comments (9)

stargazing-dino avatar stargazing-dino commented on June 21, 2024 2

This was whack. I tried every solution and the thing i finally landed on was pretty much a better implementation of the PR i made for super_tooltip like a year ago.

Anyways, the controller is just a ValueNotifier that looks like a redux action. Once it changes its action, I have a listener on it in the widget that will fire off the correct callback according to the action. This solution however correctly handles the animation time between showing/hiding tooltips unlike my old PR.

Let me know what you think ! The controller is really simple at the minute but it can be exanded.

I'll add full docs once it's been tested. To test, use

  just_the_tooltip: 0.0.6-dev

and provide a controller like any other widget

final controller = JustTheController();

JustTheTooltip(
  controller: controller,
  // ...
)

await controller.showTooltip();
await controller.hideTooltip();

I haven't thought super hard about what would happen when there's competing events or other edge cases so it might be off. Let me know

from just_the_tooltip.

stargazing-dino avatar stargazing-dino commented on June 21, 2024 1

Was actually thinking this myself ! I'll definitely add something like this in the near future

from just_the_tooltip.

stargazing-dino avatar stargazing-dino commented on June 21, 2024 1

My main struggle with this is whether I want a controller or something more declarative. The declarative option would just involve properties on the tip like isVisible and you would hold those properties on the state of the widget that has the tooltip or an ancestor.

If you could point me to a really intuitive API of a different tooltip package that has worked for you we'll in the past, I'd consider it. It might even be from the React/Vue world.

My main gripe against controllers is that it's another thing for the user to remember to dispose and I personally never liked the non-granular update process around ChnageNotifiers although that's not really the issue.

from just_the_tooltip.

aytunch avatar aytunch commented on June 21, 2024

@Nolence I also would like to add hiding the tooltip programatically. Let's say I want to show a tooltip for a fixed Duration.

After the duration is passed I want to hide it programatically without the user pressing the screen. This feature is very important for me :)

from just_the_tooltip.

aytunch avatar aytunch commented on June 21, 2024

I understand your concern perfectly. Personally I would benefit from a controller architecture.
However for this issue, we can add optional isShown and showAndHideFadeTransitionDuration fields.

from just_the_tooltip.

stargazing-dino avatar stargazing-dino commented on June 21, 2024

I'm a little dumb as to how this controller will work. I took a look at an old PR I think I wrote for super_tooltip and I naively wrote an event based controller not at all hooked up to the actual widget. Not even sure it awaits the transition.

Do you know of any resources to find out how to cleanly wire a controller to a Widget? I looked at ScrollController and PageController and those are kinda chaotic. Their animateTo's and stuff are also like one liners that don't make any sense to me.

One option I thought is to pass all of my widget callbacks to the controller and just call them in the controller. That might work but I've never seen anyone else do it

(i.e. pass in the method _showTooltip as a property to the controller and then inside the controller's showTooltip, i just call _showTooltip)
https://github.com/Nolence/just_the_tooltip/blob/0ed778c4d698689f7720a5618c3c94f776c82397/lib/src/just_the_tooltip.dart#L169

controller code:
https://github.com/Nolence/just_the_tooltip/blob/0ed778c4d698689f7720a5618c3c94f776c82397/lib/src/models/just_the_controller.dart#L3

from just_the_tooltip.

aytunch avatar aytunch commented on June 21, 2024

I personally find this kind of a controller implementation easier: https://github.com/akshathjain/sliding_up_panel/blob/master/lib/src/panel.dart

It is a simple controller class which keeps the state class as a variable inside.

from just_the_tooltip.

stargazing-dino avatar stargazing-dino commented on June 21, 2024

I really like how clean that panel solution is. One thing that concerns me though is that they don't dispose anything. It's just a class that holds a reference to state. I can imagine a situation where the controller can become out of date with the internal state. It looks like onDispose, they don't invalidate anything on the controller so I think you could get some weird results if this was used wrong.

I found this SO answer https://stackoverflow.com/questions/63954710/creating-a-custom-controller-in-flutter That kind of discusses what we're talking about here. Someone else seems to have done what I suggested here by passing in the functions to the class.

I agree with Schnodderbalken's answer though saying this might be an anti-pattern though. I would also like something closer to a ValueNotifier.

That said, in my case, it's a bit harder as I use just about every lifecycle, require a delegate to determine some state and have listeners I need to constantly worry about -- all of which were better off connected to a widget and not being passed through to a controller.

I'll mull this over some more. I think i'll need to make a large refactor to support controllers so I don't want to jump into something right away

from just_the_tooltip.

marco-1988 avatar marco-1988 commented on June 21, 2024

Hi. I use showTooltip for show tooltip when change page on pageView and works, but sometimes tooltip is not shown.
If I use debugger seems to enter on funcion every times, but sometimes tooltip is not shown.
What can I do?

from just_the_tooltip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.