mirror of
https://bitbucket.org/vendoo/vendoo_v1.0.git
synced 2025-12-25 11:47:40 +00:00
Merge branch 'Rapid-Dev-Branch'
Conflicts: Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This commit is contained in:
commit
495557ab84
Binary file not shown.
@ -68,23 +68,7 @@
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/CategoriesTableViewController.swift"
|
||||
timestampString = "494939719.123248"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "699"
|
||||
endingLineNumber = "699"
|
||||
landmarkName = "tableView(_:didSelectRowAtIndexPath:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/CategoriesTableViewController.swift"
|
||||
@ -100,7 +84,7 @@
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/CategoryPopUpController.swift"
|
||||
@ -116,7 +100,7 @@
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/EbayWebServiceManager.swift"
|
||||
@ -132,7 +116,7 @@
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/EbayWebServiceManager.swift"
|
||||
@ -164,7 +148,7 @@
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/EbayWebServiceManager.swift"
|
||||
@ -180,7 +164,7 @@
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/CategoryPopUpController.swift"
|
||||
@ -276,7 +260,7 @@
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/ItemTableViewController.swift"
|
||||
@ -285,7 +269,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "107"
|
||||
endingLineNumber = "107"
|
||||
landmarkName = "prepareForSegue(_:sender:)"
|
||||
landmarkName = "tableView(_:cellForRowAtIndexPath:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -301,7 +285,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "167"
|
||||
endingLineNumber = "167"
|
||||
landmarkName = "cancel(_:)"
|
||||
landmarkName = "prepareForSegue(_:sender:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -317,8 +301,8 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "51"
|
||||
endingLineNumber = "51"
|
||||
landmarkName = "viewDidLoad()"
|
||||
landmarkType = "5">
|
||||
landmarkName = "ListingPreviewViewController"
|
||||
landmarkType = "3">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
@ -333,7 +317,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "314"
|
||||
endingLineNumber = "314"
|
||||
landmarkName = "getSubCategories(_:detailLevel:catCode:onCompletion:)"
|
||||
landmarkName = "listItem(_:imageUrls:completion:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -349,7 +333,7 @@
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "315"
|
||||
endingLineNumber = "315"
|
||||
landmarkName = "getSubCategories(_:detailLevel:catCode:onCompletion:)"
|
||||
landmarkName = "listItem(_:imageUrls:completion:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -388,7 +372,7 @@
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/EbayWebServiceManager.swift"
|
||||
@ -401,5 +385,149 @@
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/CategoriesTableViewController.swift"
|
||||
timestampString = "494940975.718534"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "764"
|
||||
endingLineNumber = "764"
|
||||
landmarkName = "prepareForSegue(_:sender:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/NetworksTableViewController.swift"
|
||||
timestampString = "494941205.231227"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "77"
|
||||
endingLineNumber = "77"
|
||||
landmarkName = "toggleMarketPlaceVisibitlity(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/NetworksTableViewController.swift"
|
||||
timestampString = "494941253.143954"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "81"
|
||||
endingLineNumber = "81"
|
||||
landmarkName = "checkVisibility()"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/NetworksTableViewController.swift"
|
||||
timestampString = "494941355.780817"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "177"
|
||||
endingLineNumber = "177"
|
||||
landmarkName = "tableView(_:cellForRowAtIndexPath:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/ListingPreviewViewController.swift"
|
||||
timestampString = "494941872.191463"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "384"
|
||||
endingLineNumber = "384"
|
||||
landmarkName = "publishItem(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/ListingPreviewViewController.swift"
|
||||
timestampString = "494941981.555508"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "402"
|
||||
endingLineNumber = "402"
|
||||
landmarkName = "publishItem(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/ListingPreviewViewController.swift"
|
||||
timestampString = "494942021.796377"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "403"
|
||||
endingLineNumber = "403"
|
||||
landmarkName = "publishItem(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/ListingPreviewViewController.swift"
|
||||
timestampString = "494942034.726609"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "407"
|
||||
endingLineNumber = "407"
|
||||
landmarkName = "publishItem(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/ListingPreviewViewController.swift"
|
||||
timestampString = "494942036.742589"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "412"
|
||||
endingLineNumber = "412"
|
||||
landmarkName = "publishItem(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
||||
@ -129,6 +129,7 @@ class CategoriesTableViewController: UIViewController, UITableViewDelegate, UITa
|
||||
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
|
||||
cell.categoryName.text = self.categories[indexPath.row]
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true //facebook
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy
|
||||
@ -693,9 +694,14 @@ class CategoriesTableViewController: UIViewController, UITableViewDelegate, UITa
|
||||
}
|
||||
|
||||
let cell: CategoryCell! = tableView.cellForRowAtIndexPath(indexPath) as! CategoryCell//tableView.dequeueReusableCellWithIdentifier("CategoryCell", forIndexPath: indexPath) as? CategoryCell
|
||||
if(self.ebayManager.isAuthorized && cell.shouldAskAboutLeafCategories){
|
||||
self.potentialEbay = true
|
||||
self.navigateCategories()
|
||||
|
||||
if(self.ebayManager.isAuthorized ) {
|
||||
var dict: Dictionary<String, Dictionary<String, AnyObject>> = (EbayWebServiceManager.settingsDictionary["categories"]!) as! Dictionary<String, Dictionary<String, AnyObject>>
|
||||
let catDict = dict[self.selectedCategory]
|
||||
if (!(catDict!["isLeaf"] as! Bool)){
|
||||
self.potentialEbay = true
|
||||
self.navigateCategories()
|
||||
}
|
||||
}
|
||||
else {
|
||||
self.performSegueWithIdentifier("NetworkSelectionSegue", sender: self)
|
||||
|
||||
@ -211,8 +211,10 @@ extension EbayWebServiceManager {
|
||||
self.requestMaker(soapMessage, theRequest: theRequest)
|
||||
}
|
||||
|
||||
func addImagesToListing(listingID: String, imageURL: String, onCompletion: ServiceResponse) {
|
||||
func addImagesToListing(listingID: String, imageURLs: [String], listingOnCompletion: ServiceResponse, body: [String:String],onCompletion: ServiceResponse) {
|
||||
|
||||
listItem(body, imageUrls: imageURLs, completion: listingOnCompletion)
|
||||
/*
|
||||
var soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<ReviseItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">" +
|
||||
"<RequesterCredentials>" +
|
||||
@ -221,21 +223,26 @@ extension EbayWebServiceManager {
|
||||
|
||||
soapMessage = soapMessage + "<ErrorLanguage>en_US</ErrorLanguage>" +
|
||||
"<Item>" +
|
||||
"<ItemID>\(listingID)</ItemID>" +
|
||||
"<PictureDetails>" +
|
||||
"<PictureURL>\(imageURL.stringByReplacingOccurrencesOfString("&", withString: "&"))</PictureURL>" +
|
||||
"</PictureDetails>" +
|
||||
"</Item></ReviseItemRequest>"
|
||||
"<ItemID>\(listingID)</ItemID>"
|
||||
|
||||
for i in 0...(imageURLs.count - 1) {
|
||||
soapMessage = soapMessage + "<PictureDetails>" +
|
||||
"<PictureURL>\(imageURLs[i].stringByReplacingOccurrencesOfString("&", withString: "&"))</PictureURL>" +
|
||||
"</PictureDetails>"
|
||||
}
|
||||
|
||||
|
||||
soapMessage = soapMessage + "</Item></ReviseItemRequest>"
|
||||
|
||||
let url = NSURL(string: self.baseURL)
|
||||
let theRequest = NSMutableURLRequest(URL: url!)
|
||||
theRequest.addValue("ReviseItem", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
|
||||
self.completion = onCompletion
|
||||
self.requestMaker(soapMessage, theRequest: theRequest)
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
func listItem(params: [String: String], completion: ServiceResponse?){
|
||||
func listItem(params: [String: String], imageUrls: [String], completion: ServiceResponse?){
|
||||
var dict = EbayWebServiceManager.settingsDictionary
|
||||
var emailRetrievalGroup = dispatch_group_create()
|
||||
var soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
@ -272,8 +279,15 @@ extension EbayWebServiceManager {
|
||||
"<ListingDuration>\(dict["listingDuration"] as! String!)</ListingDuration>" +
|
||||
"<ListingType>\(dict["listingType"] as! String!)</ListingType>" +
|
||||
"<PaymentMethods>\(dict["payment"] as! String!)</PaymentMethods>" +
|
||||
"<PayPalEmailAddress>\(dict["paypal_email"] as! String!)</PayPalEmailAddress>" +
|
||||
"<PostalCode>\(dict["postalCode"] as! String!)</PostalCode>" +
|
||||
"<PayPalEmailAddress>\(dict["paypal_email"] as! String!)</PayPalEmailAddress><PictureDetails>"
|
||||
|
||||
for i in 0...(imageUrls.count - 1) {
|
||||
soapMessage = soapMessage +
|
||||
"<PictureURL>\(imageUrls[i].stringByReplacingOccurrencesOfString("&", withString: "&"))</PictureURL>"
|
||||
|
||||
}
|
||||
|
||||
soapMessage = soapMessage + "</PictureDetails><PostalCode>\(dict["postalCode"] as! String!)</PostalCode>" +
|
||||
"<Quantity>\(params["quantity"] as String!)</Quantity>" +
|
||||
"<ReturnPolicy>" +
|
||||
"<ReturnsAcceptedOption>\(dict["return"] as! String!)</ReturnsAcceptedOption>" +
|
||||
@ -289,7 +303,7 @@ extension EbayWebServiceManager {
|
||||
"</ShippingDetails>" +
|
||||
"<Site>US</Site>" +
|
||||
"</Item></AddItemRequest>"
|
||||
|
||||
print(soapMessage)
|
||||
let url = NSURL(string: self.baseURL)
|
||||
let theRequest = NSMutableURLRequest(URL: url!)
|
||||
theRequest.addValue("AddItem", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
|
||||
@ -492,6 +506,7 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
|
||||
dict[string] = ["cat_id": self.catID, "isLeaf": false, "level": self.catLevel]
|
||||
EbayWebServiceManager.settingsDictionary["categories"] = dict
|
||||
NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings")
|
||||
|
||||
}
|
||||
else {
|
||||
if "\(self.catDetailLevel)" == self.catLevel {
|
||||
|
||||
@ -90,6 +90,7 @@ extension FacebookGraphAPIManager {
|
||||
print(result.token)
|
||||
print(result.grantedPermissions)
|
||||
NSUserDefaults.standardUserDefaults().setBool(true, forKey:"fbAuthorized")
|
||||
self.isAuthorized = true
|
||||
|
||||
FBSDKAccessToken.setCurrentAccessToken(result.token)
|
||||
|
||||
@ -103,6 +104,10 @@ extension FacebookGraphAPIManager {
|
||||
(result, error) -> Void in
|
||||
|
||||
NSLog("Logged in with publish permisions")
|
||||
NSUserDefaults.standardUserDefaults().setBool(true, forKey:"fbAuthorized")
|
||||
self.isAuthorized = true
|
||||
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@ -60,13 +60,13 @@ class HomeViewController: UITabBarController {
|
||||
var listingImages: [UIImage] = [mainImage!]
|
||||
var count = 0
|
||||
//Get supporting images
|
||||
for i in 2...5 {
|
||||
for i in 1...4 {
|
||||
let supportListingImg1 = storageRef.child("images/\(key)/\(i).jpg")
|
||||
supportListingImg1.dataWithMaxSize(10 * 1024 * 1024, completion: {
|
||||
(data1, error) -> Void in
|
||||
|
||||
if(error != nil){
|
||||
print("support image \(i - 1) for key, \(key), does not exist")
|
||||
print("support image \(i) for key, \(key), does not exist")
|
||||
}else{
|
||||
listingImages.append(UIImage(data: data1!)!)
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import UIKit
|
||||
import FirebaseStorage
|
||||
import SWRevealViewController
|
||||
|
||||
//@TODO: Need to make multiple images work for etsy and facebook and need to implement multiple images saving to firebase
|
||||
@ -22,7 +23,11 @@ class ListingPreviewViewController: UIViewController {
|
||||
//IBOutlets
|
||||
@IBOutlet weak var containerScrollView: UIScrollView!
|
||||
@IBOutlet weak var itemQuantity: UITextView!
|
||||
@IBOutlet weak var itemPicture: UIImageView!
|
||||
@IBOutlet weak var itemPictureMain: UIImageView!
|
||||
@IBOutlet weak var itemPictureSup1: UIImageView!
|
||||
@IBOutlet weak var itemPictureSup2: UIImageView!
|
||||
@IBOutlet weak var itemPictureSup3: UIImageView!
|
||||
@IBOutlet weak var itemPictureSup4: UIImageView!
|
||||
@IBOutlet weak var itemTitle: UITextView!
|
||||
@IBOutlet weak var itemDescription: UITextView!
|
||||
@IBOutlet weak var itemPrice: UITextView!
|
||||
@ -83,7 +88,27 @@ class ListingPreviewViewController: UIViewController {
|
||||
func setListing(){
|
||||
|
||||
|
||||
self.itemPicture.image = (self.itemListingDictionary["pictures"] as? [UIImageView])![0].image
|
||||
for i in 0...((self.itemListingDictionary["pictures"] as! [UIImageView]).count - 1) {
|
||||
switch i {
|
||||
case 0:
|
||||
self.itemPictureMain.image = (self.itemListingDictionary["pictures"] as? [UIImageView])![i].image
|
||||
break
|
||||
case 1:
|
||||
self.itemPictureSup1.image = (self.itemListingDictionary["pictures"] as? [UIImageView])![i].image
|
||||
break
|
||||
case 2:
|
||||
self.itemPictureSup2.image = (self.itemListingDictionary["pictures"] as? [UIImageView])![i].image
|
||||
break
|
||||
case 3:
|
||||
self.itemPictureSup3.image = (self.itemListingDictionary["pictures"] as? [UIImageView])![i].image
|
||||
break
|
||||
case 4:
|
||||
self.itemPictureSup4.image = (self.itemListingDictionary["pictures"] as? [UIImageView])![i].image
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
self.itemTitle.text = self.itemListingDictionary["title"] as! String
|
||||
self.itemDescription.text = self.itemListingDictionary["description"] as! String
|
||||
self.itemPrice.text = self.itemListingDictionary["price"] as! String
|
||||
@ -107,7 +132,14 @@ class ListingPreviewViewController: UIViewController {
|
||||
self.etsyManager = etsyManager
|
||||
}
|
||||
|
||||
func saveToFirebase(listingImageRef: FIRStorageReference, completion: ServiceResponse! ) {
|
||||
|
||||
listingImageRef.putData(UIImageJPEGRepresentation(self.itemPictureMain.image!, 0.8)!, metadata: nil,completion: {
|
||||
(metadata, error) -> Void in
|
||||
completion(metadata, error)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Navigation
|
||||
|
||||
@ -186,7 +218,7 @@ extension ListingPreviewViewController {
|
||||
self.view.addSubview(loadingView)
|
||||
self.firManager.indicator.startAnimating()
|
||||
|
||||
if(self.itemPicture.image == nil){
|
||||
if(self.itemPictureMain.image == nil){
|
||||
let alert = UIAlertController(title: "Image Needed", message: "To proceed to choose networks, you must supply at least one picture for your listing", preferredStyle: .Alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
|
||||
|
||||
@ -198,9 +230,13 @@ extension ListingPreviewViewController {
|
||||
let newListingRef = self.firManager.ref.child("Users").child("\(self.firManager.user_email)").child("user_Listings").childByAutoId()
|
||||
let postingGroup: dispatch_group_t = dispatch_group_create()
|
||||
|
||||
/*if(!(self.networksDictionary["ebay"]!)&&(!(self.networksDictionary["etsy"]!))&&(!(self.networksDictionary["amazon"]!))&&(!(self.networksDictionary["facebook"]!))) {
|
||||
|
||||
}else {
|
||||
dispatch_g
|
||||
}*/
|
||||
//post to ebay
|
||||
if(self.networksDictionary["ebay"]!){
|
||||
/*if(self.networksDictionary["ebay"]!){
|
||||
dispatch_group_enter(postingGroup)
|
||||
|
||||
let body: [String: String] = [ "title": self.itemTitle.text,
|
||||
@ -220,7 +256,7 @@ extension ListingPreviewViewController {
|
||||
self.newInProgressListing["networkIDs"] = networkIDs
|
||||
dispatch_group_leave(postingGroup)
|
||||
})
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
//post to amazon
|
||||
@ -357,7 +393,7 @@ extension ListingPreviewViewController {
|
||||
|
||||
let imageBody = ["listing_id": networkIDs["etsy"] as! Int,
|
||||
//"type":"image/jpg",
|
||||
"image": UIImageJPEGRepresentation(self.itemPicture.image!, 0.45)!]
|
||||
"image": UIImageJPEGRepresentation(self.itemPictureMain.image!, 0.45)!]
|
||||
|
||||
self.etsyManager.sendPOSTRequest(("listings/\(networkIDs["etsy"] as! Int)/images"), body: imageBody, onCompletion: {
|
||||
(dict, error) -> Void in
|
||||
@ -374,26 +410,93 @@ extension ListingPreviewViewController {
|
||||
//post to facebook
|
||||
if(self.networksDictionary["facebook"]!){
|
||||
dispatch_group_enter(postingGroup)
|
||||
let fb_group: dispatch_group_t = dispatch_group_create()
|
||||
|
||||
let tmpDirURL = NSURL.fileURLWithPath(NSTemporaryDirectory(), isDirectory: true)
|
||||
let fileURL = tmpDirURL.URLByAppendingPathComponent("main").URLByAppendingPathExtension("jpg")
|
||||
print("FilePath: \(fileURL.path!)")
|
||||
do {
|
||||
try UIImageJPEGRepresentation(self.itemPicture.image!, 0.45)!.writeToFile(fileURL.path!, options: NSDataWritingOptions.AtomicWrite)
|
||||
try UIImageJPEGRepresentation(self.itemPictureMain.image!, 0.45)!.writeToFile(fileURL.path!, options: NSDataWritingOptions.AtomicWrite)
|
||||
}catch{
|
||||
(error)
|
||||
print(error)
|
||||
}
|
||||
|
||||
//let parameters: Dictionary<String, AnyObject> = ["message":("**"+self.itemTitle.text!+"**\n\n"+"Price: "+self.itemPrice.text! + "\n\n"+self.itemDescription.text!)]
|
||||
|
||||
let parameters: Dictionary<String, AnyObject> = ["Source": UIImageJPEGRepresentation(self.itemPicture.image!, 0.45)!, "published":false]
|
||||
|
||||
self.lastListingKey = newListingRef.key
|
||||
self.graphManager.makePOSTResquest("me/photos", params: parameters, onComplete: {
|
||||
(imageId, error) -> Void in
|
||||
|
||||
var listingParams: Dictionary<String, AnyObject> = ["message":("**"+self.itemTitle.text!+"**\n\n"+"Price: "+self.itemPrice.text! + "\n\n"+self.itemDescription.text!), "attached_media[0]":"{\"media_fbid\":\"\(imageId as! String)\"}"]
|
||||
var imageIDs: [String] = []
|
||||
|
||||
|
||||
//post multiple images to fb
|
||||
for i in 0...(self.itemListingDictionary["pictures"] as! [UIImageView]).count - 1 {
|
||||
var parameters: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
|
||||
switch (i) {
|
||||
|
||||
case 0:
|
||||
dispatch_group_enter(fb_group)
|
||||
parameters["Source"] = UIImageJPEGRepresentation(self.itemPictureMain.image!,0.45)!
|
||||
parameters["published"] = false
|
||||
self.graphManager.makePOSTResquest("me/photos", params: parameters, onComplete: {
|
||||
(imageId, error) -> Void in
|
||||
imageIDs.append(imageId as! String)
|
||||
dispatch_group_leave(fb_group)
|
||||
})
|
||||
break
|
||||
case 1:
|
||||
dispatch_group_enter(fb_group)
|
||||
parameters["Source"] = UIImageJPEGRepresentation(self.itemPictureSup1.image!,0.45)!
|
||||
parameters["published"] = false
|
||||
self.graphManager.makePOSTResquest("me/photos", params: parameters, onComplete: {
|
||||
(imageId, error) -> Void in
|
||||
imageIDs.append(imageId as! String)
|
||||
dispatch_group_leave(fb_group)
|
||||
})
|
||||
break
|
||||
case 2:
|
||||
dispatch_group_enter(fb_group)
|
||||
parameters["Source"] = UIImageJPEGRepresentation(self.itemPictureSup2.image!,0.45)!
|
||||
parameters["published"] = false
|
||||
self.graphManager.makePOSTResquest("me/photos", params: parameters, onComplete: {
|
||||
(imageId, error) -> Void in
|
||||
imageIDs.append(imageId as! String)
|
||||
dispatch_group_leave(fb_group)
|
||||
})
|
||||
break
|
||||
case 3:
|
||||
dispatch_group_enter(fb_group)
|
||||
parameters["Source"] = UIImageJPEGRepresentation(self.itemPictureSup3.image!,0.45)!
|
||||
parameters["published"] = false
|
||||
self.graphManager.makePOSTResquest("me/photos", params: parameters, onComplete: {
|
||||
(imageId, error) -> Void in
|
||||
imageIDs.append(imageId as! String)
|
||||
dispatch_group_leave(fb_group)
|
||||
})
|
||||
break
|
||||
case 4:
|
||||
dispatch_group_enter(fb_group)
|
||||
parameters["Source"] = UIImageJPEGRepresentation(self.itemPictureSup4.image!,0.45)!
|
||||
parameters["published"] = false
|
||||
self.graphManager.makePOSTResquest("me/photos", params: parameters, onComplete: {
|
||||
(imageId, error) -> Void in
|
||||
imageIDs.append(imageId as! String)
|
||||
dispatch_group_leave(fb_group)
|
||||
})
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//notifies that all images are ready to be attached to new listing on facebook
|
||||
dispatch_group_notify(fb_group, dispatch_get_main_queue(), {
|
||||
|
||||
var listingParams: Dictionary<String, AnyObject> = ["message":("**"+self.itemTitle.text!+"**\n\n"+"Price: "+self.itemPrice.text! + "\n\n"+self.itemDescription.text!)]
|
||||
|
||||
for i in 0...(self.itemListingDictionary["pictures"] as! [UIImageView]).count - 1 {
|
||||
listingParams["attached_media[\(i)]"] = "{\"media_fbid\":\"\(imageIDs[i])\"}"
|
||||
}
|
||||
|
||||
|
||||
self.graphManager.makePOSTResquest("me/feed", params: listingParams, onComplete: {
|
||||
(listingId, error) -> Void in
|
||||
|
||||
@ -407,16 +510,13 @@ extension ListingPreviewViewController {
|
||||
|
||||
|
||||
})
|
||||
/*
|
||||
|
||||
*/
|
||||
})
|
||||
|
||||
//let parameters: Dictionary<String, AnyObject> = ["":""]
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//notifies once all selected networks have been posted to
|
||||
dispatch_group_notify(postingGroup, dispatch_get_main_queue(), {
|
||||
self.newInProgressListing.update(["listingID": newListingRef.key,
|
||||
"seller email": (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!,
|
||||
@ -436,30 +536,102 @@ extension ListingPreviewViewController {
|
||||
|
||||
let storageRef = self.firManager.storage.referenceForURL((databaseDict["image_storage"] as? String)!)
|
||||
|
||||
var imageURLs: [String] = []
|
||||
let completion: ServiceResponse = {(metadata, error) -> Void in
|
||||
|
||||
//for ebay due to its unique posting flow, will use firbase image storage url to add pictures
|
||||
if (self.networksDictionary["ebay"]!){
|
||||
imageURLs.append((metadata?.downloadURL()?.absoluteString)!)
|
||||
dispatch_group_leave(postingGroup)
|
||||
}else{
|
||||
dispatch_group_leave(postingGroup)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//change code to new multi-image saving
|
||||
for i in 0...(self.itemListingDictionary["pictures"] as! [UIImageView]).count - 1 {
|
||||
switch (i) {
|
||||
|
||||
|
||||
|
||||
let listingImageRef = storageRef.child("images/\(newListingRef.key)"+".jpg")
|
||||
listingImageRef.putData(UIImageJPEGRepresentation(self.itemPicture.image!, 0.8)!, metadata: nil,completion:
|
||||
{(metadata, error) -> Void in
|
||||
|
||||
//for ebay due to its unique posting flow, will use firbase image storage url to add pictures
|
||||
case 0:
|
||||
dispatch_group_enter(postingGroup)
|
||||
if (self.networksDictionary["ebay"]!){
|
||||
var networkIDs = self.newInProgressListing["networkIDs"] as! Dictionary<String, AnyObject>
|
||||
let listingImageRef = storageRef.child("images/\(newListingRef.key)/main"+".jpg")
|
||||
self.saveToFirebase(listingImageRef, completion: completion)
|
||||
break
|
||||
case 1:
|
||||
dispatch_group_enter(postingGroup)
|
||||
let listingImageRef = storageRef.child("images/\(newListingRef.key)/1"+".jpg")
|
||||
self.saveToFirebase(listingImageRef, completion: completion)
|
||||
break
|
||||
case 2:
|
||||
dispatch_group_enter(postingGroup)
|
||||
let listingImageRef = storageRef.child("images/\(newListingRef.key)/2"+".jpg")
|
||||
self.saveToFirebase(listingImageRef, completion: completion)
|
||||
break
|
||||
case 3:
|
||||
dispatch_group_enter(postingGroup)
|
||||
let listingImageRef = storageRef.child("images/\(newListingRef.key)/3"+".jpg")
|
||||
self.saveToFirebase(listingImageRef, completion: completion)
|
||||
break
|
||||
case 4:
|
||||
dispatch_group_enter(postingGroup)
|
||||
let listingImageRef = storageRef.child("images/\(newListingRef.key)/4"+".jpg")
|
||||
self.saveToFirebase(listingImageRef, completion: completion)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
self.ebayManager.addImagesToListing(networkIDs["ebay"] as! String, imageURL: (metadata?.downloadURL()?.absoluteString)!, onCompletion: {
|
||||
(_, _) -> Void in
|
||||
dispatch_group_leave(postingGroup)
|
||||
})
|
||||
}else{
|
||||
//notify to upload multiple ebay photos
|
||||
dispatch_group_notify(postingGroup, dispatch_get_main_queue(), {
|
||||
dispatch_group_enter(postingGroup)
|
||||
if (self.networksDictionary["ebay"]!){
|
||||
|
||||
let body: [String: String] = [ "title": self.itemTitle.text,
|
||||
"quantity":self.itemQuantity.text,
|
||||
"description":self.itemDescription.text,
|
||||
"price":self.itemPrice.text,
|
||||
"category_id":self.itemListingDictionary["ebaySubCategoryID"] as! String
|
||||
]
|
||||
let listingCompletion: ServiceResponse = {
|
||||
(listingID, error) -> Void in
|
||||
if((self.newInProgressListing["networkIDs"] == nil)){
|
||||
self.newInProgressListing["networkIDs"] = Dictionary<String, AnyObject>()
|
||||
}
|
||||
var networkIDs = (self.newInProgressListing["networkIDs"] as! Dictionary<String, AnyObject>)
|
||||
networkIDs["ebay"] = listingID as! String
|
||||
self.newInProgressListing["networkIDs"] = networkIDs
|
||||
dispatch_group_leave(postingGroup)
|
||||
}
|
||||
|
||||
dispatch_group_notify(postingGroup, dispatch_get_main_queue(), {
|
||||
newListingRef.setValue(self.newInProgressListing)
|
||||
/*self.ebayManager.listItem(body, completion: {
|
||||
(listingID, error) -> Void in
|
||||
if((self.newInProgressListing["networkIDs"] == nil)){
|
||||
self.newInProgressListing["networkIDs"] = Dictionary<String, AnyObject>()
|
||||
}
|
||||
var networkIDs = (self.newInProgressListing["networkIDs"] as! Dictionary<String, AnyObject>)
|
||||
networkIDs["ebay"] = listingID as! String
|
||||
self.newInProgressListing["networkIDs"] = networkIDs
|
||||
dispatch_group_leave(postingGroup)
|
||||
})*/
|
||||
self.ebayManager.listItem(body, imageUrls: imageURLs, completion: listingCompletion)
|
||||
//self.ebayManager.addImagesToListing(networkIDs["ebay"] as! String, imageURLs: imageURLs, listingOnCompletion: listingCompletion, body: body, onCompletion: {
|
||||
//(_, _) -> Void in
|
||||
//dispatch_group_leave(postingGroup)
|
||||
//})
|
||||
|
||||
}
|
||||
else {
|
||||
dispatch_group_leave(postingGroup)
|
||||
}
|
||||
|
||||
//notify to save final listing to firebase
|
||||
dispatch_group_notify(postingGroup, dispatch_get_main_queue(), {
|
||||
newListingRef.setValue(self.newInProgressListing)
|
||||
// self.alert.title = "Listing saved with error"
|
||||
// self.alert.message = "Your listing has been saved but something went wrong when trying to publish to facebook"
|
||||
|
||||
@ -483,29 +655,28 @@ extension ListingPreviewViewController {
|
||||
self.presentViewController(alert, animated: true, completion: nil)
|
||||
})
|
||||
|
||||
// self.alert.title = "Listing saved with error"
|
||||
// self.alert.message = "Your listing has been saved but something went wrong when trying to publish to facebook"
|
||||
|
||||
|
||||
//let alert = UIAlertController(title: "Listing Published", message: "Your listing has been published", preferredStyle: .Alert)
|
||||
|
||||
// self.alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in self.alert.dismissViewControllerAnimated(true, completion: nil)}))
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func editListing(sender: AnyObject) {
|
||||
|
||||
self.performSegueWithIdentifier("EditListingSegue", sender: self)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
extension ListingPreviewViewController: UICollectionViewDelegate {
|
||||
|
||||
/*
|
||||
|
||||
@ -1039,7 +1039,11 @@
|
||||
<outlet property="edit_button" destination="yzh-tr-u8D" id="f8q-TT-a2C"/>
|
||||
<outlet property="itemCategory" destination="ije-TG-4S5" id="XGu-Uw-hLl"/>
|
||||
<outlet property="itemDescription" destination="u7b-0N-xli" id="d1N-lw-6sw"/>
|
||||
<outlet property="itemPicture" destination="K0z-pp-hzH" id="6Zm-Ig-Rm3"/>
|
||||
<outlet property="itemPictureMain" destination="K0z-pp-hzH" id="cXG-P9-emv"/>
|
||||
<outlet property="itemPictureSup1" destination="ldz-4W-iID" id="PHY-Nf-9Qv"/>
|
||||
<outlet property="itemPictureSup2" destination="MRj-nD-Hnj" id="KPH-H3-Z5z"/>
|
||||
<outlet property="itemPictureSup3" destination="L24-JN-niQ" id="fyJ-HY-klx"/>
|
||||
<outlet property="itemPictureSup4" destination="LsU-De-laD" id="eBn-7o-WIl"/>
|
||||
<outlet property="itemPrice" destination="Jh9-KG-0Yt" id="nbh-aq-W0b"/>
|
||||
<outlet property="itemQuantity" destination="shU-ew-26O" id="yNg-ov-7q5"/>
|
||||
<outlet property="itemTitle" destination="WuZ-2K-lz7" id="EkY-UX-lSj"/>
|
||||
|
||||
@ -209,7 +209,7 @@ extension NetworksTableViewController: UITableViewDataSource {
|
||||
cell = (self.tableView.dequeueReusableCellWithIdentifier("etsy", forIndexPath: indexPath) as! EtsyTableViewCell)
|
||||
break
|
||||
default:
|
||||
//loads network cell for ebay
|
||||
//loads network cell for facebook
|
||||
cell = (self.tableView.dequeueReusableCellWithIdentifier("facebook", forIndexPath: indexPath) as! FBTableViewCell)
|
||||
|
||||
break
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user