diff --git a/Vendoo.xcodeproj/project.pbxproj b/Vendoo.xcodeproj/project.pbxproj index e5b1b72..5f0cc46 100644 --- a/Vendoo.xcodeproj/project.pbxproj +++ b/Vendoo.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ 3E7CF4011CF6366300F486B2 /* EtsyRESTAPIManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E7CF4001CF6366300F486B2 /* EtsyRESTAPIManager.swift */; }; 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 */; }; 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 */; }; @@ -99,6 +100,7 @@ 3EA668A01D02836C00EE57A8 /* EbayWebServiceManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EbayWebServiceManager.swift; sourceTree = ""; }; 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 = ""; }; 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 = ""; }; @@ -288,6 +290,7 @@ 3EC325101CF703A600626C48 /* ItemCell.swift */, 3EC325141CF7104300626C48 /* ItemTableViewController.swift */, 3E0F76FB1D01B2D7004A0159 /* Listing.swift */, + 3EB54E0D1DE08A2E006D918B /* NetworkCollectionViewCell.swift */, ); name = Items; sourceTree = ""; @@ -763,6 +766,7 @@ 3E1AA4321D0DA071005FCCBB /* MenuPanelViewController.swift in Sources */, 3E4897D11D0067030069F742 /* FirebaseManager.swift in Sources */, 3E1AA4351D0DD173005FCCBB /* SettingsViewController.swift in Sources */, + 3EB54E0E1DE08A2E006D918B /* NetworkCollectionViewCell.swift in Sources */, 3E0F76FC1D01B2D7004A0159 /* Listing.swift in Sources */, 3E6CC3571CF2A94B00E00A70 /* AppDelegate.swift in Sources */, 3EC3251E1CF734C100626C48 /* NetworksTableViewController.swift in Sources */, diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate index 64d589c..25d4c59 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 9f2bbcc..c21c729 100644 --- a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -10,11 +10,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/ListingPreviewViewController.swift" - timestampString = "500766163.891715" + timestampString = "501292645.293697" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "611" - endingLineNumber = "611" + startingLineNumber = "617" + endingLineNumber = "617" landmarkName = "publishItem(_:)" landmarkType = "5"> @@ -186,7 +186,7 @@ moduleName = "Vendoo" usesParentBreakpointCondition = "Yes" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift" - timestampString = "500945316.10311" + timestampString = "501291173.047822" 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 = "500945316.10327" + timestampString = "501291173.047982" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "572" @@ -543,6 +543,53 @@ endingLineNumber = "625" landmarkName = "getListingInfo(_:onCompletion:)" landmarkType = "5"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vendoo/ItemCell.swift b/Vendoo/ItemCell.swift index fa7759f..ad23d4c 100644 --- a/Vendoo/ItemCell.swift +++ b/Vendoo/ItemCell.swift @@ -20,6 +20,7 @@ class ItemCell: UITableViewCell, UICollectionViewDelegate { @IBOutlet weak var itemStatus: UILabel! @IBOutlet weak var itemPrice: UILabel! @IBOutlet weak var networks: UICollectionView! + var selectedNetworks: [String] = [] override func awakeFromNib() { @@ -36,6 +37,10 @@ class ItemCell: UITableViewCell, UICollectionViewDelegate { // Configure the view for the selected state } + func addNetwork(network: String){ + self.selectedNetworks.append(network) + } + } @@ -51,14 +56,14 @@ extension ItemCell: UICollectionViewDataSource{ func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { // #warning Incomplete implementation, return the number of items - return 4 + return selectedNetworks.count } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { - let cell: UICollectionViewCell! - - switch (indexPath.row){ + let cell: NetworkCollectionViewCell! = self.networks.dequeueReusableCellWithReuseIdentifier("network", forIndexPath: indexPath) as! NetworkCollectionViewCell + cell.setImg(selectedNetworks[indexPath.row]) + /*switch (indexPath.row){ case 0: cell = collectionView.dequeueReusableCellWithReuseIdentifier("ebay", forIndexPath: indexPath) break @@ -71,7 +76,7 @@ extension ItemCell: UICollectionViewDataSource{ default: cell = collectionView.dequeueReusableCellWithReuseIdentifier("facebook", forIndexPath: indexPath) break - } + }*/ // Configure the cell (in this case show or hide the cell depending on which network the item is being listed on) diff --git a/Vendoo/ItemTableViewController.swift b/Vendoo/ItemTableViewController.swift index ff66e52..7dae7af 100644 --- a/Vendoo/ItemTableViewController.swift +++ b/Vendoo/ItemTableViewController.swift @@ -178,20 +178,26 @@ extension ItemTableViewController: UITableViewDataSource{ if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["areNetworksChosen"])!){ cell.networks.hidden = true }else{ + cell.selectedNetworks = [] 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["ebay"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true + cell.addNetwork("ebay_icon") } - 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["amazon"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true + cell.addNetwork("amazon_icon") } - 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["etsy"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true + cell.addNetwork("etsy_icon") } - if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["facebook"])!){ - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true + if(((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["facebook"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true + cell.addNetwork("facebook_icon") } + cell.networks.reloadData() }) @@ -208,21 +214,26 @@ extension ItemTableViewController: UITableViewDataSource{ if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["areNetworksChosen"])!){ cell.networks.hidden = true }else{ + cell.selectedNetworks = [] 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["ebay"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true + cell.addNetwork("ebay_icon") } - 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["amazon"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true + cell.addNetwork("amazon_icon") } - 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["etsy"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true + cell.addNetwork("etsy_icon") } - if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["facebook"])!){ - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["facebook"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true + cell.addNetwork("facebook_icon") } - + cell.networks.reloadData() }) } @@ -238,21 +249,26 @@ extension ItemTableViewController: UITableViewDataSource{ if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["areNetworksChosen"])!){ cell.networks.hidden = true }else{ + cell.selectedNetworks = [] 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)!.endedListings[indexPath.row].networks["ebay"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true + cell.addNetwork("ebay_icon") } - 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)!.endedListings[indexPath.row].networks["amazon"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true + cell.addNetwork("amazon_icon") } - 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)!.endedListings[indexPath.row].networks["etsy"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true + cell.addNetwork("etsy_icon") } - if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["facebook"])!){ - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["facebook"])!){ + //cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true + cell.addNetwork("facebook_icon") } - + cell.networks.reloadData() }) } diff --git a/Vendoo/ListingPreviewViewController.swift b/Vendoo/ListingPreviewViewController.swift index eaa9ac5..6eef20b 100644 --- a/Vendoo/ListingPreviewViewController.swift +++ b/Vendoo/ListingPreviewViewController.swift @@ -49,6 +49,7 @@ class ListingPreviewViewController: UIViewController { private var newInProgressListing: Dictionary = Dictionary() var loadingView: UIView! private var itemViewState = "" + private var selectedNetworks : [String] = [] override func viewDidLoad() { super.viewDidLoad() @@ -126,6 +127,11 @@ class ListingPreviewViewController: UIViewController { func setDictionary(netdictionary:Dictionary, itemdictionary: Dictionary){ self.networksDictionary = netdictionary + for (k,v) in self.networksDictionary { + if ((k != "areNetworksChosen") && v) { + self.selectedNetworks.append("\(k)_icon") + } + } self.itemListingDictionary = itemdictionary } @@ -785,14 +791,14 @@ extension ListingPreviewViewController: UICollectionViewDataSource { func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { // #warning Incomplete implementation, return the number of items - return 4 + return self.selectedNetworks.count } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { - let cell: UICollectionViewCell! - - switch (indexPath.row){ + let cell: NetworkCollectionViewCell! = self.networks.dequeueReusableCellWithReuseIdentifier("network", forIndexPath: indexPath) as! NetworkCollectionViewCell + cell.setImg(selectedNetworks[indexPath.row]) + /*switch (indexPath.row){ case 0: cell = collectionView.dequeueReusableCellWithReuseIdentifier("ebay", forIndexPath: indexPath) @@ -834,7 +840,7 @@ extension ListingPreviewViewController: UICollectionViewDataSource { cell.hidden = false } break - } + }*/ return cell diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard index b105bf2..721f882 100755 --- a/Vendoo/Main.storyboard +++ b/Vendoo/Main.storyboard @@ -960,14 +960,14 @@ - + - + @@ -975,51 +975,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -1312,66 +1270,23 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/Vendoo/NetworkCollectionViewCell.swift b/Vendoo/NetworkCollectionViewCell.swift new file mode 100644 index 0000000..f49c042 --- /dev/null +++ b/Vendoo/NetworkCollectionViewCell.swift @@ -0,0 +1,18 @@ +// +// NetworkCollectionViewCell.swift +// Vendoo +// +// Created by Okechi Onyeje on 11/19/16. +// Copyright © 2016 Okechi Onyeje. All rights reserved. +// + +import UIKit + +class NetworkCollectionViewCell: UICollectionViewCell { + @IBOutlet weak var image: UIImageView! + + func setImg(networkIcon: String!){ + + self.image.image = UIImage(named: networkIcon) + } +}