From 9a646cea6d82877026045c0b113cc434413efadb Mon Sep 17 00:00:00 2001 From: Okechi Date: Wed, 17 Feb 2016 10:29:23 -0500 Subject: [PATCH] decided to make another view controller for going back to the home screen while in party, a lot simpler and less issues with multiple party instances --- GetHip.xcodeproj/project.pbxproj | 4 ++ GetHip/BackToHomeScreenViewController.swift | 56 ++++++++++++++++ GetHip/CurrentlyPlayingViewController.swift | 27 ++++---- GetHip/HomeScreenViewController.swift | 5 +- GetHip/LoadingPartyViewController.swift | 14 +++- GetHip/LoginController.swift | 9 ++- GetHip/Main.storyboard | 73 ++++++++++++++++----- GetHip/SongSelectionViewController.swift | 13 ++-- GetHip/TestInviteFriendsController.swift | 6 +- 9 files changed, 161 insertions(+), 46 deletions(-) create mode 100644 GetHip/BackToHomeScreenViewController.swift diff --git a/GetHip.xcodeproj/project.pbxproj b/GetHip.xcodeproj/project.pbxproj index c8b6766..5a263bb 100644 --- a/GetHip.xcodeproj/project.pbxproj +++ b/GetHip.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ 3E43B8C91C37639C002F97A7 /* FBSDKCoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E1BDA751C3713F900EE3B84 /* FBSDKCoreKit.framework */; }; 3E43B8CA1C37639C002F97A7 /* FBSDKLoginKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E43B8C51C375E73002F97A7 /* FBSDKLoginKit.framework */; }; 3E43B8CF1C376F9F002F97A7 /* Logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 3E43B8CE1C376F9F002F97A7 /* Logo.png */; }; + 3E50E0401C74B97300EB9EA9 /* BackToHomeScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E50E03F1C74B97300EB9EA9 /* BackToHomeScreenViewController.swift */; }; 3E5485B31C69A7DA00E7D5AB /* LoadingPartyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E5485B21C69A7DA00E7D5AB /* LoadingPartyViewController.swift */; }; 3E5485B51C69CE2F00E7D5AB /* InvitedCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E5485B41C69CE2F00E7D5AB /* InvitedCollectionViewCell.swift */; }; 3E5952631C39DBC900C88C71 /* Friends.png in Resources */ = {isa = PBXBuildFile; fileRef = 3E59525A1C39DBC900C88C71 /* Friends.png */; }; @@ -199,6 +200,7 @@ 3E43B8C41C375E73002F97A7 /* Bolts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Bolts.framework; path = ../../FacebookSDK/Bolts.framework; sourceTree = ""; }; 3E43B8C51C375E73002F97A7 /* FBSDKLoginKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSDKLoginKit.framework; path = ../../FacebookSDK/FBSDKLoginKit.framework; sourceTree = ""; }; 3E43B8CE1C376F9F002F97A7 /* Logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Logo.png; path = "../../../Dropbox/gethip/Screens/6 Login/Assets/Logo.png"; sourceTree = ""; }; + 3E50E03F1C74B97300EB9EA9 /* BackToHomeScreenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackToHomeScreenViewController.swift; sourceTree = ""; }; 3E5485B21C69A7DA00E7D5AB /* LoadingPartyViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingPartyViewController.swift; sourceTree = ""; }; 3E5485B41C69CE2F00E7D5AB /* InvitedCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InvitedCollectionViewCell.swift; sourceTree = ""; }; 3E59525A1C39DBC900C88C71 /* Friends.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Friends.png; path = "../Get Hip/Get Hip/Assets/Friends.png"; sourceTree = ""; }; @@ -455,6 +457,7 @@ isa = PBXGroup; children = ( 3E1EE6381C6D02EB00F5C5D7 /* InPartyViewController.swift */, + 3E50E03F1C74B97300EB9EA9 /* BackToHomeScreenViewController.swift */, ); name = InParty; sourceTree = ""; @@ -853,6 +856,7 @@ 3E627FE81C55AE35005C0372 /* TDAudioMetaInfo.m in Sources */, 3E6738F51C6E9C7700B47C3E /* LoginController.swift in Sources */, 3E34125B1C54C73A006226E0 /* PartySession.swift in Sources */, + 3E50E0401C74B97300EB9EA9 /* BackToHomeScreenViewController.swift in Sources */, 3E627FF01C55AE35005C0372 /* TDAudioStream.m in Sources */, 3E627FE91C55AE35005C0372 /* TDAudioPlayer.m in Sources */, 3EDA82E31C4741C70081ED53 /* FriendDataSource.swift in Sources */, diff --git a/GetHip/BackToHomeScreenViewController.swift b/GetHip/BackToHomeScreenViewController.swift new file mode 100644 index 0000000..6e95708 --- /dev/null +++ b/GetHip/BackToHomeScreenViewController.swift @@ -0,0 +1,56 @@ +// +// BackToHomeScreenViewController.swift +// GetHip +// +// Created by Okechi on 2/17/16. +// Copyright (c) 2016 Kroleo. All rights reserved. +// + +import UIKit + +class BackToHomeScreenViewController: UIViewController { + var friendData: [FriendData] = [] + var requestData: [FriendData] = [] + var userData: [UserParseData] = [] + var partyData: PartyServiceManager! + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + func setData(prty:PartyServiceManager, user: [UserParseData], friends: [FriendData], request: [FriendData]){ + self.partyData = prty + self.userData = user + self.friendData = friends + self.requestData = request + } + // 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?) { + + if segue.identifier == "FromPartySettingsSegue" { + let nav: UINavigationController = (segue.destinationViewController as? UINavigationController)! + + let vc: SettingsTableViewController = (nav.viewControllers[0] as? SettingsTableViewController)! + vc.setData(self.userData, prty: self.partyData) + } + + if segue.identifier == "FromPartyFriendsSegue" { + let nav: UINavigationController = (segue.destinationViewController as? UINavigationController)! + + let vc: FriendsListViewController = (nav.viewControllers[0] as? FriendsListViewController)! + vc.setData(self.friendData, requst: self.requestData) + } + } + + + +} diff --git a/GetHip/CurrentlyPlayingViewController.swift b/GetHip/CurrentlyPlayingViewController.swift index 67bb825..9e55dc6 100644 --- a/GetHip/CurrentlyPlayingViewController.swift +++ b/GetHip/CurrentlyPlayingViewController.swift @@ -10,6 +10,13 @@ import UIKit import MediaPlayer class CurrentlyPlayingViewController: UIViewController { + //persistant data + var party: PartyServiceManager! + var usr: [UserParseData] = [] + var frnds: [FriendData] = [] + var requestData: [FriendData] = [] + + //controller data @IBOutlet var songImg: UIImageView! @IBOutlet var titleLabel: UILabel! @IBOutlet var artistAndAlbumLabel: UILabel! @@ -27,18 +34,8 @@ class CurrentlyPlayingViewController: UIViewController { //Guest buttons - //Regular buttons - @IBAction func partyView(sender: UIButton){ - self.performSegueWithIdentifier("InPartySegue", sender: self) - } - @IBAction func backToHome(sender: UIButton){ - self.performSegueWithIdentifier("BackToHomeScreenSegue", sender: self) - } - - - var party: PartyServiceManager! override func viewDidLoad() { super.viewDidLoad() @@ -56,8 +53,11 @@ class CurrentlyPlayingViewController: UIViewController { // Dispose of any resources that can be recreated. } - func setData(prty: PartyServiceManager){ + func setData(prty:PartyServiceManager, user: [UserParseData], friends: [FriendData], request: [FriendData]){ self.party = prty + self.usr = user + self.frnds = friends + self.requestData = request } @@ -77,9 +77,8 @@ class CurrentlyPlayingViewController: UIViewController { } if segue.identifier == "BackToHomeScreenSegue" { - let vc: HomeScreenViewController = (segue.destinationViewController as? HomeScreenViewController)! - vc.comingFromParty = true - vc.partyData = self.party + let vc: BackToHomeScreenViewController = (segue.destinationViewController as? BackToHomeScreenViewController)! + vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData) } } diff --git a/GetHip/HomeScreenViewController.swift b/GetHip/HomeScreenViewController.swift index 2d724be..81e7723 100644 --- a/GetHip/HomeScreenViewController.swift +++ b/GetHip/HomeScreenViewController.swift @@ -14,8 +14,7 @@ class HomeScreenViewController: UIViewController { var friendData: [FriendData] = [] var requestData: [FriendData] = [] var userData: [UserParseData] = [] - var partyData = PartyServiceManager() - var comingFromParty: Bool! + let partyData = PartyServiceManager() @IBOutlet weak var CreateAPartyBtn: UIButton! @@ -87,7 +86,7 @@ class HomeScreenViewController: UIViewController { self.partyData.setRole(PeerType(rawValue: 0)!) - vc.setData(self.userData, frndData: self.friendData, party: self.partyData) + vc.setData(self.userData, frndData: self.friendData, party: self.partyData, request: self.requestData) } if segue.identifier == "SettingsSegue" { diff --git a/GetHip/LoadingPartyViewController.swift b/GetHip/LoadingPartyViewController.swift index f73c599..5b11a96 100644 --- a/GetHip/LoadingPartyViewController.swift +++ b/GetHip/LoadingPartyViewController.swift @@ -10,8 +10,13 @@ import UIKit import MediaPlayer class LoadingPartyViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate{ + //persistant data var party: PartyServiceManager! - + var usr: [UserParseData] = [] + var frnds: [FriendData] = [] + var requestData: [FriendData] = [] + + //controller data @IBOutlet var songImg: UIImageView! @IBOutlet var invitedFriends: UICollectionView! @IBOutlet var songLabel: UILabel! @@ -59,8 +64,11 @@ class LoadingPartyViewController: UIViewController, UICollectionViewDataSource, } } - func setData(prty: PartyServiceManager){ + func setData(prty:PartyServiceManager, user: [UserParseData], friends: [FriendData], request: [FriendData]){ self.party = prty + self.usr = user + self.frnds = friends + self.requestData = request } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { @@ -101,7 +109,7 @@ class LoadingPartyViewController: UIViewController, UICollectionViewDataSource, // Pass the selected object to the new view controller. if(segue.identifier == "CurrentlyPlayingSegue"){ let vc: CurrentlyPlayingViewController = (segue.destinationViewController as? CurrentlyPlayingViewController)! - vc.setData(self.party) + vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData) } } diff --git a/GetHip/LoginController.swift b/GetHip/LoginController.swift index 8cbbbd8..4bc66cc 100644 --- a/GetHip/LoginController.swift +++ b/GetHip/LoginController.swift @@ -26,7 +26,7 @@ class LoginController: UIViewController, PFLogInViewControllerDelegate, UITextFi if(user != nil){ self.performSegueWithIdentifier("LoginToHomeSegue", sender: self) }else{ - var alert = UIAlertController(title: "Invalid Login", message: "Your friend request was sent successfully!", preferredStyle: .Alert) + var alert = UIAlertController(title: "Invalid Login", message: "Your username/email or password is incorrect!", preferredStyle: .Alert) alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)})) self.presentViewController(alert, animated: true, completion: nil) @@ -69,17 +69,16 @@ class LoginController: UIViewController, PFLogInViewControllerDelegate, UITextFi } // 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?) { if segue.identifier == "LoginToHomeSegue" { - let vc: HomeScreenViewController = (segue.destinationViewController as? HomeScreenViewController)! - vc.comingFromParty = false + } } - + */ func textFieldShouldReturn(textField: UITextField) -> Bool { self.view.endEditing(true) return false diff --git a/GetHip/Main.storyboard b/GetHip/Main.storyboard index 93e6b84..85ce502 100644 --- a/GetHip/Main.storyboard +++ b/GetHip/Main.storyboard @@ -1027,7 +1027,9 @@ - + + + @@ -1057,6 +1059,45 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -1072,23 +1113,13 @@ - @@ -1153,6 +1184,15 @@ + @@ -1166,7 +1206,6 @@ - @@ -1467,6 +1506,7 @@ + @@ -1476,12 +1516,15 @@ + - + + + diff --git a/GetHip/SongSelectionViewController.swift b/GetHip/SongSelectionViewController.swift index c1e59b5..b17f4a8 100644 --- a/GetHip/SongSelectionViewController.swift +++ b/GetHip/SongSelectionViewController.swift @@ -10,8 +10,10 @@ import UIKit import MediaPlayer class SongSelectionViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { - var party: PartyServiceManager! = nil - + var party: PartyServiceManager! + var usr: [UserParseData] = [] + var frnds: [FriendData] = [] + var requestData: [FriendData] = [] @IBOutlet weak var table: UITableView! @@ -85,8 +87,11 @@ class SongSelectionViewController: UIViewController, UITableViewDelegate, UITabl // Dispose of any resources that can be recreated. } - func setData(prty:PartyServiceManager){ + func setData(prty:PartyServiceManager, user: [UserParseData], friends: [FriendData], request: [FriendData]){ self.party = prty + self.usr = user + self.frnds = friends + self.requestData = request } func numberOfSectionsInTableView(tableView: UITableView) -> Int { @@ -269,7 +274,7 @@ class SongSelectionViewController: UIViewController, UITableViewDelegate, UITabl override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if(segue.identifier == "LoadingPartySegue"){ let vc: LoadingPartyViewController = (segue.destinationViewController as? LoadingPartyViewController)! - vc.setData(self.party) + vc.setData(self.party, user: self.usr, friends: self.frnds, request: self.requestData) } } diff --git a/GetHip/TestInviteFriendsController.swift b/GetHip/TestInviteFriendsController.swift index 1a89b5f..ec08416 100644 --- a/GetHip/TestInviteFriendsController.swift +++ b/GetHip/TestInviteFriendsController.swift @@ -12,6 +12,7 @@ import MultipeerConnectivity class TestInviteFriendsController: UIViewController, UITableViewDelegate, UITableViewDataSource { var usr: [UserParseData] = [] var frnds: [FriendData] = [] + var requestData: [FriendData] = [] var isFriendSelected: [Bool] = [] var partyData: PartyServiceManager! = nil @@ -41,10 +42,11 @@ class TestInviteFriendsController: UIViewController, UITableViewDelegate, UITabl } - func setData(usrDat: [UserParseData], frndData: [FriendData], party: PartyServiceManager){ + func setData(usrDat: [UserParseData], frndData: [FriendData], party: PartyServiceManager, request: [FriendData]){ self.usr = usrDat self.frnds = frndData self.partyData = party + self.requestData = request for i in 0..