Skip to content

Commit 67d2064

Browse files
committed
Updated syntax and Readme.
1 parent d31d4ee commit 67d2064

File tree

11 files changed

+86
-96
lines changed

11 files changed

+86
-96
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,10 @@ labels: bug
66
assignees: ivanvorobei
77
---
88

9-
**Describe the bug**
10-
A clear and concise description of what the bug is.
11-
12-
**To Reproduce**
13-
Steps to reproduce the behavior:
14-
15-
**Expected behavior**
16-
A clear and concise description of what you expected to happen.
17-
18-
**Screenshots**
19-
If applicable, add screenshots to help explain your problem.
20-
21-
**Smartphone (please complete the following information):**
9+
**Summary**
2210
- iOS Version [e.g. 14.5.1]
2311
- Framework Version [e.g. 3.0.8]
2412
- Installed via [e.g. SPM, Cocoapods, Manually]
25-
26-
**Additional context**
27-
Add any other context about the problem here.
13+
14+
**Describe the bug**
15+
A clear and concise description of what the bug is.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,3 @@ A clear and concise description of what the problem is. Ex. I'm always frustrate
1212

1313
**Describe the solution you'd like**
1414
A clear and concise description of what you want to happen.
15-
16-
**Describe alternatives you've considered**
17-
A clear and concise description of any alternative solutions or features you've considered.
18-
19-
**Additional context**
20-
Add any other context or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/question.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Question
33
about: Something is not clear with the project
44
title: ''
5-
labels: ''
5+
labels: 'question'
66
assignees: ivanvorobei
77

88
---

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
## Checklist
55
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
6-
- [ ] Testing in compability platforms
7-
- [ ] Installed correct via Swift Package Manager and Cocoapods
6+
- [] Testing in compability platforms
7+
- [] Installed correct via `Swift Package Manager` and `Cocoapods`

Assets/spalert-app-icon.sketch

-1.79 MB
Binary file not shown.

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ Here you find all which using in project:
2323
- // MARK: - Init
2424
- // MARK: - Lifecycle
2525
- // MARK: - Layout
26-
- // MARK: - Internal
26+
- // MARK: - Public
2727
- // MARK: - Private
28+
- // MARK: - Internal
29+
- // MARK: - Models
30+
- // MARK: - Ovveride
2831

2932
If you can't find valid, add new to codestyle agreements please. Other can be use if class is large and need struct it even without adding to codestyle agreements.

README.md

Lines changed: 44 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,13 @@
11
# SPAlert
22

3-
**Popup from Apple Music & Feedback in AppStore**. Contains `Done`, `Heart`, `Error` and other presets. Supports Dark Mode. I tried to recreate Apple's alerts as much as possible. You can find these alerts in the AppStore after feedback and after you add a song to your library in Apple Music. Support `SwiftUI`.
4-
53
<p float="left">
64
<img src="https://cdn.ivanvorobei.by/github/spalert/done.gif" width="230">
75
<img src="https://cdn.ivanvorobei.by/github/spalert/heart.gif" width="230">
86
<img src="https://cdn.ivanvorobei.by/github/spalert/message.gif" width="230">
97
</p>
108

11-
You can create more with custom images and [SFSymbols](https://developer.apple.com/sf-symbols/) more:
12-
13-
<p float="left">
14-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/bookmark.svg" width="50">
15-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/moon.svg" width="50">
16-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/star.svg" width="50">
17-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/exclamation.svg" width="50">
18-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/bolt.svg" width="50">
19-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/cart.svg" width="50">
20-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/like.svg" width="50">
21-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/dislike.svg" width="50">
22-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/privacy.svg" width="50">
23-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/search.svg" width="50">
24-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/add.svg" width="50">
25-
<img src="https://cdn.ivanvorobei.by/github/spalert/miniatures/error.svg" width="50">
26-
</p>
27-
28-
If you like the project, don't forget to `put star ★`<br>Check out my other libraries:
29-
30-
<p float="left">
31-
<a href="https://opensource.ivanvorobei.by">
32-
<img src="https://github.com/ivanvorobei/Readme/blob/main/Buttons/more-libraries.svg">
33-
</a>
34-
</p>
9+
**Popup from Apple Music & Feedback in AppStore**. Contains `Done`, `Heart`, `Error` and other. Supports Dark Mode. Support `SwiftUI`.
10+
I tried to recreate Apple's alerts as much as possible. You can find these alerts in the AppStore after feedback and after you add a song to your library in Apple Music.
3511

3612
## Navigate
3713

@@ -42,8 +18,8 @@ If you like the project, don't forget to `put star ★`<br>Check out my other li
4218
- [Quick Start](#quick-start)
4319
- [Usage](#usage)
4420
- [Duration](#duration)
21+
- [Dismiss](#dismiss)
4522
- [Layout](#layout)
46-
- [Dismiss by Tap](#dismiss-by-tap)
4723
- [Haptic](#haptic)
4824
- [Spinner](#spinner)
4925
- [Shared Appearance](#shared-appearance)
@@ -52,9 +28,7 @@ If you like the project, don't forget to `put star ★`<br>Check out my other li
5228

5329
## Installation
5430

55-
Ready for use on iOS 11+. Works with Swift 5+. Required Xcode 12.0 and higher.
56-
57-
<img align="right" src="https://cdn.ivanvorobei.by/github/spalert/spm-install-preview.png" width="520"/>
31+
Ready for use on iOS 11+.
5832

5933
### Swift Package Manager
6034

@@ -64,13 +38,13 @@ Once you have your Swift package set up, adding as a dependency is as easy as ad
6438

6539
```swift
6640
dependencies: [
67-
.package(url: "https://github.com/ivanvorobei/SPAlert", .upToNextMajor(from: "3.5.1"))
41+
.package(url: "https://github.com/ivanvorobei/SPAlert", .upToNextMajor(from: "4.0.0"))
6842
]
6943
```
7044

7145
### CocoaPods:
7246

73-
[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your `Podfile`:
47+
[CocoaPods](https://cocoapods.org) is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your `Podfile`:
7448

7549
```ruby
7650
pod 'SPAlert'
@@ -120,6 +94,20 @@ alertView.dismissInTime = false
12094

12195
In this case you shoud dismiss alert manually.
12296

97+
### Dismiss
98+
99+
If you tap the alert, it will disappear. This can be disabled:
100+
101+
```swift
102+
alertView.dismissByTap = false
103+
```
104+
105+
Also you can manually dismiss all alerts, simple call this:
106+
107+
```swift
108+
SPAlert.dismiss()
109+
```
110+
123111
### Layout
124112

125113
For customise layout and margins, use `layout` property. You can manage margins for each side, icon size and space between image and titles:
@@ -130,13 +118,6 @@ alertView.layout.margins.top = 12
130118
alertView.layout.spaceBetweenIconAndTitle = 8
131119
```
132120

133-
### Dismiss by Tap
134-
135-
If you tap the alert, it will disappear. This can be disabled:
136-
137-
```swift
138-
alertView.dismissByTap = false
139-
```
140121
### Haptic
141122

142123
For manage haptic, you shoud pass it in present method:
@@ -156,7 +137,15 @@ let alertView = SPAlertView(title: "Please, wait", preset: .spinner)
156137
alertView.present()
157138
```
158139

159-
By default for this preset `dismissInTime` disabled and need manually dismiss alert.
140+
By default for this preset `dismissInTime` disabled and need manually dismiss alert. You can do it only for one view or dimiss all alerts:
141+
142+
```swift
143+
// For one alert
144+
alertView.dismiss()
145+
146+
// For all alerts
147+
SPAlert.dismiss()
148+
```
160149

161150
### Shared Appearance
162151

@@ -176,40 +165,32 @@ Use like system alert only show message tips:
176165
```swift
177166
Button("Show alert") {
178167
showAlert = true
179-
}.spAlert(isPresent: $showAlert, message: "this is message only")
168+
}.SPAlert(isPresent: $showAlert, message: "this is message only")
180169
```
181170

182171
or show message, title, image and other configuration:
183172

184173
```swift
185174
Button("Show alert") {
186175
showAlert = true
187-
}.spAlert(isPresent: $showAlert,
188-
title: "Alert title",
189-
message: "Alert message",
190-
duration: 2.0,
191-
dismissOnTap: false,
192-
present: .custom(UIImage(systemName: "heart")!),
193-
haptic: .success,
194-
layout: .init(),
195-
completion: {
196-
print("Alert is destory")
197-
})
176+
}.SPAlert(
177+
isPresent: $showAlert,
178+
title: "Alert title",
179+
message: "Alert message",
180+
duration: 2.0,
181+
dismissOnTap: false,
182+
present: .custom(UIImage(systemName: "heart")!),
183+
haptic: .success,
184+
layout: .init(),
185+
completion: {
186+
print("Alert is destory")
187+
})
198188
```
199189

200190
## Russian Community
201191

202-
Подписывайся в телеграм-канал, если хочешь получать уведомления о новых туториалах.<br>
203-
Со сложными и непонятными задачами помогут в чате.
204-
205-
<p float="left">
206-
<a href="https://sparrowcode.by/telegram">
207-
<img src="https://github.com/ivanvorobei/Readme/blob/main/Buttons/open-telegram-channel.svg">
208-
</a>
209-
<a href="https://sparrowcode.by/telegram/chat">
210-
<img src="https://github.com/ivanvorobei/Readme/blob/main/Buttons/russian-community-chat.svg">
211-
</a>
212-
</p>
192+
Я веду [телеграм-канал](https://sparrowcode.by/telegram), там публикую новости и туториалы.<br>
193+
С проблемой помогут [в чате](https://sparrowcode.by/telegram/chat).
213194

214195
Видео-туториалы выклыдываю на [YouTube](https://ivanvorobei.by/youtube):
215196

SPAlert.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPAlert'
4-
s.version = '3.5.1'
5-
s.summary = 'Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.'
4+
s.version = '4.0.0'
5+
s.summary = 'Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets. Support SwiftUI.'
66
s.homepage = 'https://github.com/ivanvorobei/SPAlert'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPAlert.git', :tag => s.version }
88
s.license = { :type => "MIT", :file => "LICENSE" }

Sources/SPAlert/Extensions/SwiftUIExtension.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import SwiftUI
2727
@available(iOSApplicationExtension, unavailable)
2828
extension View {
2929

30-
public func spAlert(
30+
public func SPAlert(
3131
isPresent: Binding<Bool>,
3232
alertView: SPAlertView,
3333
duration: TimeInterval = 2.0,
@@ -45,7 +45,7 @@ extension View {
4545
return self
4646
}
4747

48-
public func spAlert(isPresent: Binding<Bool>,
48+
public func SPAlert(isPresent: Binding<Bool>,
4949
title: String = "",
5050
message: String? = nil,
5151
duration: TimeInterval = 2.0,
@@ -60,10 +60,10 @@ extension View {
6060
alertView.layout = layout ?? SPAlertLayout(for: preset)
6161
alertView.completion = completion
6262

63-
return spAlert(isPresent: isPresent, alertView: alertView, duration: duration, haptic: haptic)
63+
return SPAlert(isPresent: isPresent, alertView: alertView, duration: duration, haptic: haptic)
6464
}
6565

66-
public func spAlert(isPresent: Binding<Bool>,
66+
public func SPAlert(isPresent: Binding<Bool>,
6767
message: String,
6868
duration: TimeInterval = 2.0,
6969
dismissOnTap: Bool = true,
@@ -75,6 +75,6 @@ extension View {
7575
alertView.dismissByTap = dismissOnTap
7676
alertView.completion = completion
7777

78-
return spAlert(isPresent: isPresent, alertView: alertView, duration: duration, haptic: haptic)
78+
return SPAlert(isPresent: isPresent, alertView: alertView, duration: duration, haptic: haptic)
7979
}
8080
}

Sources/SPAlert/SPAlert.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,28 @@ public enum SPAlert {
6666
let alertView = SPAlertView(message: message)
6767
alertView.present(haptic: haptic, completion: completion)
6868
}
69+
70+
/**
71+
SPAlert: Dismiss all `SPAlert` views.
72+
*/
73+
public static func dismiss() {
74+
if #available(iOS 13.0, *) {
75+
for scene in UIApplication.shared.connectedScenes {
76+
if let windowScene = scene as? UIWindowSceneDelegate {
77+
for view in windowScene.window??.subviews ?? [] {
78+
if let alertView = view as? SPAlertView {
79+
alertView.dismiss()
80+
}
81+
}
82+
}
83+
}
84+
} else {
85+
guard let window = UIApplication.shared.keyWindow else { return }
86+
for view in window.subviews {
87+
if let alertView = view as? SPAlertView {
88+
alertView.dismiss()
89+
}
90+
}
91+
}
92+
}
6993
}

0 commit comments

Comments
 (0)