@@ -11,7 +11,7 @@ import UIKit
1111
1212@objc ( CFAlertViewController)
1313public class CFAlertViewController : UIViewController {
14-
14+
1515 // MARK: - Declarations
1616 public typealias CFAlertViewControllerDismissBlock = ( _ isBackgroundTapped: Bool ) -> ( )
1717
@@ -78,7 +78,7 @@ public class CFAlertViewController: UIViewController {
7878 internal var messageString : String ?
7979 internal var actionList = [ CFAlertAction] ( )
8080 internal var dismissHandler : CFAlertViewControllerDismissBlock ?
81- private var keyboardHeight : CGFloat = 0.0 {
81+ internal var keyboardHeight : CGFloat = 0.0 {
8282
8383 didSet {
8484
@@ -90,57 +90,59 @@ public class CFAlertViewController: UIViewController {
9090 }
9191 }
9292 }
93- private var tapGesture : UITapGestureRecognizer !
93+ internal var tapGesture : UITapGestureRecognizer !
9494
95- @IBOutlet private weak var mainViewBottomConstraint : NSLayoutConstraint ?
96- @IBOutlet private weak var tableView : UITableView ?
97- @IBOutlet private weak var containerViewCenterYConstraint : NSLayoutConstraint ?
98- @IBOutlet private weak var containerViewBottomConstraint : NSLayoutConstraint ?
99- @IBOutlet private weak var tableViewHeightConstraint : NSLayoutConstraint ?
95+ @IBOutlet internal weak var mainViewBottomConstraint : NSLayoutConstraint ?
96+ @IBOutlet internal weak var tableView : UITableView ?
97+ @IBOutlet internal weak var containerViewCenterYConstraint : NSLayoutConstraint ?
98+ @IBOutlet internal weak var containerViewBottomConstraint : NSLayoutConstraint ?
99+ @IBOutlet internal weak var tableViewHeightConstraint : NSLayoutConstraint ?
100100
101101
102102 // MARK: - Initialisation Method
103- convenience public init ( title: String ? ,
104- message: String ? ,
105- textAlignment: NSTextAlignment ,
106- preferredStyle: CFAlertControllerStyle ,
107- didDismissAlertHandler dismiss: CFAlertViewControllerDismissBlock ? ) {
103+ public class func alert ( title: String ? ,
104+ message: String ? ,
105+ textAlignment: NSTextAlignment ,
106+ preferredStyle: CFAlertControllerStyle ,
107+ didDismissAlertHandler dismiss: CFAlertViewControllerDismissBlock ? ) -> CFAlertViewController {
108108
109- self . init ( title: title,
110- message: message,
111- textAlignment: textAlignment,
112- preferredStyle: preferredStyle,
113- headerView: nil ,
114- footerView: nil ,
115- didDismissAlertHandler: dismiss)
116- }
117-
118- convenience public init ( title: String ? ,
119- message: String ? ,
120- textAlignment: NSTextAlignment ,
121- preferredStyle: CFAlertControllerStyle ,
122- headerView: UIView ? ,
123- footerView: UIView ? ,
124- didDismissAlertHandler dismiss: CFAlertViewControllerDismissBlock ? ) {
109+ return CFAlertViewController . alert ( title: title,
110+ message: message,
111+ textAlignment: textAlignment,
112+ preferredStyle: preferredStyle,
113+ headerView: nil ,
114+ footerView: nil ,
115+ didDismissAlertHandler: dismiss)
116+ }
117+
118+ public class func alert ( title: String ? ,
119+ message: String ? ,
120+ textAlignment: NSTextAlignment ,
121+ preferredStyle: CFAlertControllerStyle ,
122+ headerView: UIView ? ,
123+ footerView: UIView ? ,
124+ didDismissAlertHandler dismiss: CFAlertViewControllerDismissBlock ? ) -> CFAlertViewController {
125125
126126 // Get Current Bundle
127127 let bundle = Bundle ( for: CFAlertViewController . self)
128128
129129 // Create New Instance Of Alert Controller
130- self . init ( nibName: " CFAlertViewController " , bundle: bundle)
130+ let alert = CFAlertViewController . init ( nibName: " CFAlertViewController " , bundle: bundle)
131131
132132 // Assign Properties
133- self . titleString = title
134- self . messageString = message
135- self . textAlignment = textAlignment
136- self . preferredStyle = preferredStyle
137- self . setHeaderView ( headerView, shouldUpdateContainerFrame: false , withAnimation: false )
138- self . setFooterView ( footerView, shouldUpdateContainerFrame: false , withAnimation: false )
139- self . dismissHandler = dismiss
133+ alert . titleString = title
134+ alert . messageString = message
135+ alert . textAlignment = textAlignment
136+ alert . preferredStyle = preferredStyle
137+ alert . setHeaderView ( headerView, shouldUpdateContainerFrame: false , withAnimation: false )
138+ alert . setFooterView ( footerView, shouldUpdateContainerFrame: false , withAnimation: false )
139+ alert . dismissHandler = dismiss
140140
141141 // Custom Presentation
142- modalPresentationStyle = . custom
143- transitioningDelegate = self
142+ alert. modalPresentationStyle = . custom
143+ alert. transitioningDelegate = alert
144+
145+ return alert
144146 }
145147
146148
@@ -172,7 +174,7 @@ public class CFAlertViewController: UIViewController {
172174 view. addGestureRecognizer ( self . tapGesture)
173175 }
174176
175- override public func viewDidLoad( ) {
177+ public override func viewDidLoad( ) {
176178 super. viewDidLoad ( )
177179
178180 // Load Variables
@@ -182,7 +184,7 @@ public class CFAlertViewController: UIViewController {
182184 loadDisplayContent ( )
183185 }
184186
185- override public func viewWillAppear( _ animated: Bool ) {
187+ public override func viewWillAppear( _ animated: Bool ) {
186188 super. viewWillAppear ( animated)
187189
188190 // Update UI
@@ -216,7 +218,7 @@ public class CFAlertViewController: UIViewController {
216218 dismissAlert ( withAnimation: animate, isBackgroundTapped: false , completion: completion)
217219 }
218220
219- private func dismissAlert( withAnimation animate: Bool , isBackgroundTapped: Bool , completion: ( ( _: Void ) -> Void ) ? ) {
221+ internal func dismissAlert( withAnimation animate: Bool , isBackgroundTapped: Bool , completion: ( ( _: Void ) -> Void ) ? ) {
220222
221223 // Dismiss Self
222224 self . dismiss ( animated: animate, completion: { ( ) -> Void in
@@ -305,7 +307,7 @@ public class CFAlertViewController: UIViewController {
305307
306308
307309 // MARK: - Handle Tap Events
308- @objc private func viewDidTap( _ gestureRecognizer: UITapGestureRecognizer ) {
310+ @objc internal func viewDidTap( _ gestureRecognizer: UITapGestureRecognizer ) {
309311
310312 // Get Tap Location
311313 let tapLocation : CGPoint = gestureRecognizer. location ( in: self . view)
@@ -332,7 +334,7 @@ public class CFAlertViewController: UIViewController {
332334
333335
334336 // MARK: - UIKeyboardWillShowNotification
335- @objc private func keyboardWillShow( _ notification: Notification ) {
337+ @objc internal func keyboardWillShow( _ notification: Notification ) {
336338
337339 let info : [ AnyHashable : Any ] ? = notification. userInfo
338340 if let info = info {
@@ -353,7 +355,7 @@ public class CFAlertViewController: UIViewController {
353355 }
354356
355357 // MARK: UIKeyboardWillHideNotification
356- @objc private func keyboardWillHide( _ notification: Notification ) {
358+ @objc internal func keyboardWillHide( _ notification: Notification ) {
357359
358360 UIView . animate ( withDuration: 0.4 , delay: 0.0 , usingSpringWithDamping: 1.0 , initialSpringVelocity: 0.0 , options: [ . beginFromCurrentState, . curveEaseOut, . allowUserInteraction] , animations: { ( ) -> Void in
359361 // Update Keyboard Height
@@ -363,7 +365,7 @@ public class CFAlertViewController: UIViewController {
363365 }
364366
365367 // MARK: UITextViewTextDidBeginEditingNotification | UITextFieldTextDidBeginEditingNotification
366- @objc private func textViewOrTextFieldDidBeginEditing( _ notification: Notification ) {
368+ @objc internal func textViewOrTextFieldDidBeginEditing( _ notification: Notification ) {
367369
368370 if let notificationObject = notification. object, ( notificationObject is UITextField || notificationObject is UITextView ) {
369371
@@ -385,7 +387,7 @@ public class CFAlertViewController: UIViewController {
385387
386388
387389 // MARK: - View Rotation / Size Change Method
388- override public func viewWillTransition( to size: CGSize , with coordinator: UIViewControllerTransitionCoordinator ) {
390+ public override func viewWillTransition( to size: CGSize , with coordinator: UIViewControllerTransitionCoordinator ) {
389391 super. viewWillTransition ( to: size, with: coordinator)
390392 // Code here will execute before the rotation begins.
391393 // Equivalent to placing it in the deprecated method -[willRotateToInterfaceOrientation:duration:]
@@ -402,7 +404,7 @@ public class CFAlertViewController: UIViewController {
402404
403405
404406 // MARK: - Key Value Observers
405- override public func observeValue( forKeyPath keyPath: String ? , of object: Any ? , change: [ NSKeyValueChangeKey : Any ] ? , context: UnsafeMutableRawPointer ? ) {
407+ public override func observeValue( forKeyPath keyPath: String ? , of object: Any ? , change: [ NSKeyValueChangeKey : Any ] ? , context: UnsafeMutableRawPointer ? ) {
406408 if ( keyPath == " contentSize " ) {
407409 // Update Container View Frame Without Animation
408410 updateContainerViewFrame ( withAnimation: false )
0 commit comments