From ce4984780ac0668145ddbe15250d32d328c51a59 Mon Sep 17 00:00:00 2001 From: Marki Date: Tue, 16 Jul 2019 15:05:06 +0200 Subject: [PATCH] Update OnboardViewController.swift Create OnboardingDelegate for dismiss action --- OnboardKit/OnboardViewController.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/OnboardKit/OnboardViewController.swift b/OnboardKit/OnboardViewController.swift index 2dc780f..2e231b0 100644 --- a/OnboardKit/OnboardViewController.swift +++ b/OnboardKit/OnboardViewController.swift @@ -5,10 +5,17 @@ import UIKit +public enum OnboardActionType { + case onboardingComplete +} + +public protocol OnboardingDelegate: class { + func onboardViewController(_ controller: OnboardViewController, didPerform action: OnboardActionType) +} /** */ final public class OnboardViewController: UIViewController { - + public weak var delegate: OnboardingDelegate? private let pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) @@ -137,7 +144,11 @@ extension OnboardViewController: OnboardPageViewControllerDelegate { func pageViewController(_ pageVC: OnboardPageViewController, advanceTappedAt index: Int) { if index == pageItems.count - 1 { - dismiss(animated: true, completion: nil) + if let delegate = self.delegate { + delegate.onboardViewController(self, didPerform: .onboardingComplete) + } else { + dismiss(animated: true, completion: nil) + } } else { advanceToPageWithIndex(index + 1) }