diff --git a/App.xcodeproj/project.pbxproj b/App.xcodeproj/project.pbxproj index f1afbd1..09bcb24 100644 --- a/App.xcodeproj/project.pbxproj +++ b/App.xcodeproj/project.pbxproj @@ -55,6 +55,16 @@ A79825201B18A6FC00F8E795 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A798251F1B18A6FC00F8E795 /* Images.xcassets */; }; A79825231B18A6FC00F8E795 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = A79825211B18A6FC00F8E795 /* LaunchScreen.xib */; }; A798252F1B18A6FC00F8E795 /* AppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A798252E1B18A6FC00F8E795 /* AppTests.swift */; }; + CC30F6FE1DA2924D000146B4 /* FacebookInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC30F6FD1DA2924D000146B4 /* FacebookInfoVC.swift */; }; + CC30F7001DA297E4000146B4 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CC30F6FF1DA297E4000146B4 /* Default-568h@2x.png */; }; + CC30F70B1DA2ABAA000146B4 /* socialNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC30F70A1DA2ABAA000146B4 /* socialNetwork.framework */; }; + CC34EA301DA2853900255715 /* FacebookConnectVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC34EA2F1DA2853900255715 /* FacebookConnectVC.swift */; }; + CC6645911DA2B45D008360E7 /* FacebookCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC66458B1DA2B45D008360E7 /* FacebookCore.framework */; }; + CC6645921DA2B45D008360E7 /* FacebookLogin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC66458C1DA2B45D008360E7 /* FacebookLogin.framework */; }; + CC6645931DA2B45D008360E7 /* FacebookShare.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC66458D1DA2B45D008360E7 /* FacebookShare.framework */; }; + CC6645941DA2B45D008360E7 /* FBSDKCoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC66458E1DA2B45D008360E7 /* FBSDKCoreKit.framework */; }; + CC6645951DA2B45D008360E7 /* FBSDKLoginKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC66458F1DA2B45D008360E7 /* FBSDKLoginKit.framework */; }; + CC6645961DA2B45D008360E7 /* FBSDKShareKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC6645901DA2B45D008360E7 /* FBSDKShareKit.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -113,6 +123,16 @@ A79825281B18A6FC00F8E795 /* AppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; A798252D1B18A6FC00F8E795 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A798252E1B18A6FC00F8E795 /* AppTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTests.swift; sourceTree = ""; }; + CC30F6FD1DA2924D000146B4 /* FacebookInfoVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FacebookInfoVC.swift; path = App/FacebookInfoVC.swift; sourceTree = ""; }; + CC30F6FF1DA297E4000146B4 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + CC30F70A1DA2ABAA000146B4 /* socialNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = socialNetwork.framework; path = Carthage/Build/iOS/socialNetwork.framework; sourceTree = ""; }; + CC34EA2F1DA2853900255715 /* FacebookConnectVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FacebookConnectVC.swift; path = App/FacebookConnectVC.swift; sourceTree = ""; }; + CC66458B1DA2B45D008360E7 /* FacebookCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookCore.framework; path = Carthage/Build/iOS/FacebookCore.framework; sourceTree = ""; }; + CC66458C1DA2B45D008360E7 /* FacebookLogin.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookLogin.framework; path = Carthage/Build/iOS/FacebookLogin.framework; sourceTree = ""; }; + CC66458D1DA2B45D008360E7 /* FacebookShare.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FacebookShare.framework; path = Carthage/Build/iOS/FacebookShare.framework; sourceTree = ""; }; + CC66458E1DA2B45D008360E7 /* FBSDKCoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKCoreKit.framework; path = Carthage/Build/iOS/FBSDKCoreKit.framework; sourceTree = ""; }; + CC66458F1DA2B45D008360E7 /* FBSDKLoginKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKLoginKit.framework; path = Carthage/Build/iOS/FBSDKLoginKit.framework; sourceTree = ""; }; + CC6645901DA2B45D008360E7 /* FBSDKShareKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKShareKit.framework; path = Carthage/Build/iOS/FBSDKShareKit.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -120,6 +140,13 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + CC6645911DA2B45D008360E7 /* FacebookCore.framework in Frameworks */, + CC6645921DA2B45D008360E7 /* FacebookLogin.framework in Frameworks */, + CC6645931DA2B45D008360E7 /* FacebookShare.framework in Frameworks */, + CC6645941DA2B45D008360E7 /* FBSDKCoreKit.framework in Frameworks */, + CC6645951DA2B45D008360E7 /* FBSDKLoginKit.framework in Frameworks */, + CC6645961DA2B45D008360E7 /* FBSDKShareKit.framework in Frameworks */, + CC30F70B1DA2ABAA000146B4 /* socialNetwork.framework in Frameworks */, 172F50451C68E6D0000A9D78 /* AlamofireObjectMapper.framework in Frameworks */, 172F50461C68E6D0000A9D78 /* ObjectMapper.framework in Frameworks */, 177691BC1C10C13E00A3D08A /* Alamofire.framework in Frameworks */, @@ -191,6 +218,7 @@ A798250A1B18A6FC00F8E795 = { isa = PBXGroup; children = ( + CC30F6FF1DA297E4000146B4 /* Default-568h@2x.png */, A79825381B18A70C00F8E795 /* Core */, A79825151B18A6FC00F8E795 /* App */, A798252B1B18A6FC00F8E795 /* AppTests */, @@ -258,6 +286,13 @@ A79825391B18A71000F8E795 /* Frameworks */ = { isa = PBXGroup; children = ( + CC66458B1DA2B45D008360E7 /* FacebookCore.framework */, + CC66458C1DA2B45D008360E7 /* FacebookLogin.framework */, + CC66458D1DA2B45D008360E7 /* FacebookShare.framework */, + CC66458E1DA2B45D008360E7 /* FBSDKCoreKit.framework */, + CC66458F1DA2B45D008360E7 /* FBSDKLoginKit.framework */, + CC6645901DA2B45D008360E7 /* FBSDKShareKit.framework */, + CC30F70A1DA2ABAA000146B4 /* socialNetwork.framework */, 17965D541C561B0C0013D390 /* Internal */, 17965D531C561B030013D390 /* External */, ); @@ -269,6 +304,8 @@ children = ( 17EE77441C6C7C65009638A6 /* MailgunVC.swift */, 172F06811C6B2C3600B711B2 /* WeatherVC.swift */, + CC34EA2F1DA2853900255715 /* FacebookConnectVC.swift */, + CC30F6FD1DA2924D000146B4 /* FacebookInfoVC.swift */, ); name = Controllers; sourceTree = ""; @@ -425,6 +462,7 @@ buildActionMask = 2147483647; files = ( A798251E1B18A6FC00F8E795 /* Main.storyboard in Resources */, + CC30F7001DA297E4000146B4 /* Default-568h@2x.png in Resources */, A79825231B18A6FC00F8E795 /* LaunchScreen.xib in Resources */, A79825201B18A6FC00F8E795 /* Images.xcassets in Resources */, ); @@ -451,6 +489,14 @@ "$(SRCROOT)/Carthage/Build/iOS/AlamofireObjectMapper.framework", "$(SRCROOT)/Carthage/Build/iOS/ObjectMapper.framework", "$(SRCROOT)/Carthage/Build/iOS/SVProgressHUD.framework", + "$(SRCROOT)/Carthage/Build/iOS/socialNetwork.framework", + "$(SRCROOT)/Carthage/Build/iOS/FacebookCore.framework", + "$(SRCROOT)/Carthage/Build/iOS/FacebookLogin.framework", + "$(SRCROOT)/Carthage/Build/iOS/FacebookShare.framework", + "$(SRCROOT)/Carthage/Build/iOS/Bolts.framework", + "$(SRCROOT)/Carthage/Build/iOS/FBSDKShareKit.framework", + "$(SRCROOT)/Carthage/Build/iOS/FBSDKCoreKit.framework", + "$(SRCROOT)/Carthage/Build/iOS/FBSDKLoginKit.framework", ); outputPaths = ( ); @@ -468,6 +514,7 @@ 17EE77621C6CCC9A009638A6 /* MailgunResponse.swift in Sources */, 172F06821C6B2C3600B711B2 /* WeatherVC.swift in Sources */, 17EE77451C6C7C65009638A6 /* MailgunVC.swift in Sources */, + CC34EA301DA2853900255715 /* FacebookConnectVC.swift in Sources */, 172FE3431C69F0FA00496519 /* CurrentWeatherResponse.swift in Sources */, A765CDF61B25E191004CD54A /* NSBundle+Root.swift in Sources */, 172F06881C6B2C6F00B711B2 /* WeatherData.swift in Sources */, @@ -481,6 +528,7 @@ 173B57DF1C6B45FE00FEB036 /* NSURLRequest+Body.swift in Sources */, 172F06851C6B2C5F00B711B2 /* IntTransform.swift in Sources */, 8D503B681BA059AD00C84F58 /* AppError.swift in Sources */, + CC30F6FE1DA2924D000146B4 /* FacebookInfoVC.swift in Sources */, 17EE77581C6C891E009638A6 /* TownWithWoeid.swift in Sources */, 172F068E1C6B2C8A00B711B2 /* WeatherCondition.swift in Sources */, 17EE77561C6C891E009638A6 /* ForecastResponse.swift in Sources */, diff --git a/App/AppDelegate.swift b/App/AppDelegate.swift index 82edf31..15cb010 100644 --- a/App/AppDelegate.swift +++ b/App/AppDelegate.swift @@ -8,6 +8,7 @@ import UIKit import ObjectMapper +import socialNetwork import Alamofire import AlamofireObjectMapper @@ -16,12 +17,19 @@ import AlamofireObjectMapper class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - + var facebookAppDelegate: FacebookAppDelegate = FacebookAppDelegate.init() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. + + facebookAppDelegate.launch(application, launchOptions: launchOptions) + return true } + + func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { + return facebookAppDelegate.openUrl(app, open: url, options: options) + } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. @@ -39,6 +47,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + + facebookAppDelegate.didBecomeActive(application) } func applicationWillTerminate(_ application: UIApplication) { diff --git a/App/Base.lproj/Main.storyboard b/App/Base.lproj/Main.storyboard index c3d8b46..afad433 100644 --- a/App/Base.lproj/Main.storyboard +++ b/App/Base.lproj/Main.storyboard @@ -106,7 +106,9 @@ - + + + @@ -117,10 +119,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -129,6 +272,7 @@ + @@ -206,7 +350,9 @@ Forecast 2 - + + + @@ -218,5 +364,30 @@ Forecast 2 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/App/FacebookConnectVC.swift b/App/FacebookConnectVC.swift new file mode 100644 index 0000000..d839a3a --- /dev/null +++ b/App/FacebookConnectVC.swift @@ -0,0 +1,70 @@ +// +// FacebookConnectVC.swift +// App +// +// Created by Sabrine Elbahri on 03/10/2016. +// Copyright © 2016 3IE. All rights reserved. +// + +import UIKit +import socialNetwork +import SVProgressHUD + +class FacebookConnectVC: UIViewController { + + //MARK: - Properties + var firstName: String? + var lastName: String? + var email: String? + var facebookId: String? + var logInWithFacebook: LogInWithFacebook = LogInWithFacebook.init() + var logOutWithFacebook: LogOutWithFacebook = LogOutWithFacebook.init() + + //MARK: - VC methods + override func viewDidLoad() { + super.viewDidLoad() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(true) + logOutWithFacebook.logOut() + } + + //MARK: - Login + @IBAction func LogIn(_ sender: AnyObject) { + logInWithFacebook.login(self) { userInfo, cancelled, failed, isDeclinedPermissions in + if userInfo != nil { + SVProgressHUD.show(withStatus: "Chargement") + + self.facebookId = self.logInWithFacebook.getFacebookIdFromUserInfoInTheCompletionHandlerFromLoginFunction(userInfo!) + self.firstName = self.logInWithFacebook.getUserFirstNameFromUserInfoInTheCompletionHandlerFromLoginFunction(userInfo!) + self.lastName = self.logInWithFacebook.getUserLastNameFromUserInfoInTheCompletionHandlerFromLoginFunction(userInfo!) + self.email = self.logInWithFacebook.getUserEmailFromUserInfoInTheCompletionHandlerFromLoginFunction(userInfo!) + + self.performSegue(withIdentifier: "PushFacebookInfo", sender: nil) + + } + + } + } + + //MARK: - TextFieldKeyboard + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + textField.resignFirstResponder() + return true + } + + + //MARK: - Navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "PushFacebookInfo" { + let controller: FacebookInfoVC = segue.destination as! FacebookInfoVC + + controller.firstName = firstName + controller.lastName = lastName + controller.email = email + controller.facebookId = facebookId! + controller.loginWithFacebook = logInWithFacebook + } + } +} diff --git a/App/FacebookInfoVC.swift b/App/FacebookInfoVC.swift new file mode 100644 index 0000000..15630a1 --- /dev/null +++ b/App/FacebookInfoVC.swift @@ -0,0 +1,67 @@ +// +// FacebookInfoVC.swift +// App +// +// Created by Sabrine Elbahri on 03/10/2016. +// Copyright © 2016 3IE. All rights reserved. +// + +import UIKit +import socialNetwork +import SVProgressHUD + +class FacebookInfoVC: UIViewController { + + //MARK: - Outlets + @IBOutlet weak var firstNameTextField: UITextField! + @IBOutlet weak var lastNameTextField: UITextField! + @IBOutlet weak var emailTextField: UITextField! + @IBOutlet weak var ProfileImageView: UIImageView! + + //MARK: - Properties + var firstName: String? + var lastName: String? + var email: String? + var facebookId: String? + var loginWithFacebook: LogInWithFacebook? + + //MARK: - Vc methods + override func viewDidLoad() { + super.viewDidLoad() + SVProgressHUD.dismiss() + setupFacebookInformartion() + } + + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + + cropping(imageView: ProfileImageView) + + } + + //MARK: - Setup view + func setupFacebookInformartion() { + firstNameTextField.text = firstName + firstNameTextField.isEnabled = false + lastNameTextField.text = lastName + lastNameTextField.isEnabled = false + emailTextField.text = email + emailTextField.isEnabled = false + + self.loginWithFacebook?.getFacebookProfileImageUrlAsync(self.facebookId!) { image in + self.ProfileImageView.image = image + self.ProfileImageView.contentMode = .scaleAspectFit + } + } + + + //MARK: - Treatment on image + func cropping(imageView: UIImageView) { + ProfileImageView.layer.borderWidth = 1 + ProfileImageView.layer.masksToBounds = false + ProfileImageView.layer.borderColor = UIColor.white.cgColor + ProfileImageView.layer.cornerRadius = ProfileImageView.frame.height / 2 + ProfileImageView.clipsToBounds = true + } + +} diff --git a/App/Images.xcassets/Contents.json b/App/Images.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/App/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/App/Images.xcassets/loginWithFacebook.imageset/Contents.json b/App/Images.xcassets/loginWithFacebook.imageset/Contents.json new file mode 100644 index 0000000..9acae77 --- /dev/null +++ b/App/Images.xcassets/loginWithFacebook.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "loginWithFacebook.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/App/Images.xcassets/loginWithFacebook.imageset/loginWithFacebook.png b/App/Images.xcassets/loginWithFacebook.imageset/loginWithFacebook.png new file mode 100644 index 0000000..8d0d202 Binary files /dev/null and b/App/Images.xcassets/loginWithFacebook.imageset/loginWithFacebook.png differ diff --git a/App/Images.xcassets/misterrabbit.imageset/Contents.json b/App/Images.xcassets/misterrabbit.imageset/Contents.json new file mode 100644 index 0000000..0da7e07 --- /dev/null +++ b/App/Images.xcassets/misterrabbit.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "misterrabbit.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/App/Images.xcassets/misterrabbit.imageset/misterrabbit.png b/App/Images.xcassets/misterrabbit.imageset/misterrabbit.png new file mode 100644 index 0000000..c7bca3e Binary files /dev/null and b/App/Images.xcassets/misterrabbit.imageset/misterrabbit.png differ diff --git a/App/Info.plist b/App/Info.plist index 669a772..5c36d6d 100644 --- a/App/Info.plist +++ b/App/Info.plist @@ -18,10 +18,61 @@ 1.0 CFBundleSignature ???? + CFBundleURLTypes + + + CFBundleURLSchemes + + fb210886035996098 + + + CFBundleVersion 1 + FacebookAppID + 210886035996098 + FacebookDisplayName + AppTest + LSApplicationQueriesSchemes + + fbapi + fb-messenger-api + fbauth2 + fbshareextension + LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSExceptionDomains + + api.mailgun.net + + NSIncludesSubdomains + + NSTemporaryExceptionAllowsInsecureHTTPLoads + + + facebook.com + + NSIncludesSubdomains + + NSTemporaryExceptionAllowsInsecureHTTPLoads + + NSThirdPartyExceptionRequiresForwardSecrecy + + + fbcdn.net + + NSIncludesSubdomains + + NSThirdPartyExceptionRequiresForwardSecrecy + + + + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -33,25 +84,8 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight kAPIBaseUrl https://query.yahooapis.com - NSAppTransportSecurity - - NSExceptionDomains - - api.mailgun.net - - - NSIncludesSubdomains - - - NSTemporaryExceptionAllowsInsecureHTTPLoads - - - - diff --git a/Cartfile b/Cartfile index a74edb2..e0c62bd 100644 --- a/Cartfile +++ b/Cartfile @@ -3,3 +3,4 @@ github "Alamofire/AlamofireImage" ~> 3.0.0 github "Hearst-DD/ObjectMapper" ~> 2.0.0 github "tristanhimmelman/AlamofireObjectMapper" ~> 4.0.0 github "SVProgressHUD/SVProgressHUD" ~> 2.0 +github "sabrineElbahri/socialNetwork" " feature/Swift3" diff --git a/Cartfile.resolved b/Cartfile.resolved index 45b2f04..4fb65d7 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,9 @@ -github "Alamofire/Alamofire" "4.0.0" +github "Alamofire/Alamofire" "4.0.1" +github "BoltsFramework/Bolts-ObjC" "1.8.4" github "Hearst-DD/ObjectMapper" "2.0.0" github "SVProgressHUD/SVProgressHUD" "2.0.3" -github "Alamofire/AlamofireImage" "3.0.0" +github "Alamofire/AlamofireImage" "3.1.0" +github "facebook/facebook-ios-sdk" "sdk-version-4.16.0" github "tristanhimmelman/AlamofireObjectMapper" "4.0.0" +github "facebook/Facebook-sdk-swift" "0.2.0" +github "sabrineElbahri/socialNetwork" "810968ee645c3afd3ced30d9345925e47080ed20" diff --git a/Default-568h@2x.png b/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/Default-568h@2x.png differ