         self.addConstraints(hConstraintsForActivityIndicatorView)
         actionButton.addConstraint(actionButtonWidthConstraint!)
     }
-    
+
     private func invalidDismissTimer() {
         dismissTimer?.invalidate()
         dismissTimer = nil
     }
-    
+
     private func getTopViewController() -> UIViewController? {
         var topController: UIViewController? = UIApplication.sharedApplication().keyWindow?.rootViewController
         while topController?.presentedViewController != nil {

        }
        return topController
    }
    
    private func dismissAnimated(animated: Bool) {
        invalidDismissTimer()
        activityIndicatorView.stopAnimating()
        TTGSnackbar.currentInstance = nil
        
        if animated {
            bottomMarginConstraint?.constant = TTGSnackbar.snackbarHeight
            self.setNeedsLayout()
            UIView.animateWithDuration(TTGSnackbar.snackbarAnimationDuration, animations: { () -> Void in
                self.layoutIfNeeded()
                }, completion: { (Bool finished) -> Void in
                    self.dismissBlock?(snackbar: self)
                    self.removeFromSuperview()
            })
        } else {
            dismissBlock?(snackbar: self)
            self.removeFromSuperview()
        }
    }
    
    // Button action
    func doAction() {
        // Call action block first
        actionBlock?(snackbar: self)
        
        // Show activity indicator
        if duration == TTGSnackbarDuration.TTGSnackbarDurationForever && actionButton.hidden == false{
            actionButton.hidden = true

    case TTGSnackbarDurationMiddle = 3.0
    case TTGSnackbarDurationLong = 5.0
    case TTGSnackbarDurationForever = 9999999999.0 // Must dismiss manually.
}

public enum TTGSnackbarAnimationType {
    case TTGSnackbarAnimationFadeInFadeOut
    case TTGSnackbarAnimationSlideFromBottomToTop
    case TTGSnackbarAnimationSlideFromBottomBackToBottom
    case TTGSnackbarAnimationSlideFromLeftToRight
    case TTGSnackbarAnimationSlideFromRightToLeft
}

public class TTGSnackbar: UIView {
