From a72a35cc9e805dc410e23c0eb7d7a0f71b1bedc2 Mon Sep 17 00:00:00 2001 From: Boisney Philippe Date: Thu, 5 Oct 2017 09:11:06 +0200 Subject: [PATCH 01/23] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 80952e5..bd8efa4 100755 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ func alertOnboardingNext(nextStep: Int) { - [x] Tracking Events ## Version +2.0 ## Author Philippe BOISNEY (phil.boisney(@)gmail.com) From a8bcedb91d8979a1f281333c8846ece155eaeee5 Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Wed, 6 Dec 2017 19:02:25 +0900 Subject: [PATCH 02/23] Fixing multi-line title. --- AlertOnboarding/AlertChildPageViewController.xib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AlertOnboarding/AlertChildPageViewController.xib b/AlertOnboarding/AlertChildPageViewController.xib index a004aca..913ccda 100644 --- a/AlertOnboarding/AlertChildPageViewController.xib +++ b/AlertOnboarding/AlertChildPageViewController.xib @@ -22,7 +22,7 @@ - - - - - + + + + - - + + From b84f6112fa04ec96ba2fdc7561d6d9d0396443b7 Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Thu, 7 Dec 2017 12:48:47 +0900 Subject: [PATCH 06/23] Removing increased padding on top/bottom constraints. Actually, since the horizontal constraints were the only concern, I reverted the two vertical constraints. I think this should be fine now. --- AlertOnboarding/AlertChildPageViewController.xib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AlertOnboarding/AlertChildPageViewController.xib b/AlertOnboarding/AlertChildPageViewController.xib index c57bd1f..bc919eb 100644 --- a/AlertOnboarding/AlertChildPageViewController.xib +++ b/AlertOnboarding/AlertChildPageViewController.xib @@ -39,11 +39,11 @@ - + - + From 29392f2ac780d9ae05645b4ec992c97cfdea4775 Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Thu, 7 Dec 2017 13:59:08 +0900 Subject: [PATCH 07/23] Adding support for configurable "Next" button instead of "Skip" button. Guarding against a crash. --- .DS_Store | Bin 14340 -> 0 bytes .gitignore | 1 + AlertOnboarding/AlertOnboarding.swift | 13 ++++++++++++ AlertOnboarding/AlertPageViewController.swift | 19 ++++++++++++++---- 4 files changed, 29 insertions(+), 4 deletions(-) delete mode 100644 .DS_Store create mode 100644 .gitignore diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 777396d7aef7146e47dfbb3b7fb9baec134055ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14340 zcmeHNZEO@p7=GWtlXdjJB=W+c|n@_;mgT99%DWvZ(HIwZh_^#((umULqPXRh44oyO0lERsM#ARrJB2nYlO z0{sMJs$#;nGO23ms{`AK?Qq-XZ`FI-b+*`9pJSEd>iy_ zFSnj6`FO5mxhwh-1Gzi32iS13LErXr%iRIFJD`7N^c4zvXD7daHykj?ttbTo0)c@D zlu%P1?HzBQACB1_anE_ogUsad=nN+;)3(}ZB>TEf{d;XsT7D12z$UG)L!30f4ZF;? zjB~`?kwgDDhaNOQ^h?P17KvQUHzY%U|9iCuNH%ZW!#J4!8=qjA%4-0JFc zSTLfnXyhnK9$m~nYU${k!tHif*p0YJXJsU@%{wwQJ?ht+B5r%CzR|YL{(2<3+0eUM z)d_XBh&24X0CpIPYPI7IESo&teF`|ZPxVK6& z`?RW)ySo=JtEmbss_Cf;bT3^{T@|RAzo4f_Jtj%za~9XGYl-*ld-|DYpL_m=BPTv# zmrG>uAKoyYANQ9hspg}hIWaRz^Jhc-rff1CuFL3gI-59j1$$G_ozH+y8KcyN>Sop} zt?D>-DeL2|VO!2-J>igTRZASgbal+O{7Y?)*=DlCa$42WSj3Da&4{blnr7IzO{caJ zCzh~Hv&nW07N%v3tM74H-+-3!b zBdd1v=#f8e?Y+kJlR`ZHXuLjd#0fb;J?4-v- zH|&Rl@D#ibZ^Bz}0zQXt;5+yUeuiJ*SGWY15wQRZu?WXuIac5_oP!H+Auh%xxEw=R zj}6#}>u@tRV+(G@ooL`LG_eDdcn98zcj4W5KR$ww;z2xwNAOjA4Ugmd_yL~6(|C?g zsvt$>hSbEl#q(rSymdPLFLuF!LD<>Q*igE97_;--SkB3blP3Elt?R$ZIrlY_VjinF zZ9F=q=;E<9o1;^RxfRot=_z985`Gi0QQzayOC8ncjh<04lkrNG_~ERIITBG{E$|MN zs*1Uc*y;%0>k(Fy)gszaR z=H_ScHC*&~`5XL>Be58#;5Ed?dAJN$U=ZtwjjM1yHsJ;g<0jmJtr)>5YQ#kgcbLlf%)o zX^y6s$iA_szVgQT>`gCwxjorS*=gqF`{XSAUN}(*1Ox&C0fB%(Kp-&O5MclH%cQ_V z5QbLDE-BIk=&MaT=4(=wMtniqP5Q%2-USqrM;rY!@8*nKMZL5CYFw6tJFu0VS#*#<~_CWy4~?7-WOM+a;>UJYwY oCF%>ZI@w-ssYdB4Yy|8VPD20ljVIzieIjCIkkOIS|3m-(3HBBqy#N3J diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/AlertOnboarding/AlertOnboarding.swift b/AlertOnboarding/AlertOnboarding.swift index 7a2ebd1..5201828 100644 --- a/AlertOnboarding/AlertOnboarding.swift +++ b/AlertOnboarding/AlertOnboarding.swift @@ -45,6 +45,9 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { open var percentageRatioHeight: CGFloat = 0.8 open var percentageRatioWidth: CGFloat = 0.8 + @objc open var nextInsteadOfSkip = false + + @objc open var titleNextButton = "NEXT" @objc open var titleSkipButton = "SKIP" @objc open var titleGotItButton = "GOT IT !" @@ -218,6 +221,16 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { //MARK: BUTTON ACTIONS --------------------------------- @objc func onClick(){ + if (nextInsteadOfSkip) { + if let viewController = self.container.viewControllerAtIndex((self.container.pageController.viewControllers?[0] as! AlertChildPageViewController).pageIndex!-1) + { + self.container.pageController.setViewControllers([viewController], direction: UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil) + self.container.didMoveToPageIndex(pageIndex: (viewController as! AlertChildPageViewController).pageIndex) + + return; + } + } + self.hide() } diff --git a/AlertOnboarding/AlertPageViewController.swift b/AlertOnboarding/AlertPageViewController.swift index e665bbf..17fbd9d 100644 --- a/AlertOnboarding/AlertPageViewController.swift +++ b/AlertOnboarding/AlertPageViewController.swift @@ -47,6 +47,10 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, override func viewDidLoad() { super.viewDidLoad() + if (alertview.nextInsteadOfSkip) { + self.alertview.buttonBottom.setTitle(alertview.titleNextButton, for: UIControlState()) + } + self.configurePageViewController() self.configurePageControl() @@ -95,6 +99,9 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, func viewControllerAtIndex(_ index : Int) -> UIViewController? { + if (index<0 || index>=arrayOfImage.count) { + return nil; + } var pageContentViewController: AlertChildPageViewController! let podBundle = Bundle(for: self.classForCoder) @@ -126,9 +133,11 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, } func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) { - let pageContentViewController = pageViewController.viewControllers![0] as! AlertChildPageViewController - let index = pageContentViewController.pageIndex - self.currentStep = (arrayOfImage.count - index! - 1) + didMoveToPageIndex(pageIndex: (pageViewController.viewControllers![0] as! AlertChildPageViewController).pageIndex) + } + + func didMoveToPageIndex(pageIndex: Int) { + self.currentStep = (arrayOfImage.count - pageIndex - 1) self.delegate?.nextStep(self.currentStep) //Check if user watching the last step if currentStep == arrayOfImage.count - 1 { @@ -139,9 +148,11 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, self.maxStep = currentStep } if pageControl != nil { - pageControl.currentPage = arrayOfImage.count - index! - 1 + pageControl.currentPage = arrayOfImage.count - pageIndex - 1 if pageControl.currentPage == arrayOfImage.count - 1 { self.alertview.buttonBottom.setTitle(alertview.titleGotItButton, for: UIControlState()) + } else if (alertview.nextInsteadOfSkip) { + self.alertview.buttonBottom.setTitle(alertview.titleNextButton, for: UIControlState()) } else { self.alertview.buttonBottom.setTitle(alertview.titleSkipButton, for: UIControlState()) } From 45f405390db41aae5c0130c19e291bc38a51d4a4 Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Fri, 8 Dec 2017 16:36:20 +0900 Subject: [PATCH 08/23] Adding support for changing fonts. --- AlertOnboarding/AlertOnboarding.swift | 6 +++++- AlertOnboarding/AlertPageViewController.swift | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/AlertOnboarding/AlertOnboarding.swift b/AlertOnboarding/AlertOnboarding.swift index 5201828..2b050f8 100644 --- a/AlertOnboarding/AlertOnboarding.swift +++ b/AlertOnboarding/AlertOnboarding.swift @@ -36,6 +36,10 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { @objc open var colorTitleLabel: UIColor = UIColor(red: 171/255, green: 177/255, blue: 196/255, alpha: 1.0) @objc open var colorDescriptionLabel: UIColor = UIColor(red: 171/255, green: 177/255, blue: 196/255, alpha: 1.0) + @objc open var fontTitleLabel: UIFont? = UIFont(name: "Avenir-Heavy", size: 17); + @objc open var fontDescriptionLabel: UIFont? = UIFont(name: "Avenir-Book", size: 13); + @objc open var fontButtonText: UIFont? = UIFont(name: "Avenir-Black", size: 15); + @objc open var colorPageIndicator = UIColor(red: 171/255, green: 177/255, blue: 196/255, alpha: 1.0) @objc open var colorCurrentPageIndicator = UIColor(red: 118/255, green: 125/255, blue: 152/255, alpha: 1.0) @@ -137,7 +141,7 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { fileprivate func configure(_ arrayOfImage: [String], arrayOfTitle: [String], arrayOfDescription: [String]) { self.buttonBottom = UIButton(frame: CGRect(x: 0,y: 0, width: 0, height: 0)) - self.buttonBottom.titleLabel?.font = UIFont(name: "Avenir-Black", size: 15) + self.buttonBottom.titleLabel?.font = fontButtonText self.buttonBottom.addTarget(self, action: #selector(AlertOnboarding.onClick), for: .touchUpInside) self.background = UIView(frame: CGRect(x: 0,y: 0, width: 0, height: 0)) diff --git a/AlertOnboarding/AlertPageViewController.swift b/AlertOnboarding/AlertPageViewController.swift index 17fbd9d..414a700 100644 --- a/AlertOnboarding/AlertPageViewController.swift +++ b/AlertOnboarding/AlertPageViewController.swift @@ -124,8 +124,10 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, pageContentViewController.image.image = UIImage(named: arrayOfImage[realIndex]) pageContentViewController.image.layer.minificationFilter=kCAFilterTrilinear + pageContentViewController.labelMainTitle.font = alertview.fontTitleLabel pageContentViewController.labelMainTitle.text = arrayOfTitle[realIndex] pageContentViewController.labelMainTitle.textColor = alertview.colorTitleLabel + pageContentViewController.labelDescription.font = alertview.fontDescriptionLabel pageContentViewController.labelDescription.text = arrayOfDescription[realIndex] pageContentViewController.labelDescription.textColor = alertview.colorDescriptionLabel From a3a01405bc809f381fb1e3935c5a26912d11d15e Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Fri, 8 Dec 2017 16:40:44 +0900 Subject: [PATCH 09/23] Removing problematic line count limitation. --- AlertOnboarding/AlertChildPageViewController.xib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AlertOnboarding/AlertChildPageViewController.xib b/AlertOnboarding/AlertChildPageViewController.xib index bc919eb..c7ff824 100644 --- a/AlertOnboarding/AlertChildPageViewController.xib +++ b/AlertOnboarding/AlertChildPageViewController.xib @@ -28,7 +28,7 @@ - @@ -95,6 +95,8 @@ + + diff --git a/Pod/Classes/AlertChildPageViewController.swift b/Pod/Classes/AlertChildPageViewController.swift index 97f8fa4..d13c93d 100644 --- a/Pod/Classes/AlertChildPageViewController.swift +++ b/Pod/Classes/AlertChildPageViewController.swift @@ -15,6 +15,9 @@ import UIKit @objc @IBOutlet public private(set) weak var image: UIImageView! @objc @IBOutlet public private(set) weak var labelMainTitle: UILabel! @objc @IBOutlet public private(set) weak var labelDescription: UITextView! + // Default to 80% (0.8) of container view. Adjust multiplier to desired value + @objc @IBOutlet weak var imageAspectRatio: NSLayoutConstraint! + @objc @IBOutlet weak var imageContainerView: UIView! override public func viewDidLoad() { super.viewDidLoad() @@ -23,4 +26,25 @@ import UIKit override public func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } + + func setImageAspectRatio(_ ratio: CGFloat) { + let newConstraint = imageAspectRatio.constraintWithMultiplier(ratio) + imageContainerView.removeConstraint(imageAspectRatio) + imageContainerView.addConstraint(newConstraint) + imageContainerView.layoutIfNeeded() + } +} + +extension NSLayoutConstraint { + + func constraintWithMultiplier(_ multiplier: CGFloat) -> NSLayoutConstraint { + return NSLayoutConstraint(item: firstItem!, + attribute: firstAttribute, + relatedBy: relation, + toItem: secondItem, + attribute: secondAttribute, + multiplier: multiplier, + constant: constant) + } + } diff --git a/Pod/Classes/AlertOnboarding.swift b/Pod/Classes/AlertOnboarding.swift index f8eb83a..c672361 100644 --- a/Pod/Classes/AlertOnboarding.swift +++ b/Pod/Classes/AlertOnboarding.swift @@ -26,7 +26,6 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { fileprivate var container: AlertPageViewController! open var background: UIView! - //PUBLIC VARS ------------------------ @objc open var colorForAlertViewBackground: UIColor = UIColor.white @@ -44,6 +43,8 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { @objc open var colorCurrentPageIndicator = UIColor(red: 118/255, green: 125/255, blue: 152/255, alpha: 1.0) @objc open var imageContentMode: UIView.ContentMode = .scaleToFill + /// Defines proportion between imageView and its containerView. Default is 80% (0.8) + open var imageAspectRatio: CGFloat? open var heightForAlertView: CGFloat! open var widthForAlertView: CGFloat! diff --git a/Pod/Classes/AlertPageViewController.swift b/Pod/Classes/AlertPageViewController.swift index 8471ce9..e6973a4 100644 --- a/Pod/Classes/AlertPageViewController.swift +++ b/Pod/Classes/AlertPageViewController.swift @@ -119,6 +119,9 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, pageContentViewController.image.image = arrayOfAlerts[realIndex].image pageContentViewController.image.contentMode = alertview.imageContentMode + if let imageAspectRatio = alertview.imageAspectRatio { + pageContentViewController.setImageAspectRatio(imageAspectRatio) + } pageContentViewController.image.layer.minificationFilter = CALayerContentsFilter.trilinear pageContentViewController.labelMainTitle.font = alertview.fontTitleLabel pageContentViewController.labelMainTitle.text = arrayOfAlerts[realIndex].title From ef6451896de63fa723fd848b827c380eb257fdac Mon Sep 17 00:00:00 2001 From: gabmarfer Date: Mon, 3 Jun 2019 15:17:35 +0200 Subject: [PATCH 23/23] Make public alert properties --- Pod/Classes/Alert.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Pod/Classes/Alert.swift b/Pod/Classes/Alert.swift index d40e2a0..670ce35 100644 --- a/Pod/Classes/Alert.swift +++ b/Pod/Classes/Alert.swift @@ -9,9 +9,9 @@ import UIKit @objc public class Alert: NSObject { - var image: UIImage - var title: String - var text: String + public var image: UIImage + public var title: String + public var text: String @objc public init(image: UIImage, title: String, text: String) { self.image = image