diff --git a/socialCalendar.xcodeproj/project.pbxproj b/socialCalendar.xcodeproj/project.pbxproj index 4d905ea..82d9599 100644 --- a/socialCalendar.xcodeproj/project.pbxproj +++ b/socialCalendar.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 025122511A3782CB00F3900A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 025122501A3782CB00F3900A /* Main.storyboard */; }; + 024A45BB1A33AB0900757D93 /* CalendarTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024A45BA1A33AB0900757D93 /* CalendarTableViewController.swift */; }; + 024A45BD1A33AB1C00757D93 /* CalendarTabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024A45BC1A33AB1C00757D93 /* CalendarTabBarViewController.swift */; }; 02C91E741A2E08E100B3977B /* Accounts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02C91E731A2E08E100B3977B /* Accounts.framework */; }; 02C91E761A2E08E500B3977B /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02C91E751A2E08E500B3977B /* AudioToolbox.framework */; }; 02C91E781A2E08ED00B3977B /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02C91E771A2E08EC00B3977B /* CFNetwork.framework */; }; @@ -26,9 +28,9 @@ 02C91E921A2E094F00B3977B /* ParseUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02C91E8E1A2E094F00B3977B /* ParseUI.framework */; }; 02C91E981A2E288700B3977B /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02C91E971A2E288700B3977B /* LoginViewController.swift */; }; 02F911991A2E604C00B15744 /* Miles.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02F911971A2E604C00B15744 /* Miles.storyboard */; }; + 1053D7D41A320C99006CB437 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1053D7D31A320C99006CB437 /* CoreData.framework */; }; 02F9119C1A2E61EE00B15744 /* Kevin.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02F9119A1A2E61EE00B15744 /* Kevin.storyboard */; }; 103679601A2E3124001D63D2 /* friends.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 1036795E1A2E3124001D63D2 /* friends.xcdatamodeld */; }; - 1053D7D41A320C99006CB437 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1053D7D31A320C99006CB437 /* CoreData.framework */; }; 1079FEF41A2D4AD900654080 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1079FEF31A2D4AD900654080 /* AppDelegate.swift */; }; 1079FEF61A2D4AD900654080 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1079FEF51A2D4AD900654080 /* ViewController.swift */; }; 1079FEFB1A2D4AD900654080 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1079FEFA1A2D4AD900654080 /* Images.xcassets */; }; @@ -54,6 +56,8 @@ /* Begin PBXFileReference section */ 025122501A3782CB00F3900A /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = ../Main.storyboard; sourceTree = ""; }; + 024A45BA1A33AB0900757D93 /* CalendarTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalendarTableViewController.swift; sourceTree = ""; }; + 024A45BC1A33AB1C00757D93 /* CalendarTabBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalendarTabBarViewController.swift; sourceTree = ""; }; 02C91E731A2E08E100B3977B /* Accounts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accounts.framework; path = System/Library/Frameworks/Accounts.framework; sourceTree = SDKROOT; }; 02C91E751A2E08E500B3977B /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 02C91E771A2E08EC00B3977B /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; @@ -70,11 +74,11 @@ 02C91E8C1A2E094F00B3977B /* Parse.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Parse.framework; sourceTree = ""; }; 02C91E8D1A2E094F00B3977B /* ParseFacebookUtils.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ParseFacebookUtils.framework; sourceTree = ""; }; 02C91E8E1A2E094F00B3977B /* ParseUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ParseUI.framework; sourceTree = ""; }; + 1053D7D31A320C99006CB437 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 02C91E971A2E288700B3977B /* LoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; 02F911981A2E604C00B15744 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Miles.storyboard; sourceTree = ""; }; 02F9119B1A2E61EE00B15744 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Kevin.storyboard; sourceTree = ""; }; 1036795F1A2E3124001D63D2 /* friends.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = friends.xcdatamodel; sourceTree = ""; }; - 1053D7D31A320C99006CB437 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 1079FEEE1A2D4AD900654080 /* socialCalendar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = socialCalendar.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1079FEF21A2D4AD900654080 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1079FEF31A2D4AD900654080 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -177,6 +181,8 @@ 1036795E1A2E3124001D63D2 /* friends.xcdatamodeld */, 02F9119A1A2E61EE00B15744 /* Kevin.storyboard */, 02F911971A2E604C00B15744 /* Miles.storyboard */, + 024A45BA1A33AB0900757D93 /* CalendarTableViewController.swift */, + 024A45BC1A33AB1C00757D93 /* CalendarTabBarViewController.swift */, 1079FEF31A2D4AD900654080 /* AppDelegate.swift */, 1079FEF51A2D4AD900654080 /* ViewController.swift */, 02C91E971A2E288700B3977B /* LoginViewController.swift */, @@ -334,10 +340,12 @@ 1079FEF41A2D4AD900654080 /* AppDelegate.swift in Sources */, 103679601A2E3124001D63D2 /* friends.xcdatamodeld in Sources */, 10F2D1361A2E2AB000DDD58D /* Friend.swift in Sources */, + 024A45BD1A33AB1C00757D93 /* CalendarTabBarViewController.swift in Sources */, 10F2D1341A2E2A9600DDD58D /* FriendsTableViewController.swift in Sources */, 10F2D1321A2E29C300DDD58D /* EditFriendsTableViewController.swift in Sources */, 10F2D13C1A2E2AFA00DDD58D /* FriendDetailsTableViewController.swift in Sources */, 10F2D13E1A2E2B3400DDD58D /* FriendTableViewCell.swift in Sources */, + 024A45BB1A33AB0900757D93 /* CalendarTableViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/socialCalendar/Base.lproj/Miles.storyboard b/socialCalendar/Base.lproj/Miles.storyboard index 92e98ee..cadaba8 100644 --- a/socialCalendar/Base.lproj/Miles.storyboard +++ b/socialCalendar/Base.lproj/Miles.storyboard @@ -1,25 +1,9 @@ - + - - - - - - - - - - - - - - - - @@ -55,6 +39,7 @@ + - + + + + + + + + + + + + + + + + + @@ -323,10 +324,10 @@ - + - + diff --git a/socialCalendar/CalendarTabBarViewController.swift b/socialCalendar/CalendarTabBarViewController.swift new file mode 100644 index 0000000..7a39bd9 --- /dev/null +++ b/socialCalendar/CalendarTabBarViewController.swift @@ -0,0 +1,35 @@ +// +// CalendarTabBarViewController.swift +// socialCalendar +// +// Created by Miles Crabill on 12/6/14. +// Copyright (c) 2014 AIT. All rights reserved. +// + +import UIKit + +class CalendarTabBarViewController: UITabBarController { + + 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. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/socialCalendar/CalendarTableViewController.swift b/socialCalendar/CalendarTableViewController.swift new file mode 100644 index 0000000..c0337e3 --- /dev/null +++ b/socialCalendar/CalendarTableViewController.swift @@ -0,0 +1,97 @@ +// +// CalendarTableViewController.swift +// socialCalendar +// +// Created by Miles Crabill on 12/6/14. +// Copyright (c) 2014 AIT. All rights reserved. +// + +import UIKit + +class CalendarTableViewController: UITableViewController { + + 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("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. + } + */ + +} diff --git a/socialCalendar/Info.plist b/socialCalendar/Info.plist index eccf8f8..4318277 100644 --- a/socialCalendar/Info.plist +++ b/socialCalendar/Info.plist @@ -25,7 +25,7 @@ UILaunchStoryboardName LaunchScreen UIMainStoryboardFile - Main + Miles UIRequiredDeviceCapabilities armv7 diff --git a/socialCalendar/LoginViewController.swift b/socialCalendar/LoginViewController.swift index 47802d3..8efdea9 100644 --- a/socialCalendar/LoginViewController.swift +++ b/socialCalendar/LoginViewController.swift @@ -15,15 +15,12 @@ class LoginViewController: UIViewController { @IBOutlet weak var messageLabel: UILabel! @IBAction func loginVerifyButton(sender: AnyObject) { + var username = usernameTextField.text var password = passwordTextField.text if username != "" && password != "" { loginUser() - var currentUser = PFUser.currentUser() - if currentUser != nil { - presentTabBarViewController() - } } else { var errorPopup = UIAlertController(title: "Please enter a username and password.", message: nil, preferredStyle: .Alert) var okayAction = UIAlertAction(title: "Okay", style: .Default, handler: nil) @@ -40,7 +37,7 @@ class LoginViewController: UIViewController { PFUser.logInWithUsernameInBackground(usernameTextField.text, password: passwordTextField.text) { user, error in if user != nil { - print("logged in") + self.performSegueWithIdentifier("login", sender: self) } else { var errorPopup = UIAlertController(title: "Login failed.", message: error.localizedDescription, preferredStyle: .Alert) var okayAction = UIAlertAction(title: "Okay", style: .Default, handler: nil) @@ -80,10 +77,8 @@ class LoginViewController: UIViewController { user.signUpInBackgroundWithBlock { success, error in - // TODO - // change if we modify class of the tab bar controller if success { - self.presentTabBarViewController() + self.performSegueWithIdentifier("login", sender: self.navigationController) } else { var errorPopup = UIAlertController(title: "An error occurred while registering", message: error.localizedDescription, preferredStyle: .Alert) var okayActionInner = UIAlertAction(title: "Okay", style: .Default, handler: nil) @@ -97,37 +92,47 @@ class LoginViewController: UIViewController { presentViewController(signupPopup, animated: true, completion: nil) } - func presentTabBarViewController() { - var vc = self.storyboard?.instantiateViewControllerWithIdentifier("TabBarController") as UITabBarController - self.navigationController?.pushViewController(vc, animated: true) + func logout() { + PFUser.logOut() + self.navigationController?.popToRootViewControllerAnimated(true) } override func viewDidLoad() { super.viewDidLoad() - - // Do any additional setup after loading the view. - var currentUser = PFUser.currentUser() if currentUser != nil { // cached user logged in - presentTabBarViewController() + performSegueWithIdentifier("login", sender: self) } + // 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. + if segue.identifier == "login" { + let vc = segue.destinationViewController as CalendarTabBarViewController + vc.navigationItem.hidesBackButton = true + vc.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Log Out", style: .Plain, target: self, action: "logout") + vc.navigationItem.title = "Logged in as " + PFUser.currentUser().username + } + } + + override func shouldPerformSegueWithIdentifier(identifier: String?, sender: AnyObject?) -> Bool { + // if no one is logged in, don't perform segue + if identifier == "login" && PFUser.currentUser() == nil { + return false + } + + return true } - */ }