Skip to content

Commit 54eccaa

Browse files
committed
Update to 1.0.1
Add haptic. Update Readme.
1 parent cbb8a5f commit 54eccaa

File tree

5 files changed

+66
-5
lines changed

5 files changed

+66
-5
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPAlert
2-
Native popup **alert similar to Apple Music or Feedback in AppStore** app. Support animations. I tried to repeat Apple alert as much as possible. You can download example app [Code - Learn Swift & Design](https://itunes.apple.com/app/id1453325619) from AppStore. If you like the project, do not forget to **put star ★**
2+
Native popup **alert similar to Apple Music or Feedback in AppStore** app. Support animations. I tried to repeat Apple alert as much as possible. You can download example app [Debts - Spending tracker](https://itunes.apple.com/app/id1446635818) from AppStore. If you like the project, do not forget to **put star ★**
33

44
### Preview
55

@@ -9,8 +9,6 @@ Native popup **alert similar to Apple Music or Feedback in AppStore** app. Suppo
99
<img src="https://github.com/IvanVorobei/SPAlert/blob/master/Resources/Preview-Message.gif" width="250">
1010
</p>
1111

12-
13-
1412
## Navigate
1513

1614
- [Requirements](#requirements)
@@ -20,6 +18,7 @@ Native popup **alert similar to Apple Music or Feedback in AppStore** app. Suppo
2018
- [Duration](#duration)
2119
- [Layout](#layout)
2220
- [Dismiss by Tap](#dismiss-by-tap)
21+
- [Haptic](#haptic)
2322
- [Corner Radius](#corner-radius)
2423
- [Other Projects (+gif)](#my-projects)
2524
- [SPStorkController](#spstorkcontroller)
@@ -103,6 +102,16 @@ If you click on the alert, it will disappear ahead of time. This can be disabled
103102
alertView.dismissByTap = false
104103
```
105104

105+
### Haptic
106+
107+
If you use presets, the vibro-response will be start automatically. If you want to customize this, you need set property `haptic`:
108+
109+
```swift
110+
alertView.haptic = .success
111+
```
112+
113+
For disable haptic, set it to `.none`.
114+
106115
### Corner Radius
107116

108117
I use a corner radius like an Apple. If you need to change it, see the property `cornerRadius`:

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 = "1.0.0"
4+
s.version = "1.0.1"
55
s.summary = "Native popup alert similar to Apple Music or Feedback in AppStore app."
66
s.homepage = "https://github.com/IvanVorobei/SPAlert"
77
s.source = { :git => "https://github.com/IvanVorobei/SPAlert.git", :tag => s.version }

Source/SPAlert/SPAlertHaptic.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// The MIT License (MIT)
2+
// Copyright © 2019 Ivan Vorobei ([email protected])
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 enum SPAlertHaptic {
25+
26+
case success
27+
case none
28+
29+
func impact() {
30+
switch self {
31+
case .success:
32+
let generator = UINotificationFeedbackGenerator()
33+
generator.notificationOccurred(UINotificationFeedbackGenerator.FeedbackType.success)
34+
default:
35+
break
36+
}
37+
}
38+
}

Source/SPAlert/SPAlertPreset.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public enum SPAlertPreset {
5555
return layout
5656
}
5757
}
58+
59+
var haptic: SPAlertHaptic {
60+
switch self {
61+
case .done:
62+
return .success
63+
case .heart:
64+
return .success
65+
}
66+
}
5867
}
5968

6069
public struct SPAlertLayout {

Source/SPAlert/SPAlertView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ open class SPAlertView: UIView {
2727
public var cornerRadius: CGFloat = 8
2828
public var dismissByTap: Bool = true
2929
public var contentColor: UIColor = #colorLiteral(red: 0.3450980392, green: 0.3411764706, blue: 0.3450980392, alpha: 1)
30+
public var haptic: SPAlertHaptic = .none
3031

3132
public var layout = SPAlertLayout()
3233

@@ -50,6 +51,7 @@ open class SPAlertView: UIView {
5051
super.init(frame: CGRect.zero)
5152
self.iconView = preset.iconView
5253
self.layout = preset.layout
54+
self.haptic = preset.haptic
5355
self.titleLabel = UILabel()
5456
self.titleLabel?.text = title
5557
if let message = message {
@@ -135,11 +137,14 @@ open class SPAlertView: UIView {
135137
//MARK: - Public Methods
136138

137139
func present() {
140+
141+
self.haptic.impact()
142+
138143
self.keyWindow.addSubview(self)
139144
self.layoutIfNeeded()
140-
141145
self.alpha = 0
142146
self.transform = transform.scaledBy(x: 0.8, y: 0.8)
147+
143148
UIView.animate(withDuration: 0.2, animations: {
144149
self.alpha = 1
145150
self.transform = CGAffineTransform.identity

0 commit comments

Comments
 (0)