History Segment and Sold and Unsold filter implemented

This commit is contained in:
Okechi Onyeje 2016-12-31 16:49:05 -05:00
parent 88e2de116f
commit 986e20407b
4 changed files with 257 additions and 133 deletions

View File

@ -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">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "502130607.978907"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "253"
endingLineNumber = "253"
landmarkName = "tableView(_:cellForRowAtIndexPath:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "502130713.514106"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "258"
endingLineNumber = "258"
startingLineNumber = "281"
endingLineNumber = "281"
landmarkName = "tableView(_:cellForRowAtIndexPath:)"
landmarkType = "5">
</BreakpointContent>
@ -70,16 +38,16 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "504755002.558106"
timestampString = "504910196.477146"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "88"
endingLineNumber = "88"
landmarkName = "segSwitch(_:)"
startingLineNumber = "92"
endingLineNumber = "92"
landmarkName = "activeHistorSegSwitch(_:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
@ -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">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "504912890.797569"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "224"
endingLineNumber = "224"
landmarkName = "tableView(_:numberOfRowsInSection:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "504912890.797569"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "409"
endingLineNumber = "409"
landmarkName = "tableView(_:titleForHeaderInSection:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/ItemTableViewController.swift"
timestampString = "504912890.797569"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "410"
endingLineNumber = "410"
landmarkName = "tableView(_:titleForHeaderInSection:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -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,22 +189,78 @@ 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
//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 {
//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{
}else{
//shows both respective sections cells
if(section == 1){
return ((self.tabBarController as? HomeViewController)?.endedListings.count)!
}else{
return ((self.tabBarController as? HomeViewController)?.soldListings.count)!
}
}
}
}
@ -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,7 +318,12 @@ extension ItemTableViewController: UITableViewDataSource{
}
}
else if tableSegmentController.selectedSegmentIndex == 1 {
//Sold and Unsold Listings
else {
//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
@ -256,20 +336,16 @@ extension ItemTableViewController: UITableViewDataSource{
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()
@ -277,9 +353,9 @@ extension ItemTableViewController: UITableViewDataSource{
}
}
else{
cell.itemImage.image = (self.tabBarController as? HomeViewController)?.soldListings[indexPath.row].images[0] //come back
//section for sold listings
}else{
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
@ -291,20 +367,16 @@ extension ItemTableViewController: UITableViewDataSource{
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()
@ -314,21 +386,45 @@ extension ItemTableViewController: UITableViewDataSource{
}
}
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{
//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
}
}
}

View File

@ -1194,22 +1194,22 @@
<rect key="frame" x="0.0" y="44" width="375" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="Selling"/>
<segment title="Unsold"/>
<segment title="Sold"/>
<segment title="Active"/>
<segment title="History"/>
</segments>
<color key="tintColor" red="0.2784313725" green="0.80392156859999997" blue="0.68235294120000001" alpha="1" colorSpace="calibratedRGB"/>
<connections>
<action selector="segSwitch:" destination="Iwh-sn-a0Q" eventType="valueChanged" id="YfI-EH-qgs"/>
<action selector="activeHistorSegSwitch:" destination="Iwh-sn-a0Q" eventType="valueChanged" id="Ejr-V9-nMo"/>
</connections>
</segmentedControl>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="123" sectionHeaderHeight="1" sectionFooterHeight="28" id="Thg-pb-lhN">
<rect key="frame" x="0.0" y="80" width="375" height="535"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<inset key="contentInset" minX="0.0" minY="10" maxX="0.0" maxY="0.0"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Item Cell" rowHeight="123" id="zmO-fi-nTP" customClass="ItemCell" customModule="Vendoo" customModuleProvider="target">
<rect key="frame" x="0.0" y="1" width="375" height="123"/>
<rect key="frame" x="0.0" y="11" width="375" height="123"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="zmO-fi-nTP" id="CoK-hy-32b">
<rect key="frame" x="0.0" y="0.0" width="375" height="122.5"/>
@ -1292,6 +1292,17 @@
</tableViewCell>
</prototypes>
</tableView>
<segmentedControl hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" id="hyA-UD-JyK">
<rect key="frame" x="127" y="73" width="121" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="Sold"/>
<segment title="Unsold"/>
</segments>
<connections>
<action selector="historyFilterSegSwitch:" destination="Iwh-sn-a0Q" eventType="valueChanged" id="hlT-aZ-WSw"/>
</connections>
</segmentedControl>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
@ -1302,6 +1313,7 @@
<nil key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina47"/>
<connections>
<outlet property="historyFilter" destination="hyA-UD-JyK" id="ey9-bb-et0"/>
<outlet property="itemTable" destination="Thg-pb-lhN" id="u15-xE-hz6"/>
<outlet property="menuButton" destination="WjT-mo-4jm" id="1CT-vV-KLK"/>
<outlet property="tableSegmentController" destination="X2D-np-ma4" id="DbB-DF-wEF"/>
@ -1570,7 +1582,7 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="notification_cell" rowHeight="69" id="9G8-XI-ptI" customClass="NotificationTableViewCell" customModule="Vendoo" customModuleProvider="target">
<rect key="frame" x="0.0" y="72" width="375" height="69"/>
<rect key="frame" x="0.0" y="28" width="375" height="69"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="9G8-XI-ptI" id="r3f-6Q-p1g">
<rect key="frame" x="0.0" y="0.0" width="375" height="68.5"/>
@ -1701,7 +1713,7 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Change_Pass_Cell" id="ceq-sl-ClT">
<rect key="frame" x="0.0" y="72" width="375" height="44"/>
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ceq-sl-ClT" id="Waq-fu-UxD">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
@ -1718,7 +1730,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Delete_Account_Cell" id="Lha-cf-Sfc">
<rect key="frame" x="0.0" y="116" width="375" height="44"/>
<rect key="frame" x="0.0" y="72" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Lha-cf-Sfc" id="kmF-Sb-d0c">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
@ -2476,12 +2488,12 @@
<image name="start" width="50" height="50"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="NOz-ya-avj"/>
<segue reference="syc-IR-LNQ"/>
<segue reference="Ds4-LY-IRj"/>
<segue reference="Gnt-iE-cW9"/>
<segue reference="eaI-bm-1aI"/>
<segue reference="nUj-1v-ftF"/>
<segue reference="NOz-ya-avj"/>
<segue reference="qb4-wt-avv"/>
</inferredMetricsTieBreakers>
<color key="tintColor" red="0.2784313725" green="0.80392156859999997" blue="0.68235294120000001" alpha="1" colorSpace="calibratedRGB"/>