diff --git a/Vendoo.xcodeproj/project.pbxproj b/Vendoo.xcodeproj/project.pbxproj index 5f0cc46..59df3ab 100644 --- a/Vendoo.xcodeproj/project.pbxproj +++ b/Vendoo.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ 3EA668A11D02836C00EE57A8 /* EbayWebServiceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EA668A01D02836C00EE57A8 /* EbayWebServiceManager.swift */; }; 3EB2F5161CF442CF002E6D2C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EB2F5151CF442CF002E6D2C /* Security.framework */; }; 3EB54E0E1DE08A2E006D918B /* NetworkCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EB54E0D1DE08A2E006D918B /* NetworkCollectionViewCell.swift */; }; + 3EB54E101DE1397A006D918B /* Not_TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EB54E0F1DE1397A006D918B /* Not_TableViewCell.swift */; }; 3EC325111CF703A600626C48 /* ItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EC325101CF703A600626C48 /* ItemCell.swift */; }; 3EC325151CF7104300626C48 /* ItemTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EC325141CF7104300626C48 /* ItemTableViewController.swift */; }; 3EC3251E1CF734C100626C48 /* NetworksTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EC3251D1CF734C100626C48 /* NetworksTableViewController.swift */; }; @@ -101,6 +102,7 @@ 3EA668A21D02ECB100EE57A8 /* libicucore.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libicucore.tbd; path = usr/lib/libicucore.tbd; sourceTree = SDKROOT; }; 3EB2F5151CF442CF002E6D2C /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 3EB54E0D1DE08A2E006D918B /* NetworkCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkCollectionViewCell.swift; sourceTree = ""; }; + 3EB54E0F1DE1397A006D918B /* Not_TableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Not_TableViewCell.swift; sourceTree = ""; }; 3EC325101CF703A600626C48 /* ItemCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemCell.swift; sourceTree = ""; }; 3EC325141CF7104300626C48 /* ItemTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemTableViewController.swift; sourceTree = ""; }; 3EC3251D1CF734C100626C48 /* NetworksTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworksTableViewController.swift; sourceTree = ""; }; @@ -339,6 +341,7 @@ children = ( 3EE734E71DCD34B900F771AE /* NotificationTableViewCell.swift */, 3EE734E51DCD34AE00F771AE /* NotificationsViewController.swift */, + 3EB54E0F1DE1397A006D918B /* Not_TableViewCell.swift */, ); name = Notifications; sourceTree = ""; @@ -776,6 +779,7 @@ 3E1DC3CF1D42328C0091BC60 /* CategoryCell.swift in Sources */, 3EC325111CF703A600626C48 /* ItemCell.swift in Sources */, 3E3A004A1D76680E00A3A5B6 /* ServiceNotificationManager.swift in Sources */, + 3EB54E101DE1397A006D918B /* Not_TableViewCell.swift in Sources */, 3EA668A11D02836C00EE57A8 /* EbayWebServiceManager.swift in Sources */, 3EF422B21D73262000B9A3EB /* UserCell.swift in Sources */, 3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */, diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate index fb0a3c5..45431d9 100644 Binary files a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate and b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 59c0025..3a2882a 100644 --- a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -186,7 +186,7 @@ moduleName = "Vendoo" usesParentBreakpointCondition = "Yes" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift" - timestampString = "501301326.689405" + timestampString = "501440965.919907" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "570" @@ -201,7 +201,7 @@ moduleName = "Vendoo" usesParentBreakpointCondition = "Yes" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift" - timestampString = "501301326.689558" + timestampString = "501440965.920274" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "572" @@ -663,12 +663,124 @@ shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "Vendoo/MenuPanelViewController.swift" - timestampString = "501301326.548836" + filePath = "Vendoo/HomeViewController.swift" + timestampString = "501429562.960347" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "111" - endingLineNumber = "111" + startingLineNumber = "41" + endingLineNumber = "41" + landmarkName = "viewDidLoad()" + landmarkType = "5"> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vendoo/.DS_Store b/Vendoo/.DS_Store index 2f7f955..cf8ea48 100644 Binary files a/Vendoo/.DS_Store and b/Vendoo/.DS_Store differ diff --git a/Vendoo/HomeViewController.swift b/Vendoo/HomeViewController.swift index a1326c5..ac3be80 100644 --- a/Vendoo/HomeViewController.swift +++ b/Vendoo/HomeViewController.swift @@ -38,16 +38,34 @@ class HomeViewController: UITabBarController { let listingDict = userDict!["user_Listings"] as? [String : AnyObject] //sync notifications - /*if userDict!["notifications"] != nil { + if userDict!["notifications"] != nil { self.notifications = [] for (_, v) in userDict!["notifications"] as! [String : AnyObject] { - if v["seen"] as! Bool == false { - self.notifications.append(v as! Dictionary) + if v["seen"] as! Bool == false/*add network visibility as well*/{ + var is_networkAuth = false + switch((v["network"] as! String)){ + case "ebay": + is_networkAuth = NSUserDefaults.standardUserDefaults().boolForKey("ebayAuthorized") + break + case "etsy": + is_networkAuth = NSUserDefaults.standardUserDefaults().boolForKey("etsyAuthorized") + break + case "facebook" : + is_networkAuth = NSUserDefaults.standardUserDefaults().boolForKey("fbAuthorized") + break + case "amazon": + break + default: + break + } + if is_networkAuth { + self.notifications.append(v as! Dictionary) + } } } NSUserDefaults.standardUserDefaults().setObject(self.notifications, forKey: "notifications") - }*/ + } NSUserDefaults.standardUserDefaults().setObject(userDict!["name"] as? String, forKey: "name") @@ -151,6 +169,13 @@ class HomeViewController: UITabBarController { NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil) self.notificationsManager.setListings(self.userListings) self.notificationsManager.startServicePolling() + /*self.notificationsManager.startServicePolling({ + (_,_) -> Void in + NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil) + + + })*/ + } diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard index 2a684fe..16a3c1d 100755 --- a/Vendoo/Main.storyboard +++ b/Vendoo/Main.storyboard @@ -1393,7 +1393,7 @@ - + @@ -1421,6 +1421,7 @@ + @@ -1567,7 +1568,7 @@ - + @@ -1643,7 +1644,7 @@ - + @@ -1660,7 +1661,7 @@ - + @@ -2418,11 +2419,11 @@ - - + - + + diff --git a/Vendoo/MenuPanelViewController.swift b/Vendoo/MenuPanelViewController.swift index 89eb499..97a57f2 100644 --- a/Vendoo/MenuPanelViewController.swift +++ b/Vendoo/MenuPanelViewController.swift @@ -11,6 +11,7 @@ import FirebaseAuth import Locksmith class MenuPanelViewController: UIViewController{ + var count = (NSUserDefaults.standardUserDefaults().objectForKey("notifications") == nil ? 0 : (NSUserDefaults.standardUserDefaults().objectForKey("notifications") as! [Dictionary]).count) //Outlets @IBOutlet weak var table: UITableView! @@ -107,8 +108,10 @@ extension MenuPanelViewController: UITableViewDataSource (cell as! UserCell).email.text = (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)! break case 1: - cell = self.table.dequeueReusableCellWithIdentifier("Notifications_Cell")! - break + let cellN: Not_TableViewCell! + cellN = self.table.dequeueReusableCellWithIdentifier("Notifications_Cell")! as! Not_TableViewCell + cellN.count.text = "\(count)" + return cellN case 2: cell = self.table.dequeueReusableCellWithIdentifier("Settings_Cell")! break diff --git a/Vendoo/Not_TableViewCell.swift b/Vendoo/Not_TableViewCell.swift new file mode 100644 index 0000000..c950abd --- /dev/null +++ b/Vendoo/Not_TableViewCell.swift @@ -0,0 +1,25 @@ +// +// TableViewCell.swift +// Vendoo +// +// Created by Okechi Onyeje on 11/19/16. +// Copyright © 2016 Okechi Onyeje. All rights reserved. +// + +import UIKit + +class Not_TableViewCell: UITableViewCell { + @IBOutlet weak var count: UILabel! + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/Vendoo/SettingsViewController.swift b/Vendoo/SettingsViewController.swift index e731b06..a7c8c0a 100644 --- a/Vendoo/SettingsViewController.swift +++ b/Vendoo/SettingsViewController.swift @@ -9,13 +9,15 @@ import UIKit import Locksmith import FirebaseAuth +import FirebaseDatabase +import FirebaseStorage class SettingsViewController: UIViewController { //IBOutlet @IBOutlet weak var closeButton: UIBarButtonItem! @IBOutlet weak var table: UITableView! - + var firbase = FirebaseManager() override func viewDidLoad() { super.viewDidLoad() @@ -184,6 +186,74 @@ extension SettingsViewController: UITableViewDelegate { //put in deletion code later print("account deleted, add in deletion code as well as deauthorization code for any network currently authorized") + + + + //get all listing information for current user + print((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!) + self.firbase.ref.child("Users/\(self.firbase.user_email)").observeSingleEventOfType( .Value, withBlock: { + (snapshot) -> Void in + + let userDict = snapshot.value as? [String : AnyObject] + let listingDict = userDict!["user_Listings"] as? [String : AnyObject] + + if listingDict != nil { + for (key, values) in listingDict! { + self.firbase.ref.child("Global_listings").child(key).removeValue() + FIRStorage.storage().referenceForURL((userDict!["image_storage"] as? String)!).child("images/\(key)").deleteWithCompletion({ + (error) -> Void in + }) + } + } + + self.firbase.ref.child("Users").child(self.firbase.user_email).removeValueWithCompletionBlock({ + (error, ref) -> Void in + + if error == nil { + FIRAuth.auth()?.currentUser?.deleteWithCompletion({ + (profile) -> Void in + + do{ + try Locksmith.deleteDataForUserAccount((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, inService: "vendoo") + + do { + try Locksmith.deleteDataForUserAccount((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, inService: "vendoo_oauth_ebay") + }catch { + (error) + print(error) + } + + do { + try Locksmith.deleteDataForUserAccount((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, inService: "vendoo_oauth_etsy") + }catch { + (error) + print(error) + } + + do { + try Locksmith.deleteDataForUserAccount((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, inService: "vendoo_oauth_amazon") + }catch { + (error) + print(error) + } + + for key in Array(NSUserDefaults.standardUserDefaults().dictionaryRepresentation().keys) { + NSUserDefaults.standardUserDefaults().removeObjectForKey(key) + } + + let vc = self.storyboard?.instantiateViewControllerWithIdentifier("SignInViewController") + self.presentViewController(vc!, animated: true, completion: nil) + } + catch{ + (error) + print(error) + } + }) + } + }) + }) + + alert.dismissViewControllerAnimated(true, completion: nil) }else{