diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate index 9c60f35..e80f2b6 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 7f6a5e8..4ee939a 100644 --- a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -10,43 +10,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/ItemTableViewController.swift" - timestampString = "502130300.686017" + timestampString = "504912890.797569" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "217" - endingLineNumber = "217" - landmarkName = "tableView(_:cellForRowAtIndexPath:)" - landmarkType = "5"> - - - - - - - - @@ -70,16 +38,16 @@ @@ -312,7 +280,7 @@ moduleName = "Vendoo" usesParentBreakpointCondition = "Yes" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ExternalWebViewController.swift" - timestampString = "504766122.581369" + timestampString = "504912892.065671" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "32" @@ -327,7 +295,7 @@ moduleName = "Vendoo" usesParentBreakpointCondition = "Yes" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ExternalWebViewController.swift" - timestampString = "504766122.581543" + timestampString = "504912892.065782" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "32" @@ -342,7 +310,7 @@ moduleName = "Vendoo" usesParentBreakpointCondition = "Yes" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ExternalWebViewController.swift" - timestampString = "504766122.581743" + timestampString = "504912892.065878" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "32" @@ -357,7 +325,7 @@ moduleName = "Vendoo" usesParentBreakpointCondition = "Yes" urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/ExternalWebViewController.swift" - timestampString = "504766122.58194" + timestampString = "504912892.06597" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "32" @@ -383,5 +351,53 @@ landmarkType = "5"> + + + + + + + + + + + + diff --git a/Vendoo/ItemTableViewController.swift b/Vendoo/ItemTableViewController.swift index 192efa7..56ed247 100644 --- a/Vendoo/ItemTableViewController.swift +++ b/Vendoo/ItemTableViewController.swift @@ -21,6 +21,9 @@ class ItemTableViewController: UIViewController { @IBOutlet weak var menuButton: UIBarButtonItem! + @IBOutlet weak var historyFilter: UISegmentedControl! + + var loadingView: UIView! var selectedListing: Listing! override func viewDidLoad() { @@ -63,6 +66,7 @@ class ItemTableViewController: UIViewController { super.viewWillAppear(animated) (menuButton.target as! SWRevealViewController).delegate = self self.tabBarController?.tabBar.hidden = false + } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() @@ -85,9 +89,27 @@ class ItemTableViewController: UIViewController { // MARK: - IBAction extension ItemTableViewController { - @IBAction func segSwitch(sender: UISegmentedControl) { + @IBAction func activeHistorSegSwitch(sender: UISegmentedControl) { + self.itemTable.reloadData() + //History Segement + if(self.tableSegmentController.selectedSegmentIndex == 1){ + self.historyFilter.enabled = true + self.historyFilter.userInteractionEnabled = true + self.historyFilter.hidden = false + + //Active segment + }else{ + self.historyFilter.selectedSegmentIndex = UISegmentedControlNoSegment + self.historyFilter.enabled = false + self.historyFilter.userInteractionEnabled = false + self.historyFilter.hidden = true + } + } + + @IBAction func historyFilterSegSwitch(sender: UISegmentedControl) { self.itemTable.reloadData() } + } // MARK: - Side Menu View @@ -167,27 +189,83 @@ extension ItemTableViewController { // MARK: - TableView Datasource methods extension ItemTableViewController: UITableViewDataSource{ + + func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + + //if in the history segment + if(self.tableSegmentController.selectedSegmentIndex == 1){ + //hides title of unsold section if Sold filter selected + if(self.historyFilter.selectedSegmentIndex == 0){ + if(section == 1){ + return 0.0 + }else{ + return self.itemTable.sectionHeaderHeight + } + + //hides title of sold section if Unsold filter selected + }else if(self.historyFilter.selectedSegmentIndex == 1){ + if(section == 0){ + return 0.0 + }else{ + return self.itemTable.sectionHeaderHeight + } + + //Shows both section titles + }else{ + return self.itemTable.sectionHeaderHeight + } + }else{ + return self.itemTable.sectionHeaderHeight + } + } + func numberOfSectionsInTableView(tableView: UITableView) -> Int { - // #warning Incomplete implementation, return the number of sections - return 1 + //number of sections for active segment + if self.tableSegmentController.selectedSegmentIndex == 0 { + return 1 + } + else { + return 2 + } } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - // #warning Incomplete implementation, return the number of rows + //if in the active segment 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)! + + //if in the history segment + else { + //hides unsold section cells if Sold filter selected + if(self.historyFilter.selectedSegmentIndex == 0){ + if(section == 1){ + return 0 + }else{ + return ((self.tabBarController as? HomeViewController)?.soldListings.count)! + } + //hides sold section cells if Unsold filter selected + }else if(self.historyFilter.selectedSegmentIndex == 1){ + if(section == 0){ + return 0 + }else{ + return ((self.tabBarController as? HomeViewController)?.endedListings.count)! + } + }else{ + //shows both respective sections cells + if(section == 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) @@ -195,6 +273,7 @@ extension ItemTableViewController: UITableViewDataSource{ //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 + //Active and unpublished listings 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 @@ -220,20 +299,16 @@ extension ItemTableViewController: UITableViewDataSource{ 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 cell.addNetwork("ebay_icon") } 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 cell.addNetwork("etsy_icon") } 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() @@ -243,92 +318,113 @@ extension ItemTableViewController: UITableViewDataSource{ } } - 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 + + //Sold and Unsold Listings + else { - cell.itemStatus.text = "Status: Unsold" + //unsold listings section + if indexPath.section == 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 - if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["areNetworksChosen"])!){ - cell.networks.hidden = true + cell.itemStatus.text = "Status: Unsold" + + 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.addNetwork("ebay_icon") + } + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["amazon"])!){ + cell.addNetwork("amazon_icon") + } + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["etsy"])!){ + cell.addNetwork("etsy_icon") + + } + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["facebook"])!){ + cell.addNetwork("facebook_icon") + } + cell.networks.reloadData() + }) + + } + + //section for sold listings }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 - cell.addNetwork("ebay_icon") - } - 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 - cell.addNetwork("etsy_icon") - - } - 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() - }) + cell.itemImage.image = (self.tabBarController as? HomeViewController)?.soldListings[indexPath.row].images[0] + 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{ + cell.selectedNetworks = [] + dispatch_async(dispatch_get_main_queue(), { + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["ebay"])!){ + cell.addNetwork("ebay_icon") + } + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["amazon"])!){ + cell.addNetwork("amazon_icon") + } + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["etsy"])!){ + cell.addNetwork("etsy_icon") + + } + if(((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["facebook"])!){ + cell.addNetwork("facebook_icon") + } + cell.networks.reloadData() + }) + + } } + + } - 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{ - 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 - cell.addNetwork("ebay_icon") - } - 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 - cell.addNetwork("etsy_icon") - - } - 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() - }) - - } - } return cell } func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + + //view listing that is active or draft 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] - } + + //view listing that is sold or unsold else{ - self.selectedListing = (self.tabBarController as? HomeViewController)?.soldListings[indexPath.row] + //unsold + if(indexPath.section == 1){ + self.selectedListing = (self.tabBarController as? HomeViewController)?.endedListings[indexPath.row] + //sold + }else{ + self.selectedListing = (self.tabBarController as? HomeViewController)?.soldListings[indexPath.row] + } + } self.performSegueWithIdentifier("ItemDetailSegue", sender: self) } + + func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + if(self.tableSegmentController.selectedSegmentIndex == 1){ + if(section == 1){ + return "Unsold" + }else{ + return "Sold" + } + }else{ + return nil + } + } } diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard index d1a54d2..ab1395e 100755 --- a/Vendoo/Main.storyboard +++ b/Vendoo/Main.storyboard @@ -1194,22 +1194,22 @@ - - - + + - + + - + @@ -1292,6 +1292,17 @@ + @@ -1302,6 +1313,7 @@ + @@ -1570,7 +1582,7 @@ - + @@ -1701,7 +1713,7 @@ - + @@ -1718,7 +1730,7 @@ - + @@ -2476,12 +2488,12 @@ - +