"Initial"

This commit is contained in:
Okechi 2016-01-28 05:44:20 -05:00
commit c2dc551eec
45 changed files with 3766 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:GetHip.xcodeproj">
</FileRef>
</Workspace>

136
GetHip/AppDelegate.swift Normal file
View File

@ -0,0 +1,136 @@
//
// AppDelegate.swift
// GetHip
//
// Created by Okechi on 1/1/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Parse.logLevel()
//NSNotificationCenter.defaultCenter().addObserver(self, selector: "receiveWillSendURLRequestNotification:", name: PFNetworkWillSendURLRequestNotification, object: nil)
//NSNotificationCenter.defaultCenter().addObserver(self, selector: "receiveDidReceiveURLResponseNotification:", name: PFNetworkDidReceiveURLResponseNotification, object: nil)
// Override point for customization after application launch.
Parse.setApplicationId("OUFlGeqCzg03ZbstGcbskj7UNwp53Y0yad9Fi6I0", clientKey: "xaw0kbAFnBi3zLhT1uSnzrzju56m7CnQJ8hJHW1K")
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions);
let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
print(paths[0])
return true
}
func receiveWillSendURLRequestNotification(notification: NSNotification) {
ParseNetDebug.receiveWillSendURLRequestNotification(notification)
}
func receiveDidReceiveURLResponseNotification(notification: NSNotification) {
ParseNetDebug.receiveDidReceiveURLResponseNotification(notification)
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
FBSDKAppEvents.activateApp()
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
self.saveContext()
}
// MARK: - Core Data stack
lazy var applicationDocumentsDirectory: NSURL = {
// The directory the application uses to store the Core Data store file. This code uses a directory named "oonyeje.Kroleo.GetHip" in the application's documents Application Support directory.
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
return urls[urls.count-1] as! NSURL
}()
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
let modelURL = NSBundle.mainBundle().URLForResource("GetHip", withExtension: "momd")!
return NSManagedObjectModel(contentsOfURL: modelURL)!
}()
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
// The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
// Create the coordinator and store
var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("GetHip.sqlite")
var error: NSError? = nil
var failureReason = "There was an error creating or loading the application's saved data."
if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil {
coordinator = nil
// Report any error we got.
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
dict[NSLocalizedFailureReasonErrorKey] = failureReason
dict[NSUnderlyingErrorKey] = error
error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
// Replace this with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog("Unresolved error \(error), \(error!.userInfo)")
abort()
}
return coordinator
}()
lazy var managedObjectContext: NSManagedObjectContext? = {
// Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
let coordinator = self.persistentStoreCoordinator
if coordinator == nil {
return nil
}
var managedObjectContext = NSManagedObjectContext()
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()
// MARK: - Core Data Saving support
func saveContext () {
if let moc = self.managedObjectContext {
var error: NSError? = nil
if moc.hasChanges && !moc.save(&error) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog("Unresolved error \(error), \(error!.userInfo)")
abort()
}
}
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleAspectFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="542" y="377"/>
</view>
</objects>
</document>

35
GetHip/Bridging-Header.h Normal file
View File

@ -0,0 +1,35 @@
//
// Bridging-Header.h
// GetHip
//
// Created by Okechi on 1/1/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
#ifndef GetHip_Bridging_Header_h
#define GetHip_Bridging_Header_h
#import <Parse/Parse.h>
#import <ParseUI/ParseUI.h>
#import <ParseFacebookUtilsV4/ParseFacebookUtilsV4.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import "ParseNetDebug.h"
//TDAudioPlayer
#import "NSInputStream+URLInitialization.h"
#import "NSMutableArray+QueueMethods.h"
#import "TDAudioMetaInfo.h"
#import "TDAudioInputStreamer.h"
#import "TDAudioOutputStreamer.h"
#import "TDAudioPlayerConstants.h"
#import "TDAudioPlayer.h"
#import "TDAudioFileStream.h"
#import "TDAudioQueue.h"
#import "TDAudioQueueBuffer.h"
#import "TDAudioQueueBufferManager.h"
#import "TDAudioQueueController.h"
#import "TDAudioQueueFiller.h"
#import "TDAudioStream.h"
#endif

19
GetHip/FriendData.swift Normal file
View File

@ -0,0 +1,19 @@
//
// FriendData.swift
// GetHip
//
// Created by Okechi on 1/13/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation
class FriendData {
var displayName: String!
var profileImg: UIImage!
init(display: String){
self.displayName = display
self.profileImg = nil
}
}

View File

@ -0,0 +1,65 @@
//
// FriendDataSource.swift
// GetHip
//
// Created by Okechi on 1/13/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation
class FriendDataSource{
var dataSource: [FriendData]
init() {
dataSource = []
var query = PFUser.query()
var currentUser: String! = PFUser.currentUser()?.username
let predicate: NSPredicate = NSPredicate(format: "(((RequestStatus = %@) OR (RequestStatus = %@)) AND (username = %@))", argumentArray: ["accepted", "pending",currentUser])
var friendsQuery: PFQuery = PFQuery(className: "FriendRequest", predicate: predicate)
friendsQuery.includeKey("OtherUser").findObjectsInBackgroundWithBlock {
(objects, error) -> Void in
//print(error)
if error == nil {
for object in objects! {
//var image:UIImage = UIImage()
let userName = object.objectForKey("OtherUser")!.objectForKey("username") as! String
/* let pimage:PFFile = object["profilePicture"] as! PFFile
pimage.getDataInBackgroundWithBlock({
(imageData, error) -> Void in
if !(error != nil) {
image = UIImage(data: imageData!)!
}
})*/
var newFriend: FriendData = FriendData(display: userName)
//print(userName)
self.dataSource.append(newFriend)
}
NSLog("%d", self.dataSource.count)
}
NSNotificationCenter.defaultCenter().postNotificationName("refreshTableView", object: nil)
}
}
func getFriends() -> [FriendData]{
return self.dataSource
}
}

24
GetHip/FriendsCell.swift Normal file
View File

@ -0,0 +1,24 @@
//
// FriendsCell.swift
// GetHip
//
// Created by Okechi on 1/8/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class FriendsCell: UITableViewCell {
@IBOutlet var friendName: UILabel!
@IBOutlet var proImage: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}

View File

@ -0,0 +1,105 @@
//
// FriendsListViewController.swift
// GetHip
//
// Created by Okechi on 1/5/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class FriendsListViewController: UITableViewController/*PFQueryTableViewController*/ {
//var manager = FriendDataSource()
var friends = []
@IBOutlet weak var table: UITableView!
@IBAction func dismissFriendView(sender: UIBarButtonItem) {
self.parentViewController?.dismissViewControllerAnimated(true, completion: nil)
}
func setData(frnds:[FriendData]){
self.friends = frnds
}
override func viewDidLoad() {
super.viewDidLoad()
self.table.delegate = self
self.table.dataSource = self
//self.navigationItem.rightBarButtonItem = self.editButtonItem()
//self.friends = manager.getFriends()
//NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshTable:", name: "refreshTableView", object: nil)
//debug statements
}
/*func refreshTable(notification: NSNotification){
self.friends = manager.getFriends()
self.table.reloadData()
}*/
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.friends.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let friend = self.friends[indexPath.row] as? FriendData
let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as? FriendsCell
//sets display name of friend (print for debugging purposes)
cell!.friendName.text = friend!.displayName
println(friend!.displayName)
//sets profile image of current cell
//checks if friend user has a profile image or not
if friend?.profileImg == nil {
cell!.proImage.backgroundColor = UIColor.grayColor()
}
else{
}
//rounds uiimage and configures UIImageView
//cell!.proImage.layer.borderWidth = 3.0
//cell!.proImage.clipsToBounds = true
cell!.proImage.layer.cornerRadius = cell!.proImage.frame.size.width/2
//cell!.proImage.layer.borderColor = UIColor.whiteColor().CGColor
//cell!.proImage.layer.masksToBounds = true
return cell!
}
override func setEditing(editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
self.table.setEditing(editing, animated: true)
if editing{
}
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
switch editingStyle {
case .Delete:
//delete friend from users friend array, parse, and tableView
println("delete")
default:
return
}
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>GetHip.xcdatamodel</string>
</dict>
</plist>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model name="Test1.xcdatamodel" userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" macOSVersion="Automatic" iOSVersion="Automatic">
<elements/>
</model>

View File

@ -0,0 +1,101 @@
//
// HomeScreenViewController.swift
// GetHip
//
// Created by Okechi on 1/3/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class HomeScreenViewController: UIViewController {
var usrDataManager = UserParseDataSource()
var frndDataManager = FriendDataSource()
var friendData: [FriendData] = []
var userData: [UserParseData] = []
let partyData = PartyServiceManager()
@IBOutlet weak var CreateAPartyBtn: UIButton!
//async data update methods
func refreshFriendData(notification:NSNotification){
self.friendData = self.frndDataManager.getFriends()
}
func refreshUserData(notification:NSNotification){
self.userData = self.usrDataManager.getUser()
self.partyData.setPeerID((self.userData[0].displayName))
self.partyData.setAdvertiser()
}
func loadID(notification: NSNotification){
self.performSegueWithIdentifier("InviteFriendsSegue", sender: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.backgroundColor = UIColor.whiteColor()
CreateAPartyBtn.layer.cornerRadius = 5
CreateAPartyBtn.layer.borderWidth = 1
NSNotificationCenter.defaultCenter().addObserver(self, selector: "loadID:", name: "gotDisplayID", object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshFriendData:", name: "refreshTableView", object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshUserData:", name: "refreshSettingsView", object: nil) }
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "InviteFriendsSegue" {
let nav: UINavigationController = (segue.destinationViewController as? UINavigationController)!
let vc: TestInviteFriendsController = (nav.viewControllers[0] as? TestInviteFriendsController)!
//initialize host role
self.partyData.setRole(PeerType(rawValue: 0)!)
//initialize browser to find nearby friends
self.partyData.setBrowser()
//initialize session
self.partyData.initializeSession()
vc.setData(self.userData, frndData: self.friendData, party: self.partyData)
}
if segue.identifier == "SettingsSegue" {
let nav: UINavigationController = (segue.destinationViewController as? UINavigationController)!
let vc: SettingsTableViewController = (nav.viewControllers[0] as? SettingsTableViewController)!
vc.setData(self.userData)
}
if segue.identifier == "FriendListSegue" {
let nav: UINavigationController = (segue.destinationViewController as? UINavigationController)!
let vc: FriendsListViewController = (nav.viewControllers[0] as? FriendsListViewController)!
vc.setData(self.friendData)
}
}
/*
// 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.
}
*/
}

View File

@ -0,0 +1,20 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"subtype" : "retina4",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "1x.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "3x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,25 @@
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "1x-1.png",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "1x.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,38 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

53
GetHip/Info.plist Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>oonyeje.Kroleo.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1166375230058840</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>FacebookAppID</key>
<string>1166375230058840</string>
<key>FacebookDisplayName</key>
<string>Get Hip!</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,35 @@
//
// InviteFriendCell.swift
// GetHip
//
// Created by Okechi on 1/23/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class InviteFriendCell: UITableViewCell {
@IBOutlet var friendName: UILabel!
@IBOutlet var proImage: UIImageView!
@IBOutlet var rdioButton: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
// Drawing code
}
*/
}

View File

@ -0,0 +1,116 @@
//
// InviteFriendsView.swift
// GetHip
//
// Created by Okechi on 1/22/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
import MultipeerConnectivity
class InviteFriendsViewControler: UITableViewController{
var usr: [UserParseData] = []
var frnds: [FriendData] = []
let partyService = PartyServiceManager()
@IBAction func cancelInvites(sender: UIBarButtonItem) {
self.parentViewController?.dismissViewControllerAnimated(true, completion: nil)
}
func setData(usrDat: [UserParseData], frndData: [FriendData]){
self.usr = usrDat
self.frnds = frndData
//self.partyService.setData(self.usr[0].displayName)
}
override func viewDidLoad() {
super.viewDidLoad()
// 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.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 0
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 0
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("InviteCell", forIndexPath: indexPath) as! InviteFriendCell
// Configure the cell...
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.
}
*/
}
//extensions for connecting and inviting peers

View File

@ -0,0 +1,52 @@
//
// LoginViewController.swift
// GetHip
//
// Created by Okechi on 1/2/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class LoginViewController: PFLogInViewController{
var backgroundImage: UIImageView!;
override func viewDidLoad() {
super.viewDidLoad()
self.signUpController = SignUpViewController()
//set custom logo background image
backgroundImage = UIImageView(image: UIImage(named: "1x"))
backgroundImage.contentMode = UIViewContentMode.ScaleAspectFill
self.logInView!.insertSubview(backgroundImage, atIndex: 0)
//customize common buttons in login
customizeButtons(logInView?.logInButton!)
//customize login button
logInView!.logInButton?.setTitle("Sign In", forState: .Normal)
//var loginFrame: CGRect = logInView!.logInButton!.frame
//loginFrame.origin.x = loginFrame.origin.x
//loginFrame.origin.y = loginFrame.origin.y
//loginFrame.size.width = loginFrame.size.width - 100
//loginFrame.size.height = loginFrame.size.height
//logInView!.logInButton!.frame = loginFrame
//customize password forget button
logInView!.passwordForgottenButton?.setTitleColor(UIColor.whiteColor(), forState: .Normal)
}
func customizeButtons(button: UIButton!){
button.setBackgroundImage(nil, forState: .Normal)
button.backgroundColor = UIColor.clearColor()
button.layer.cornerRadius = 5
button.layer.borderWidth = 1
button.layer.borderColor = UIColor.whiteColor().CGColor
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
//stretch background image to fill screen
backgroundImage.frame = CGRectMake(0, 0, self.logInView!.frame.width, self.logInView!.frame.height)
}
}

183
GetHip/Main.storyboard Normal file
View File

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="6mR-Ay-Hzp">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--Login View Controller-->
<scene sceneID="VdH-cE-Gd7">
<objects>
<viewController id="6mR-Ay-Hzp" userLabel="Login View Controller" customClass="ViewController" customModule="GetHip" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="yTV-g7-erQ"/>
<viewControllerLayoutGuide type="bottom" id="gXm-Ft-J4A"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="r17-av-M3G">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<connections>
<segue destination="i3K-xv-zw1" kind="show" identifier="HomeScreenSegue" id="dYP-IJ-p2K"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="i4i-Mt-4g3" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="671" y="362"/>
</scene>
<!--Home Screen View Controller-->
<scene sceneID="74v-iN-Rpu">
<objects>
<viewController id="i3K-xv-zw1" customClass="HomeScreenViewController" customModule="GetHip" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="TfY-s2-B0B"/>
<viewControllerLayoutGuide type="bottom" id="nqn-B0-8f9"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="TKW-IF-c3d">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="Turntable@3x.png" translatesAutoresizingMaskIntoConstraints="NO" id="Ugh-Mp-5Vj">
<rect key="frame" x="104" y="208" width="112" height="112"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iPz-hc-0g2" userLabel="CreateParty">
<rect key="frame" x="93" y="335" width="134" height="26"/>
<state key="normal" backgroundImage="Create@3x.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NHH-gh-nMz" userLabel="Friends">
<rect key="frame" x="19" y="44" width="56" height="32"/>
<constraints>
<constraint firstAttribute="width" secondItem="NHH-gh-nMz" secondAttribute="height" multiplier="7:4" id="yQ8-AL-Ipt"/>
</constraints>
<state key="normal" image="Friends@3x.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<variation key="default">
<mask key="constraints">
<exclude reference="yQ8-AL-Ipt"/>
</mask>
</variation>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8gk-cL-0Zc" userLabel="Settings">
<rect key="frame" x="274" y="44" width="30" height="29"/>
<state key="normal" image="Settings@3x.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<segue destination="0Tt-tN-iza" kind="show" id="bZG-mB-VR5"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yyg-Ne-RP5" userLabel="Favorites">
<rect key="frame" x="19" y="483" width="44" height="44"/>
<state key="normal" image="Star@3x.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="NHH-gh-nMz" firstAttribute="top" secondItem="TfY-s2-B0B" secondAttribute="bottom" constant="24" id="A3A-61-Dhj"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="A3A-61-Dhj"/>
</mask>
</variation>
</view>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<connections>
<outlet property="CreateAPartyBtn" destination="iPz-hc-0g2" id="LS0-K7-TZL"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="DGZ-Up-yND" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1409" y="-630"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="tiH-l9-ICs">
<objects>
<navigationController id="0Tt-tN-iza" sceneMemberID="viewController">
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="nIj-4Q-9QA">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="hze-Wf-sBw" kind="relationship" relationship="rootViewController" id="orR-fo-mrF"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="XlG-Ef-dN4" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1868" y="-1281"/>
</scene>
<!--View Controller-->
<scene sceneID="DdO-46-Oce">
<objects>
<viewController id="hze-Wf-sBw" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="0iX-Pt-wMZ"/>
<viewControllerLayoutGuide type="bottom" id="y0v-Q6-Get"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="ctw-5J-FC7">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="Fdh-6Y-dZF">
<rect key="frame" x="0.0" y="64" width="320" height="269"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="TEr-Ei-tdB">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="TEr-Ei-tdB" id="lWp-UC-Usq">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="q3Z-7M-2bk">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="q3Z-7M-2bk" id="km5-ox-ec8">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="hNW-1m-4W0">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hNW-1m-4W0" id="9Gc-eb-pvb">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="75P-WS-8qX">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="75P-WS-8qX" id="wJd-HF-alU">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="Yny-0N-8ky">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Yny-0N-8ky" id="v3I-yE-JqX">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="nFi-x9-pS7"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Qjc-mB-GgZ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2346" y="-1281"/>
</scene>
</scenes>
<resources>
<image name="Create@3x.png" width="471" height="93"/>
<image name="Friends@3x.png" width="219" height="126"/>
<image name="Settings@3x.png" width="116" height="113"/>
<image name="Star@3x.png" width="172" height="166"/>
<image name="Turntable@3x.png" width="434" height="434"/>
</resources>
</document>

25
GetHip/ParseNetDebug.h Normal file
View File

@ -0,0 +1,25 @@
//
// ParseNetDebug.h
// GetHip
//
// Created by Okechi on 1/6/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
#ifndef GetHip_ParseNetDebug_h
#define GetHip_ParseNetDebug_h
#import <Foundation/Foundation.h>
#import <Parse/Parse.h>
@interface ParseNetDebug : NSObject
+ (void)receiveWillSendURLRequestNotification:(NSNotification *) notification;
+ (void)receiveDidReceiveURLResponseNotification:(NSNotification *) notification;
@end
#endif

29
GetHip/ParseNetDebug.m Normal file
View File

@ -0,0 +1,29 @@
//
// ParseNetDebug.m
// GetHip
//
// Created by Okechi on 1/7/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
#import "ParseNetDebug.h"
@implementation ParseNetDebug: NSObject
+ (void)receiveWillSendURLRequestNotification:(NSNotification *) notification {
NSURLRequest *request = notification.userInfo[PFNetworkNotificationURLRequestUserInfoKey];
NSLog(@"URL : %@", request.URL.absoluteString);
NSLog(@"Method : %@", request.HTTPMethod);
NSLog(@"Headers : %@", request.allHTTPHeaderFields);
NSLog(@"Request Body : %@", [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding]);
}
+ (void)receiveDidReceiveURLResponseNotification:(NSNotification *) notification {
NSURLRequest *request = notification.userInfo[PFNetworkNotificationURLRequestUserInfoKey];
NSHTTPURLResponse *response = notification.userInfo[PFNetworkNotificationURLResponseUserInfoKey];
NSString *responseBody = notification.userInfo[PFNetworkNotificationURLResponseBodyUserInfoKey];
NSLog(@"URL : %@", request.URL.absoluteString);
NSLog(@"Status Code : %ld", (long)response.statusCode);
NSLog(@"Headers : %@", response.allHeaderFields);
NSLog(@"Response Body : %@", responseBody);
}
@end

View File

@ -0,0 +1,233 @@
//
// PartyServiceManager.swift
// GetHip
//
// Created by Okechi on 1/22/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation
import MultipeerConnectivity
protocol PartyServiceManagerDelegate {
func didConnectToPeer(serviceManager: PartyServiceManager, didConnectToPeer peerIDName: String )
func foundAPeer(serviceManager: PartyServiceManager, foundPeer: String)
}
enum PeerType : Int {
case Host = 0
case Guest = 1
}
enum HostSignalType: String {
case PauseAudio = "Pause"
case PlayAudio = "Play"
}
class PartyServiceManager: NSObject {
let PartyServiceType = "GetHip-Party"
var serviceAdvertiser: MCNearbyServiceAdvertiser! = nil
var myPeerID: MCPeerID! = nil
var serviceBrowser: MCNearbyServiceBrowser! = nil
var session: MCSession! = nil
// var delegate: PartyServiceManagerDelegate?
//peer variables
var foundPeers: [String] = []
var invitedFriends: [String] = []
var role: PeerType! = nil
var connectingPeersDictionary = NSMutableDictionary()
var disconnectedPeersDictionary = NSMutableDictionary()
/*init(){
//self.serviceAdvertiser = MCNearbyServiceAdvertiser(peer: self.myPeerID, discoveryInfo: nil, serviceType: self.PartyServiceType)
//super.init()
//self.serviceAdvertiser.delegate = self
}*/
/*deinit {
//stop all session services
self.serviceAdvertiser.stopAdvertisingPeer()
self.serviceBrowser.stopBrowsingForPeers()
}*/
/*lazy var session: MCSession = {
let session = MCSession(peer: self.myPeerID, securityIdentity: nil, encryptionPreference: MCEncryptionPreference.Required)
}()*/
//Peer Initializer
func setPeerID(dispName: String){
self.myPeerID = MCPeerID(displayName: dispName)
println("PeerID set to %@", self.myPeerID.displayName)
}
func setRole(peerRole: PeerType){
self.role = peerRole
println("Role set to %@", self.role.rawValue)
}
//Listening methods
func setAdvertiser(){
self.serviceAdvertiser = MCNearbyServiceAdvertiser(peer: self.myPeerID, discoveryInfo: nil, serviceType: self.PartyServiceType)
self.serviceAdvertiser!.delegate = self
println("Advertiser Set")
}
func startListening(){
self.serviceAdvertiser.startAdvertisingPeer()
println("Started Listening for invitations")
}
func stopListening(){
self.serviceAdvertiser.stopAdvertisingPeer()
println("Stopped listening for invitations")
}
//Browsing Methods
func setBrowser(){
self.serviceBrowser = MCNearbyServiceBrowser(peer: self.myPeerID, serviceType: self.PartyServiceType)
self.serviceBrowser.delegate = self
println("Browser Set")
}
func startBrowser(){
self.serviceBrowser.startBrowsingForPeers()
println("Started Browsing for peers")
}
func stopBrowsing(){
self.serviceBrowser.stopBrowsingForPeers()
println("Stopped Browsing for peers")
}
//Audio Streaming methods
func openOutputStream() -> NSMutableArray{
var outputs: NSMutableArray?
for peer in self.session.connectedPeers {
outputs?.addObject(self.session.startStreamWithName("music", toPeer: peer as! MCPeerID, error: nil))
}
return outputs!
}
func outputStreamForPeer(peer: MCPeerID) -> NSOutputStream {
return session.startStreamWithName("music", toPeer: peer, error: nil)
}
//Host Methods
func initializeSession(){
self.session = MCSession(peer: self.myPeerID, securityIdentity: nil, encryptionPreference: MCEncryptionPreference.Required)
println("Started Browsing for peers")
}
//Deprecated
/*
func setData(dispName: String){
//initialize session variable
self.myPeerID = MCPeerID(displayName: dispName)
self.serviceAdvertiser = MCNearbyServiceAdvertiser(peer: self.myPeerID, discoveryInfo: nil, serviceType: self.PartyServiceType)
self.serviceBrowser = MCNearbyServiceBrowser(peer: self.myPeerID, serviceType: self.PartyServiceType)
self.session = MCSession(peer: self.myPeerID, securityIdentity: nil, encryptionPreference: MCEncryptionPreference.Required)
//assign session delegates
self.serviceAdvertiser.delegate = self
self.serviceBrowser.delegate = self
self.session.delegate = self
//start all services
self.serviceAdvertiser.startAdvertisingPeer()
self.serviceBrowser.startBrowsingForPeers()
}
*/
func connectedPeers() -> [AnyObject]{
return self.session.connectedPeers
}
}
//delegate extensions
extension PartyServiceManager: MCNearbyServiceBrowserDelegate{
func browser(browser: MCNearbyServiceBrowser!, didNotStartBrowsingForPeers error: NSError!) {
NSLog("%@", "didNotStartBrowsingForPeers: \(error)")
}
func browser(browser: MCNearbyServiceBrowser!, foundPeer peerID: MCPeerID!, withDiscoveryInfo info: [NSObject : AnyObject]!) {
if(peerID.displayName != self.myPeerID.displayName) {
NSLog("%@", "foundPeer: \(peerID)")
self.foundPeers.append(peerID.displayName)
}
//implement way of picking which friends from friend list are invited
}
func browser(browser: MCNearbyServiceBrowser!, lostPeer peerID: MCPeerID!) {
NSLog("%@", "lostPeer: \(peerID)")
}
}
extension PartyServiceManager: MCNearbyServiceAdvertiserDelegate{
func advertiser(advertiser: MCNearbyServiceAdvertiser!, didNotStartAdvertisingPeer error: NSError!) {
NSLog("%@", "didNotStartAdvertisingPeer: \(error)")
}
func advertiser(advertiser: MCNearbyServiceAdvertiser!, didReceiveInvitationFromPeer peerID: MCPeerID!, withContext context: NSData!, invitationHandler: ((Bool, MCSession!) -> Void)!) {
NSLog("%@", "invitingPeer: \(peerID)")
}
}
extension PartyServiceManager: MCSessionDelegate{
func session(session: MCSession!, peer peerID: MCPeerID!, didChangeState state: MCSessionState) {
NSLog("%@", "peer \(peerID) didChangeState: \(state.stringValue())")
}
func session(session: MCSession!, didReceiveData data: NSData!, fromPeer peerID: MCPeerID!) {
NSLog("%@", "didRecieveData: \(data)")
}
func session(session: MCSession!, didReceiveStream stream: NSInputStream!, withName streamName: String!, fromPeer peerID: MCPeerID!) {
NSLog("%@", "didRecieveStream: \(streamName) from peer: \(peerID)")
}
func session(session: MCSession!, didFinishReceivingResourceWithName resourceName: String!, fromPeer peerID: MCPeerID!, atURL localURL: NSURL!, withError error: NSError!) {
NSLog("%@", "didFinishReceivingResourceWithName: \(resourceName) from peer: \(peerID)")
}
func session(session: MCSession!, didStartReceivingResourceWithName resourceName: String!, fromPeer peerID: MCPeerID!, withProgress progress: NSProgress!) {
NSLog("%@", "didStartReceivingResourceWithName: \(resourceName) from peer: \(peerID)")
}
}
//state extensions
extension MCSessionState{
func stringValue() -> String {
switch(self){
case .NotConnected: return "NotConnected"
case .Connecting: return "Connecting"
case .Connected: return "Connected"
default: return "Unknown"
}
}
}

41
GetHip/PartySession.swift Normal file
View File

@ -0,0 +1,41 @@
//
// PartySessionManager.swift
// GetHip
//
// Created by Okechi on 1/24/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation
import MediaPlayer
class PartySession {
private var partyName: String! = ""
private var guests: [FriendData] = []
private var host: FriendData! = nil
private var currentSong: MPMediaItem! = nil
func setPartyName(name: String){
}
func addGuests(guest: FriendData){
self.guests.append(guest)
}
func setHost(newHost: FriendData){
self.host = newHost
}
func getPartyName() -> String {
return self.partyName
}
func getGuests() -> [FriendData] {
return self.guests
}
func getHost() -> FriendData {
return self.host
}
}

View File

@ -0,0 +1,9 @@
//
// PartySessionManager.swift
// GetHip
//
// Created by Okechi on 1/24/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation

View File

@ -0,0 +1,66 @@
//
// SettingsCellWrapper.swift
// GetHip
//
// Created by Okechi on 1/21/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation
class DisplayNameCell: UITableViewCell {
@IBOutlet var dispName: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
class UserNameCell: UITableViewCell {
@IBOutlet var usrName: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
class EmailCell: UITableViewCell {
@IBOutlet var email: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
class ResetPassCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
class ProfilePicCell: UITableViewCell{
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}

View File

@ -0,0 +1,213 @@
//
// SettingsDetailViewWrapper.swift
// GetHip
//
// Created by Okechi on 1/22/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class DisplayDetailViewController: UIViewController {
var possibleName: String!
@IBOutlet weak var textfield: UITextField?
@IBOutlet weak var ChnDspName: UIButton!
@IBAction func DspBtnConfrim(sender: UIButton) {
self.possibleName = self.textfield?.text
//sanitize and alert for input and success later
var query = PFUser.query()
var currentUser = PFUser.currentUser()
query!.whereKey("username", equalTo: (currentUser?.username as String!))
query!.getFirstObjectInBackgroundWithBlock {
(object, error) -> Void in
if error != nil || object == nil {
println("Object request failed")
}
else if let object = object{
object.setObject(self.possibleName, forKey: "displayName")
object.saveInBackground()
//NSNotificationCenter.defaultCenter().postNotificationName("savingName", object: nil)
}
}
println(self.possibleName)
}
var displayName: String!
func setData(display: String){
self.displayName = display
}
func refreshView(notification: NSNotification){
}
override func viewDidLoad() {
super.viewDidLoad()
self.textfield?.placeholder = self.displayName
self.ChnDspName.layer.borderWidth = 1
self.ChnDspName.layer.cornerRadius = 5
self.ChnDspName.layer.borderColor = UIColor.blackColor().CGColor
// Do any additional setup after loading the view.
NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshView:", name: "savingName", object: nil)
}
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.
}
*/
}
class EmailDetailViewController: UIViewController {
var possibleEmail: String!
@IBOutlet weak var textfield: UITextField?
@IBOutlet weak var ChnEmailBtn: UIButton!
@IBAction func ChnEmailComfirm(sender: UIButton) {
self.possibleEmail = self.textfield?.text
//sanitize and alert for input and success later
var query = PFUser.query()
var currentUser = PFUser.currentUser()
query!.whereKey("username", equalTo: (currentUser?.username as String!))
query!.getFirstObjectInBackgroundWithBlock {
(object, error) -> Void in
if error != nil || object == nil {
println("Object request failed")
}
else if let object = object{
object.setObject(self.possibleEmail, forKey: "email")
object.saveInBackground()
NSNotificationCenter.defaultCenter().postNotificationName("savingEmail", object: nil)
}
}
println(self.possibleEmail)
}
var email: String!
func setData(email: String){
self.email = email
}
override func viewDidLoad() {
super.viewDidLoad()
self.textfield?.placeholder = self.email
self.ChnEmailBtn.layer.borderWidth = 1
self.ChnEmailBtn.layer.cornerRadius = 5
self.ChnEmailBtn.layer.borderColor = UIColor.blackColor().CGColor
// Do any additional setup after loading the view.
NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshView:", name: "savingEmail", object: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func refreshView(notification: NSNotification){
}
/*
// 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.
}
*/
}
class ProfileDetailViewController: UIViewController {
var profileImg: UIImageView!
@IBOutlet weak var img: UIImageView!
@IBOutlet weak var ChngPhtoBtn: UIButton!
@IBAction func changePhoto(sender: UIButton) {
//code to change profileImg
}
func setData(){
self.profileImg = nil
}
override func viewDidLoad() {
super.viewDidLoad()
self.img!.layer.cornerRadius = self.img!.frame.size.width/2
if self.profileImg == nil{
self.img!.backgroundColor = UIColor.grayColor()
}
else{
self.img = self.profileImg
}
self.ChngPhtoBtn!.layer.borderWidth = 1
self.ChngPhtoBtn!.layer.cornerRadius = 5
self.ChngPhtoBtn!.layer.borderColor = UIColor.blackColor().CGColor
// 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.
}
*/
}

View File

@ -0,0 +1,280 @@
//
// SettingsTableViewController.swift
// GetHip
//
// Created by Okechi on 1/21/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class SettingsTableViewController: UITableViewController {
// var manager = UserParseDataSource()
var user = []
@IBOutlet weak var logOutBtn: UIButton!
@IBOutlet weak var table: UITableView!
@IBAction func dismissSettingsView(sender: UIBarButtonItem) {
self.parentViewController?.dismissViewControllerAnimated(true, completion: nil)
}
@IBAction func logOutUser(sender: UIButton) {
PFUser.logOut()
if PFUser.currentUser() == nil {
self.performSegueWithIdentifier("LogOutSegue", sender: sender)
}
}
func setData(usr:[UserParseData]){
self.user = usr
}
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "Settings"
self.logOutBtn.layer.borderWidth = 1
self.logOutBtn.layer.cornerRadius = 5
self.logOutBtn.layer.borderColor = UIColor.blackColor().CGColor
//NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshTable:", name: "refreshSettingsView", object: nil)
self.table.reloadData()
// 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.
}
// 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 5
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
println(indexPath.row)
switch indexPath.row {
case 0:
let cell = (self.tableView.dequeueReusableCellWithIdentifier("DispNameCell", forIndexPath: indexPath) as? DisplayNameCell)!
if self.user.count > 0 {
cell.dispName.text = (self.user[0] as? UserParseData)!.displayName
}
return cell
case 1:
let cell = (self.tableView.dequeueReusableCellWithIdentifier("UserNameCell", forIndexPath: indexPath) as? UserNameCell)!
if self.user.count > 0 {
cell.usrName.text = (self.user[0] as? UserParseData)!.username
}
return cell
case 2:
let cell = (self.tableView.dequeueReusableCellWithIdentifier("EmailCell", forIndexPath: indexPath) as? EmailCell)!
if self.user.count > 0 {
cell.email.text = (self.user[0] as? UserParseData)!.email
}
return cell
case 3:
let cell = (self.table.dequeueReusableCellWithIdentifier("PassCell", forIndexPath: indexPath) as? ResetPassCell)!
if self.user.count > 0 {
}
return cell
default:
let cell = (self.table.dequeueReusableCellWithIdentifier("PictureCell", forIndexPath: indexPath) as? ProfilePicCell)!
if self.user.count > 0 {
}
return cell
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
switch indexPath.row {
//display name view
case 0:
if self.user.count > 0 {
self.performSegueWithIdentifier("DisplayNameSegue", sender: nil)
}
//user name view
case 1:
if self.user.count > 0 {
}
break
//email view
case 2:
if self.user.count > 0 {
self.performSegueWithIdentifier("EmailSegue", sender: nil)
}
//reset pass
case 3:
if self.user.count > 0 {
}
break
//Profile Picture View
default:
if self.user.count > 0 {
self.performSegueWithIdentifier("PhotoSegue", sender: nil)
}
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let indexPath = self.table.indexPathForSelectedRow() {
switch indexPath.row {
//display name view
case 0:
if self.user.count > 0 {
let vc: DisplayDetailViewController = (segue.destinationViewController as? DisplayDetailViewController)!
vc.setData((self.user[0] as? UserParseData)!.displayName)
println(vc.displayName)
}
//email view
case 2:
if self.user.count > 0 {
let vc: EmailDetailViewController = (segue.destinationViewController as? EmailDetailViewController)!
vc.setData((self.user[0] as? UserParseData)!.email)
println(vc.email)
}
//reset pass
case 3:
if self.user.count > 0 {
}
//Profile Picture View
default:
if self.user.count > 0 {
let vc: ProfileDetailViewController = (segue.destinationViewController as? ProfileDetailViewController)!
vc.setData()
println("img")
}
}
}
}
/* func refreshTable(notification: NSNotification){
self.user = manager.getUser()
self.table.reloadData()
}*/
/*
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as! UITableViewCell
// Configure the cell...
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.
}
*/
}

View File

@ -0,0 +1,29 @@
//
// SignUpViewController.swift
// GetHip
//
// Created by Okechi on 1/3/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class SignUpViewController: PFSignUpViewController{
var backgroundImage: UIImageView!;
override func viewDidLoad() {
super.viewDidLoad()
//set custom logo background image
backgroundImage = UIImageView(image: UIImage(named: "1x"))
backgroundImage.contentMode = UIViewContentMode.ScaleAspectFill
signUpView!.insertSubview(backgroundImage, atIndex: 0)
//self.signUpController?.signUpView!.insertSubview(backgroundImage, atIndex: 1)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
//stretch background image to fill screen
backgroundImage.frame = CGRectMake(0, 0, signUpView!.frame.width, signUpView!.frame.height)
}
}

View File

@ -0,0 +1,70 @@
//
// SongCell.swift
// GetHip
//
// Created by Okechi on 1/24/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class SongCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
class AlbumCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
class ArtistCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
class FilterCell: UITableViewCell {
@IBOutlet var filterBtn: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}

View File

@ -0,0 +1,226 @@
//
// SongSelectionViewController.swift
// GetHip
//
// Created by Okechi on 1/24/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
import MediaPlayer
class SongSelectionViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var table: UITableView!
@IBAction func selectFilter(sender: AnyObject) {
let filterMenu = UIAlertController(title: nil, message:nil, preferredStyle: .ActionSheet)
let cell: FilterCell = self.table.cellForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0)) as! FilterCell
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
(alert: UIAlertAction!) -> Void in
})
let songFilterAction = UIAlertAction(title: "Songs", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
self.filter = "Songs"
cell.filterBtn.titleLabel?.text = self.filter
self.table.reloadData()
})
let albumFilterAction = UIAlertAction(title: "Albums", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
self.filter = "Albums"
cell.filterBtn.titleLabel?.text = self.filter
self.table.reloadData()
})
let artistFilterAction = UIAlertAction(title: "Artists", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
self.filter = "Artists"
cell.filterBtn.titleLabel?.text = self.filter
self.table.reloadData()
})
switch self.filter {
case "Artists":
filterMenu.addAction(songFilterAction)
filterMenu.addAction(albumFilterAction)
case "Albums":
filterMenu.addAction(songFilterAction)
filterMenu.addAction(artistFilterAction)
break
default:
filterMenu.addAction(artistFilterAction)
filterMenu.addAction(albumFilterAction)
break
}
filterMenu.addAction(cancelAction)
self.presentViewController(filterMenu, animated: true, completion: nil)
}
private var filter: String! = "Songs"
@IBAction func cancelInvites(sender: UIBarButtonItem) {
self.parentViewController?.dismissViewControllerAnimated(true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
self.table.delegate = self
self.table.dataSource = self
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
switch self.filter{
//return number of rows for albums
case "albums":
var albumsQuery = MPMediaQuery.albumsQuery()
var albums = albumsQuery.collections
return albums.count + 1
//return number of rows for artists
case "artists":
var artistsQuery = MPMediaQuery.artistsQuery()
var artists = artistsQuery.items
return artists.count + 1
//return number of rows for song
default:
var songsQuery = MPMediaQuery.songsQuery()
var songs = songsQuery.items
return songs.count + 1
}
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if( indexPath.row == 0){
let cell = self.table.dequeueReusableCellWithIdentifier("FilterCell", forIndexPath: indexPath) as? FilterCell
return cell!
}
else{
switch self.filter{
//return albums cell
case "albums":
let cell = self.table.dequeueReusableCellWithIdentifier("AlbumCell", forIndexPath: indexPath) as? AlbumCell
var albumsQuery = MPMediaQuery.albumsQuery()
var albums = albumsQuery.items
var rowItem: MPMediaItem = albums[indexPath.row - 1] as! MPMediaItem
cell?.textLabel?.text = rowItem.valueForProperty(MPMediaItemPropertyAlbumTitle) as? String!
cell?.detailTextLabel?.text = rowItem.valueForProperty(MPMediaItemPropertyAlbumArtist) as? String!
var artwork: MPMediaItemArtwork = rowItem.valueForProperty(MPMediaItemPropertyArtwork) as! MPMediaItemArtwork
var artworkImage = artwork.imageWithSize(CGSize(width: 44,height: 44))
if(artworkImage != nil){
cell?.imageView?.image = artworkImage
}
else{
cell?.imageView?.backgroundColor = UIColor.grayColor()
}
return cell!
//return artists cell
case "artists":
let cell = self.table.dequeueReusableCellWithIdentifier("ArtistCell", forIndexPath: indexPath) as? ArtistCell
var artistsQuery = MPMediaQuery.artistsQuery()
var artists = artistsQuery.items
var rowItem: MPMediaItem = artists[indexPath.row - 1] as! MPMediaItem
cell?.textLabel?.text = rowItem.valueForProperty(MPMediaItemPropertyArtist) as? String!
var artwork: MPMediaItemArtwork = rowItem.valueForProperty(MPMediaItemPropertyArtwork) as! MPMediaItemArtwork
var artworkImage = artwork.imageWithSize(CGSize(width: 44,height: 44))
if(artworkImage != nil){
cell?.imageView?.image = artworkImage
}
else{
cell?.imageView?.backgroundColor = UIColor.grayColor()
}
return cell!
//return song cell
default:
let cell = self.table.dequeueReusableCellWithIdentifier("SongCell", forIndexPath: indexPath) as? SongCell
var songsQuery = MPMediaQuery.songsQuery()
var songs = songsQuery.items
var rowItem: MPMediaItem = songs[indexPath.row - 1] as! MPMediaItem
cell?.textLabel?.text = rowItem.valueForProperty(MPMediaItemPropertyTitle) as? String!
cell?.detailTextLabel?.text = rowItem.valueForProperty(MPMediaItemPropertyArtist) as? String!
var artwork: MPMediaItemArtwork = rowItem.valueForProperty(MPMediaItemPropertyArtwork) as! MPMediaItemArtwork
var artworkImage = artwork.imageWithSize(CGSize(width: 44,height: 44))
if(artworkImage != nil){
cell?.imageView?.image = artworkImage
}
else{
cell?.imageView?.backgroundColor = UIColor.grayColor()
}
return cell!
}
}
}
/*
// 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.
}
*/
}

View File

@ -0,0 +1,36 @@
//
// TestInviteFriendsCell.swift
// GetHip
//
// Created by Okechi on 1/23/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation
import UIKit
class TestInviteFriendsCell: UITableViewCell {
@IBOutlet var friendName: UILabel!
@IBOutlet var proImage: UIImageView!
@IBOutlet var rdioButton: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
// Drawing code
}
*/
}

View File

@ -0,0 +1,187 @@
//
// TestInviteFriendsController.swift
// GetHip
//
// Created by Okechi on 1/23/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
import MultipeerConnectivity
class TestInviteFriendsController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var usr: [UserParseData] = []
var frnds: [FriendData] = []
var isFriendSelected: [Bool] = []
var partyData: PartyServiceManager! = nil
@IBOutlet weak var table: UITableView!
@IBAction func cancelInvites(sender: UIBarButtonItem) {
self.partyData.stopBrowsing()
self.partyData.serviceBrowser = nil
println("Browser service deinitialized and browser deinitialized")
self.parentViewController?.dismissViewControllerAnimated(true, completion: nil)
}
@IBAction func sendInvites(sender: UIButton) {
var numSelected = 0
for booli in self.isFriendSelected {
if booli == true {
numSelected++
}
}
if(numSelected > 0){
self.performSegueWithIdentifier("selectSongSegue", sender: sender)
}
else{
println("Select a friend")
}
}
func setData(usrDat: [UserParseData], frndData: [FriendData], party: PartyServiceManager){
self.usr = usrDat
self.frnds = frndData
self.partyData = party
for i in 0..<self.frnds.count{
self.isFriendSelected.append(false)
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.table.delegate = self
self.table.dataSource = 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.
}
// MARK: - Table view data source
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return self.frnds.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let friend = self.frnds[indexPath.row]
let cell = self.table.dequeueReusableCellWithIdentifier("TestInviteCell", forIndexPath: indexPath) as? TestInviteFriendsCell
//sets display name of friend (print for debugging purposes)
cell!.friendName.text = friend.displayName
println(friend.displayName)
//sets profile image of current cell
//checks if friend user has a profile image or not
if friend.profileImg == nil {
cell!.proImage.backgroundColor = UIColor.grayColor()
}
else{
}
//rounds uiimage and configures UIImageView
//cell!.proImage.layer.borderWidth = 3.0
//cell!.proImage.clipsToBounds = true
cell!.proImage.layer.cornerRadius = cell!.proImage.frame.size.width/2
cell!.alpha = 0.5
//cell!.proImage.layer.borderColor = UIColor.whiteColor().CGColor
//cell!.proImage.layer.masksToBounds = true
cell!.rdioButton.layer.cornerRadius = cell!.rdioButton.frame.size.width/2
return cell!
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell = table.cellForRowAtIndexPath(indexPath) as? TestInviteFriendsCell
if self.isFriendSelected[indexPath.row] == false{
cell!.rdioButton.setBackgroundImage(UIImage(named: "Blue Check.png"), forState: UIControlState.Normal)
self.isFriendSelected[indexPath.row] = true
}
else{
cell!.rdioButton.setBackgroundImage(UIImage(named: "Tap Circle.png"), forState: UIControlState.Normal)
self.isFriendSelected[indexPath.row] = false
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var invited: [FriendData] = []
for var i = 0; i < self.isFriendSelected.count; i++ {
if (self.isFriendSelected[i] == true) {
invited.append(self.frnds[i])
}
}
println(invited.count)
}
/*
// 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.
}
*/
}

View File

@ -0,0 +1,27 @@
//
// UserParseData.swift
// GetHip
//
// Created by Okechi on 1/22/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation
import Foundation
class UserParseData {
var username: String!
var displayName: String!
var profileImg: UIImageView!
var email: String!
init(usrName: String, dispName: String, email: String){
self.username = usrName
self.profileImg = nil //proImage
self.displayName = dispName
self.email = email
}
}

View File

@ -0,0 +1,64 @@
//
// UserParseDataSource.swift
// GetHip
//
// Created by Okechi on 1/22/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import Foundation
class UserParseDataSource{
var user: [UserParseData]
init() {
user = []
var query = PFUser.query()
var currentUser = PFUser.currentUser()
query!.whereKey("username", equalTo: (currentUser?.username as String!))
query!.findObjectsInBackgroundWithBlock {
(objects, error) -> Void in
//print(error)
if error == nil {
for object in objects! {
var usr: UserParseData
var usrName: String!
var profileImage: UIImageView
var displayName: String
var email: String
usrName = object.objectForKey("username")! as! String
displayName = object.objectForKey("displayName") as! String
if displayName.isEmpty {
displayName = usrName
}
email = object.objectForKey("email")! as! String
usr = UserParseData(usrName: usrName, dispName: displayName, email: email)
self.user.append(usr)
//print(userName)
}
}
NSNotificationCenter.defaultCenter().postNotificationName("refreshSettingsView", object: nil)
}
}
func getUser() -> [UserParseData]{
return self.user
}
}

View File

@ -0,0 +1,69 @@
//
// ViewController.swift
// GetHip
//
// Created by Okechi on 1/1/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
class ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate{
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if (PFUser.currentUser() == nil){
let loginViewController = LoginViewController()
loginViewController.delegate = self
loginViewController.fields = .UsernameAndPassword | .LogInButton | .PasswordForgotten | .SignUpButton //add fb button later, need to figure out error
//loginViewController.signUpController?.delegate = self
//*no longer needed since I am assigning custom signupController that inherits the signupController
//hides parse logo
loginViewController.logInView?.logo?.hidden = true
loginViewController.signUpController?.signUpView?.logo?.hidden = true
self.presentViewController(loginViewController, animated: false, completion: nil)
}
else{
presentLoggedInAlert()
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil)
presentLoggedInAlert()
}
func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil)
presentLoggedInAlert()
}
func presentLoggedInAlert() {
self.performSegueWithIdentifier("HomeScreenSegue", sender: nil)
}
}

View File

@ -0,0 +1,36 @@
//
// GetHipTests.swift
// GetHipTests
//
// Created by Okechi on 1/1/16.
// Copyright (c) 2016 Kroleo. All rights reserved.
//
import UIKit
import XCTest
class GetHipTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}
}

24
GetHipTests/Info.plist Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>oonyeje.Kroleo.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>