diff --git a/.DS_Store b/.DS_Store
index 8a7a61a..7492825 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/Pods/Pods.xcodeproj/xcuserdata/okechi.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/okechi.xcuserdatad/xcschemes/xcschememanagement.plist
index e52404f..1ac8c3b 100644
--- a/Pods/Pods.xcodeproj/xcuserdata/okechi.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/Pods/Pods.xcodeproj/xcuserdata/okechi.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -127,6 +127,11 @@
primary
+ 0EB19C1377A747F81110D44E2D5FCF78
+
+ primary
+
+
0FF38C485BD8E73F614C919F834D6EAB
primary
diff --git a/Vendoo.xcodeproj/project.pbxproj b/Vendoo.xcodeproj/project.pbxproj
index c4ff4cf..e5b1b72 100644
--- a/Vendoo.xcodeproj/project.pbxproj
+++ b/Vendoo.xcodeproj/project.pbxproj
@@ -16,6 +16,7 @@
3E1B1F0B1D2493EE00DBCF08 /* EtsySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1B1F0A1D2493EE00DBCF08 /* EtsySettingsViewController.swift */; };
3E1DC3CD1D4232490091BC60 /* CategoriesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1DC3CC1D4232490091BC60 /* CategoriesTableViewController.swift */; };
3E1DC3CF1D42328C0091BC60 /* CategoryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1DC3CE1D42328C0091BC60 /* CategoryCell.swift */; };
+ 3E3A004A1D76680E00A3A5B6 /* ServiceNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E3A00491D76680E00A3A5B6 /* ServiceNotificationManager.swift */; };
3E4897D11D0067030069F742 /* FirebaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4897D01D0067030069F742 /* FirebaseManager.swift */; };
3E6CC3571CF2A94B00E00A70 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6CC3561CF2A94B00E00A70 /* AppDelegate.swift */; };
3E6CC3591CF2A94B00E00A70 /* SignInViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6CC3581CF2A94B00E00A70 /* SignInViewController.swift */; };
@@ -40,6 +41,8 @@
3EC3252F1CF894E500626C48 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EC3252E1CF894E500626C48 /* AVFoundation.framework */; };
3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ECEDB861CF9C722003566B3 /* ListingPreviewViewController.swift */; };
3EDE75AE1D67B92F00BC3472 /* CategoryPopUpController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EDE75AD1D67B92F00BC3472 /* CategoryPopUpController.swift */; };
+ 3EE734E61DCD34AE00F771AE /* NotificationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE734E51DCD34AE00F771AE /* NotificationsViewController.swift */; };
+ 3EE734E81DCD34B900F771AE /* NotificationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EE734E71DCD34B900F771AE /* NotificationTableViewCell.swift */; };
3EF422B21D73262000B9A3EB /* UserCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EF422B11D73262000B9A3EB /* UserCell.swift */; };
3EFB0E331D0B968300A05D7A /* SideMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EFB0E321D0B968300A05D7A /* SideMenuView.swift */; };
3F8E0464700649BDD8B552B1 /* Pods_Vendoo_VendooTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B876489113F498AF1D2FD7E9 /* Pods_Vendoo_VendooTests.framework */; };
@@ -74,6 +77,7 @@
3E1B1F0A1D2493EE00DBCF08 /* EtsySettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EtsySettingsViewController.swift; sourceTree = ""; };
3E1DC3CC1D4232490091BC60 /* CategoriesTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CategoriesTableViewController.swift; sourceTree = ""; };
3E1DC3CE1D42328C0091BC60 /* CategoryCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CategoryCell.swift; sourceTree = ""; };
+ 3E3A00491D76680E00A3A5B6 /* ServiceNotificationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceNotificationManager.swift; sourceTree = ""; };
3E4897D01D0067030069F742 /* FirebaseManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseManager.swift; sourceTree = ""; };
3E6CC3531CF2A94B00E00A70 /* Vendoo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Vendoo.app; sourceTree = BUILT_PRODUCTS_DIR; };
3E6CC3561CF2A94B00E00A70 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
@@ -106,6 +110,8 @@
3EC3252E1CF894E500626C48 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
3ECEDB861CF9C722003566B3 /* ListingPreviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListingPreviewViewController.swift; sourceTree = ""; };
3EDE75AD1D67B92F00BC3472 /* CategoryPopUpController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CategoryPopUpController.swift; sourceTree = ""; };
+ 3EE734E51DCD34AE00F771AE /* NotificationsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationsViewController.swift; sourceTree = ""; };
+ 3EE734E71DCD34B900F771AE /* NotificationTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationTableViewCell.swift; sourceTree = ""; };
3EF422B11D73262000B9A3EB /* UserCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserCell.swift; sourceTree = ""; };
3EFB0E321D0B968300A05D7A /* SideMenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideMenuView.swift; sourceTree = ""; };
7D1FC6F6278B48A7BA9A9E03 /* Pods_Vendoo_VendooUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Vendoo_VendooUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -171,6 +177,7 @@
3E4897CE1D0062860069F742 /* Services */ = {
isa = PBXGroup;
children = (
+ 3E3A00491D76680E00A3A5B6 /* ServiceNotificationManager.swift */,
3EA668941D026E2A00EE57A8 /* EbayServices */,
3E4897CF1D00629B0069F742 /* FirebaseServices */,
3E7CF3FF1CF6363200F486B2 /* EtsyServices */,
@@ -324,9 +331,19 @@
name = NewItemPostingSession;
sourceTree = "";
};
+ 3EE734E41DCD347900F771AE /* Notifications */ = {
+ isa = PBXGroup;
+ children = (
+ 3EE734E71DCD34B900F771AE /* NotificationTableViewCell.swift */,
+ 3EE734E51DCD34AE00F771AE /* NotificationsViewController.swift */,
+ );
+ name = Notifications;
+ sourceTree = "";
+ };
3EFB0E2F1D0B95B200A05D7A /* Menu */ = {
isa = PBXGroup;
children = (
+ 3EE734E41DCD347900F771AE /* Notifications */,
3E1AA4331D0DD0B2005FCCBB /* Settings */,
3EFB0E321D0B968300A05D7A /* SideMenuView.swift */,
3E1AA4311D0DA071005FCCBB /* MenuPanelViewController.swift */,
@@ -741,6 +758,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 3EE734E81DCD34B900F771AE /* NotificationTableViewCell.swift in Sources */,
3E6CC35B1CF2A94B00E00A70 /* SignUpViewController.swift in Sources */,
3E1AA4321D0DA071005FCCBB /* MenuPanelViewController.swift in Sources */,
3E4897D11D0067030069F742 /* FirebaseManager.swift in Sources */,
@@ -753,11 +771,13 @@
3E7CF3FC1CF5FE9400F486B2 /* RecoverPasswordViewController.swift in Sources */,
3E1DC3CF1D42328C0091BC60 /* CategoryCell.swift in Sources */,
3EC325111CF703A600626C48 /* ItemCell.swift in Sources */,
+ 3E3A004A1D76680E00A3A5B6 /* ServiceNotificationManager.swift in Sources */,
3EA668A11D02836C00EE57A8 /* EbayWebServiceManager.swift in Sources */,
3EF422B21D73262000B9A3EB /* UserCell.swift in Sources */,
3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */,
3E1B1F0B1D2493EE00DBCF08 /* EtsySettingsViewController.swift in Sources */,
3EC325231CF7DA5500626C48 /* HomeViewController.swift in Sources */,
+ 3EE734E61DCD34AE00F771AE /* NotificationsViewController.swift in Sources */,
3EC3252D1CF894C400626C48 /* ItemImagePickerViewController.swift in Sources */,
3E1DC3CD1D4232490091BC60 /* CategoriesTableViewController.swift in Sources */,
3E7CF4011CF6366300F486B2 /* EtsyRESTAPIManager.swift in Sources */,
diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate
index 456e6b2..6518c2a 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
new file mode 100644
index 0000000..eb86d1b
--- /dev/null
+++ b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -0,0 +1,786 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Vendoo/.DS_Store b/Vendoo/.DS_Store
index 851e8ae..2f7f955 100644
Binary files a/Vendoo/.DS_Store and b/Vendoo/.DS_Store differ
diff --git a/Vendoo/AppDelegate.swift b/Vendoo/AppDelegate.swift
index cf9c9cc..a38a8a6 100644
--- a/Vendoo/AppDelegate.swift
+++ b/Vendoo/AppDelegate.swift
@@ -19,11 +19,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
- // Override point for customization after application launch.
//configures firebase for app use
FIRApp.configure()
+ // Override point for customization after application launch.
+ self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
+
+ let storyboard = UIStoryboard(name: "Main", bundle: nil)
+ let view: UIViewController!
+ if NSUserDefaults.standardUserDefaults().boolForKey("signedIn"){
+ view = storyboard.instantiateViewControllerWithIdentifier("SignInViewController")
+ }else {
+ view = storyboard.instantiateViewControllerWithIdentifier("SignUp")
+ }
+
+
+ self.window?.rootViewController = view
+ self.window?.makeKeyAndVisible()
+
//configure facebook for app
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
diff --git a/Vendoo/EbayWebServiceManager.swift b/Vendoo/EbayWebServiceManager.swift
index 81d10dd..1458763 100644
--- a/Vendoo/EbayWebServiceManager.swift
+++ b/Vendoo/EbayWebServiceManager.swift
@@ -41,6 +41,9 @@ class EbayWebServiceManager: NSObject {
private var isGettingSubCategories: Bool = false
private var isRevisingListing: Bool = false
private var requestGroup: dispatch_group_t = dispatch_group_create()
+ var isGettingNotification: Bool = false
+ private var qtySold: Int!
+ private var currItemQuantity: Int!
//---------------------------------------------//
@@ -346,6 +349,27 @@ extension EbayWebServiceManager {
self.catDetailLevel = detailLevel
self.requestMaker(soapMessage, theRequest: theRequest)
}
+
+ func getListingInfo(listingID: String, onComplete: ServiceResponse?){
+ var soapMessage = "" +
+ "" +
+ "" +
+ "\(self.xmlResponseDictionary["eBayAuthToken"] as! String)" +
+ ""
+
+ soapMessage = soapMessage +
+ "\(listingID)" +
+ ""
+
+ let url = NSURL(string: self.baseURL)
+ let theRequest = NSMutableURLRequest(URL: url!)
+ theRequest.addValue("GetItem", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
+
+ self.completion = onComplete
+ self.isGettingNotification = true
+ self.requestMaker(soapMessage, theRequest: theRequest)
+
+ }
}
extension EbayWebServiceManager: NSURLConnectionDelegate {
@@ -471,21 +495,23 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
self.completion(nil, nil)
break
case "UserID" :
- print(string)
- EbayWebServiceManager.settingsDictionary["userID"] = string
- NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings")
- print(self.xmlResponseDictionary["eBayAuthToken"])
- let soapmessage = "" +
- "" +
- "\(self.xmlResponseDictionary["eBayAuthToken"] as! String)" +
- "0ReturnAll1" +
- ""
-
- let url = NSURL(string: self.baseURL)
- let theRequest = NSMutableURLRequest(URL: url!)
- theRequest.addValue("GetCategories", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
- self.completion(nil, nil)
- self.requestMaker(soapmessage, theRequest: theRequest)
+ if(!self.isGettingNotification) {
+ print(string)
+ EbayWebServiceManager.settingsDictionary["userID"] = string
+ NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings")
+ print(self.xmlResponseDictionary["eBayAuthToken"])
+ let soapmessage = "" +
+ "" +
+ "\(self.xmlResponseDictionary["eBayAuthToken"] as! String)" +
+ "0ReturnAll1" +
+ ""
+
+ let url = NSURL(string: self.baseURL)
+ let theRequest = NSMutableURLRequest(URL: url!)
+ theRequest.addValue("GetCategories", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
+ self.completion(nil, nil)
+ self.requestMaker(soapmessage, theRequest: theRequest)
+ }
break
/*
Used to build both the top level categories, and subcategories on request during item listing workflow
@@ -497,9 +523,16 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
self.catLevel = string
break
case "CategoryName" :
- if(!self.isGettingSubCategories) {
- if((EbayWebServiceManager.settingsDictionary["categories"]) == nil) {
- EbayWebServiceManager.settingsDictionary["categories"] = Dictionary>()
+ if (!self.isGettingNotification) {
+ if(!self.isGettingSubCategories) {
+ if((EbayWebServiceManager.settingsDictionary["categories"]) == nil) {
+ EbayWebServiceManager.settingsDictionary["categories"] = Dictionary>()
+ }
+ var dict: Dictionary> = (EbayWebServiceManager.settingsDictionary["categories"]!) as! Dictionary>
+
+ dict[string] = ["cat_id": self.catID, "isLeaf": false, "level": self.catLevel]
+ EbayWebServiceManager.settingsDictionary["categories"] = dict
+ NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings")
}
var dict: Dictionary> = (EbayWebServiceManager.settingsDictionary["categories"]!) as! Dictionary>
@@ -509,16 +542,17 @@ 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
+
break
case "LeafCategory":
@@ -547,13 +581,38 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
Used during the listing creation process to save the new listing id, as well as adding pictures to the new listing
*/
case "ItemID":
- self.completion(string, nil)
+ if (!self.isGettingNotification) {
+ self.completion(string, nil)
+ }
break
case "ReviseItemResponse":
self.isRevisingListing = true
break
+ /*
+ Used for retrieving listing info for notifications
+ */
+ case "Quantity":
+ if self.isGettingNotification {
+ print("Quantity: \(string)")
+ self.currItemQuantity = Int(string)
+ }
+ break
+ case "QuantitySold":
+ if self.isGettingNotification {
+ print("QuantitySold: \(string)")
+ self.qtySold = Int(string)
+ }
+ break
+ case "ListingStatus":
+ if self.isGettingNotification {
+ print("ListingStatus: \(string)")
+ self.completion(["status":string, "quantitySold": self.qtySold, "itemQuantity": self.currItemQuantity], nil)
+ self.qtySold = nil
+ self.currItemQuantity = nil
+ }
+ break
default:
//print(string)
print("\(self.currentElementName):\(string)")
diff --git a/Vendoo/EtsyRESTAPIManager.swift b/Vendoo/EtsyRESTAPIManager.swift
index d9e1204..e36346e 100644
--- a/Vendoo/EtsyRESTAPIManager.swift
+++ b/Vendoo/EtsyRESTAPIManager.swift
@@ -608,6 +608,28 @@ extension EtsyRESTAPIManager {
)
}
+ //gets listing info
+ func getListingInfo (request: String, onCompletion: ServiceResponse?) {
+ self.oauthswift.client.get(self.baseURL + request,
+ success: {
+ (data, response) -> Void in
+ let dataString = NSString(data: data, encoding: NSUTF8StringEncoding)
+ let dict = self.convertStringToDictionary(dataString! as String)
+ print(dict)
+ print(response)
+ var dict2 = (dict!["results"] as! [[String : AnyObject]])
+
+ let listingState = dict2[0]["state"] as! String
+
+ onCompletion!(["status":listingState], nil)
+
+
+ }, failure: {
+ (error) -> Void in
+ print(error)
+ }
+ )}
+
//sends the pregenerated url as a request to api service
func sendPOSTRequest(request: String, var body: [String: AnyObject]?, onCompletion: ServiceResponse?) {
diff --git a/Vendoo/FacebookGraphAPIManager.swift b/Vendoo/FacebookGraphAPIManager.swift
index d86b931..2948775 100644
--- a/Vendoo/FacebookGraphAPIManager.swift
+++ b/Vendoo/FacebookGraphAPIManager.swift
@@ -238,4 +238,18 @@ extension FacebookGraphAPIManager {
return boolResult
}
+ func getListingInfo(requestPath: String!, onCompletion: ServiceResponse!){
+ let graphRequest:FBSDKGraphRequest = FBSDKGraphRequest(graphPath: requestPath, parameters: nil, HTTPMethod: "GET")
+ dispatch_async(dispatch_get_main_queue(), {
+ graphRequest.startWithCompletionHandler({
+ (id, result, error) -> Void in
+ if error == nil {
+ onCompletion((result as! [String : AnyObject])["data"] as! [[String:AnyObject]],nil)
+ }
+
+
+ })
+ })
+ }
+
}
diff --git a/Vendoo/HomeViewController.swift b/Vendoo/HomeViewController.swift
index f82bba5..a1326c5 100644
--- a/Vendoo/HomeViewController.swift
+++ b/Vendoo/HomeViewController.swift
@@ -16,11 +16,16 @@ 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]))
override func viewDidLoad() {
super.viewDidLoad()
-
+ ServiceNotificationManager.delegate = self
+ self.notificationsManager.setManagers(fbGraphManager, fireManager: firebaseManager, ebayManager: ebayGraphManager, etsyManager: etsyManager)
// Do any additional setup after loading the view.
dispatch_async(dispatch_get_main_queue(), {
@@ -32,14 +37,27 @@ class HomeViewController: UITabBarController {
let listingDict = userDict!["user_Listings"] as? [String : AnyObject]
+ //sync notifications
+ /*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)
+ }
+ }
+
+ NSUserDefaults.standardUserDefaults().setObject(self.notifications, forKey: "notifications")
+ }*/
+
NSUserDefaults.standardUserDefaults().setObject(userDict!["name"] as? String, forKey: "name")
if listingDict != nil {
+ var notificationStartTracker = 0
dispatch_async(dispatch_get_main_queue(), {
-
-
+ //let notificationStartGroup = dispatch_group_create()
for (key, values) in listingDict! {
let serviceGroup: dispatch_group_t = dispatch_group_create()
+ //dispatch_group_enter(notificationStartGroup)
self.firebaseManager.ref.observeSingleEventOfType(.Value, withBlock: { snapshot in
let databaseDict = snapshot.value as! [String : AnyObject]
@@ -54,6 +72,7 @@ class HomeViewController: UITabBarController {
if(error != nil){
print("problem retrieving items")
+ notificationStartTracker += 1
}else{
let mainImage = UIImage(data: dataMain!)
@@ -74,6 +93,9 @@ class HomeViewController: UITabBarController {
count+=1
if(count == 4){
dispatch_group_leave(serviceGroup)
+ notificationStartTracker += 1
+ //dispatch_group_enter(notificationStartGroup)
+ //dispatch_group_leave(notificationStartGroup)
}
})
@@ -83,20 +105,58 @@ 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)!
- ))
- NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil)
+ 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)
+ self.notificationsManager.setListings(self.userListings)
+ self.notificationsManager.startServicePolling()
+ }
+
+
+
})
+
@@ -108,6 +168,11 @@ class HomeViewController: UITabBarController {
}
+ /*
+ dispatch_group_notify(notificationStartGroup, dispatch_get_main_queue(), {
+
+
+ })*/
@@ -139,3 +204,239 @@ class HomeViewController: UITabBarController {
}
+
+
+extension HomeViewController: ServiceNotificationManagerDelegate {
+ func listingHasFinishedRetrievingNotifications() {
+ NSUserDefaults.standardUserDefaults().setObject(self.notifications, forKey: "notifications")
+ }
+
+ func listingHasStartedRetrievingNotifications() {
+
+ }
+
+ func listingHasEnded(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?) {
+ var notificationArray: [[String: AnyObject]] = self.notifications
+
+ if (fbInfo != nil) {
+ notificationArray.append(
+ [
+ "network": "facebook",
+ "message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
+ "type": "ended",
+ "seen":false,
+ "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
+ "UUID": NSUUID().UUIDString
+ ]
+ )
+ }
+
+ if (ebayInfo != nil) {
+ let notification = [
+ "network": "ebay",
+ "message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
+ "type": (ebayInfo as! [String : AnyObject])["type"] as! String,
+ "seen":false,
+ "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
+ "UUID": NSUUID().UUIDString
+ ]
+
+ notificationArray.append(
+ notification as! [String : AnyObject]
+ )
+ 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()
+ })*/
+
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: {
+ (snapshot) -> Void in
+
+ var userDict = snapshot.value as? [String : AnyObject]
+ var notifications = userDict!["notifications"] as? [String: AnyObject]
+
+ if notifications == nil {
+ userDict!["notifications"] = [((ebayInfo as! [String : AnyObject])["listingKey"] as! String):notification]
+ }else {
+ notifications![((ebayInfo as! [String : AnyObject])["listingKey"] as! String)] = notification
+ userDict!["notifications"] = notifications
+ }
+
+ var listings = userDict!["user_Listings"] as! [String: AnyObject]
+ var listingDict = (listings[((ebayInfo as! [String : AnyObject])["listingKey"] as! String)] as! [String : AnyObject])
+ listingDict["listingStatus"] = "Ended"
+
+ //save everything back to their respective dictionaries
+ listings[((ebayInfo as! [String : AnyObject])["listingKey"] as! String)] = listingDict
+ userDict!["user_Listings"] = listings
+
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").setValue(userDict, withCompletionBlock: {
+ (error, reference) -> Void in
+
+ if error == nil {
+ //reload data for notifications
+ NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications")
+ itemsView.itemTable.reloadData()
+ }
+ })
+
+ })
+
+ }
+
+ if (amazonInfo != nil) {
+ notificationArray.append(
+ [
+ "network": "amazon",
+ "message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
+ "type": (ebayInfo as! [String : AnyObject])["type"] as! String,
+ "seen":false,
+ "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
+ "UUID": NSUUID().UUIDString
+ ]
+ )
+ }
+
+ if (etsyInfo != nil) {
+ let notification = [
+ "network": "etsy",
+ "message": (etsyInfo as! [String : AnyObject])["notification"] as! String,
+ "type": "ended",
+ "seen":false,
+ "key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String,
+ "UUID": NSUUID().UUIDString
+ ]
+ notificationArray.append(
+ notification as! [String : AnyObject]
+ )
+ self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)}))
+ self.userListings = self.userListings.filter({$0.key != ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)})
+ let itemsView = self.viewControllers![0] as! ItemTableViewController
+
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: {
+ (snapshot) -> Void in
+
+ var userDict = snapshot.value as? [String : AnyObject]
+ var notifications = userDict!["notifications"] as? [String: AnyObject]
+
+ if notifications == nil {
+ userDict!["notifications"] = [((etsyInfo as! [String : AnyObject])["listingKey"] as! String):notification]
+ }else {
+ notifications![((etsyInfo as! [String : AnyObject])["listingKey"] as! String)] = notification
+ userDict!["notifications"] = notifications
+ }
+
+ var listings = userDict!["user_Listings"] as! [String: AnyObject]
+ var listingDict = (listings[((etsyInfo as! [String : AnyObject])["listingKey"] as! String)] as! [String : AnyObject])
+ listingDict["listingStatus"] = "Ended"
+
+ //save everything back to their respective dictionaries
+ listings[((etsyInfo as! [String : AnyObject])["listingKey"] as! String)] = listingDict
+ userDict!["user_Listings"] = listings
+
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").setValue(userDict, withCompletionBlock: {
+ (error, reference) -> Void in
+
+ if error == nil {
+ //reload data for notifications
+ NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications")
+ itemsView.itemTable.reloadData()
+ }
+ })
+
+ })
+ }
+
+ }
+
+ func listingHasNewNotifications(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?) {
+
+ var notificationArray: [Dictionary] = self.notifications
+
+ if (fbInfo != nil) {
+ notificationArray.append(fbInfo as! [String : AnyObject])
+
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType(.Value, withBlock: {
+ (snapshot) -> Void in
+
+ var userDict = snapshot.value as? [String : AnyObject]
+
+ if (userDict!["notifications"] != nil) {
+ var notificationsFir = userDict!["notifications"] as! [String : AnyObject]
+ notificationsFir[fbInfo!["UUID"] as! String] = fbInfo
+
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/notifications").setValue(notificationsFir, withCompletionBlock: {
+ (error, reference) -> Void in
+
+ if error == nil {
+ NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications")
+ }
+
+ })
+ }else {
+ let id = (fbInfo!["UUID"] as! String)
+ print(id)
+ userDict!["notifications"] = ([ id : fbInfo as! [String:AnyObject]])
+ self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").setValue(userDict, withCompletionBlock: {
+ (error, reference) -> Void in
+
+ if error == nil {
+ NSUserDefaults.standardUserDefaults().setObject(notificationArray, forKey: "notifications")
+ }
+ })
+ }
+ })
+
+
+ }
+
+ if (ebayInfo != nil) {
+ notificationArray.append(
+ [
+ "network": "ebay",
+ "message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
+ "type": (ebayInfo as! [String : AnyObject])["type"] as! String,
+ "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
+ "UUID": NSUUID().UUIDString
+ ]
+ )
+ }
+
+ if (amazonInfo != nil) {
+ notificationArray.append(
+ [
+ "network": "amazon",
+ "message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
+ "type": "",
+ "key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
+ "UUID": NSUUID().UUIDString
+ ]
+ )
+ }
+
+ if (etsyInfo != nil) {
+ notificationArray.append(
+ [
+ "network": "etsy",
+ "message": (etsyInfo as! [String : AnyObject])["notification"] as! String,
+ "type": (etsyInfo as! [String : AnyObject])["type"] as! String,
+ "key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String,
+ "UUID": NSUUID().UUIDString
+ ]
+ )
+ }
+
+ //@TODO: add firbase logic to add notifications and delete already viewed notifications
+ //reload data for notifications
+
+ }
+}
diff --git a/Vendoo/ItemImagePickerViewController.swift b/Vendoo/ItemImagePickerViewController.swift
index 61863ab..bee776f 100644
--- a/Vendoo/ItemImagePickerViewController.swift
+++ b/Vendoo/ItemImagePickerViewController.swift
@@ -45,6 +45,8 @@ class ItemImagePickerViewController: UIViewController {
private var imageIndex: Int!
private var isEditing: Bool = false
private var currentInformation: Dictionary!
+
+
override func viewDidLoad() {
super.viewDidLoad()
@@ -292,7 +294,7 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi
(alert: UIAlertAction!) -> Void in
})
- let cameraAction = UIAlertAction(title: "Take a New Pic", style: .Default, handler: {
+ let cameraAction = UIAlertAction(title: "Take a New Item Picture", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
self.picker.allowsEditing = false
self.picker.sourceType = UIImagePickerControllerSourceType.Camera
@@ -301,7 +303,7 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi
})
- let galleryAction = UIAlertAction(title: "Select a Profile Pic", style: .Default, handler: {
+ let galleryAction = UIAlertAction(title: "Select a Picture for Your Item", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
self.picker.allowsEditing = false
self.picker.sourceType = .PhotoLibrary
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/Listing.swift b/Vendoo/Listing.swift
index a0373b0..76ec5cc 100644
--- a/Vendoo/Listing.swift
+++ b/Vendoo/Listing.swift
@@ -20,6 +20,7 @@ class Listing : NSObject {
var images: [UIImage]!
var key: String!
var networks: Dictionary!
+ var listingStatus: String!
init(itemTitle:String, itemCategory: String!, itemQuantity: String!, itemPrice: String!, itemDescription: String!, itemImages: [UIImage], isDraftListing: Bool, itemKey: String, networksSellingOn: Dictionary){
diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard
index 88d4ab6..b105bf2 100755
--- a/Vendoo/Main.storyboard
+++ b/Vendoo/Main.storyboard
@@ -157,7 +157,7 @@
-
+
@@ -491,7 +491,7 @@
-
+
@@ -515,6 +515,9 @@
+
+
+
@@ -526,7 +529,7 @@
-
+
@@ -550,6 +553,9 @@
+
+
+
@@ -561,7 +567,7 @@
-
+
@@ -585,6 +591,9 @@
+
+
+
@@ -596,7 +605,7 @@
-
+
@@ -620,6 +629,9 @@
+
+
+
@@ -631,7 +643,7 @@
-
+