Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
68B695541DFA643F00D3BEA7 /* Frameworks */,
68B695551DFA643F00D3BEA7 /* Resources */,
5A6F3A57A5B4341A0D73BF0E /* [CP] Embed Pods Frameworks */,
4D3CBFE2048DCCC99B4492A9 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -118,20 +117,20 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0810;
LastUpgradeCheck = 0910;
LastUpgradeCheck = 1120;
ORGANIZATIONNAME = ebt;
TargetAttributes = {
68B695561DFA643F00D3BEA7 = {
CreatedOnToolsVersion = 8.1;
DevelopmentTeam = AY957U87NM;
LastSwiftMigration = 0910;
LastSwiftMigration = 1120;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 68B695521DFA643F00D3BEA7 /* Build configuration list for PBXProject "Example" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -161,41 +160,28 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
4D3CBFE2048DCCC99B4492A9 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-resources.sh\"\n";
showEnvVarsInLog = 0;
};
5A6F3A57A5B4341A0D73BF0E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxRelay/RxRelay.framework",
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
"${BUILT_PRODUCTS_DIR}/RxUIAlertController/RxUIAlertController.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxRelay.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxUIAlertController.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
AE49EF36DBB328161162ECEE /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -254,6 +240,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand All @@ -263,13 +250,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -310,6 +299,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand All @@ -319,13 +309,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -367,7 +359,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.morenotepad.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -384,7 +376,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.morenotepad.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
28 changes: 19 additions & 9 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
PODS:
- RxCocoa (4.0.0):
- RxSwift (~> 4.0)
- RxSwift (4.0.0)
- RxUIAlertController (1.1.0):
- RxCocoa (5.0.1):
- RxRelay (~> 5)
- RxSwift (~> 5)
- RxRelay (5.0.1):
- RxSwift (~> 5)
- RxSwift (5.0.1)
- RxUIAlertController (1.2):
- RxCocoa
- RxSwift

DEPENDENCIES:
- RxUIAlertController (from `../`)

SPEC REPOS:
trunk:
- RxCocoa
- RxRelay
- RxSwift

EXTERNAL SOURCES:
RxUIAlertController:
:path: ../
:path: "../"

SPEC CHECKSUMS:
RxCocoa: d62846ca96495d862fa4c59ea7d87e5031d7340e
RxSwift: fd680d75283beb5e2559486f3c0ff852f0d35334
RxUIAlertController: d8f3c7683902ace299d22f59f0c60e77e8478a62
RxCocoa: e741b9749968e8a143e2b787f1dfbff2b63d0a5c
RxRelay: 89d54507f4fd4d969e6ec1d4bd7f3673640b4640
RxSwift: e2dc62b366a3adf6a0be44ba9f405efd4c94e0c4
RxUIAlertController: 52096a2e7ec1a70658fe87b052db268e5820429c

PODFILE CHECKSUM: e001db0045e2931dc0163727851e37d20de11750

COCOAPODS: 1.3.1
COCOAPODS: 1.8.4
6 changes: 3 additions & 3 deletions RxUIAlertController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "RxUIAlertController"
s.version = "1.1.1"
s.version = "1.2"
s.summary = "ReactiveX way to use UIAlertController on iOS."
s.description = <<-EOS
RxSwift binding for [Permission](https://github.com/delba/Permission) API that helps you with UIAlertController in iOS.
Expand All @@ -9,8 +9,8 @@ Pod::Spec.new do |s|
s.license = 'MIT'
s.author = { "roshanman" => "morenotepad@163.com" }
s.source = { :git => "https://github.com/roshanman/RxUIAlertController.git", :tag => s.version.to_s }
s.platform = :ios, '8.0'
s.ios.deployment_target = '8.0'
s.platform = :ios, '10.0'
s.ios.deployment_target = '10.0'
s.source_files = 'Source/*.swift'
s.dependency 'RxSwift'
s.dependency 'RxCocoa'
Expand Down
17 changes: 7 additions & 10 deletions Source/RxAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ import UIKit
import RxSwift
import RxCocoa

@available(iOS 8.0, *)
public func Alert(title: String?, message: String?) -> AlertController {
return AlertController(title: title, message: message, preferredStyle: .alert)
}

@available(iOS 8.0, *)
public func ActionSheet(title: String?, message: String?) -> AlertController {
return AlertController(title: title, message: message, preferredStyle: .actionSheet)
}

@available(iOS 8.0, *)
public class AlertController: NSObject {

public struct Result {
Expand All @@ -40,7 +37,7 @@ public class AlertController: NSObject {
private var retainSelf: Any?
private let disposeBag = DisposeBag()

init(title: String?, message: String?, preferredStyle: UIAlertControllerStyle) {
init(title: String?, message: String?, preferredStyle: UIAlertController.Style) {
alertController = .init(title:title, message:message, preferredStyle:preferredStyle)

super.init()
Expand All @@ -56,12 +53,12 @@ public class AlertController: NSObject {
retainSelf = self
}

public func addAction(title: String, style: UIAlertActionStyle = .default,
public func addAction(title: String, style: UIAlertAction.Style = .default,
configure: ((UIAlertController, UIAlertAction) -> Void)? = nil) -> Self {
let action = UIAlertAction(title: title, style: style) { [unowned self] action in

let result = Result(alert: self.alertController, buttonTitle: title,
buttonIndex: self.alertController.actions.index(of: action) ?? 0)
buttonIndex: self.alertController.actions.firstIndex(of: action) ?? 0)

self.observer?.onNext(result)
self.observer?.onCompleted()
Expand All @@ -73,7 +70,7 @@ public class AlertController: NSObject {
}

@available(iOS 9.0, *)
public func addPreferredAction(title: String, style: UIAlertActionStyle = .default,
public func addPreferredAction(title: String, style: UIAlertAction.Style = .default,
configure: ((UIAlertController, UIAlertAction) -> Void)? = nil) -> Self {
return addAction(title: title, style: style) { alertController, action in
alertController.preferredAction = action
Expand Down Expand Up @@ -134,8 +131,8 @@ public class AlertController: NSObject {
private var topViewController:UIViewController? {
var topController = self.presentedController

while topController?.childViewControllers.last != nil {
topController = topController?.childViewControllers.last!
while topController?.children.last != nil {
topController = topController?.children.last!
}

return topController
Expand Down Expand Up @@ -176,7 +173,7 @@ public class AlertController: NSObject {
}

public extension Reactive where Base: AlertController {
public func show(animated: Bool = true, completion: (() -> Void)? = nil) -> Observable<AlertController.Result> {
func show(animated: Bool = true, completion: (() -> Void)? = nil) -> Observable<AlertController.Result> {
self.base.show(animated: animated, completion: completion)

return Observable.create { observer in
Expand Down