diff --git a/Vendoo.xcodeproj/project.pbxproj b/Vendoo.xcodeproj/project.pbxproj index 6cc5f36..5715c21 100644 --- a/Vendoo.xcodeproj/project.pbxproj +++ b/Vendoo.xcodeproj/project.pbxproj @@ -40,6 +40,7 @@ 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 */; }; + 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 */; }; A87525ED0EE7D42D9A7708D8 /* Pods_Vendoo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23ECC3C8465826BD6AC74A02 /* Pods_Vendoo.framework */; }; @@ -105,6 +106,7 @@ 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 = ""; }; + 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; }; A44ED233D6B5454EF92FEB08 /* Pods-Vendoo-VendooUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vendoo-VendooUITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Vendoo-VendooUITests/Pods-Vendoo-VendooUITests.debug.xcconfig"; sourceTree = ""; }; @@ -328,6 +330,7 @@ 3E1AA4331D0DD0B2005FCCBB /* Settings */, 3EFB0E321D0B968300A05D7A /* SideMenuView.swift */, 3E1AA4311D0DA071005FCCBB /* MenuPanelViewController.swift */, + 3EF422B11D73262000B9A3EB /* UserCell.swift */, ); name = Menu; sourceTree = ""; @@ -751,6 +754,7 @@ 3E1DC3CF1D42328C0091BC60 /* CategoryCell.swift in Sources */, 3EC325111CF703A600626C48 /* ItemCell.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 */, diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate index fff33d0..b64a123 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 d9f43cb..0c096f1 100644 --- a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -6,16 +6,16 @@ @@ -25,29 +25,13 @@ shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "Vendoo/EbayWebServiceManager.swift" - timestampString = "493665751.744" + filePath = "Vendoo/ListingPreviewViewController.swift" + timestampString = "493861794.122107" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "234" - endingLineNumber = "234" - landmarkName = "listItem(_:completion:)" - landmarkType = "5"> - - - - @@ -57,605 +41,61 @@ shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "Vendoo/EbayWebServiceManager.swift" - timestampString = "493665751.744" + filePath = "Vendoo/ListingPreviewViewController.swift" + timestampString = "493861800.925503" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "289" - endingLineNumber = "289" - landmarkName = "listItem(_:completion:)" + startingLineNumber = "99" + endingLineNumber = "99" + landmarkName = "prepareForSegue(_:sender:)" landmarkType = "5"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -666,28 +106,42 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/ListingPreviewViewController.swift" - timestampString = "493663551.342447" + timestampString = "493930954.132313" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "268" - endingLineNumber = "268" - landmarkName = "publishItem(_:)" - landmarkType = "5"> + startingLineNumber = "579" + endingLineNumber = "579" + landmarkName = "ListingPreviewViewController" + landmarkType = "3"> + + + + @@ -698,13 +152,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/ListingPreviewViewController.swift" - timestampString = "493662437.215315" + timestampString = "494033422.080596" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "500" - endingLineNumber = "500" - landmarkName = "publishItem(_:)" - landmarkType = "5"> + startingLineNumber = "678" + endingLineNumber = "678"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Vendoo/.DS_Store b/Vendoo/.DS_Store index 8d98363..10bee23 100644 Binary files a/Vendoo/.DS_Store and b/Vendoo/.DS_Store differ diff --git a/Vendoo/FirebaseManager.swift b/Vendoo/FirebaseManager.swift index 925e6e4..82fdc63 100644 --- a/Vendoo/FirebaseManager.swift +++ b/Vendoo/FirebaseManager.swift @@ -31,11 +31,9 @@ class FirebaseManager: NSObject { // do some stuff once if(!snapshot.hasChild(self.user_email)){ - let user = ["user_Listings": "","listing_Keys": "","favorite_listings_keys": ""] - // let userUpdates = ["/Users/\((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!)" : user] + let user = ["name": (NSUserDefaults.standardUserDefaults().objectForKey("name") as? String)!, "user_Listings": "", "listing_Keys": "", "favorite_listings_keys": ""] self.ref.child("Users").child(self.user_email).setValue(user) - //self.ref.child("Users").setValue(["email": (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!]) } }) diff --git a/Vendoo/HomeViewController.swift b/Vendoo/HomeViewController.swift index e5ceaaf..9c3e36f 100644 --- a/Vendoo/HomeViewController.swift +++ b/Vendoo/HomeViewController.swift @@ -23,15 +23,21 @@ class HomeViewController: UITabBarController { // Do any additional setup after loading the view. dispatch_async(dispatch_get_main_queue(), { - self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings").observeSingleEventOfType( .Value, withBlock: { + + //get all listing information for current user + self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: { (snapshot) -> Void in - let listingDict = snapshot.value as? [String : AnyObject] + let userDict = snapshot.value as? [String : AnyObject] + + let listingDict = userDict!["user_Listings"] as? [String : AnyObject] + + NSUserDefaults.standardUserDefaults().setObject(userDict!["name"] as? String, forKey: "name") + if listingDict != nil { dispatch_async(dispatch_get_main_queue(), { - for (key, values) in listingDict! { let serviceGroup: dispatch_group_t = dispatch_group_create() self.firebaseManager.ref.observeSingleEventOfType(.Value, withBlock: { snapshot in diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard index 98bbf3b..cab292d 100755 --- a/Vendoo/Main.storyboard +++ b/Vendoo/Main.storyboard @@ -1388,7 +1388,7 @@ - + @@ -1396,14 +1396,14 @@ + + + + @@ -1593,7 +1597,7 @@ - + @@ -1610,7 +1614,7 @@ - + @@ -1671,7 +1675,7 @@ - + @@ -1688,7 +1692,7 @@ - + @@ -2446,10 +2450,10 @@ - + + - diff --git a/Vendoo/MenuPanelViewController.swift b/Vendoo/MenuPanelViewController.swift index dc53499..467db0a 100644 --- a/Vendoo/MenuPanelViewController.swift +++ b/Vendoo/MenuPanelViewController.swift @@ -99,7 +99,11 @@ extension MenuPanelViewController: UITableViewDataSource let cell: UITableViewCell switch(indexPath.row){ case 0: - cell = self.table.dequeueReusableCellWithIdentifier("User_Cell")! + + cell = (self.table.dequeueReusableCellWithIdentifier("User_Cell", forIndexPath: indexPath) as! UserCell) + + (cell as! UserCell).name.text = "Hi " + (NSUserDefaults.standardUserDefaults().objectForKey("name") as? String)! + (cell as! UserCell).email.text = (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)! break case 1: cell = self.table.dequeueReusableCellWithIdentifier("Notifications_Cell")! diff --git a/Vendoo/SignUpViewController.swift b/Vendoo/SignUpViewController.swift index fab4bcb..3de1cc9 100644 --- a/Vendoo/SignUpViewController.swift +++ b/Vendoo/SignUpViewController.swift @@ -6,10 +6,11 @@ // Copyright © 2016 Okechi Onyeje. All rights reserved. // -//NEED TO PROMPT NEW USER THAT THEY HAVE BEEN LOGGED IN, NEED TO ADD AN INDICTOR TO LET USER KNOW THEY NEED TO WAIT AND NEED TO SEGUE TO MAIN SCREEN VIEW CONTROLLER +//@FIXME: NEED TO PROMPT NEW USER THAT THEY HAVE BEEN LOGGED IN, NEED TO ADD AN INDICTOR TO LET USER KNOW THEY NEED TO WAIT AND NEED TO SEGUE TO MAIN SCREEN VIEW CONTROLLER import UIKit import FirebaseAuth +import Firebase import Locksmith class SignUpViewController: UIViewController { @@ -43,43 +44,56 @@ class SignUpViewController: UIViewController { extension SignUpViewController { @IBAction func signUpUser(sender: AnyObject) { - let finalEmail = email!.text!.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) - - if isValidEmail(finalEmail){ + if( (self.email.text != "") && (self.name.text != "") && (self.password.text != "")) { + let finalEmail = email!.text!.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) - FIRAuth.auth()?.createUserWithEmail(email.text!, password: password.text!) { (user, error) in - if error != nil { - /* - if ( error!.userInfo[("error_name" as NSObject!)] == "ERROR_WEAK_PASSWORD"){ - - - } - */ - print("user could not be created") - print(error!.localizedDescription) - return - } - else{ - - //save user account - NSUserDefaults.standardUserDefaults().setBool(true, forKey: "signedIn") - NSUserDefaults.standardUserDefaults().setObject(self.email.text, forKey: "email") - - //save user credentials in Keychain - do{ - try Locksmith.saveData(["pass": self.password.text!], forUserAccount: self.email.text!, inService: "vendoo") - print("account credentials saved") + if isValidEmail(finalEmail){ + FIRAuth.auth()?.createUserWithEmail(email.text!, password: password.text!) { (user, error) in + if error != nil { + /* + if ( error!.userInfo[("error_name" as NSObject!)] == "ERROR_WEAK_PASSWORD"){ + + + } + */ + print("user could not be created") + print(error!.localizedDescription) + return } - catch{ - //could not save data to keychain - print("account credentials could not be saved") + else{ + //save user account + NSUserDefaults.standardUserDefaults().setBool(true, forKey: "signedIn") + NSUserDefaults.standardUserDefaults().setObject(self.email.text, forKey: "email") + NSUserDefaults.standardUserDefaults().setObject(self.name.text, forKey: "name") + + + //save user credentials in Keychain + do{ + try Locksmith.saveData(["pass": self.password.text!], forUserAccount: self.email.text!, inService: "vendoo") + print("account credentials saved") + } + catch{ + //could not save data to keychain + print("account credentials could not be saved") + + } + self.performSegueWithIdentifier("HomeScreenSegue", sender:nil) } - self.performSegueWithIdentifier("HomeScreenSegue", sender:nil) } + } + + }else { + + var alert = UIAlertController(title: "Missing Required Fields", message: "You are missing required field(s) to complete your Vendoo sign up. Please make sure the email, name, and password fields have been filled.", preferredStyle: .Alert) + alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: {(action: UIAlertAction!) in + })) + self.presentViewController(alert, animated: true, completion: nil) + } + } diff --git a/Vendoo/UserCell.swift b/Vendoo/UserCell.swift new file mode 100644 index 0000000..fa8847d --- /dev/null +++ b/Vendoo/UserCell.swift @@ -0,0 +1,19 @@ +// +// UserCell.swift +// Vendoo +// +// Created by Okechi Onyeje on 8/28/16. +// Copyright © 2016 Okechi Onyeje. All rights reserved. +// + +import UIKit + +class UserCell: UITableViewCell { + @IBOutlet weak var name: UILabel! + @IBOutlet weak var email: UILabel! + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } +}