Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Finished removing hamburger nav and changed messaging view
  • Loading branch information
mafellows committed Mar 7, 2016
commit 97e05690daef98dff14eb20eb34b82e5e19e3d71
50 changes: 32 additions & 18 deletions Cluster.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file modified Cluster/.DS_Store
Binary file not shown.
279 changes: 52 additions & 227 deletions Cluster/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Cluster/Cluster-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <ParseUI/PFImageView.h>
#import <MBProgressHUD/MBProgressHUD.h>
#import <SlackTextViewController/SLKTextViewController.h>
#import "SWRevealViewController.h"
#import <SlackTextViewController/SLKTextViewController.h>
15 changes: 15 additions & 0 deletions Cluster/Extensions/UIColor+KlusterColors.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// UIColor+KlusterColors.swift
// Cluster
//
// Created by Michael Fellows on 3/4/16.
// Copyright © 2016 ImagineME. All rights reserved.
//

import Foundation

extension UIColor {
static func klusterPurpleColor() -> UIColor {
return UIColor(red: 195.0 / 255.0, green: 127.0 / 255.0, blue: 230.0 / 255.0, alpha: 1.0)
}
}
74 changes: 54 additions & 20 deletions Cluster/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class HomeViewController: UIViewController {
@IBOutlet weak var searchButton: UIButton!
@IBOutlet weak var menuButton: UIButton!
@IBOutlet weak var currentUserProfileImageButton:UIButton!
@IBOutlet weak var currentUserFullNameButton:UIButton!
@IBOutlet weak var profileAvatar: PFImageView!
@IBOutlet var createKlusterButton: UIButton!

//MARK: - UICollectionViewDataSource
Expand Down Expand Up @@ -50,23 +48,19 @@ class HomeViewController: UIViewController {
self.view.addGestureRecognizer(tapRecognizer)

// Update the user profile information
let user = PFUser.currentUser()
self.profileAvatar.file = user?.objectForKey("avatarThumbnail") as? PFFile
self.profileAvatar.loadInBackground()

let firstName = user?.objectForKey("firstName") as? String
self.currentUserFullNameButton.setTitle(firstName, forState: .Normal)

profileAvatar.layer.cornerRadius = 10.0
profileAvatar.clipsToBounds = true

//Side Menu
if self.revealViewController() != nil {
menuButton.addTarget(self.revealViewController(), action: "revealToggle:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
// let user = PFUser.currentUser()
// self.profileAvatar.file = user?.objectForKey("avatarThumbnail") as? PFFile
// self.profileAvatar.loadInBackground()
//
// let firstName = user?.objectForKey("firstName") as? String
// self.currentUserFullNameButton.setTitle(firstName, forState: .Normal)
//
// profileAvatar.layer.cornerRadius = 10.0
// profileAvatar.clipsToBounds = true

self.calculateCurrentLocation()

self.addProfileView()
}

override func viewWillAppear(animated: Bool) {
Expand Down Expand Up @@ -161,6 +155,45 @@ class HomeViewController: UIViewController {
}
}
}

private func addProfileView() {
let user = PFUser.currentUser()
let firstName = user?.objectForKey("firstName") as? String
let maxWidth = self.view.frame.size.width - 200.0
let font = UIFont.systemFontOfSize(17)
let labelWidth = self.widthForlabel(firstName, font: font, maxWidth: maxWidth)
let profileFrame = CGRectMake(0, 0, labelWidth, 40)
let userProfileView = ProfileNameView.init(frame: profileFrame)
userProfileView.layoutForUser(user)
self.view.addSubview(userProfileView)

let profileRecognizer = UITapGestureRecognizer.init(target: self, action: "profileTapped:")
userProfileView.addGestureRecognizer(profileRecognizer)

let metrics = ["spacing" : 6]
let views = ["userProfileView" : userProfileView]
let profileH = NSLayoutConstraint.constraintsWithVisualFormat("H:[userProfileView]-|", options: NSLayoutFormatOptions(rawValue: 0) , metrics: nil, views: views)
let profileY = NSLayoutConstraint.constraintsWithVisualFormat("V:[userProfileView]-(spacing)-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics , views: views)
self.view.addConstraints(profileH)
self.view.addConstraints(profileY)
}

private func widthForlabel(text: String?, font: UIFont, maxWidth: CGFloat) -> CGFloat {
let label:UILabel = UILabel(frame: CGRectMake(0, 0, maxWidth, CGFloat.max))
label.numberOfLines = 1
label.lineBreakMode = NSLineBreakMode.ByWordWrapping
label.font = font
label.text = text

label.sizeToFit()
return label.frame.height
}

func profileTapped(sender: UITapGestureRecognizer) {
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
let profileController = storyboard.instantiateViewControllerWithIdentifier("ProfileViewController")
self.presentViewController(profileController, animated: true, completion: nil)
}
}

extension HomeViewController : UICollectionViewDataSource
Expand Down Expand Up @@ -247,12 +280,13 @@ extension HomeViewController : UICollectionViewDataSource

func featuredImageViewTapped(sender: UITapGestureRecognizer) {
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
let klusterVC = storyboard.instantiateViewControllerWithIdentifier("KlusterViewController") as! KlusterViewController;
let messagesController = storyboard.instantiateViewControllerWithIdentifier("MessagesTableViewController") as! MessagesTableViewController
let k = Kluster.init(object: self.klusters[(sender.view?.tag)!])
klusterVC.kluster = k
messagesController.kluster = k


// Show kluster
let navigationController = UINavigationController.init(rootViewController: klusterVC)
let navigationController = UINavigationController.init(rootViewController: messagesController)
self.presentViewController(navigationController, animated: true, completion: nil);
}

Expand Down
74 changes: 36 additions & 38 deletions Cluster/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to show you nearby Klusters. </string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1524087811242588</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1524087811242588</string>
<key>FacebookDisplayName</key>
<string>Kluster</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -33,47 +18,46 @@
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
<array>
<string>BondoluoPeek.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<key>CFBundleURLTypes</key>
<array>
<string>armv7</string>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1524087811242588</string>
</array>
</dict>
</array>
<key>UISupportedInterfaceOrientations</key>
<key>CFBundleVersion</key>
<string>1</string>
<key>FacebookAppID</key>
<string>1524087811242588</string>
<key>FacebookDisplayName</key>
<string>Kluster</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>fbauth2</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
Expand All @@ -82,9 +66,23 @@
</dict>
</dict>
</dict>
<key>LSApplicationQueriesSchemes</key>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to show you nearby Klusters. </string>
<key>UIAppFonts</key>
<array>
<string>fbauth2</string>
<string>BondoluoPeek.ttf</string>
</array>
<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>
1 change: 0 additions & 1 deletion Cluster/KlusterViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class KlusterViewController: UIViewController, CAPSPageMenuDelegate {

// Optional delegate
pageMenu!.delegate = self

self.view.addSubview(pageMenu!.view)
}

Expand Down
2 changes: 1 addition & 1 deletion Cluster/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LoginViewController: UIViewController {

// Make graph request for current user and get their information
// user_location, user_birthday, user_about_me
let params = ["fields" : "first_name, last_name, email, name, id, picture, user_birthday"]
let params = ["fields" : "first_name, last_name, email, name, id, picture"]

let request: FBSDKGraphRequest = FBSDKGraphRequest.init(graphPath: "me", parameters: params, HTTPMethod: "GET")
request.startWithCompletionHandler({ (connection: FBSDKGraphRequestConnection!, result: AnyObject?, graphRequestError: NSError?) -> Void in
Expand Down
6 changes: 4 additions & 2 deletions Cluster/MembersTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ class MembersTableViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false

self.navigationItem.title = "Members"

self.tableView.tableFooterView = UIView()

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
Expand Down
6 changes: 5 additions & 1 deletion Cluster/MessageTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class MessageTextView: UIView {
let buttonWidth = 60.0 as CGFloat
let textFieldWidth = width - (3 * textFieldPadding) - buttonWidth

let spacingView = UIView.init(frame: CGRectMake(0, 0, width, 1.0))
spacingView.backgroundColor = UIColor(white: 0.0, alpha: 0.1)
self.addSubview(spacingView)

let textFieldFrame = CGRectMake(textFieldPadding, textFieldPadding, textFieldWidth, height - (2 * textFieldPadding))
textField = UITextField.init(frame: textFieldFrame)
textField.placeholder = "Enter a message..."
Expand All @@ -32,7 +36,7 @@ class MessageTextView: UIView {
sendButton = UIButton.init(type: .Custom)
sendButton.setTitle("Send", forState: .Normal)
sendButton.frame = CGRectMake(textFieldWidth + (2 * textFieldPadding), textFieldPadding, buttonWidth, height - (2 * textFieldPadding))
sendButton.setTitleColor(.blueColor(), forState: .Normal)
sendButton.setTitleColor(.klusterPurpleColor(), forState: .Normal)
self.addSubview(sendButton)
}

Expand Down
17 changes: 17 additions & 0 deletions Cluster/MessagesNavigationController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// MessagesNavigationController.swift
// Cluster
//
// Created by Michael Fellows on 3/7/16.
// Copyright © 2016 ImagineME. All rights reserved.
//

import UIKit

class MessagesNavigationController : UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()

self.view.backgroundColor = .clearColor()
}
}
45 changes: 44 additions & 1 deletion Cluster/MessagesTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ class MessagesTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()

// Format the navigation bar
self.navigationItem.title = self.kluster.title
// self.navigationController?.navigationBar.backgroundColor = .klusterPurpleColor()

let dismissItem = UIBarButtonItem.init(image: UIImage(named: "CloseButton2"),
style: .Plain,
target: self,
action: "dismissPressed:")
self.navigationItem.leftBarButtonItem = dismissItem

let menuItem = UIBarButtonItem.init(title: "Menu", style: .Plain, target: self, action: "menuPressed:")
self.navigationItem.rightBarButtonItem = menuItem

self.fetchMessages()

// Update the keyboard status
Expand All @@ -50,6 +63,18 @@ class MessagesTableViewController: UITableViewController {
self.fetchMessages()
}

func dismissPressed(sender: UIBarButtonItem) {
self.dismissViewControllerAnimated(true, completion: nil)
}

func menuPressed(sender: UIBarButtonItem) {
let popover = PopoverMenuController()
popover.kluster = self.kluster
let messageNavController = UINavigationController.init(rootViewController: popover)
messageNavController.modalPresentationStyle = UIModalPresentationStyle.Custom
self.presentViewController(messageNavController, animated: false, completion: nil)
}

override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(true)

Expand Down Expand Up @@ -81,7 +106,12 @@ class MessagesTableViewController: UITableViewController {
print("Error fetching messages.")
} else {
self.messages = objects as! [PFObject]
self.messages = self.messages.reverse()

self.tableView.reloadData()

// Scroll to the last index path...
self.scrollTableToBottom(false)
}
}
}
Expand Down Expand Up @@ -141,6 +171,10 @@ class MessagesTableViewController: UITableViewController {
return textViewHeight
}

override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.textView.textField.resignFirstResponder()
}
Expand Down Expand Up @@ -188,7 +222,16 @@ class MessagesTableViewController: UITableViewController {
frame.origin.y = self.windowHeight! - convertedKeyboardEndFrame.size.height - self.textViewHeight
self.textView.frame = frame
}
}) { (finished) -> Void in
}) { (completed) -> Void in
self.scrollTableToBottom(true)
}
}

private func scrollTableToBottom(animated: Bool) {
if (self.messages.count > 0) {
let indexToScrollTo = Int(self.messages.count - 1)
let lastIndexPath = NSIndexPath.init(forItem: indexToScrollTo, inSection: 0)
self.tableView.scrollToRowAtIndexPath(lastIndexPath, atScrollPosition: .Top, animated: animated)
}
}
}
Loading