Login/Logout Button fixed

This commit is contained in:
Okechi Onyeje 2016-11-19 20:31:30 -05:00
parent 6ba4044d86
commit d11d2f0e60
5 changed files with 27 additions and 17 deletions

View File

@ -525,8 +525,8 @@
endingColumnNumber = "9223372036854775807"
startingLineNumber = "611"
endingLineNumber = "611"
landmarkName = "EtsyRESTAPIManager"
landmarkType = "3">
landmarkName = "sendGETRequest(_:onCompletion:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy

View File

@ -105,7 +105,7 @@ class EtsyRESTAPIManager: NSObject {
extension EtsyRESTAPIManager {
//makes application ready for use with users etsy account
func authorizeApp(viewcontroller: UIViewController){
func authorizeApp(viewcontroller: UIViewController, onComplete: ServiceResponse!){
var boolResult: Bool!
@ -225,6 +225,8 @@ extension EtsyRESTAPIManager {
EtsyRESTAPIManager.settingsDictionary["userID"] = dict2[0]["login_name"]!
NSUserDefaults.standardUserDefaults().setObject(EtsyRESTAPIManager.settingsDictionary, forKey: "etsySettings")
onComplete(nil,nil)
self.sendGETRequest("/private/shops/__SELF__/payment_templates", onCompletion: {
(data, error) -> Void in

View File

@ -65,7 +65,7 @@ class FacebookGraphAPIManager: NSObject {
//MARK: - OAuth Methods
extension FacebookGraphAPIManager {
func authorizeApp(viewcontroller: UIViewController) -> Bool{
func authorizeApp(viewcontroller: UIViewController, onComplete: ServiceResponse!) -> Bool{
login.loginBehavior = FBSDKLoginBehavior.Web
if(!self.isAuthorized){
@ -107,11 +107,13 @@ extension FacebookGraphAPIManager {
NSUserDefaults.standardUserDefaults().setBool(true, forKey:"fbAuthorized")
self.isAuthorized = true
onComplete(nil,nil)
})
})
}else{
onComplete(nil,nil)
}
}

View File

@ -800,21 +800,27 @@ extension NetworksTableViewController {
break
case is EtsyTableViewCell.Type:
let tabBar = self.tabBarController
((tabBar as? HomeViewController)?.etsyManager.authorizeApp(self))!
((tabBar as? HomeViewController)?.etsyManager.authorizeApp(self, onComplete: {
something , _ -> Void in
dispatch_async(dispatch_get_main_queue(), {
sender.setTitle("Logout", forState: UIControlState.Normal)
(sender.superview?.superview as! EtsyTableViewCell).settingsBtn.enabled = true
(sender.superview?.superview as! EtsyTableViewCell).settingsBtn.hidden = false
})
}))!
break
case is FBTableViewCell.Type:
let tabBar = self.tabBarController
((tabBar as? HomeViewController)?.fbGraphManager.authorizeApp(self))!
((tabBar as? HomeViewController)?.fbGraphManager.authorizeApp(self, onComplete: {
something , _ -> Void in
dispatch_async(dispatch_get_main_queue(), {
sender.setTitle("Logout", forState: UIControlState.Normal)
(sender.superview?.superview as! FBTableViewCell).settingsBtn.enabled = true
(sender.superview?.superview as! FBTableViewCell).settingsBtn.hidden = false
})
}))!
break
default: