     public var clickedButtonAction: ((_ buttonIndex: Int) -> (Void))? // all buttons
     public var clickedCancelButtonAction: (() -> Void)? // for cancel button
     public var clickedOtherButtonAction: ((_ buttonIndex: Int) -> (Void))? // sometimes you want to handle the other button click event but don't want to write if/else in clickedButtonAction closure, use this property
-    
+
+
     // MARK: Constants
     
     private let kSeparatorWidth: CGFloat = 0.5

        dismissOnOutsideClicked = false
        hideSeparator = false
        cornerRadius = kDefaultCornerRadius
        cancelButtonIndex = 0
        appearTime = 0.2
        disappearTime = 0.1
        appearType = .default
        disappearType = .default
        buttonTitleColor = UIColor(red: 0, green: 0.478431, blue: 1, alpha: 1)

        view.bringSubviewToFront(self)
        
        switch appearType {
        case .default:
            self.transform = CGAffineTransform(scaleX: 1.1, y: 1.1)
            self.alpha = 0.6

            UIView.animate(withDuration: appearTime) {
                self.transform = CGAffineTransform.identity
                self.alpha = 1
            } completion: { _ in
                self.delegate?.didPresentAlertView?(self)
            }
        case .fadeIn:
            self.alpha = 0

            UIView.animate(withDuration: appearTime, delay: 0, options: .curveEaseInOut) {
                self.alpha = 1
            } completion: { _ in
                self.delegate?.didPresentAlertView?(self)
            }
        case .flyFromTop:
            let tempFrame = self.frame
            self.frame = CGRect(x: self.frame.origin.x, y: 0 - self.frame.size.height - 10, width: self.frame.size.width, height: self.frame.size.height)

            UIView.animate(withDuration: appearTime, delay: 0, options: .curveEaseInOut) {
                self.frame = tempFrame
            } completion: { _ in
                self.delegate?.didPresentAlertView?(self)
            }
        case .flyFromLeft:
            let tempFrame = self.frame
            self.frame = CGRect(x: 0 - self.frame.size.width - 10, y: self.frame.origin.y, width: self.frame.size.width, height: self.frame.size.height)

            UIView.animate(withDuration: appearTime, delay: 0, options: .curveEaseInOut) {
                self.frame = tempFrame
            } completion: { _ in
                self.delegate?.didPresentAlertView?(self)
            }
        }
    }
    
    // dismiss the alert view programmatically
    public func dismiss() {
        self.delegate?.willDismissAlertView?(self)

        if dimView != nil {
            UIView.animate(withDuration: disappearTime) {
                self.dimView?.alpha = 0
            } completion: { _ in
                self.dimView?.removeFromSuperview()
                self.dimView = nil
            }
        }

        switch disappearType {
        case .default:
            self.transform = CGAffineTransform.identity

            UIView.animate(withDuration: disappearTime, delay: 0.02, options: .curveEaseOut) {
                self.alpha = 0
            } completion: { _ in
                self.removeFromSuperview()
                self.delegate?.didDismissAlertView?(self)
            }
        case .fadeOut:
            self.alpha = 1

            UIView.animate(withDuration: disappearTime, delay: 0.02, options: .curveEaseOut) {
                self.alpha = 0
            } completion: { _ in
                self.removeFromSuperview()
                self.delegate?.didDismissAlertView?(self)
            }
        case .flyToBottom:
            UIView.animate(withDuration: disappearTime, delay: 0.02, options: .curveEaseOut) {
                self.frame = CGRect(x: self.frame.origin.x, y: self.superview!.frame.size.height + 10, width: self.frame.size.width, height: self.frame.size.height)
            } completion: { _ in
                self.removeFromSuperview()
                self.delegate?.didDismissAlertView?(self)
            }
        case .flyToRight:
            UIView.animate(withDuration: disappearTime, delay: 0.02, options: .curveEaseOut) {
                self.frame = CGRect(x: self.superview!.frame.size.width + 10, y: self.frame.origin.y, width: self.frame.size.width, height: self.frame.size.height)
            } completion: { _ in
                self.removeFromSuperview()
                self.delegate?.didDismissAlertView?(self)
            }
        }
    }
    
    // handle button click events
    public func handleButtonClicked(_ handler: @escaping (_ buttonIndex: Int) -> Void) {
        clickedButtonAction = handler
    }
}


// MARK: Private Functions

extension SwiftAlertView {

    private func setUp(title: String? = nil,
                       message: String? = nil,
