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

Feature request: Callback when presented and dismissed #50

Closed
pjcau opened this issue Jun 14, 2018 · 12 comments
Closed

Feature request: Callback when presented and dismissed #50

pjcau opened this issue Jun 14, 2018 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@pjcau
Copy link

pjcau commented Jun 14, 2018

Is your feature request related to a problem? Please describe.
I should have a callback when popup is presented and dismissed, to do actions after presented or dismissed popup.

Describe the solution you'd like
I should have a callback when popup is presented and dismissed.

Describe alternatives you've considered
Maybe it's possible to add a delegate with to methods when finishing the animation for presenting and same when dismissing.

Additional context
nothing

@huri000
Copy link
Owner

huri000 commented Jun 14, 2018

Hi @pjcau,
Sure, could you please edit the issue as a Feature-Request according to the project guidelines and explain exactly your requirements? Then I could review them and decide how to implement a solution.

@pjcau pjcau changed the title Callback when presented and dismissed Feature request: Callback when presented and dismissed Jun 14, 2018
@pjcau
Copy link
Author

pjcau commented Jun 14, 2018

@huri000 tell me it's all right. If press edit on post, I can edit only the title not the labels.

J

@huri000
Copy link
Owner

huri000 commented Jun 14, 2018

Great. I'll figure something out and keep you posted (next few days).

@huri000 huri000 self-assigned this Jun 14, 2018
@huri000 huri000 added the enhancement New feature or request label Jun 14, 2018
@Banck
Copy link

Banck commented Jun 14, 2018

@huri000 Hello!
I just wanted to open the same "issue". Could you please add completion block in SwiftEntryKit.dismiss() , because:
I present the new controller when some button was pressing in alert. I have this code:

alertView.okButtonDidTap = {
SwiftEntryKit.dismiss()
okAction?()
}

and in "okAction" I'm presenting the new controller. But the alert is flashing sometimes. If add some delay like 1 second (to be sure, that alert was closed) everything is fine

Thanks

@pjcau
Copy link
Author

pjcau commented Jun 14, 2018 via email

@pjcau
Copy link
Author

pjcau commented Jun 15, 2018

I tried your solution but infact works only the user taps the button, not drag or tap outside the message to dismiss. Maybe it's not the good solution for me and this feature.

J

@Banck
Copy link

Banck commented Jun 15, 2018

Seems you didn't get me.
I meant, that I need a clouser "completed" in method SwiftEntryKit.dismiss().
I didn't give you any solution, just asked @huri000 to make a closure in SwiftEntryKit.dismiss() too. :-)

@pjcau
Copy link
Author

pjcau commented Jun 15, 2018

OK, Now it's clear. thank @Banck @huri000

@huri000
Copy link
Owner

huri000 commented Jun 16, 2018

After thinking about it, I'm goings to add another construct to EKAttributes that contains the entry life-cycle callbacks. It's going to look something like:

    public struct LifecycleActions {
        
        public typealias Action = () -> Void

        /** Executed before the entry appears - before the animation starts.
         Might not get called in case another entry with a higher display priority is displayed.
         */
        public var willAppear: Action?
        
        /** Executed after the animation ends.
         Might not get called in case another entry with a higher display priority is displayed.
         */
        public var didAppear: Action?

        /** Executed before the entry disappears (Before the animation starts) */
        public var willDisappear: Action?
        
        /** Executed after the entry disappears (After the animation ends) */
        public var didDisappear: Action?
        
        public init(willAppear: Action? = nil, didAppear: Action? = nil, willDisappear: Action? = nil, didDisappear: Action? = nil) {
            self.willAppear = willAppear
            self.didAppear = didAppear
            self.willDisappear = willDisappear
            self.didDisappear = didDisappear
        }
    }

In addition:

  • SwiftEntryKit.dismiss() will have a completion handler
  • EKAttributes.PopBehavior will have a completion handler as well.

Let me know your thoughts.
Thanks!

@pjcau
Copy link
Author

pjcau commented Jun 16, 2018

@huri000 I think that’s OK.

J

@huri000
Copy link
Owner

huri000 commented Jun 16, 2018

Check out 0.4.2

  • Lifecycle section in README.md
  • Dismissing an Entry in README.md.

I'm a little conflicted about an additional event for pop. It seems overdone to me but I'm still considering it. Let me know if you think otherwise.

I consider the issue resolved. 🎉

@huri000 huri000 closed this as completed Jun 16, 2018
@kyrylhorbushko
Copy link

thanks for this! especially if u working with SwiftUI and dealing with something like this -isPresented: Binding<Bool>

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

4 participants