Added restriction to adding a friend already in friend list, added camera and library access to settings menu to change user photo, will add parse connections to change photo and add profile image queries tomorrow or this weekend 2/05/16-2/07/16

This commit is contained in:
Okechi 2016-02-04 02:52:17 -05:00
parent ea10811a37
commit 7f5afd95fd
8 changed files with 118 additions and 16 deletions

View File

@ -672,6 +672,7 @@
TargetAttributes = { TargetAttributes = {
3E1BDA4B1C37111D00EE3B84 = { 3E1BDA4B1C37111D00EE3B84 = {
CreatedOnToolsVersion = 6.3.2; CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = 24WJ762CQL;
}; };
3E1BDA631C37111D00EE3B84 = { 3E1BDA631C37111D00EE3B84 = {
CreatedOnToolsVersion = 6.3.2; CreatedOnToolsVersion = 6.3.2;
@ -922,6 +923,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
/Users/okechi/Documents/FacebookSDK, /Users/okechi/Documents/FacebookSDK,
@ -935,6 +938,7 @@
"$(SDKROOT)/usr/lib/system", "$(SDKROOT)/usr/lib/system",
); );
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "$PROJECT_NAME/Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "$PROJECT_NAME/Bridging-Header.h";
}; };
name = Debug; name = Debug;
@ -943,6 +947,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
/Users/okechi/Documents/FacebookSDK, /Users/okechi/Documents/FacebookSDK,
@ -956,6 +962,7 @@
"$(SDKROOT)/usr/lib/system", "$(SDKROOT)/usr/lib/system",
); );
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "$PROJECT_NAME/Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "$PROJECT_NAME/Bridging-Header.h";
}; };
name = Release; name = Release;

View File

@ -15,11 +15,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate , CLLocationManagerDelegat
var window: UIWindow? var window: UIWindow?
// var locationStarted = false // var locationStarted = false
// var locationManager: CLLocationManager = CLLocationManager() var locationManager: CLLocationManager!
// var app = UIApplication.sharedApplication() // var app = UIApplication.sharedApplication()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.registerForRemoteNotifications()
//create new CLLocaationManager //create new CLLocaationManager
/*var locationStarted = false /*var locationStarted = false
locationManager.delegate = self*/ locationManager.delegate = self*/
@ -36,6 +36,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate , CLLocationManagerDelegat
let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
print(paths[0])*/ print(paths[0])*/
startSignificantChangeUpdates()
return true return true
} }
@ -77,6 +78,50 @@ class AppDelegate: UIResponder, UIApplicationDelegate , CLLocationManagerDelegat
self.saveContext() self.saveContext()
} }
//Core Location
func startSignificantChangeUpdates(){
if(locationManager == nil){
locationManager = CLLocationManager()
}
locationManager.delegate = self
locationManager.startMonitoringSignificantLocationChanges()
}
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
var location: CLLocation! = locations.last as! CLLocation
var geo:PFGeoPoint! = PFGeoPoint(location: location)
var query = PFQuery(className: "_User")
var currentUser = PFUser.currentUser()
query.whereKey("username", equalTo: (currentUser?.username as String!))
query.getFirstObjectInBackgroundWithBlock({
(object: PFObject?, error: NSError?) -> Void in
if(error == nil){
object?.setObject(geo, forKey: "location")
object?.saveInBackground()
}
})
}
/*
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
NSLog("Did register for remote notifications with device token (%@)", deviceToken)
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
NSLog("Did Fail to register for remote notifications")
NSLog("%@, %@", error, error.localizedDescription)
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
}*/
// MARK: - Core Data stack // MARK: - Core Data stack

View File

@ -133,12 +133,12 @@ extension FriendRequestViewController: UITextFieldDelegate{
self.searchedUsername = searchBar.text self.searchedUsername = searchBar.text
var inFriendsList: Bool = false var inFriendsList: Bool = false
/*for name in self.frnds{ for name in self.frnds{
if name == self.searchedUsername{ if name == self.searchedUsername{
inFriendsList = true inFriendsList = true
break break
} }
}*/ }
if(inFriendsList == false){ if(inFriendsList == false){
var query = PFQuery(className: "_User") var query = PFQuery(className: "_User")
query.whereKey("username", equalTo: searchedUsername) query.whereKey("username", equalTo: searchedUsername)
@ -157,6 +157,7 @@ extension FriendRequestViewController: UITextFieldDelegate{
}) })
}else{ }else{
let alert = UIAlertController(title: "Already Friends", message: "You are already friends with this user!", preferredStyle: .Alert) let alert = UIAlertController(title: "Already Friends", message: "You are already friends with this user!", 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) self.presentViewController(alert, animated: true, completion: nil)
} }

View File

@ -141,10 +141,12 @@ class FriendsListViewController: UIViewController, UITableViewDelegate, UITableV
} }
if segue.identifier == "FriendRequestSegue" { if segue.identifier == "FriendRequestSegue" {
/* var frndNames: [String] = [] var frndNames: [String] = []
println(self.friends.count)
for i in 0...self.friends.count-1{ for i in 0...self.friends.count-1{
var str:String! = self.friends[i].displayName as String! var frends: FriendData! = self.friends[i] as! FriendData
frndNames.append(str) println(frends.displayName!)
frndNames.append(frends.displayName!)
} }
/*for name in self.friends{ /*for name in self.friends{
@ -154,7 +156,7 @@ class FriendsListViewController: UIViewController, UITableViewDelegate, UITableV
}*/ }*/
let vc: FriendRequestViewController = (segue.destinationViewController as? FriendRequestViewController)! let vc: FriendRequestViewController = (segue.destinationViewController as? FriendRequestViewController)!
vc.setData(frndNames)*/ vc.setData(frndNames)
} }
} }

View File

@ -95,7 +95,7 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Username" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J2y-S7-GWi"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Username" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J2y-S7-GWi">
<rect key="frame" x="78" y="21" width="89" height="21"/> <rect key="frame" x="78" y="21" width="234" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
@ -262,7 +262,7 @@
<outlet property="table" destination="Bxz-d2-wT5" id="iuG-He-Fll"/> <outlet property="table" destination="Bxz-d2-wT5" id="iuG-He-Fll"/>
<segue destination="Iog-DT-pLJ" kind="show" identifier="FriendRequestSegue" id="7VN-Pi-TCg"/> <segue destination="Iog-DT-pLJ" kind="show" identifier="FriendRequestSegue" id="7VN-Pi-TCg"/>
<segue destination="Rnb-lz-mp4" kind="show" identifier="PendingRequestSegue" id="Q5N-t6-TQW"/> <segue destination="Rnb-lz-mp4" kind="show" identifier="PendingRequestSegue" id="Q5N-t6-TQW"/>
<segue destination="QG7-6d-dTi" kind="showDetail" identifier="NoRequestSegue" id="4Uy-oz-55l"/> <segue destination="QG7-6d-dTi" kind="show" identifier="NoRequestSegue" id="4Uy-oz-55l"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="2xN-Sf-spI" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="2xN-Sf-spI" userLabel="First Responder" sceneMemberID="firstResponder"/>

View File

@ -59,6 +59,9 @@ class PendingRequestViewController: UITableViewController {
if(error == nil){ if(error == nil){
object!.setObject("accepted", forKey: "RequestStatus") object!.setObject("accepted", forKey: "RequestStatus")
object!.save() object!.save()
} }
}) })
}) })
@ -67,11 +70,17 @@ class PendingRequestViewController: UITableViewController {
}) })
}) })
cell.proImg.hidden = true
cell.acceptButton.hidden = true
cell.denyButton.hidden = true
var tempString = cell.friendName.text!
cell.friendName.text = "You added " + tempString + "!!"
//self.table.reloadData()
} }
@IBAction func didRejectFriend(sender: AnyObject?){ @IBAction func didRejectFriend(sender: AnyObject?){
} }
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()

View File

@ -159,9 +159,9 @@ class EmailDetailViewController: UIViewController {
} }
class ProfileDetailViewController: UIViewController { class ProfileDetailViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
var profileImg: UIImageView! var profileImg: UIImageView!
private var picker = UIImagePickerController()
@IBOutlet weak var img: UIImageView! @IBOutlet weak var img: UIImageView!
@IBOutlet weak var ChngPhtoBtn: UIButton! @IBOutlet weak var ChngPhtoBtn: UIButton!
@ -169,7 +169,32 @@ class ProfileDetailViewController: UIViewController {
@IBAction func changePhoto(sender: UIButton) { @IBAction func changePhoto(sender: UIButton) {
//code to change profileImg let captureMenu = UIAlertController(title: nil, message:nil, preferredStyle: .ActionSheet)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
(alert: UIAlertAction!) -> Void in
})
let cameraAction = UIAlertAction(title: "Take a New Pic", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
self.picker.allowsEditing = false
self.picker.sourceType = UIImagePickerControllerSourceType.Camera
self.picker.cameraCaptureMode = .Photo
self.presentViewController(self.picker, animated: true, completion: nil)
})
let galleryAction = UIAlertAction(title: "Select a Profile Pic", style: .Default, handler: {
(alert: UIAlertAction!) -> Void in
self.picker.allowsEditing = false
self.picker.sourceType = .PhotoLibrary
self.presentViewController(self.picker, animated: true, completion: nil)
})
captureMenu.addAction(galleryAction)
captureMenu.addAction(cameraAction)
captureMenu.addAction(cancelAction)
self.presentViewController(captureMenu, animated: true, completion: nil)
} }
@ -190,6 +215,7 @@ class ProfileDetailViewController: UIViewController {
self.ChngPhtoBtn!.layer.borderWidth = 1 self.ChngPhtoBtn!.layer.borderWidth = 1
self.ChngPhtoBtn!.layer.cornerRadius = 5 self.ChngPhtoBtn!.layer.cornerRadius = 5
self.ChngPhtoBtn!.layer.borderColor = UIColor.blackColor().CGColor self.ChngPhtoBtn!.layer.borderColor = UIColor.blackColor().CGColor
self.picker.delegate = self
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
} }
@ -199,6 +225,14 @@ class ProfileDetailViewController: UIViewController {
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
//MARK: -Image Picker Delegate
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
dismissViewControllerAnimated(true, completion: nil)
}
/* /*
// MARK: - Navigation // MARK: - Navigation

View File

@ -9,7 +9,7 @@
import UIKit import UIKit
class ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate{ class ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate{
var autoSignin: Bool! = true
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib // Do any additional setup after loading the view, typically from a nib
@ -35,7 +35,10 @@ class ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpV
self.presentViewController(loginViewController, animated: false, completion: nil) self.presentViewController(loginViewController, animated: false, completion: nil)
} }
else{ else{
presentLoggedInAlert()
presentLoggedInAlert()
} }
} }
@ -49,6 +52,7 @@ class ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpV
func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) { func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil) self.dismissViewControllerAnimated(true, completion: nil)
presentLoggedInAlert() presentLoggedInAlert()
self.autoSignin = false
} }
func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) { func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) {