JoeFryer / JDFTooltips

A simple library for showing tooltip-like popups on iOS
MIT License
189 stars 42 forks source link

Auto-dismiss #1

Open JoeFryer opened 9 years ago

JoeFryer commented 9 years ago

Add the option to auto-dismiss a tooltip after a certain amount of time.

renjithn commented 9 years ago

@JoeFryer Great Job on this library. Will this enhancement be coming soon?

JoeFryer commented 9 years ago

Hey @renjithn - thanks! Yeah, I should think I'll get around to this pretty soon.

mzekrallah commented 9 years ago

Hi @JoeFryer. Any update on this feature ? awesome component.

JoeFryer commented 9 years ago

Hi @mzekrallah - sorry, I haven't had a chance to look at this yet. Feel free to have a look and submit a PR, if you like :)

mzekrallah commented 9 years ago

@JoeFryer Thank you for your awesome library. I converted the library to Xamarin.iOS and I will share that soon. For those who want a quick way to add auto-dismissing in SequentialManager .. the code is something like this :

    void ShowTooltip (JDFTooltipView tooltip)
    {
        if (this.ShowsBackdropView) {
            tooltip.ShowInView (this.BackdropView);
        } else {
            tooltip.Show ();
        }

        if (tooltip.DismissAfterSeconds > 0) {

            DismissTimer = new System.Threading.Timer (delegate(object state) {
                this.InvokeOnMainThread (() => HandleTooltipTap (null));
            },
                null,
                TimeSpan.FromSeconds (tooltip.DismissAfterSeconds),
                TimeSpan.Zero);
        }
    }

            [Export ("handleTooltipTap:")]
    public void HandleTooltipTap (UIGestureRecognizer gestureRecogniser)
    {
        if (DismissTimer != null) {
            DismissTimer.Change (Timeout.Infinite, Timeout.Infinite);
            DismissTimer = null;
        }
        this.ShowNextTooltip ();
    }
JoeFryer commented 9 years ago

That's great - thanks @mzekrallah! Hopefully I should be able to get round to doing this anyway.