diff --git a/GetHip.xcodeproj/project.pbxproj b/GetHip.xcodeproj/project.pbxproj index e27281d..dee6ce5 100644 --- a/GetHip.xcodeproj/project.pbxproj +++ b/GetHip.xcodeproj/project.pbxproj @@ -41,6 +41,8 @@ 3E379F021C3F794500F7BCCD /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E379EFC1C3F794500F7BCCD /* Security.framework */; }; 3E379F031C3F794500F7BCCD /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E379EFD1C3F794500F7BCCD /* StoreKit.framework */; }; 3E379F051C3F982900F7BCCD /* FriendsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E379F041C3F982900F7BCCD /* FriendsCell.swift */; }; + 3E3B14DC1C5BBB3B001C437F /* PendingRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E3B14DB1C5BBB3B001C437F /* PendingRequestViewController.swift */; }; + 3E3B14DE1C5BCC9B001C437F /* FriendRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E3B14DD1C5BCC9B001C437F /* FriendRequestViewController.swift */; }; 3E4169491C385F1000B193AF /* 1x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3E4169481C385F1000B193AF /* 1x.png */; }; 3E4169551C398A5B00B193AF /* SignUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4169541C398A5B00B193AF /* SignUpViewController.swift */; }; 3E4169571C399C4D00B193AF /* Images-3.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3E4169561C399C4D00B193AF /* Images-3.xcassets */; }; @@ -162,6 +164,8 @@ 3E379EFD1C3F794500F7BCCD /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; 3E379F041C3F982900F7BCCD /* FriendsCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FriendsCell.swift; sourceTree = ""; }; 3E3842E11C3E15DE005DD1FB /* ParseNetDebug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ParseNetDebug.h; sourceTree = ""; }; + 3E3B14DB1C5BBB3B001C437F /* PendingRequestViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PendingRequestViewController.swift; sourceTree = ""; }; + 3E3B14DD1C5BCC9B001C437F /* FriendRequestViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FriendRequestViewController.swift; sourceTree = ""; }; 3E4169481C385F1000B193AF /* 1x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = 1x.png; path = "../../../Dropbox/Gethip/Screens/Logo Screen/6 Logo Screen/1x.png"; sourceTree = ""; }; 3E4169541C398A5B00B193AF /* SignUpViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignUpViewController.swift; sourceTree = ""; }; 3E4169561C399C4D00B193AF /* Images-3.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Images-3.xcassets"; sourceTree = ""; }; @@ -291,6 +295,8 @@ 3E379F041C3F982900F7BCCD /* FriendsCell.swift */, 3EDA82E01C473E900081ED53 /* FriendData.swift */, 3E1AAD131C3BD92600809367 /* FriendsListViewController.swift */, + 3E3B14DB1C5BBB3B001C437F /* PendingRequestViewController.swift */, + 3E3B14DD1C5BCC9B001C437F /* FriendRequestViewController.swift */, ); name = FriendListSource; sourceTree = ""; @@ -775,6 +781,7 @@ 3E1AAD141C3BD92600809367 /* FriendsListViewController.swift in Sources */, 3E326BCE1C51C77600F785CF /* SettingsCellWrapper.swift in Sources */, 3E627FF31C55AE35005C0372 /* TDAudioPlayerConstants.m in Sources */, + 3E3B14DC1C5BBB3B001C437F /* PendingRequestViewController.swift in Sources */, 3E379EF61C3E646000F7BCCD /* ParseNetDebug.m in Sources */, 3E627FED1C55AE35005C0372 /* TDAudioQueueBufferManager.m in Sources */, 3EBE976F1C53E6950079B54A /* InviteFriendCell.swift in Sources */, @@ -794,6 +801,7 @@ 3E4169551C398A5B00B193AF /* SignUpViewController.swift in Sources */, 3E627FEE1C55AE35005C0372 /* TDAudioQueueController.m in Sources */, 3E627FE71C55AE35005C0372 /* NSMutableArray+QueueMethods.m in Sources */, + 3E3B14DE1C5BCC9B001C437F /* FriendRequestViewController.swift in Sources */, 3E18D4931C51F6230012F7DF /* UserParseData.swift in Sources */, 3E5952851C39E54A00C88C71 /* HomeScreenViewController.swift in Sources */, ); diff --git a/GetHip/FriendData.swift b/GetHip/FriendData.swift index e469700..973361c 100644 --- a/GetHip/FriendData.swift +++ b/GetHip/FriendData.swift @@ -11,9 +11,14 @@ import Foundation class FriendData { var displayName: String! var profileImg: UIImage! + var status: String! - init(display: String){ + init(display: String, status: String){ self.displayName = display self.profileImg = nil + self.status = status + } + + } diff --git a/GetHip/FriendDataSource.swift b/GetHip/FriendDataSource.swift index 18949b5..9fcd372 100644 --- a/GetHip/FriendDataSource.swift +++ b/GetHip/FriendDataSource.swift @@ -30,6 +30,7 @@ class FriendDataSource{ //var image:UIImage = UIImage() let userName = object.objectForKey("OtherUser")!.objectForKey("username") as! String + let requestStatus = object.objectForKey("RequestStatus")! as! String /* let pimage:PFFile = object["profilePicture"] as! PFFile @@ -41,7 +42,7 @@ class FriendDataSource{ } })*/ - var newFriend: FriendData = FriendData(display: userName) + var newFriend: FriendData = FriendData(display: userName, status: requestStatus) //print(userName) self.dataSource.append(newFriend) diff --git a/GetHip/FriendRequestViewController.swift b/GetHip/FriendRequestViewController.swift new file mode 100644 index 0000000..c3184b8 --- /dev/null +++ b/GetHip/FriendRequestViewController.swift @@ -0,0 +1,43 @@ +// +// FriendRequestViewController.swift +// GetHip +// +// Created by Okechi on 1/29/16. +// Copyright (c) 2016 Kroleo. All rights reserved. +// + +import UIKit + +class FriendRequestViewController: UIViewController { + + @IBOutlet var displayImage: UIImageView! + @IBOutlet var foundName: UILabel! + @IBOutlet var sendRequest: UIButton! + @IBOutlet var searchBar: UISearchBar! + + + override func viewDidLoad() { + super.viewDidLoad() + self.displayImage.layer.cornerRadius = self.displayImage.frame.size.width/2 + self.sendRequest.enabled = false + self.sendRequest.tintColor = UIColor.grayColor() + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/GetHip/FriendsCell.swift b/GetHip/FriendsCell.swift index 0f71b9d..6bcecf9 100644 --- a/GetHip/FriendsCell.swift +++ b/GetHip/FriendsCell.swift @@ -25,6 +25,7 @@ class FriendsCell: UITableViewCell { class FriendRequestCell: UITableViewCell { + @IBOutlet var requestNumber: UILabel! override func awakeFromNib() { super.awakeFromNib() @@ -34,3 +35,19 @@ class FriendRequestCell: UITableViewCell { super.setSelected(selected, animated: animated) } } + +class PendingFriendCell: UITableViewCell { + @IBOutlet var proImg: UIImageView! + @IBOutlet var friendName: UILabel! + @IBOutlet var denyButton: UIButton! + @IBOutlet var acceptButton: UIButton! + + override func awakeFromNib() { + super.awakeFromNib() + } + + override func setSelected(selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + } + +} diff --git a/GetHip/FriendsListViewController.swift b/GetHip/FriendsListViewController.swift index a57c34e..0464eb1 100644 --- a/GetHip/FriendsListViewController.swift +++ b/GetHip/FriendsListViewController.swift @@ -11,6 +11,7 @@ import UIKit class FriendsListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource/*PFQueryTableViewController*/ { //var manager = FriendDataSource() var friends = [] + var request = [] @IBOutlet weak var table: UITableView! @@ -19,10 +20,13 @@ class FriendsListViewController: UIViewController, UITableViewDelegate, UITableV self.parentViewController?.dismissViewControllerAnimated(true, completion: nil) } - + @IBAction func addFriend(sender: UIBarButtonItem){ + self.performSegueWithIdentifier("FriendRequestSegue", sender: nil) + } - func setData(frnds:[FriendData]){ + func setData(frnds:[FriendData], requst: [FriendData]){ self.friends = frnds + self.request = requst } override func viewDidLoad() { super.viewDidLoad() @@ -60,6 +64,8 @@ class FriendsListViewController: UIViewController, UITableViewDelegate, UITableV if( indexPath.row == 0){ let cell = self.table.dequeueReusableCellWithIdentifier("RequestCell", forIndexPath: indexPath) as? FriendRequestCell + //sets count for current number of request + cell?.requestNumber.text = String(self.request.count) return cell! } @@ -95,6 +101,18 @@ class FriendsListViewController: UIViewController, UITableViewDelegate, UITableV } + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + + if(indexPath.row == 0){ + if(self.request.count == 0){ + self.performSegueWithIdentifier("NoRequestSegue", sender: nil) + }else{ + self.performSegueWithIdentifier("PendingRequestSegue", sender: nil) + } + } + + } + override func setEditing(editing: Bool, animated: Bool) { super.setEditing(editing, animated: animated) self.table.setEditing(editing, animated: true) @@ -113,5 +131,18 @@ class FriendsListViewController: UIViewController, UITableViewDelegate, UITableV } } + + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + if segue.identifier == "PendingRequestSegue" { + + let vc: PendingRequestViewController = (segue.destinationViewController as? PendingRequestViewController)! + vc.setData(self.request as! [FriendData]) + + } + + if segue.identifier == "FriendRequestSegue" { + + } + } } diff --git a/GetHip/HomeScreenViewController.swift b/GetHip/HomeScreenViewController.swift index 9633b68..9a8be8c 100644 --- a/GetHip/HomeScreenViewController.swift +++ b/GetHip/HomeScreenViewController.swift @@ -12,6 +12,7 @@ class HomeScreenViewController: UIViewController { var usrDataManager = UserParseDataSource() var frndDataManager = FriendDataSource() var friendData: [FriendData] = [] + var requestData: [FriendData] = [] var userData: [UserParseData] = [] let partyData = PartyServiceManager() @@ -20,7 +21,16 @@ class HomeScreenViewController: UIViewController { //async data update methods func refreshFriendData(notification:NSNotification){ - self.friendData = self.frndDataManager.getFriends() + + let friendInfo = self.frndDataManager.getFriends() + + for pendingFriend in friendInfo { + if pendingFriend.status == "pending"{ + self.requestData.append(pendingFriend) + }else{ + self.friendData.append(pendingFriend) + } + } } func refreshUserData(notification:NSNotification){ @@ -85,7 +95,7 @@ class HomeScreenViewController: UIViewController { let nav: UINavigationController = (segue.destinationViewController as? UINavigationController)! let vc: FriendsListViewController = (nav.viewControllers[0] as? FriendsListViewController)! - vc.setData(self.friendData) + vc.setData(self.friendData, requst: self.requestData) } } diff --git a/GetHip/Main.storyboard b/GetHip/Main.storyboard index 6df3bcb..0ad5f51 100644 --- a/GetHip/Main.storyboard +++ b/GetHip/Main.storyboard @@ -26,10 +26,10 @@ - + - + @@ -55,12 +55,22 @@ + + + + + @@ -79,13 +89,13 @@ - + - + @@ -113,6 +123,12 @@ + + + + + + @@ -121,6 +137,9 @@ + + + @@ -194,6 +213,9 @@ + + + @@ -228,15 +250,19 @@ - + + + + + - - + + diff --git a/GetHip/PendingRequestViewController.swift b/GetHip/PendingRequestViewController.swift new file mode 100644 index 0000000..8e0d1b4 --- /dev/null +++ b/GetHip/PendingRequestViewController.swift @@ -0,0 +1,129 @@ +// +// PendingRequestViewController.swift +// GetHip +// +// Created by Okechi on 1/29/16. +// Copyright (c) 2016 Kroleo. All rights reserved. +// + +import UIKit + +class PendingRequestViewController: UITableViewController { + @IBOutlet var table:UITableView! + + var requests = [] + + override func viewDidLoad() { + super.viewDidLoad() + self.title = "Friend Requests" + self.table.dataSource = self + self.table.delegate = self + + // Uncomment the following line to preserve selection between presentations + // self.clearsSelectionOnViewWillAppear = false + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem() + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + func setData(data: [FriendData]){ + self.requests = data + } + + // MARK: - Table view data source + + override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + // #warning Potentially incomplete method implementation. + // Return the number of sections. + return 1 + } + + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + // #warning Incomplete method implementation. + // Return the number of rows in the section. + return self.requests.count + } + + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + + let pending = self.requests[indexPath.row] as? FriendData + let cell = self.table.dequeueReusableCellWithIdentifier("PendingCell", forIndexPath: indexPath) as? PendingFriendCell + + //sets display name of friend (print for debugging purposes) + cell!.friendName.text = pending!.displayName + //println(friend!.displayName) + + //sets profile image of current cell + //checks if friend user has a profile image or not + if pending?.profileImg == nil { + cell!.proImg.backgroundColor = UIColor.grayColor() + } + else{ + + } + + //rounds uiimage and configures UIImageView + //cell!.proImage.layer.borderWidth = 3.0 + //cell!.proImage.clipsToBounds = true + cell!.proImg.layer.cornerRadius = cell!.proImg.frame.size.width/2 + + //cell!.proImage.layer.borderColor = UIColor.whiteColor().CGColor + //cell!.proImage.layer.masksToBounds = true + + + return cell! + + } + + + /* + // Override to support conditional editing of the table view. + override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { + // Return NO if you do not want the specified item to be editable. + return true + } + */ + + /* + // Override to support editing the table view. + override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { + if editingStyle == .Delete { + // Delete the row from the data source + tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) + } else if editingStyle == .Insert { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } + } + */ + + /* + // Override to support rearranging the table view. + override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { + + } + */ + + /* + // Override to support conditional rearranging of the table view. + override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { + // Return NO if you do not want the item to be re-orderable. + return true + } + */ + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ + +}