Skip to content

Commit b8f05ee

Browse files
committed
Add .add preset
Update layouts for `.bookmark` perset.
1 parent 946face commit b8f05ee

File tree

9 files changed

+129
-13
lines changed

9 files changed

+129
-13
lines changed

Assets/Readme/Miniature - Add.svg

Lines changed: 13 additions & 0 deletions
Loading

Assets/Sketch/Presets.sketch

1.64 KB
Binary file not shown.

Example/Controllers/ViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class ViewController: UITableViewController {
88
Alert(key: "Heart", preset: .heart, title: "Love", subtitle: "We'll recommend more like this for you"),
99
Alert(key: "Doc", preset: .doc, title: "Document saved", subtitle: "See in folder new file"),
1010
Alert(key: "Bookmark", preset: .bookmark, title: "Added to bookmark", subtitle: "See bookmarks screen"),
11+
Alert(key: "Add", preset: .add, title: "Added to Folder", subtitle: nil),
1112
Alert(key: "Error", preset: .error, title: "Oops", subtitle: "Please try again later"),
1213
Alert(key: "Message", preset: nil, title: nil, subtitle: "Email required")
1314
]

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ For now supporting `Done`, `Heart`, `Doc`, `Error`, `Bookmark` & `Message` prese
7676

7777
<p float="left">
7878
<img src="https://github.com/ivanvorobei/SPAlert/blob/master/Assets/Readme/Miniature%20-%20Done.svg" width="80">
79+
<img src="https://github.com/ivanvorobei/SPAlert/blob/master/Assets/Readme/Miniature%20-%20Add.svg" width="80">
7980
<img src="https://github.com/ivanvorobei/SPAlert/blob/master/Assets/Readme/Miniature%20-%20Heart.svg" width="80">
8081
<img src="https://github.com/ivanvorobei/SPAlert/blob/master/Assets/Readme/Miniature%20-%20Doc.svg" width="80">
8182
<img src="https://github.com/ivanvorobei/SPAlert/blob/master/Assets/Readme/Miniature%20-%20Bookmark.svg" width="80">

SPAlert.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "SPAlert"
4-
s.version = "2.0.4"
4+
s.version = "2.0.5"
55
s.summary = "Native alert from Apple Music & Feedback. Contains Done, Heart & Message presets."
66
s.homepage = "https://github.com/IvanVorobei/SPAlert"
77
s.source = { :git => "https://github.com/IvanVorobei/SPAlert.git", :tag => s.version }

SPAlert.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
F412052B2382AF64009C2AC7 /* SPAlertLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = F41205222382AEFA009C2AC7 /* SPAlertLayout.swift */; };
2626
F4A5A92C2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A5A92B2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift */; };
2727
F4A8361A2385588300EB32E0 /* SPAlertIconDocView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A836192385588300EB32E0 /* SPAlertIconDocView.swift */; };
28+
F4CA67B5238ABD0100E72F79 /* SPAlertIconAddView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4CA67B4238ABD0100E72F79 /* SPAlertIconAddView.swift */; };
2829
/* End PBXBuildFile section */
2930

3031
/* Begin PBXContainerItemProxy section */
@@ -78,6 +79,7 @@
7879
F41205262382AF29009C2AC7 /* SPAlertIconAnimatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconAnimatable.swift; sourceTree = "<group>"; };
7980
F4A5A92B2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconBookmarkView.swift; sourceTree = "<group>"; };
8081
F4A836192385588300EB32E0 /* SPAlertIconDocView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconDocView.swift; sourceTree = "<group>"; };
82+
F4CA67B4238ABD0100E72F79 /* SPAlertIconAddView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconAddView.swift; sourceTree = "<group>"; };
8183
/* End PBXFileReference section */
8284

8385
/* Begin PBXFrameworksBuildPhase section */
@@ -160,6 +162,7 @@
160162
706F89492383277500ECF5D1 /* SPAlertIconErrorView.swift */,
161163
F4A836192385588300EB32E0 /* SPAlertIconDocView.swift */,
162164
F4A5A92B2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift */,
165+
F4CA67B4238ABD0100E72F79 /* SPAlertIconAddView.swift */,
163166
);
164167
path = Icons;
165168
sourceTree = "<group>";
@@ -363,6 +366,7 @@
363366
F41204E92382AC9B009C2AC7 /* SPAlertView.swift in Sources */,
364367
706F894A2383277500ECF5D1 /* SPAlertIconErrorView.swift in Sources */,
365368
F41205292382AF5C009C2AC7 /* SPAlertIconAnimatable.swift in Sources */,
369+
F4CA67B5238ABD0100E72F79 /* SPAlertIconAddView.swift in Sources */,
366370
F41204EB2382AC9B009C2AC7 /* SPAlertIconHeartView.swift in Sources */,
367371
F4A8361A2385588300EB32E0 /* SPAlertIconDocView.swift in Sources */,
368372
F412052B2382AF64009C2AC7 /* SPAlertLayout.swift in Sources */,

Source/SPAlert/Models/SPAlertPreset.swift

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public enum SPAlertPreset {
3030
case heart
3131
case doc
3232
case bookmark
33+
case add
3334
case error
3435

3536
/**
@@ -45,6 +46,8 @@ public enum SPAlertPreset {
4546
return SPAlertIconDocView()
4647
case .bookmark:
4748
return SPAlertIconBookmarkView()
49+
case .add:
50+
return SPAlertIconAddView()
4851
case .error:
4952
return SPAlertIconErrorView()
5053
}
@@ -81,19 +84,27 @@ public enum SPAlertPreset {
8184
return layout
8285
case .bookmark:
8386
var layout = SPAlertLayout()
84-
layout.topSpace = 51
87+
layout.topSpace = 57
8588
layout.bottomSpace = 29
8689
layout.iconWidth = 112
87-
layout.iconHeight = 77
88-
layout.bottomIconSpace = 35
90+
layout.iconHeight = 94
91+
layout.bottomIconSpace = 36
92+
return layout
93+
case .add:
94+
var layout = SPAlertLayout()
95+
layout.topSpace = 63
96+
layout.bottomSpace = 29
97+
layout.iconWidth = 106
98+
layout.iconHeight = 106
99+
layout.bottomIconSpace = 39
89100
return layout
90101
case .error:
91102
var layout = SPAlertLayout()
92103
layout.topSpace = 63
93104
layout.bottomSpace = 29
94-
layout.iconWidth = 112
95-
layout.iconHeight = 112
96-
layout.bottomIconSpace = 35
105+
layout.iconWidth = 100
106+
layout.iconHeight = 100
107+
layout.bottomIconSpace = 37
97108
return layout
98109
}
99110
}
@@ -111,6 +122,8 @@ public enum SPAlertPreset {
111122
return .success
112123
case .bookmark:
113124
return .success
125+
case .add:
126+
return .success
114127
case .error:
115128
return .error
116129
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// The MIT License (MIT)
2+
// Copyright © 2019 Ivan Vorobei (ivanvorobei@icloud.com)
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
import UIKit
23+
24+
public class SPAlertIconAddView: UIView, SPAlertIconAnimatable {
25+
26+
public func animate() {
27+
animateLeftToRightLine()
28+
animateBottomFromTopLine()
29+
}
30+
31+
private func animateLeftToRightLine() {
32+
let length = frame.width
33+
34+
let topToBottomLine = UIBezierPath()
35+
topToBottomLine.move(to: CGPoint(x: length * 0, y: length * 0.5))
36+
topToBottomLine.addLine(to: CGPoint(x: length * 1, y: length * 0.5))
37+
38+
let animatableLayer = CAShapeLayer()
39+
animatableLayer.path = topToBottomLine.cgPath
40+
animatableLayer.fillColor = UIColor.clear.cgColor
41+
animatableLayer.strokeColor = tintColor?.cgColor
42+
animatableLayer.lineWidth = 9
43+
animatableLayer.lineCap = .round
44+
animatableLayer.lineJoin = .round
45+
animatableLayer.strokeEnd = 0
46+
self.layer.addSublayer(animatableLayer)
47+
48+
let animation = CABasicAnimation(keyPath: "strokeEnd")
49+
animation.duration = 0.3
50+
animation.fromValue = 0
51+
animation.toValue = 1
52+
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
53+
54+
animatableLayer.strokeEnd = 1
55+
animatableLayer.add(animation, forKey: "animation")
56+
}
57+
58+
private func animateBottomFromTopLine() {
59+
let length = frame.width
60+
61+
let bottomToTopLine = UIBezierPath()
62+
bottomToTopLine.move(to: CGPoint(x: length * 0.5, y: length * 1))
63+
bottomToTopLine.addLine(to: CGPoint(x: length * 0.5, y: length * 0))
64+
65+
let animatableLayer = CAShapeLayer()
66+
animatableLayer.path = bottomToTopLine.cgPath
67+
animatableLayer.fillColor = UIColor.clear.cgColor
68+
animatableLayer.strokeColor = tintColor?.cgColor
69+
animatableLayer.lineWidth = 9
70+
animatableLayer.lineCap = .round
71+
animatableLayer.lineJoin = .round
72+
animatableLayer.strokeEnd = 0
73+
self.layer.addSublayer(animatableLayer)
74+
75+
let animation = CABasicAnimation(keyPath: "strokeEnd")
76+
animation.duration = 0.3
77+
animation.fromValue = 0
78+
animation.toValue = 1
79+
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
80+
81+
animatableLayer.strokeEnd = 1
82+
animatableLayer.add(animation, forKey: "animation")
83+
}
84+
}

Source/SPAlert/Views/Icons/SPAlertIconErrorView.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public class SPAlertIconErrorView: UIView, SPAlertIconAnimatable {
3232
let length = frame.width
3333

3434
let topToBottomLine = UIBezierPath()
35-
topToBottomLine.move(to: CGPoint(x: length * 0.1, y: length * 0.1))
36-
topToBottomLine.addLine(to: CGPoint(x: length * 0.9, y: length * 0.9))
35+
topToBottomLine.move(to: CGPoint(x: length * 0, y: length * 0))
36+
topToBottomLine.addLine(to: CGPoint(x: length * 1, y: length * 1))
3737

3838
let animatableLayer = CAShapeLayer()
3939
animatableLayer.path = topToBottomLine.cgPath
@@ -46,7 +46,7 @@ public class SPAlertIconErrorView: UIView, SPAlertIconAnimatable {
4646
self.layer.addSublayer(animatableLayer)
4747

4848
let animation = CABasicAnimation(keyPath: "strokeEnd")
49-
animation.duration = 0.3
49+
animation.duration = 0.22
5050
animation.fromValue = 0
5151
animation.toValue = 1
5252
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
@@ -59,8 +59,8 @@ public class SPAlertIconErrorView: UIView, SPAlertIconAnimatable {
5959
let length = frame.width
6060

6161
let bottomToTopLine = UIBezierPath()
62-
bottomToTopLine.move(to: CGPoint(x: length * 0.1, y: length * 0.9))
63-
bottomToTopLine.addLine(to: CGPoint(x: length * 0.9, y: length * 0.1))
62+
bottomToTopLine.move(to: CGPoint(x: length * 0, y: length * 1))
63+
bottomToTopLine.addLine(to: CGPoint(x: length * 1, y: length * 0))
6464

6565
let animatableLayer = CAShapeLayer()
6666
animatableLayer.path = bottomToTopLine.cgPath
@@ -73,7 +73,7 @@ public class SPAlertIconErrorView: UIView, SPAlertIconAnimatable {
7373
self.layer.addSublayer(animatableLayer)
7474

7575
let animation = CABasicAnimation(keyPath: "strokeEnd")
76-
animation.duration = 0.3
76+
animation.duration = 0.22
7777
animation.fromValue = 0
7878
animation.toValue = 1
7979
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)

0 commit comments

Comments
 (0)