From 9797db41b7c12dad34b94d0e5456e6e6e917c3af Mon Sep 17 00:00:00 2001 From: Nikita Lutsenko Date: Mon, 3 Oct 2016 20:15:28 -0700 Subject: [PATCH 1/3] Update Facebook ObjC SDK dependency to 4.16. --- Cartfile | 2 +- Cartfile.resolved | 2 +- Carthage/Checkouts/facebook-ios-sdk | 2 +- FacebookCore.podspec | 2 +- FacebookLogin.podspec | 4 ++-- FacebookShare.podspec | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cartfile b/Cartfile index bd89cb0a..e006cb7b 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "facebook/facebook-ios-sdk" ~> 4.14 +github "facebook/facebook-ios-sdk" ~> 4.16 diff --git a/Cartfile.resolved b/Cartfile.resolved index 19d2a920..65603cf6 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ github "BoltsFramework/Bolts-ObjC" "1.8.4" -github "facebook/facebook-ios-sdk" "sdk-version-4.15.0" +github "facebook/facebook-ios-sdk" "sdk-version-4.16.0" diff --git a/Carthage/Checkouts/facebook-ios-sdk b/Carthage/Checkouts/facebook-ios-sdk index 07dd5904..31797f4d 160000 --- a/Carthage/Checkouts/facebook-ios-sdk +++ b/Carthage/Checkouts/facebook-ios-sdk @@ -1 +1 @@ -Subproject commit 07dd5904e4fd0683143d3d0a61f5a11fb3b52c88 +Subproject commit 31797f4dd1977f44441ce0753e7788857119a765 diff --git a/FacebookCore.podspec b/FacebookCore.podspec index 14f63b2d..798e710e 100644 --- a/FacebookCore.podspec +++ b/FacebookCore.podspec @@ -26,5 +26,5 @@ Pod::Spec.new do |s| s.pod_target_xcconfig = { 'ENABLE_TESTABILITY' => 'YES' } s.ios.dependency 'Bolts', '~> 1.8' - s.ios.dependency 'FBSDKCoreKit', '~> 4.15' + s.ios.dependency 'FBSDKCoreKit', '~> 4.16' end diff --git a/FacebookLogin.podspec b/FacebookLogin.podspec index d4dddbd9..55aee879 100644 --- a/FacebookLogin.podspec +++ b/FacebookLogin.podspec @@ -21,6 +21,6 @@ Pod::Spec.new do |s| s.ios.dependency 'FacebookCore', '~> 0.2' s.ios.dependency 'Bolts', '~> 1.8' - s.ios.dependency 'FBSDKCoreKit', '~> 4.15' - s.ios.dependency 'FBSDKLoginKit', '~> 4.15' + s.ios.dependency 'FBSDKCoreKit', '~> 4.16' + s.ios.dependency 'FBSDKLoginKit', '~> 4.16' end diff --git a/FacebookShare.podspec b/FacebookShare.podspec index fa44f419..3957fd22 100644 --- a/FacebookShare.podspec +++ b/FacebookShare.podspec @@ -26,6 +26,6 @@ Pod::Spec.new do |s| s.ios.dependency 'FacebookCore', '~> 0.2' s.ios.dependency 'Bolts', '~> 1.8' - s.ios.dependency 'FBSDKCoreKit', '~> 4.15' - s.ios.dependency 'FBSDKShareKit', '~> 4.15' + s.ios.dependency 'FBSDKCoreKit', '~> 4.16' + s.ios.dependency 'FBSDKShareKit', '~> 4.16' end From 5894114400f6fbe31009bf3d3826fbe2f3c2078c Mon Sep 17 00:00:00 2001 From: Mohshin Shah Date: Fri, 28 Oct 2016 13:25:40 +0530 Subject: [PATCH 2/3] Added UIAlertController custom options and single call back for each --- Samples/Catalog/Sources/AlertController.swift | 94 +++++++++++++++++-- 1 file changed, 88 insertions(+), 6 deletions(-) diff --git a/Samples/Catalog/Sources/AlertController.swift b/Samples/Catalog/Sources/AlertController.swift index aa294aea..48a8ee26 100644 --- a/Samples/Catalog/Sources/AlertController.swift +++ b/Samples/Catalog/Sources/AlertController.swift @@ -19,12 +19,94 @@ import Foundation import UIKit +extension UIAlertAction { + + /// Action types most commonly used + public enum actionType{ + + ///Ok Option + case ok + + /// Default Cancel Option + case cancel + + /// Destructive action with custom title + case destructive(String) + + /// Custom action with title and style + case custom(String,UIAlertActionStyle) + + /** + Creates the action instance for UIAlertController + - parameter handler: Call Back function + - returns UIAlertAction Instance + */ + public func action(handler:((String) -> Void)? = nil) -> UIAlertAction { + + //Default value + var actionStyle = UIAlertActionStyle.default + var title = "" + + // Action configuration based on the action type + switch self { + + case .cancel: + actionStyle = .cancel + title = "Cancel" + + case .destructive(let optionTitle): + title = optionTitle + actionStyle = .destructive + + case .custom(let optionTitle, let style): + title = optionTitle + actionStyle = style + + default: + title = "Ok" + } + + //Creating UIAlertAction instance + let action = UIAlertAction(title:title,style:actionStyle, handler: {(nativeAction) in + if (handler != nil){ + handler!(title) + } + }) + + return action + } + } +} + extension UIAlertController { - convenience init(title: String, message: String) { - self.init(title: title, message: message, preferredStyle: .alert) - let action = UIAlertAction(title: NSLocalizedString("OK", comment: "OK action"), - style: .default, - handler: nil) - addAction(action) + + /** + Creates the alert view controller using the actions specified + + - parameter title: Title of the alert. + - parameter message: Alert message body. + - parameter actions: Variable numbre of actions as an Array of actionType values. + - parameter style: UIAlertControllerStyle enum value + - parameter handler: Handler block/closure for the clicked option. + + - let alert = UIAlertController.init(title:"Confirm",message:"Do you want to quit sign up and login with other account ?",actions:.custom("Yes,.default),.custom("Cancel",.destructive)){ (buttonTitle) in + if buttonTitle == "Yes"{ + print("Yes Clicked") + } + } + + self.present(alert, animated: true, completion: nil) + + */ + convenience init(title: String, message: String ,actions:UIAlertAction.actionType...,style: UIAlertControllerStyle = .alert,handler:((String) -> Swift.Void)? = nil) { + + //initialize the contoller (self) instance + self.init(title: title, message: message, preferredStyle:style) + + //Fetching actions specidied by the user and adding actions accordingly + for actionType in actions { + addAction(actionType.action(handler: handler)) + } } } + From 28debae88383f515a8146ff21ef5f492c1e8f347 Mon Sep 17 00:00:00 2001 From: Mohshin Shah Date: Fri, 28 Oct 2016 13:33:56 +0530 Subject: [PATCH 3/3] Default option as OK for UIAlertController extension --- Samples/Catalog/Sources/AlertController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Samples/Catalog/Sources/AlertController.swift b/Samples/Catalog/Sources/AlertController.swift index 48a8ee26..d4ab8fca 100644 --- a/Samples/Catalog/Sources/AlertController.swift +++ b/Samples/Catalog/Sources/AlertController.swift @@ -98,7 +98,7 @@ extension UIAlertController { self.present(alert, animated: true, completion: nil) */ - convenience init(title: String, message: String ,actions:UIAlertAction.actionType...,style: UIAlertControllerStyle = .alert,handler:((String) -> Swift.Void)? = nil) { + convenience init(title: String, message: String ,actions:[UIAlertAction.actionType] = [.ok],style: UIAlertControllerStyle = .alert,handler:((String) -> Swift.Void)? = nil) { //initialize the contoller (self) instance self.init(title: title, message: message, preferredStyle:style)