Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions SweetAlert.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
9B4CD1001A06E55200B65DE0 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Sahil Wasan";
TargetAttributes = {
9B4CD1071A06E55200B65DE0 = {
Expand All @@ -145,7 +145,7 @@
};
buildConfigurationList = 9B4CD1031A06E55200B65DE0 /* Build configuration list for PBXProject "SweetAlert" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -215,18 +215,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -254,25 +263,35 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
9B4CD1261A06E55300B65DE0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -292,6 +311,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -304,7 +324,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "GNDBL.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -316,7 +336,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "GNDBL.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion SweetAlert/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
68 changes: 34 additions & 34 deletions SweetAlert/SweetAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ open class SweetAlert: UIViewController {
init() {
super.init(nibName: nil, bundle: nil)
self.view.frame = UIScreen.main.bounds
self.view.autoresizingMask = [UIViewAutoresizing.flexibleHeight, UIViewAutoresizing.flexibleWidth]
self.view.autoresizingMask = [UIView.AutoresizingMask.flexibleHeight, UIView.AutoresizingMask.flexibleWidth]
self.view.backgroundColor = UIColor(red:0, green:0, blue:0, alpha:kBakcgroundTansperancy)
self.view.addSubview(contentView)

Expand Down Expand Up @@ -108,7 +108,7 @@ open class SweetAlert: UIViewController {
// Subtitle
if self.subTitleTextView.text.isEmpty == false {
let subtitleString = subTitleTextView.text! as NSString
let rect = subtitleString.boundingRect(with: CGSize(width: width, height: 0.0), options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: [NSFontAttributeName:subTitleTextView.font!], context: nil)
let rect = subtitleString.boundingRect(with: CGSize(width: width, height: 0.0), options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font:subTitleTextView.font!], context: nil)
textViewHeight = ceil(rect.size.height) + 10.0
subTitleTextView.frame = CGRect(x: x, y: y, width: width, height: textViewHeight)
contentView.addSubview(subTitleTextView)
Expand All @@ -117,8 +117,8 @@ open class SweetAlert: UIViewController {

var buttonRect:[CGRect] = []
for button in buttons {
let string = button.title(for: UIControlState())! as NSString
buttonRect.append(string.boundingRect(with: CGSize(width: width, height:0.0), options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes:[NSFontAttributeName:button.titleLabel!.font], context:nil))
let string = button.title(for: UIControl.State())! as NSString
buttonRect.append(string.boundingRect(with: CGSize(width: width, height:0.0), options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes:[NSAttributedString.Key.font:button.titleLabel!.font!], context:nil))
}

var totalWidth: CGFloat = 0.0
Expand All @@ -136,7 +136,7 @@ open class SweetAlert: UIViewController {
buttonX = buttons[i].frame.origin.x + kWidthMargin + buttonRect[i].size.width + 20.0
buttons[i].layer.cornerRadius = 5.0
self.contentView.addSubview(buttons[i])
buttons[i].addTarget(self, action: #selector(SweetAlert.pressed(_:)), for: UIControlEvents.touchUpInside)
buttons[i].addTarget(self, action: #selector(SweetAlert.pressed(_:)), for: UIControl.Event.touchUpInside)

}
y += kHeightMargin + buttonRect[0].size.height + 10.0
Expand All @@ -157,7 +157,7 @@ open class SweetAlert: UIViewController {
contentView.clipsToBounds = true
}

open func pressed(_ sender: UIButton!) {
@objc open func pressed(_ sender: UIButton!) {
self.closeAlert(sender.tag)
}

Expand All @@ -168,7 +168,7 @@ open class SweetAlert: UIViewController {
let ver = sver.floatValue
if ver < 8.0 {
// iOS versions before 7.0 did not switch the width and height on device roration
if UIInterfaceOrientationIsLandscape(UIApplication.shared.statusBarOrientation) {
if UIApplication.shared.statusBarOrientation.isLandscape {
let ssz = sz
sz = CGSize(width:ssz.height, height:ssz.width)
}
Expand All @@ -184,7 +184,7 @@ open class SweetAlert: UIViewController {
SweetAlertContext.shouldNotAnimate = false
}

UIView.animate(withDuration: 0.5, delay: 0.0, options: UIViewAnimationOptions.curveEaseOut, animations: { () -> Void in
UIView.animate(withDuration: 0.5, delay: 0.0, options: UIView.AnimationOptions.curveEaseOut, animations: { () -> Void in
self.view.alpha = 0.0
}) { (Bool) -> Void in
self.view.removeFromSuperview()
Expand Down Expand Up @@ -242,7 +242,7 @@ open class SweetAlert: UIViewController {
userAction = action
let window: UIWindow = UIApplication.shared.keyWindow!
window.addSubview(view)
window.bringSubview(toFront: view)
window.bringSubviewToFront(view)
view.frame = window.bounds
self.setupContentView()
self.setupTitleLabel()
Expand Down Expand Up @@ -272,19 +272,19 @@ open class SweetAlert: UIViewController {
}
buttons = []
if buttonTitle.isEmpty == false {
let button: UIButton = UIButton(type: UIButtonType.custom)
button.setTitle(buttonTitle, for: UIControlState())
let button: UIButton = UIButton(type: UIButton.ButtonType.custom)
button.setTitle(buttonTitle, for: UIControl.State())
button.backgroundColor = buttonColor
button.isUserInteractionEnabled = true
button.tag = 0
buttons.append(button)
}

if otherButtonTitle != nil && otherButtonTitle!.isEmpty == false {
let button: UIButton = UIButton(type: UIButtonType.custom)
button.setTitle(otherButtonTitle, for: UIControlState())
let button: UIButton = UIButton(type: UIButton.ButtonType.custom)
button.setTitle(otherButtonTitle, for: UIControl.State())
button.backgroundColor = otherButtonColor
button.addTarget(self, action: #selector(SweetAlert.pressed(_:)), for: UIControlEvents.touchUpInside)
button.addTarget(self, action: #selector(SweetAlert.pressed(_:)), for: UIControl.Event.touchUpInside)
button.tag = 1
buttons.append(button)
}
Expand Down Expand Up @@ -355,7 +355,7 @@ class CancelAnimatedView: AnimatableView {
setupLayers()
var t = CATransform3DIdentity;
t.m34 = 1.0 / -500.0;
t = CATransform3DRotate(t, CGFloat(90.0 * M_PI / 180.0), 1, 0, 0);
t = CATransform3DRotate(t, CGFloat(90.0 * .pi / 180.0), 1, 0, 0);
circleLayer.transform = t
crossPathLayer.opacity = 0.0
}
Expand All @@ -370,8 +370,8 @@ class CancelAnimatedView: AnimatableView {

fileprivate var outlineCircle: CGPath {
let path = UIBezierPath()
let startAngle: CGFloat = CGFloat((0) / 180.0 * M_PI) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * M_PI) //360
let startAngle: CGFloat = CGFloat((0) / 180.0 * .pi) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * .pi) //360
path.addArc(withCenter: CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.width/2.0), radius: self.frame.size.width/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)

return path.cgPath
Expand All @@ -392,7 +392,7 @@ class CancelAnimatedView: AnimatableView {
circleLayer.path = outlineCircle
circleLayer.fillColor = UIColor.clear.cgColor;
circleLayer.strokeColor = UIColor.colorFromRGB(0xF27474).cgColor;
circleLayer.lineCap = kCALineCapRound
circleLayer.lineCap = CAShapeLayerLineCap.round
circleLayer.lineWidth = 4;
circleLayer.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)
circleLayer.position = CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.height/2.0)
Expand All @@ -401,7 +401,7 @@ class CancelAnimatedView: AnimatableView {
crossPathLayer.path = crossPath
crossPathLayer.fillColor = UIColor.clear.cgColor;
crossPathLayer.strokeColor = UIColor.colorFromRGB(0xF27474).cgColor;
crossPathLayer.lineCap = kCALineCapRound
crossPathLayer.lineCap = CAShapeLayerLineCap.round
crossPathLayer.lineWidth = 4;
crossPathLayer.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)
crossPathLayer.position = CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.height/2.0)
Expand All @@ -412,19 +412,19 @@ class CancelAnimatedView: AnimatableView {
override func animate() {
var t = CATransform3DIdentity;
t.m34 = 1.0 / -500.0;
t = CATransform3DRotate(t, CGFloat(90.0 * M_PI / 180.0), 1, 0, 0);
t = CATransform3DRotate(t, CGFloat(90.0 * .pi / 180.0), 1, 0, 0);

var t2 = CATransform3DIdentity;
t2.m34 = 1.0 / -500.0;
t2 = CATransform3DRotate(t2, CGFloat(-M_PI), 1, 0, 0);
t2 = CATransform3DRotate(t2, CGFloat(-1.0 * .pi), 1, 0, 0);

let animation = CABasicAnimation(keyPath: "transform")
let time = 0.3
animation.duration = time;
animation.fromValue = NSValue(caTransform3D: t)
animation.toValue = NSValue(caTransform3D:t2)
animation.isRemovedOnCompletion = false
animation.fillMode = kCAFillModeForwards
animation.fillMode = CAMediaTimingFillMode.forwards
self.circleLayer.add(animation, forKey: "transform")


Expand All @@ -446,7 +446,7 @@ class CancelAnimatedView: AnimatableView {
fadeInAnimation.fromValue = 0.3
fadeInAnimation.toValue = 1.0
fadeInAnimation.isRemovedOnCompletion = false
fadeInAnimation.fillMode = kCAFillModeForwards
fadeInAnimation.fillMode = CAMediaTimingFillMode.forwards
self.crossPathLayer.add(fadeInAnimation, forKey: "opacity")
}

Expand All @@ -472,8 +472,8 @@ class InfoAnimatedView: AnimatableView {

var outlineCircle: CGPath {
let path = UIBezierPath()
let startAngle: CGFloat = CGFloat((0) / 180.0 * M_PI) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * M_PI) //360
let startAngle: CGFloat = CGFloat((0) / 180.0 * .pi) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * .pi) //360
path.addArc(withCenter: CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.width/2.0), radius: self.frame.size.width/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)

let factor:CGFloat = self.frame.size.width / 1.5
Expand All @@ -489,7 +489,7 @@ class InfoAnimatedView: AnimatableView {
circleLayer.path = outlineCircle
circleLayer.fillColor = UIColor.clear.cgColor;
circleLayer.strokeColor = UIColor.colorFromRGB(0xF8D486).cgColor;
circleLayer.lineCap = kCALineCapRound
circleLayer.lineCap = CAShapeLayerLineCap.round
circleLayer.lineWidth = 4;
circleLayer.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)
circleLayer.position = CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.height/2.0)
Expand All @@ -501,7 +501,7 @@ class InfoAnimatedView: AnimatableView {
let colorAnimation = CABasicAnimation(keyPath:"strokeColor")
colorAnimation.duration = 1.0;
colorAnimation.repeatCount = HUGE
colorAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
colorAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
colorAnimation.autoreverses = true
colorAnimation.fromValue = UIColor.colorFromRGB(0xF7D58B).cgColor
colorAnimation.toValue = UIColor.colorFromRGB(0xF2A665).cgColor
Expand Down Expand Up @@ -533,16 +533,16 @@ class SuccessAnimatedView: AnimatableView {

var outlineCircle: CGPath {
let path = UIBezierPath()
let startAngle: CGFloat = CGFloat((0) / 180.0 * M_PI) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * M_PI) //360
let startAngle: CGFloat = CGFloat((0) / 180.0 * .pi) //0
let endAngle: CGFloat = CGFloat((360) / 180.0 * .pi) //360
path.addArc(withCenter: CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.height/2.0), radius: self.frame.size.width/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)
return path.cgPath
}

var path: CGPath {
let path = UIBezierPath()
let startAngle:CGFloat = CGFloat((60) / 180.0 * M_PI) //60
let endAngle:CGFloat = CGFloat((200) / 180.0 * M_PI) //190
let startAngle:CGFloat = CGFloat((60) / 180.0 * .pi) //60
let endAngle:CGFloat = CGFloat((200) / 180.0 * .pi) //190
path.addArc(withCenter: CGPoint(x: self.frame.size.width/2.0, y: self.frame.size.height/2.0), radius: self.frame.size.width/2.0, startAngle: startAngle, endAngle: endAngle, clockwise: false)
path.addLine(to: CGPoint(x: 36.0 - 10.0 ,y: 60.0 - 10.0))
path.addLine(to: CGPoint(x: 85.0 - 20.0, y: 30.0 - 20.0))
Expand All @@ -557,7 +557,7 @@ class SuccessAnimatedView: AnimatableView {
outlineLayer.path = outlineCircle
outlineLayer.fillColor = UIColor.clear.cgColor;
outlineLayer.strokeColor = UIColor(red: 150.0/255.0, green: 216.0/255.0, blue: 115.0/255.0, alpha: 1.0).cgColor;
outlineLayer.lineCap = kCALineCapRound
outlineLayer.lineCap = CAShapeLayerLineCap.round
outlineLayer.lineWidth = 4;
outlineLayer.opacity = 0.1
self.layer.addSublayer(outlineLayer)
Expand All @@ -567,7 +567,7 @@ class SuccessAnimatedView: AnimatableView {
circleLayer.path = path
circleLayer.fillColor = UIColor.clear.cgColor;
circleLayer.strokeColor = UIColor(red: 150.0/255.0, green: 216.0/255.0, blue: 115.0/255.0, alpha: 1.0).cgColor;
circleLayer.lineCap = kCALineCapRound
circleLayer.lineCap = CAShapeLayerLineCap.round
circleLayer.lineWidth = 4;
circleLayer.actions = [
"strokeStart": NSNull(),
Expand All @@ -591,7 +591,7 @@ class SuccessAnimatedView: AnimatableView {
strokeStart.toValue = 0.68
strokeStart.duration = 7.0*factor
strokeStart.beginTime = CACurrentMediaTime() + 3.0*factor
strokeStart.fillMode = kCAFillModeBackwards
strokeStart.fillMode = CAMediaTimingFillMode.backwards
strokeStart.timingFunction = timing
circleLayer.strokeStart = 0.68
circleLayer.strokeEnd = 0.93
Expand Down
3 changes: 2 additions & 1 deletion SweetAlert/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class ViewController: UIViewController {
}

@IBAction func customIconAlert(_ sender: AnyObject) {
_ = SweetAlert().showAlert("Sweet!", subTitle: "Here's a custom image.", style: AlertStyle.customImag(imageFile: "thumb.jpg"))

_ = SweetAlert().showAlert("Sweet!", subTitle: "Here's a custom image.", style: .customImage(imageFile: "thumb.jpg"))
}

}
Expand Down