diff --git a/Assets/Readme/Miniature - Bolt.svg b/Assets/Readme/Miniature - Bolt.svg
new file mode 100644
index 0000000..0e46df5
--- /dev/null
+++ b/Assets/Readme/Miniature - Bolt.svg
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/Assets/Sketch/Presets.sketch b/Assets/Sketch/Presets.sketch
index 62c3d95..107a7c5 100644
Binary files a/Assets/Sketch/Presets.sketch and b/Assets/Sketch/Presets.sketch differ
diff --git a/Example/Controllers/ViewController.swift b/Example/Controllers/ViewController.swift
index 019a7ad..b4f3e5d 100644
--- a/Example/Controllers/ViewController.swift
+++ b/Example/Controllers/ViewController.swift
@@ -14,6 +14,7 @@ class ViewController: UITableViewController {
Alert(key: "Exclamation", preset: .exclamation, title: "Oops", subtitle: "Something went wrong"),
Alert(key: "Question", preset: .question, title: "Oops", subtitle: "Form not complete"),
Alert(key: "Message", preset: .message, title: "Message sended", subtitle: "You can check history"),
+ Alert(key: "Bolt", preset: .bolt, title: "Power", subtitle: "Now turned on"),
Alert(key: "Add", preset: .add, title: "Added to Folder", subtitle: nil),
Alert(key: "Error", preset: .error, title: "Oops", subtitle: "Please try again later"),
Alert(key: "Shuffle", preset: .shuffle, title: "Songs Shuffled", subtitle: nil),
diff --git a/Readme.md b/Readme.md
index 72c67c4..8289f4f 100644
--- a/Readme.md
+++ b/Readme.md
@@ -17,8 +17,9 @@ And other
-
+
+
diff --git a/SPAlert.podspec b/SPAlert.podspec
index 5e3409d..3a4d89d 100644
--- a/SPAlert.podspec
+++ b/SPAlert.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "SPAlert"
- s.version = "2.0.14"
+ s.version = "2.0.15"
s.summary = "Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets."
s.homepage = "https://github.com/IvanVorobei/SPAlert"
s.source = { :git => "https://github.com/IvanVorobei/SPAlert.git", :tag => s.version }
diff --git a/SPAlert.xcodeproj/project.pbxproj b/SPAlert.xcodeproj/project.pbxproj
index db94896..214efb4 100644
--- a/SPAlert.xcodeproj/project.pbxproj
+++ b/SPAlert.xcodeproj/project.pbxproj
@@ -26,6 +26,7 @@
F412052B2382AF64009C2AC7 /* SPAlertLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = F41205222382AEFA009C2AC7 /* SPAlertLayout.swift */; };
F421EFF12398684E000A566D /* SPAlertIconFlagView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F421EFF02398684E000A566D /* SPAlertIconFlagView.swift */; };
F46AAEFE2392E97200BE9131 /* SPAlertIconMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F46AAEFD2392E97200BE9131 /* SPAlertIconMessageView.swift */; };
+ F47D2FA6239D718400A346A5 /* SPAlertIconBoltView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47D2FA5239D718400A346A5 /* SPAlertIconBoltView.swift */; };
F47EE19D23959ADB00B02DF2 /* SPAlertIconShuffleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47EE19C23959ADB00B02DF2 /* SPAlertIconShuffleView.swift */; };
F47EE19F23959AE500B02DF2 /* SPAlertIconRepeatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47EE19E23959AE500B02DF2 /* SPAlertIconRepeatView.swift */; };
F4A5A92C2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A5A92B2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift */; };
@@ -88,6 +89,7 @@
F41205262382AF29009C2AC7 /* SPAlertIconAnimatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconAnimatable.swift; sourceTree = ""; };
F421EFF02398684E000A566D /* SPAlertIconFlagView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconFlagView.swift; sourceTree = ""; };
F46AAEFD2392E97200BE9131 /* SPAlertIconMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconMessageView.swift; sourceTree = ""; };
+ F47D2FA5239D718400A346A5 /* SPAlertIconBoltView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconBoltView.swift; sourceTree = ""; };
F47EE19C23959ADB00B02DF2 /* SPAlertIconShuffleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconShuffleView.swift; sourceTree = ""; };
F47EE19E23959AE500B02DF2 /* SPAlertIconRepeatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconRepeatView.swift; sourceTree = ""; };
F4A5A92B2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconBookmarkView.swift; sourceTree = ""; };
@@ -187,6 +189,7 @@
F47EE19E23959AE500B02DF2 /* SPAlertIconRepeatView.swift */,
F421EFF02398684E000A566D /* SPAlertIconFlagView.swift */,
F40FB629239ADF940090BA57 /* SPAlertIconQuestionView.swift */,
+ F47D2FA5239D718400A346A5 /* SPAlertIconBoltView.swift */,
);
path = Icons;
sourceTree = "";
@@ -388,6 +391,7 @@
F4E4459D2390524A0067FF5C /* SPAlertIconExclamationView.swift in Sources */,
F41204EA2382AC9B009C2AC7 /* SPAlertPreset.swift in Sources */,
F4A5A92C2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift in Sources */,
+ F47D2FA6239D718400A346A5 /* SPAlertIconBoltView.swift in Sources */,
F41204EC2382AC9B009C2AC7 /* SPAlertIconDoneView.swift in Sources */,
F41204E92382AC9B009C2AC7 /* SPAlertView.swift in Sources */,
F421EFF12398684E000A566D /* SPAlertIconFlagView.swift in Sources */,
diff --git a/Source/SPAlert/Models/SPAlertPreset.swift b/Source/SPAlert/Models/SPAlertPreset.swift
index 3eeab1d..cd6a404 100644
--- a/Source/SPAlert/Models/SPAlertPreset.swift
+++ b/Source/SPAlert/Models/SPAlertPreset.swift
@@ -36,6 +36,7 @@ public enum SPAlertPreset {
case flag
case message
case question
+ case bolt
case add
case error
case shuffle
@@ -74,6 +75,8 @@ public enum SPAlertPreset {
return SPAlertIconFlagView()
case .question:
return SPAlertIconQuestionView()
+ case .bolt:
+ return SPAlertIconBoltView()
}
}
@@ -146,6 +149,14 @@ public enum SPAlertPreset {
layout.iconHeight = 90
layout.bottomIconSpace = 36
return layout
+ case .bolt:
+ var layout = SPAlertLayout()
+ layout.topSpace = 45
+ layout.bottomSpace = 27
+ layout.iconWidth = 116
+ layout.iconHeight = 116
+ layout.bottomIconSpace = 34
+ return layout
case .moon:
var layout = SPAlertLayout()
layout.topSpace = 49
@@ -230,6 +241,8 @@ public enum SPAlertPreset {
return .success
case .flag:
return .success
+ case .bolt:
+ return .success
}
}
}
diff --git a/Source/SPAlert/Views/Icons/SPAlertIconBoltView.swift b/Source/SPAlert/Views/Icons/SPAlertIconBoltView.swift
new file mode 100644
index 0000000..6aeecf3
--- /dev/null
+++ b/Source/SPAlert/Views/Icons/SPAlertIconBoltView.swift
@@ -0,0 +1,108 @@
+// The MIT License (MIT)
+// Copyright © 2019 Ivan Vorobei (ivanvorobei@icloud.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+import UIKit
+
+public class SPAlertIconBoltView: UIView {
+
+ init() {
+ super.init(frame: .zero)
+ self.backgroundColor = .clear
+ }
+
+ required init?(coder aDecoder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ public override func draw(_ rect: CGRect) {
+ super.draw(rect)
+ BoltDraw.draw(frame: rect, resizing: .aspectFit, fillColor: self.tintColor)
+ }
+
+ class BoltDraw: NSObject {
+
+ @objc dynamic public class func draw(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 60, height: 56), resizing: ResizingBehavior = .aspectFit, fillColor: UIColor = UIColor(red: 0.349, green: 0.345, blue: 0.353, alpha: 1.000)) {
+ let context = UIGraphicsGetCurrentContext()!
+ context.saveGState()
+ let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 47, height: 71), target: targetFrame)
+ context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
+ context.scaleBy(x: resizedFrame.width / 47, y: resizedFrame.height / 71)
+ let bezierPath = UIBezierPath()
+ bezierPath.move(to: CGPoint(x: 4.16, y: 42.19))
+ bezierPath.addCurve(to: CGPoint(x: 2, y: 40.16), controlPoint1: CGPoint(x: 2.9, y: 42.19), controlPoint2: CGPoint(x: 2, y: 41.33))
+ bezierPath.addCurve(to: CGPoint(x: 2.81, y: 38.24), controlPoint1: CGPoint(x: 2, y: 39.5), controlPoint2: CGPoint(x: 2.3, y: 38.9))
+ bezierPath.addLine(to: CGPoint(x: 30, y: 4.25))
+ bezierPath.addCurve(to: CGPoint(x: 34.07, y: 6.44), controlPoint1: CGPoint(x: 32.04, y: 1.71), controlPoint2: CGPoint(x: 35.21, y: 3.35))
+ bezierPath.addLine(to: CGPoint(x: 25.12, y: 30.69))
+ bezierPath.addLine(to: CGPoint(x: 42.07, y: 30.69))
+ bezierPath.addCurve(to: CGPoint(x: 44.2, y: 32.73), controlPoint1: CGPoint(x: 43.33, y: 30.69), controlPoint2: CGPoint(x: 44.2, y: 31.59))
+ bezierPath.addCurve(to: CGPoint(x: 43.42, y: 34.65), controlPoint1: CGPoint(x: 44.2, y: 33.42), controlPoint2: CGPoint(x: 43.93, y: 34.02))
+ bezierPath.addLine(to: CGPoint(x: 16.23, y: 68.67))
+ bezierPath.addCurve(to: CGPoint(x: 12.15, y: 66.45), controlPoint1: CGPoint(x: 14.19, y: 71.18), controlPoint2: CGPoint(x: 10.98, y: 69.54))
+ bezierPath.addLine(to: CGPoint(x: 21.11, y: 42.19))
+ bezierPath.addLine(to: CGPoint(x: 4.16, y: 42.19))
+ bezierPath.close()
+ fillColor.setFill()
+ bezierPath.fill()
+ context.restoreGState()
+ }
+
+ @objc(StyleKitNameResizingBehavior)
+ public enum ResizingBehavior: Int {
+
+ case aspectFit
+ case aspectFill
+ case stretch
+ case center
+
+ public func apply(rect: CGRect, target: CGRect) -> CGRect {
+ if rect == target || target == CGRect.zero {
+ return rect
+ }
+
+ var scales = CGSize.zero
+ scales.width = abs(target.width / rect.width)
+ scales.height = abs(target.height / rect.height)
+
+ switch self {
+ case .aspectFit:
+ scales.width = min(scales.width, scales.height)
+ scales.height = scales.width
+ case .aspectFill:
+ scales.width = max(scales.width, scales.height)
+ scales.height = scales.width
+ case .stretch:
+ break
+ case .center:
+ scales.width = 1
+ scales.height = 1
+ }
+
+ var result = rect.standardized
+ result.size.width *= scales.width
+ result.size.height *= scales.height
+ result.origin.x = target.minX + (target.width - result.width) / 2
+ result.origin.y = target.minY + (target.height - result.height) / 2
+ return result
+ }
+ }
+ }
+}