Skip to content
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

I needed to add a delegate or a completionHandler for when animation is done #23

Closed
waelsaad opened this issue Jun 22, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@waelsaad
Copy link

waelsaad commented Jun 22, 2020

Hi,

Very nice library, I was just a bit suprised because the library didn't have a delegate that is triggered when the animation is complete. I am hoping something like this could be added so I can integrate the library using Swift Package Manager.

    /**
     Use this method for force dismiss controller. By default it call automatically.
     */
    @objc public func dismiss() {
        UIView.animate(withDuration: 0.2, animations: {
            self.alpha = 0
            self.transform = self.transform.scaledBy(x: 0.8, y: 0.8)
        }, completion: { finished in
            self.delegate?.didFinishAnimation()
            self.removeFromSuperview()
        })
    }

or adding a completionHandler
    public func present(completionHandler: @escaping (() -> Void)) {
        haptic.impact()
        keyWindow.addSubview(self)
        layoutIfNeeded()
        layoutSubviews()
        alpha = 0
        transform = transform.scaledBy(x: 0.8, y: 0.8)

        UIView.animate(withDuration: 0.2, animations: {
            self.alpha = 1
            self.transform = CGAffineTransform.identity
        }, completion: { _ in
            if let iconView = self.iconView as? SPAlertIconAnimatable {
                iconView.animate()
            }
            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + self.duration) {
                self.dismiss(completionHandler: completionHandler)
            }
        })
    }
@waelsaad waelsaad changed the title I needed to add a delegate for when animation is done self.delegate?.didFinishAnimation() I needed to add a delegate or a completionHandler for when animation is done self.delegate?.didFinishAnimation() Jun 22, 2020
@waelsaad waelsaad changed the title I needed to add a delegate or a completionHandler for when animation is done self.delegate?.didFinishAnimation() I needed to add a delegate or a completionHandler for when animation is done Jun 22, 2020
@ivanvorobei ivanvorobei added the enhancement New feature or request label Jun 22, 2020
@salvatoreboemia
Copy link

Very nice feature

@ivanvorobei
Copy link
Member

Available in 3.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants