Skip to content

Commit 5435ae3

Browse files
committed
Merge branch 'develop'
2 parents c45d6aa + 53e1a68 commit 5435ae3

File tree

9 files changed

+33
-55
lines changed

9 files changed

+33
-55
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1
1+
4.0

Alertift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Alertift"
3-
s.version = "2.0"
3+
s.version = "3.0"
44
s.summary = "UIAlertControlelr wrapper for Swift."
55
s.homepage = "https://github.com/sgr-ksmt/Alertift"
66
# s.screenshots = ""

Alertift.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295
PRODUCT_NAME = "$(TARGET_NAME)";
296296
SKIP_INSTALL = YES;
297297
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
298-
SWIFT_VERSION = 3.0;
298+
SWIFT_VERSION = 4.0;
299299
};
300300
name = Debug;
301301
};
@@ -314,7 +314,7 @@
314314
PRODUCT_BUNDLE_IDENTIFIER = "-.Alertift";
315315
PRODUCT_NAME = "$(TARGET_NAME)";
316316
SKIP_INSTALL = YES;
317-
SWIFT_VERSION = 3.0;
317+
SWIFT_VERSION = 4.0;
318318
};
319319
name = Release;
320320
};

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
OTHER_SWIFT_FLAGS = "-Xfrontend -debug-time-function-bodies";
286286
PRODUCT_BUNDLE_IDENTIFIER = "-.alertift.Demo";
287287
PRODUCT_NAME = "$(TARGET_NAME)";
288-
SWIFT_VERSION = 3.0;
288+
SWIFT_VERSION = 4.0;
289289
TARGETED_DEVICE_FAMILY = "1,2";
290290
};
291291
name = Debug;
@@ -299,7 +299,7 @@
299299
OTHER_SWIFT_FLAGS = "-Xfrontend -debug-time-function-bodies";
300300
PRODUCT_BUNDLE_IDENTIFIER = "-.alertift.Demo";
301301
PRODUCT_NAME = "$(TARGET_NAME)";
302-
SWIFT_VERSION = 3.0;
302+
SWIFT_VERSION = 4.0;
303303
TARGETED_DEVICE_FAMILY = "1,2";
304304
};
305305
name = Release;

Demo/Demo/ViewController.swift

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ class ViewController: UIViewController {
5252
Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awesome UIAlertController wrapper.")
5353
.titleTextColor(.red)
5454
.messageTextColor(.blue)
55-
.action(.default("")) {
56-
print($0)
55+
.action(.default("")) { (action, index, _) in
56+
print(action, index)
5757
}
58-
.action(.default("")) {
59-
print($0)
58+
.action(.default("")) { (action, index, _) in
59+
print(action, index)
6060
}
61-
.finally {
62-
print($0)
61+
.finally { (action, index, _) in
62+
print(action, index)
6363
}
6464
.show(on: self)
6565
}
@@ -72,12 +72,12 @@ class ViewController: UIViewController {
7272

7373
private func showYesOrNoAlert() {
7474
Alertift.alert(title: "Sample 2",message: "Do you like 🍣?")
75-
.action(.default("Yes"), isPreferred: true) { _ in
75+
.action(.default("Yes"), isPreferred: true) { (_, _, _) in
7676
Alertift.alert(message: "🍣🍣🍣")
7777
.action(.default("Close"))
7878
.show()
7979
}
80-
.action(.cancel("No")) { _ in
80+
.action(.cancel("No")) { (_, _, _) in
8181
Alertift.alert(message: "😂😂😂")
8282
.action(.destructive("Close"))
8383
.show()
@@ -99,8 +99,7 @@ class ViewController: UIViewController {
9999
print("\(index), \(text)")
100100
}
101101
.action(.cancel("Cancel"))
102-
.action(.default("Sign in")) {
103-
let textFields = $0.2
102+
.action(.default("Sign in")) { (_, _, textFields) in
104103
let id = textFields?.first?.text ?? ""
105104
let password = textFields?.last?.text ?? ""
106105
Alertift.alert(title: "Sign in successfully", message: "ID: \(id)\nPassword: \(password)")
@@ -111,8 +110,8 @@ class ViewController: UIViewController {
111110
}
112111
private func showActionSheet(anchorView: UIView) {
113112
Alertift.actionSheet(message: "Which food do you like?", anchorView: anchorView)
114-
.actions(["🍣", "🍎", "🍖", "🍅"]) {
115-
print($0)
113+
.actions(["🍣", "🍎", "🍖", "🍅"]) { (action, index) in
114+
print(action, index)
116115
}
117116
.action(.cancel("None of them"))
118117
.finally { action, index in

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awes
1010
```
1111

1212
[![GitHub release](https://img.shields.io/github/release/sgr-ksmt/Alertift.svg)](https://github.com/sgr-ksmt/Alertift/releases)
13-
![Language](https://img.shields.io/badge/language-Swift%203-orange.svg)
13+
![Language](https://img.shields.io/badge/language-Swift%204.0-orange.svg)
1414
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
1515
[![CocoaPods](https://img.shields.io/badge/Cocoa%20Pods-✓-4BC51D.svg?style=flat)](https://cocoapods.org/pods/Alertift)
1616
[![CocoaPodsDL](https://img.shields.io/cocoapods/dt/Alertift.svg)](https://cocoapods.org/pods/Alertift)
@@ -101,7 +101,11 @@ Alertift.actionSheet(message: "Which food do you like?")
101101
- Add the following to your *Cartfile*:
102102

103103
```bash
104-
github "sgr-ksmt/Alertift" ~> 1.3
104+
# Swift4 or later
105+
github "sgr-ksmt/Alertift" ~> 3.0
106+
107+
# Less than Swift4
108+
github "sgr-ksmt/Alertift" ~> 2.0
105109
```
106110

107111
- Run `carthage update`
@@ -115,7 +119,11 @@ github "sgr-ksmt/Alertift" ~> 1.3
115119
it, simply add the following line to your Podfile:
116120

117121
```ruby
118-
pod 'Alertift', '~> 1.3'
122+
# Swift4 or later
123+
pod 'Alertift', '~> 3.0'
124+
125+
# Less than Swift4
126+
pod 'Alertift', '~> 2.0'
119127
```
120128

121129
and run `pod install`

Sources/ActionSheet.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension Alertift {
3636
/// Add action to alertController
3737
public func action(_ action: Alertift.Action, handler: Handler? = nil) -> Self {
3838
_alertController.addAction(buildAlertAction(action, handler:
39-
merge(_alertController.actionHandler, handler ?? { _ in })
39+
merge(_alertController.actionHandler, handler ?? { (_, _) in })
4040
))
4141
return self
4242
}
@@ -79,19 +79,11 @@ extension Alertift {
7979
}
8080

8181
func convertFinallyHandler(_ handler: Any) -> InnerAlertController.FinallyHandler {
82-
return { (handler as? Handler)?($0.0, $0.1) }
82+
return { (action, index, _) in (handler as? Handler)?(action, index) }
8383
}
8484

8585
deinit {
8686
Debug.log()
8787
}
8888
}
8989
}
90-
91-
/// Deprecations
92-
extension Alertift.ActionSheet {
93-
@available(*, unavailable, message: "use new 'action(_:handler)'")
94-
public func action(_ action: Alertift.Action, handler: @escaping () -> Void = {}) -> Self {
95-
fatalError("")
96-
}
97-
}

Sources/Alert.swift

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extension Alertift {
5454
addActionToAlertController(
5555
buildAlertAction(
5656
action,
57-
handler: merge(_alertController.actionWithTextFieldsHandler, handler ?? { _ in })
57+
handler: merge(_alertController.actionWithTextFieldsHandler, handler ?? { (_, _, _)in })
5858
),
5959
isPreferred: isPreferred
6060
)
@@ -98,24 +98,11 @@ extension Alertift {
9898
}
9999

100100
func convertFinallyHandler(_ handler: Any) -> InnerAlertController.FinallyHandler {
101-
return { (handler as? Handler)?($0.0, $0.1, $0.2) }
101+
return { (handler as? Handler)?($0, $1, $2) }
102102
}
103103

104104
deinit {
105105
Debug.log()
106106
}
107107
}
108108
}
109-
110-
/// Deprecations
111-
extension Alertift.Alert {
112-
@available(*, unavailable, message: "use new 'action(_:isPreferred:handler)'")
113-
public func action(_ action: Alertift.Action, isPreferred: Bool = false, handler: @escaping () -> Void = {}) -> Self {
114-
fatalError("")
115-
}
116-
117-
@available(*, unavailable, message: "use new 'action(_:isPreferred:handler)'")
118-
final public func action(_ action: Alertift.Action, isPreferred: Bool = false, textFieldsHandler handler: @escaping ActionWithTextFieldsHandler) -> Self {
119-
fatalError("")
120-
}
121-
}

Sources/AlertType.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ extension AlertType {
145145
/// - Parameters:
146146
/// - viewController: The view controller to display over the current view controller’s content. Default is **UIApplication.shared.keyWindow?.rootViewController**
147147
/// - completion: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.
148-
final public func show(on viewController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController, completion: (() -> Void)? = nil) {
148+
public func show(on viewController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController, completion: (() -> Void)? = nil) {
149149
if _inner._alertController.preferredStyle == .actionSheet && UIScreen.main.traitCollection.userInterfaceIdiom == .pad {
150150
if _inner._alertController.popoverPresentationController?.sourceView == nil {
151151
_inner._alertController.popoverPresentationController?.sourceView = viewController?.view
@@ -166,11 +166,3 @@ extension AlertType {
166166
})
167167
}
168168
}
169-
170-
/// Deprecations
171-
extension AlertType {
172-
@available(*, unavailable, message: "use new 'buildAlertAction(_:handler:)'")
173-
func buildAlertAction(_ action: Alertift.Action, handler: @escaping () -> Void) -> UIAlertAction {
174-
fatalError("")
175-
}
176-
}

0 commit comments

Comments
 (0)