diff --git a/CardPresentationController/CardConfiguration.swift b/CardPresentationController/CardConfiguration.swift index b50f461..b57dd49 100644 --- a/CardPresentationController/CardConfiguration.swift +++ b/CardPresentationController/CardConfiguration.swift @@ -36,6 +36,9 @@ public struct CardConfiguration { /// Set to false to disable interactive dismissal public var allowInteractiveDismissal = true + /// A completion block runs after dismiss the presented view controller + public var dismissCompletion: (() -> Void)? = nil + /// Default initializer, with most suitable values init() {} @@ -55,7 +58,8 @@ extension CardConfiguration { cornerRadius: CGFloat? = nil, backFadeAlpha: CGFloat? = nil, initialTransitionFrame: CGRect? = nil, - allowInteractiveDismissal: Bool? = nil) + allowInteractiveDismissal: Bool? = nil, + dismissCompletion: (() -> Void)? = nil) { if let verticalSpacing = verticalSpacing { self.verticalSpacing = verticalSpacing @@ -88,5 +92,9 @@ extension CardConfiguration { if let allowInteractiveDismissal = allowInteractiveDismissal { self.allowInteractiveDismissal = allowInteractiveDismissal } + + if let dismissCompletion = dismissCompletion { + self.dismissCompletion = dismissCompletion + } } } diff --git a/CardPresentationController/CardPresentationController.swift b/CardPresentationController/CardPresentationController.swift index fdcf029..2a5c851 100644 --- a/CardPresentationController/CardPresentationController.swift +++ b/CardPresentationController/CardPresentationController.swift @@ -200,7 +200,7 @@ public class CardPresentationController: UIPresentationController { cardAnimator.isInteractive = true // and then initiate dismissal - presentedViewController.dismiss(animated: true) + presentedViewController.dismiss(animated: true, completion: configuration.dismissCompletion) case .changed: if !hasStartedPan { return }