Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sgr-ksmt committed Aug 28, 2017
2 parents c45d6aa + 53e1a68 commit 5435ae3
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1
4.0
2 changes: 1 addition & 1 deletion Alertift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Alertift"
s.version = "2.0"
s.version = "3.0"
s.summary = "UIAlertControlelr wrapper for Swift."
s.homepage = "https://github.com/sgr-ksmt/Alertift"
# s.screenshots = ""
Expand Down
4 changes: 2 additions & 2 deletions Alertift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -314,7 +314,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "-.Alertift";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
4 changes: 2 additions & 2 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
OTHER_SWIFT_FLAGS = "-Xfrontend -debug-time-function-bodies";
PRODUCT_BUNDLE_IDENTIFIER = "-.alertift.Demo";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -299,7 +299,7 @@
OTHER_SWIFT_FLAGS = "-Xfrontend -debug-time-function-bodies";
PRODUCT_BUNDLE_IDENTIFIER = "-.alertift.Demo";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
23 changes: 11 additions & 12 deletions Demo/Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class ViewController: UIViewController {
Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awesome UIAlertController wrapper.")
.titleTextColor(.red)
.messageTextColor(.blue)
.action(.default("")) {
print($0)
.action(.default("")) { (action, index, _) in
print(action, index)
}
.action(.default("")) {
print($0)
.action(.default("")) { (action, index, _) in
print(action, index)
}
.finally {
print($0)
.finally { (action, index, _) in
print(action, index)
}
.show(on: self)
}
Expand All @@ -72,12 +72,12 @@ class ViewController: UIViewController {

private func showYesOrNoAlert() {
Alertift.alert(title: "Sample 2",message: "Do you like 🍣?")
.action(.default("Yes"), isPreferred: true) { _ in
.action(.default("Yes"), isPreferred: true) { (_, _, _) in
Alertift.alert(message: "🍣🍣🍣")
.action(.default("Close"))
.show()
}
.action(.cancel("No")) { _ in
.action(.cancel("No")) { (_, _, _) in
Alertift.alert(message: "😂😂😂")
.action(.destructive("Close"))
.show()
Expand All @@ -99,8 +99,7 @@ class ViewController: UIViewController {
print("\(index), \(text)")
}
.action(.cancel("Cancel"))
.action(.default("Sign in")) {
let textFields = $0.2
.action(.default("Sign in")) { (_, _, textFields) in
let id = textFields?.first?.text ?? ""
let password = textFields?.last?.text ?? ""
Alertift.alert(title: "Sign in successfully", message: "ID: \(id)\nPassword: \(password)")
Expand All @@ -111,8 +110,8 @@ class ViewController: UIViewController {
}
private func showActionSheet(anchorView: UIView) {
Alertift.actionSheet(message: "Which food do you like?", anchorView: anchorView)
.actions(["🍣", "🍎", "🍖", "🍅"]) {
print($0)
.actions(["🍣", "🍎", "🍖", "🍅"]) { (action, index) in
print(action, index)
}
.action(.cancel("None of them"))
.finally { action, index in
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awes
```

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

```bash
github "sgr-ksmt/Alertift" ~> 1.3
# Swift4 or later
github "sgr-ksmt/Alertift" ~> 3.0

# Less than Swift4
github "sgr-ksmt/Alertift" ~> 2.0
```

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

```ruby
pod 'Alertift', '~> 1.3'
# Swift4 or later
pod 'Alertift', '~> 3.0'

# Less than Swift4
pod 'Alertift', '~> 2.0'
```

and run `pod install`
Expand Down
12 changes: 2 additions & 10 deletions Sources/ActionSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension Alertift {
/// Add action to alertController
public func action(_ action: Alertift.Action, handler: Handler? = nil) -> Self {
_alertController.addAction(buildAlertAction(action, handler:
merge(_alertController.actionHandler, handler ?? { _ in })
merge(_alertController.actionHandler, handler ?? { (_, _) in })
))
return self
}
Expand Down Expand Up @@ -79,19 +79,11 @@ extension Alertift {
}

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

deinit {
Debug.log()
}
}
}

/// Deprecations
extension Alertift.ActionSheet {
@available(*, unavailable, message: "use new 'action(_:handler)'")
public func action(_ action: Alertift.Action, handler: @escaping () -> Void = {}) -> Self {
fatalError("")
}
}
17 changes: 2 additions & 15 deletions Sources/Alert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension Alertift {
addActionToAlertController(
buildAlertAction(
action,
handler: merge(_alertController.actionWithTextFieldsHandler, handler ?? { _ in })
handler: merge(_alertController.actionWithTextFieldsHandler, handler ?? { (_, _, _)in })
),
isPreferred: isPreferred
)
Expand Down Expand Up @@ -98,24 +98,11 @@ extension Alertift {
}

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

deinit {
Debug.log()
}
}
}

/// Deprecations
extension Alertift.Alert {
@available(*, unavailable, message: "use new 'action(_:isPreferred:handler)'")
public func action(_ action: Alertift.Action, isPreferred: Bool = false, handler: @escaping () -> Void = {}) -> Self {
fatalError("")
}

@available(*, unavailable, message: "use new 'action(_:isPreferred:handler)'")
final public func action(_ action: Alertift.Action, isPreferred: Bool = false, textFieldsHandler handler: @escaping ActionWithTextFieldsHandler) -> Self {
fatalError("")
}
}
10 changes: 1 addition & 9 deletions Sources/AlertType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ extension AlertType {
/// - Parameters:
/// - viewController: The view controller to display over the current view controller’s content. Default is **UIApplication.shared.keyWindow?.rootViewController**
/// - 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.
final public func show(on viewController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController, completion: (() -> Void)? = nil) {
public func show(on viewController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController, completion: (() -> Void)? = nil) {
if _inner._alertController.preferredStyle == .actionSheet && UIScreen.main.traitCollection.userInterfaceIdiom == .pad {
if _inner._alertController.popoverPresentationController?.sourceView == nil {
_inner._alertController.popoverPresentationController?.sourceView = viewController?.view
Expand All @@ -166,11 +166,3 @@ extension AlertType {
})
}
}

/// Deprecations
extension AlertType {
@available(*, unavailable, message: "use new 'buildAlertAction(_:handler:)'")
func buildAlertAction(_ action: Alertift.Action, handler: @escaping () -> Void) -> UIAlertAction {
fatalError("")
}
}

0 comments on commit 5435ae3

Please sign in to comment.