diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate
index 6a7ce46..dc2f0c7 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 520eda7..c78dbce 100644
--- a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -9,640 +9,29 @@
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
-<<<<<<< HEAD
filePath = "Vendoo/HomeViewController.swift"
- timestampString = "494906385.49118"
+ timestampString = "497362780.635053"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "183"
- endingLineNumber = "183">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >>>>>> Rapid-Dev-Branch
- startingColumnNumber = "9223372036854775807"
- endingColumnNumber = "9223372036854775807"
- startingLineNumber = "865"
- endingLineNumber = "865"
- landmarkName = "toggleNetworkSelection(_:)"
- landmarkType = "5">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<<<<<<< HEAD
-
-
-
-
-
-
-=======
->>>>>>> Rapid-Dev-Branch
-
-
-
-
-
-
-
-
-
-
-=======
- urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/SignInViewController.swift"
- timestampString = "496597493.364189"
- startingColumnNumber = "9223372036854775807"
- endingColumnNumber = "9223372036854775807"
- startingLineNumber = "57"
- endingLineNumber = "57"
- offsetFromSymbolStart = "19">
->>>>>>> Rapid-Dev-Branch
-
-
-=======
- urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/SignInViewController.swift"
- timestampString = "496597493.364295"
- startingColumnNumber = "9223372036854775807"
- endingColumnNumber = "9223372036854775807"
- startingLineNumber = "58"
- endingLineNumber = "58"
- offsetFromSymbolStart = "37">
->>>>>>> Rapid-Dev-Branch
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >>>>>> Rapid-Dev-Branch
+ startingLineNumber = "238"
+ endingLineNumber = "238"
+ landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
landmarkType = "5">
diff --git a/Vendoo/EbayWebServiceManager.swift b/Vendoo/EbayWebServiceManager.swift
index 31e9faa..1458763 100644
--- a/Vendoo/EbayWebServiceManager.swift
+++ b/Vendoo/EbayWebServiceManager.swift
@@ -542,14 +542,14 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
}
else {
- if "\(self.catDetailLevel)" == self.catLevel {
+ /*if "\(self.catDetailLevel)" == self.catLevel {
if((self.subCategories[string] == nil )){
self.subCategories[string] = ["cat_id": self.catID, "isLeaf": false, "level": self.catLevel]
}
}
- self.currentCategory = string
+ self.currentCategory = string*/
}
diff --git a/Vendoo/HomeViewController.swift b/Vendoo/HomeViewController.swift
index df1063e..8a1ee65 100644
--- a/Vendoo/HomeViewController.swift
+++ b/Vendoo/HomeViewController.swift
@@ -16,6 +16,8 @@ class HomeViewController: UITabBarController {
let firebaseManager = FirebaseManager()
let ebayGraphManager = EbayWebServiceManager()
var userListings: [Listing] = []
+ var endedListings: [Listing] = []
+ var soldListings: [Listing] = []
var notificationsManager = ServiceNotificationManager()
var notifications: [Dictionary] = (NSUserDefaults.standardUserDefaults().objectForKey("notifications") == nil ? [] : (NSUserDefaults.standardUserDefaults().objectForKey("notifications") as! [Dictionary]))
@@ -91,17 +93,47 @@ class HomeViewController: UITabBarController {
dispatch_group_notify(serviceGroup, dispatch_get_main_queue(), {
print(listingImages.count)
let listingInfo = values as? [String : AnyObject]
- self.userListings.append(
- Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!,
- itemCategory: listingInfo!["listingCategory"] as? String,
- itemQuantity: (listingInfo!["listingQuantity"] as? String)!,
- itemPrice: listingInfo!["listingPrice"] as? String,
- itemDescription: listingInfo!["listingDescription"] as? String,
- itemImages: listingImages,
- isDraftListing: (listingInfo!["isListingDraft"] as? Bool)!,
- itemKey: key,
- networksSellingOn: (listingInfo!["networks"] as? Dictionary)!
+
+ if listingInfo!["listingStatus"] == nil {
+ self.userListings.append(
+ Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!,
+ itemCategory: listingInfo!["listingCategory"] as? String,
+ itemQuantity: (listingInfo!["listingQuantity"] as? String)!,
+ itemPrice: listingInfo!["listingPrice"] as? String,
+ itemDescription: listingInfo!["listingDescription"] as? String,
+ itemImages: listingImages,
+ isDraftListing: (listingInfo!["isListingDraft"] as? Bool)!,
+ itemKey: key,
+ networksSellingOn: (listingInfo!["networks"] as? Dictionary)!
))
+ }
+ else if listingInfo!["listingStatus"] as? String == "Ended" {
+ self.endedListings.append(
+ Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!,
+ itemCategory: listingInfo!["listingCategory"] as? String,
+ itemQuantity: (listingInfo!["listingQuantity"] as? String)!,
+ itemPrice: listingInfo!["listingPrice"] as? String,
+ itemDescription: listingInfo!["listingDescription"] as? String,
+ itemImages: listingImages,
+ isDraftListing: (listingInfo!["isListingDraft"] as? Bool)!,
+ itemKey: key,
+ networksSellingOn: (listingInfo!["networks"] as? Dictionary)!
+ ))
+ }
+ else if listingInfo!["listingStatus"] as? String == "Sold" {
+ self.soldListings.append(
+ Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!,
+ itemCategory: listingInfo!["listingCategory"] as? String,
+ itemQuantity: (listingInfo!["listingQuantity"] as? String)!,
+ itemPrice: listingInfo!["listingPrice"] as? String,
+ itemDescription: listingInfo!["listingDescription"] as? String,
+ itemImages: listingImages,
+ isDraftListing: (listingInfo!["isListingDraft"] as? Bool)!,
+ itemKey: key,
+ networksSellingOn: (listingInfo!["networks"] as? Dictionary)!
+ ))
+ }
+
print(notificationStartTracker)
if(notificationStartTracker == listingDict?.count){
NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil)
@@ -189,11 +221,24 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
[
"network": "ebay",
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
- "type": "ended",
+ "type": (ebayInfo as! [String : AnyObject])["type"] as! String,
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
"UUID": NSUUID().UUIDString
]
)
+ self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((ebayInfo as! [String : AnyObject])["listingKey"] as! String)}))
+ self.userListings = self.userListings.filter({$0.key != ((ebayInfo as! [String : AnyObject])["listingKey"] as! String)})
+ let itemsView = self.viewControllers![0] as! ItemTableViewController
+
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((ebayInfo as! [String : AnyObject])["listingKey"] as! String))").observeSingleEventOfType( .Value, withBlock: {
+ (snapshot) -> Void in
+
+ var listingDict = snapshot.value as? [String : AnyObject]
+ listingDict!["listingStatus"] = "Ended"
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((ebayInfo as! [String : AnyObject])["listingKey"] as! String))").setValue(listingDict)
+
+ itemsView.itemTable.reloadData()
+ })
}
if (amazonInfo != nil) {
@@ -201,7 +246,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
[
"network": "amazon",
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
- "type": "ended",
+ "type": (ebayInfo as! [String : AnyObject])["type"] as! String,
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
"UUID": NSUUID().UUIDString
]
@@ -230,7 +275,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
[
"network": "facebook",
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
- "type": "ended",
+ "type": (ebayInfo as! [String : AnyObject])["type"] as! String,
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
"UUID": NSUUID().UUIDString
]
@@ -242,7 +287,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
[
"network": "ebay",
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
- "type": "ended",
+ "type": (ebayInfo as! [String : AnyObject])["type"] as! String,
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
"UUID": NSUUID().UUIDString
]
@@ -254,7 +299,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
[
"network": "amazon",
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
- "type": "ended",
+ "type": "",
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
"UUID": NSUUID().UUIDString
]
@@ -266,7 +311,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
[
"network": "etsy",
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
- "type": "ended",
+ "type": "",
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
"UUID": NSUUID().UUIDString
]
diff --git a/Vendoo/ItemTableViewController.swift b/Vendoo/ItemTableViewController.swift
index 2da8be4..ff66e52 100644
--- a/Vendoo/ItemTableViewController.swift
+++ b/Vendoo/ItemTableViewController.swift
@@ -80,6 +80,12 @@ class ItemTableViewController: UIViewController {
}
+// MARK: - IBAction
+extension ItemTableViewController {
+ @IBAction func segSwitch(sender: UISegmentedControl) {
+ self.itemTable.reloadData()
+ }
+}
// MARK: - Navigation
extension ItemTableViewController {
@@ -129,63 +135,143 @@ extension ItemTableViewController: UITableViewDataSource{
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
- return ((self.tabBarController as? HomeViewController)?.userListings.count)!
+ if self.tableSegmentController.selectedSegmentIndex == 0 {
+ return ((self.tabBarController as? HomeViewController)?.userListings.count)!
+ }
+ else if tableSegmentController.selectedSegmentIndex == 1 {
+ return ((self.tabBarController as? HomeViewController)?.endedListings.count)!
+ }
+ else{
+ return ((self.tabBarController as? HomeViewController)?.soldListings.count)!
+ }
+
+
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: ItemCell! = (tableView.dequeueReusableCellWithIdentifier("Item Cell", forIndexPath: indexPath) as! ItemCell)
-
-
-
// Configure the cell...
//for each listing cell generated need to find the marketplaces it belongs to, the listing price, the name of the item, the status of the item, and the item image.
//Once these objects are retrieved, access the ItemCell properties and manipulate as needed
- cell.itemImage.image = (self.tabBarController as? HomeViewController)?.userListings[indexPath.row].images[0] //come back
- cell.itemName.text = (self.tabBarController as? HomeViewController)!.userListings[indexPath.row].title
- cell.itemPrice.text = (self.tabBarController as? HomeViewController)!.userListings[indexPath.row].price
- //check if item is published
- if((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].isDraft!){
- cell.itemStatus.text = "Status: Unpublished"
- dispatch_async(dispatch_get_main_queue(), {
-
- cell.alpha = 0.5
-
-
- })
+ if self.tableSegmentController.selectedSegmentIndex == 0 {
+ cell.itemImage.image = (self.tabBarController as? HomeViewController)?.userListings[indexPath.row].images[0] //come back
+ cell.itemName.text = (self.tabBarController as? HomeViewController)!.userListings[indexPath.row].title
+ cell.itemPrice.text = (self.tabBarController as? HomeViewController)!.userListings[indexPath.row].price
- }else {
- cell.itemStatus.text = "Status: Active"
- }
-
- if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["areNetworksChosen"])!){
- cell.networks.hidden = true
- }else{
- dispatch_async(dispatch_get_main_queue(), {
- if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["ebay"])!){
- cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
- }
- if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["amazon"])!){
- cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
- }
- if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["etsy"])!){
- cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
+ //check if item is published
+ if((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].isDraft!){
+ cell.itemStatus.text = "Status: Unpublished"
+ dispatch_async(dispatch_get_main_queue(), {
- }
- if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["facebook"])!){
- cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
- }
-
- })
+ cell.alpha = 0.5
+
+
+ })
+
+ }else {
+ cell.itemStatus.text = "Status: Active"
+ }
+ if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["areNetworksChosen"])!){
+ cell.networks.hidden = true
+ }else{
+ dispatch_async(dispatch_get_main_queue(), {
+ if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["ebay"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
+ }
+ if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["amazon"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
+ }
+ if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["etsy"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
+
+ }
+ if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["facebook"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
+ }
+
+ })
+
+ }
+
}
+ else if tableSegmentController.selectedSegmentIndex == 1 {
+ cell.itemImage.image = (self.tabBarController as? HomeViewController)?.endedListings[indexPath.row].images[0] //come back
+ cell.itemName.text = (self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].title
+ cell.itemPrice.text = (self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].price
+
+ cell.itemStatus.text = "Status: Unsold"
+
+ if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["areNetworksChosen"])!){
+ cell.networks.hidden = true
+ }else{
+ dispatch_async(dispatch_get_main_queue(), {
+ if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["ebay"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
+ }
+ if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["amazon"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
+ }
+ if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["etsy"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
+
+ }
+ if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["facebook"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
+ }
+
+ })
+
+ }
+
+ }
+ else{
+ cell.itemImage.image = (self.tabBarController as? HomeViewController)?.soldListings[indexPath.row].images[0] //come back
+ cell.itemName.text = (self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].title
+ cell.itemPrice.text = (self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].price
+
+ cell.itemStatus.text = "Status: Sold"
+
+ if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["areNetworksChosen"])!){
+ cell.networks.hidden = true
+ }else{
+ dispatch_async(dispatch_get_main_queue(), {
+ if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["ebay"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
+ }
+ if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["amazon"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
+ }
+ if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["etsy"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
+
+ }
+ if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["facebook"])!){
+ cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
+ }
+
+ })
+
+ }
+ }
+
+
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
- self.selectedListing = (self.tabBarController as? HomeViewController)?.userListings[indexPath.row]
+ if self.tableSegmentController.selectedSegmentIndex == 0 {
+ self.selectedListing = (self.tabBarController as? HomeViewController)?.userListings[indexPath.row]
+ }
+ else if tableSegmentController.selectedSegmentIndex == 1 {
+ self.selectedListing = (self.tabBarController as? HomeViewController)?.endedListings[indexPath.row]
+ }
+ else{
+ self.selectedListing = (self.tabBarController as? HomeViewController)?.soldListings[indexPath.row]
+ }
self.performSegueWithIdentifier("ItemDetailSegue", sender: self)
}
}
diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard
index cb927f7..a2f6b1f 100755
--- a/Vendoo/Main.storyboard
+++ b/Vendoo/Main.storyboard
@@ -1242,14 +1242,18 @@
-
+
+
+
+
+
@@ -2501,11 +2505,11 @@
+
+
-
-
-
+
diff --git a/Vendoo/ServiceNotificationManager.swift b/Vendoo/ServiceNotificationManager.swift
index 9afef9f..cac2c7e 100644
--- a/Vendoo/ServiceNotificationManager.swift
+++ b/Vendoo/ServiceNotificationManager.swift
@@ -33,7 +33,8 @@ class ServiceNotificationManager: NSObject {
}
func startServicePolling() {
- timer = NSTimer.scheduledTimerWithTimeInterval(10.0, target: self, selector: #selector(ServiceNotificationManager.pollServices), userInfo: nil, repeats: true)
+ //timer = NSTimer.scheduledTimerWithTimeInterval(60.0, target: self, selector: #selector(ServiceNotificationManager.pollServices), userInfo: nil, repeats: true)
+ pollServices()
}
func stopServicePolling() {
@@ -76,18 +77,33 @@ class ServiceNotificationManager: NSObject {
(listingNotificationInfo, error) -> Void in
//dispatch_group_leave(notificationGroup)
let info = (listingNotificationInfo as! [String : AnyObject])
- if((info["quantitySold"] as! Int) > 0) {
- //@TODO: Add both firbase logic and code logic to do notifications for sold listings
- }
if(info["status"] as! String == "Ended") {
- ServiceNotificationManager.delegate?.listingHasEnded(
- nil,
- ebayInfo: [
- "notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has ended on ebay.",
- "listingKey": listing.key],
- amazonInfo: nil,
- etsyInfo: nil
- )
+ if((info["quantitySold"] as! Int) > 0) {
+ //@TODO: Add both firbase logic and code logic to do notifications for sold listings
+ if (((info["itemQuantity"] as! Int) - (info["quantitySold"] as! Int)) == 0) {
+
+ ServiceNotificationManager.delegate?.listingHasNewNotifications(
+ nil,
+ ebayInfo: [
+ "type": "Sold",
+ "notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has sold out on ebay.",
+ "listingKey": listing.key],
+ amazonInfo: nil,
+ etsyInfo: nil
+ )
+ }
+ }else{
+ ServiceNotificationManager.delegate?.listingHasEnded(
+ nil,
+ ebayInfo: [
+ "type": "Ended",
+ "notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has ended on ebay.",
+ "listingKey": listing.key],
+ amazonInfo: nil,
+ etsyInfo: nil
+ )
+ }
+
}