diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 1cb2f939..ce06c0e8 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -9,6 +9,10 @@ /* Begin PBXBuildFile section */ 0A02E46F1AC9208A00235DBF /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A02E46E1AC9208A00235DBF /* libxml2.dylib */; }; 0A0A11821AE389380008772C /* RegisterSkillsLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A0A11811AE389380008772C /* RegisterSkillsLayout.swift */; }; + 0A1CAC6B1AFA3D8900826B45 /* SkillHomeViewControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CAC6A1AFA3D8900826B45 /* SkillHomeViewControllerExtension.swift */; }; + 0A1CAC6E1AFA42D400826B45 /* SkillHomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CAC6D1AFA42D400826B45 /* SkillHomeViewController.swift */; }; + 0A1CAC701AFA481600826B45 /* SkillHomeHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CAC6F1AFA481600826B45 /* SkillHomeHeaderView.swift */; }; + 0A1CAC731AFA526200826B45 /* SkillHomeSectionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1CAC721AFA526200826B45 /* SkillHomeSectionButton.swift */; }; 0A271FD71ACA055400822DFC /* YepAudioService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A271FD61ACA055400822DFC /* YepAudioService.swift */; }; 0A3E60601ACCA9C0003DC853 /* String+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A3E605F1ACCA9C0003DC853 /* String+Yep.swift */; }; 0A3E60671ACCAECE003DC853 /* YepLocationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A3E60661ACCAECE003DC853 /* YepLocationService.swift */; }; @@ -171,6 +175,10 @@ /* Begin PBXFileReference section */ 0A02E46E1AC9208A00235DBF /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; 0A0A11811AE389380008772C /* RegisterSkillsLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RegisterSkillsLayout.swift; path = ViewControllers/Register/RegisterSkillsLayout.swift; sourceTree = ""; }; + 0A1CAC6A1AFA3D8900826B45 /* SkillHomeViewControllerExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SkillHomeViewControllerExtension.swift; path = ViewControllers/SkillPage/SkillHomeViewControllerExtension.swift; sourceTree = ""; }; + 0A1CAC6D1AFA42D400826B45 /* SkillHomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SkillHomeViewController.swift; path = ViewControllers/SkillHome/SkillHomeViewController.swift; sourceTree = ""; }; + 0A1CAC6F1AFA481600826B45 /* SkillHomeHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SkillHomeHeaderView.swift; path = Views/SkillHomeHeaderView/SkillHomeHeaderView.swift; sourceTree = ""; }; + 0A1CAC721AFA526200826B45 /* SkillHomeSectionButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SkillHomeSectionButton.swift; path = Views/SkillHomeSectionButton/SkillHomeSectionButton.swift; sourceTree = ""; }; 0A271FD61ACA055400822DFC /* YepAudioService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepAudioService.swift; path = Services/YepAudioService.swift; sourceTree = ""; }; 0A3E605F1ACCA9C0003DC853 /* String+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "String+Yep.swift"; path = "Extensions/String+Yep.swift"; sourceTree = ""; }; 0A3E60661ACCAECE003DC853 /* YepLocationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepLocationService.swift; path = Services/YepLocationService.swift; sourceTree = ""; }; @@ -362,6 +370,31 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0A1CAC6C1AFA3D8C00826B45 /* SkillPage */ = { + isa = PBXGroup; + children = ( + 0A1CAC6D1AFA42D400826B45 /* SkillHomeViewController.swift */, + 0A1CAC6A1AFA3D8900826B45 /* SkillHomeViewControllerExtension.swift */, + ); + name = SkillPage; + sourceTree = ""; + }; + 0A1CAC711AFA481900826B45 /* SkillHomeHeaderView */ = { + isa = PBXGroup; + children = ( + 0A1CAC6F1AFA481600826B45 /* SkillHomeHeaderView.swift */, + ); + name = SkillHomeHeaderView; + sourceTree = ""; + }; + 0A1CAC741AFA526400826B45 /* SkillHomeSectionButton */ = { + isa = PBXGroup; + children = ( + 0A1CAC721AFA526200826B45 /* SkillHomeSectionButton.swift */, + ); + name = SkillHomeSectionButton; + sourceTree = ""; + }; 0A3E60631ACCAC02003DC853 /* NSDate+TimeAgo */ = { isa = PBXGroup; children = ( @@ -482,6 +515,7 @@ 0A5D83951AC5D3CD000045BF /* TabBar */, 50894CF21AEA472B000981AF /* Settings */, 50894CFF1AEA5A7E000981AF /* EditProfile */, + 0A1CAC6C1AFA3D8C00826B45 /* SkillPage */, ); name = ViewControllers; sourceTree = ""; @@ -549,6 +583,8 @@ 508D16BE1ADCAF0900270E3F /* PullToRefresh */, 50EB8CCC1AEA1AC5001AC1EE /* Media */, 50E61CEC1AF1F6A600908A9D /* ConversationTitle */, + 0A1CAC711AFA481900826B45 /* SkillHomeHeaderView */, + 0A1CAC741AFA526400826B45 /* SkillHomeSectionButton */, ); name = Views; sourceTree = ""; @@ -1330,8 +1366,10 @@ 508D17471ACCF4710092D666 /* ChatLeftAudioCell.swift in Sources */, 50894D021AEA6433000981AF /* EditProfileLessInfoCell.swift in Sources */, 50894CFA1AEA54BA000981AF /* SettingsMoreCell.swift in Sources */, + 0A1CAC6B1AFA3D8900826B45 /* SkillHomeViewControllerExtension.swift in Sources */, 502AE51B1AB70DDB005BD199 /* WelcomeViewController.swift in Sources */, 50894D071AEDFDA2000981AF /* EditProfileMoreInfoCell.swift in Sources */, + 0A1CAC731AFA526200826B45 /* SkillHomeSectionButton.swift in Sources */, 50E114F41ABBF9CC00F13000 /* Models.swift in Sources */, 5053AD551AF83B0F00B3CBFA /* ChatRightLocationCell.swift in Sources */, 50A9D4571ACD393A000B2599 /* YepWaverView.swift in Sources */, @@ -1345,9 +1383,11 @@ 5023DE591AB6DBC100B3EE96 /* UIImage+Yep.swift in Sources */, 50EB8CBF1AE89ED8001AC1EE /* ChatLeftVideoCell.swift in Sources */, 502AE5331AB86020005BD199 /* RegisterVerifyMobileViewController.swift in Sources */, + 0A1CAC6E1AFA42D400826B45 /* SkillHomeViewController.swift in Sources */, 502AE5401AB88862005BD199 /* SkillRankCell.swift in Sources */, 50C090A01ADE391600CC6389 /* AddSkillsReusableView.swift in Sources */, 5023DE2D1AB685ED00B3EE96 /* DiscoverViewController.swift in Sources */, + 0A1CAC701AFA481600826B45 /* SkillHomeHeaderView.swift in Sources */, 502AE53A1AB871C1005BD199 /* YepAlert.swift in Sources */, 5053AD4D1AF79EEA00B3CBFA /* UserPickedLocationPin.swift in Sources */, 50C0909D1ADE294800CC6389 /* RegisterPickSkillsLayout.swift in Sources */, diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index a1486c2a..be777729 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -511,11 +511,12 @@ + - + @@ -553,7 +554,56 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index 2b141592..8941989f 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -14,6 +14,10 @@ class YepConfig { static let minMessageSampleViewWidth: CGFloat = 25.0 + static let skillHomeHeaderViewHeight: CGFloat = 250.0 + + static let skillHomeHeaderButtonHeight: CGFloat = 50.0 + class func clientType() -> Int { // TODO: clientType #if DEBUG diff --git a/Yep/Extensions/UIFont+Yep.swift b/Yep/Extensions/UIFont+Yep.swift index b74dc262..f25681bb 100644 --- a/Yep/Extensions/UIFont+Yep.swift +++ b/Yep/Extensions/UIFont+Yep.swift @@ -14,11 +14,15 @@ extension UIFont { } class func skillTextFont() -> UIFont { - return UIFont(name: "Helvetica-Light", size: 14)! + return UIFont(name: "HelveticaNeue-Light", size: 14)! } class func skillTextLargeFont() -> UIFont { - return UIFont(name: "Helvetica-Light", size: 20)! + return UIFont(name: "HelveticaNeue-Light", size: 20)! + } + + class func skillHomeTextLargeFont() -> UIFont { + return UIFont(name: "HelveticaNeue", size: 18)! } class func navigationBarTitleFont() -> UIFont { diff --git a/Yep/Images.xcassets/Cover3.imageset/Contents.json b/Yep/Images.xcassets/Cover3.imageset/Contents.json new file mode 100644 index 00000000..a0834732 --- /dev/null +++ b/Yep/Images.xcassets/Cover3.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "Cover3.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Yep/Images.xcassets/Cover3.imageset/Cover3.png b/Yep/Images.xcassets/Cover3.imageset/Cover3.png new file mode 100644 index 00000000..a517c385 Binary files /dev/null and b/Yep/Images.xcassets/Cover3.imageset/Cover3.png differ diff --git a/Yep/Services/YepService.swift b/Yep/Services/YepService.swift index 6efb27d8..cd893c76 100644 --- a/Yep/Services/YepService.swift +++ b/Yep/Services/YepService.swift @@ -522,7 +522,7 @@ func discoverUsers(#masterSkills: [String], #learningSkills: [String], #discover let parse: JSONDictionary -> [DiscoveredUser]? = { data in - println("discoverUsers: \(data)") +// println("discoverUsers: \(data)") if let usersData = data["users"] as? [JSONDictionary] { diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index b8d6f4a8..ace2002d 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -25,7 +25,8 @@ class ProfileViewController: UIViewController { @IBOutlet weak var sayHiView: UIView! @IBOutlet weak var sayHiButton: UIButton! - + + var shouldBackToDefaultNavgationbar = true let skillCellIdentifier = "SkillCell" let headerCellIdentifier = "ProfileHeaderCell" @@ -140,6 +141,11 @@ class ProfileViewController: UIViewController { super.viewWillDisappear(animated) if let navigationController = navigationController { + + if !shouldBackToDefaultNavgationbar { + return + } + navigationController.navigationBar.backgroundColor = nil navigationController.navigationBar.translucent = true navigationController.navigationBar.shadowImage = nil @@ -164,9 +170,19 @@ class ProfileViewController: UIViewController { // MARK: Navigation override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + + shouldBackToDefaultNavgationbar = true + if segue.identifier == "showConversation" { let vc = segue.destinationViewController as! ConversationViewController vc.conversation = sender as! Conversation + } else if segue.identifier == "showSkillHome" { + + if let cell = sender as? SkillCell { + let vc = segue.destinationViewController as! SkillHomeViewController + vc.skillName = cell.skillLabel.text + shouldBackToDefaultNavgationbar = false + } } } @@ -512,6 +528,16 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { return CGSizeMake(collectionViewWidth, 0) } + + func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { + + if indexPath.section == ProfileSection.Learning.rawValue || indexPath.section == ProfileSection.Master.rawValue { + let cell = collectionView.cellForItemAtIndexPath(indexPath) as! SkillCell + + self.performSegueWithIdentifier("showSkillHome", sender: cell) + } + + } } diff --git a/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift b/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift new file mode 100644 index 00000000..47af72db --- /dev/null +++ b/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift @@ -0,0 +1,110 @@ +// +// SkillHomeViewController.swift +// Yep +// +// Created by kevinzhow on 15/5/6. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class SkillHomeViewController: UIViewController { + + var skillName: String? { + didSet { + self.title = skillName + } + } + + @IBOutlet weak var headerView: SkillHomeHeaderView! + + @IBOutlet weak var headerViewHeightLayoutConstraint: NSLayoutConstraint! + + var discoveredMasterUsers = [DiscoveredUser]() + + var discoveredLearningUsers = [DiscoveredUser]() + + override func viewDidLoad() { + super.viewDidLoad() + + if let skillNameString = skillName { + discoverUserBySkillName(skillNameString) + } + + self.headerViewHeightLayoutConstraint.constant = YepConfig.skillHomeHeaderViewHeight + + customTitleView() + + // Do any additional setup after loading the view. + } + + func customTitleView() { + + var titleLabel = UILabel() + + let textAttributes = [ + NSForegroundColorAttributeName: UIColor.whiteColor(), + NSFontAttributeName: UIFont.skillHomeTextLargeFont() + ] + + var titleAttr = NSMutableAttributedString(string: skillName!, attributes:textAttributes) + + titleLabel.attributedText = titleAttr + + titleLabel.textAlignment = NSTextAlignment.Center + + titleLabel.backgroundColor = UIColor.yepTintColor() + + titleLabel.sizeToFit() + + titleLabel.bounds = CGRectInset(titleLabel.frame, -25.0, -4.0) + + titleLabel.layer.cornerRadius = titleLabel.frame.size.height/2.0 + + titleLabel.layer.masksToBounds = true + + self.navigationItem.titleView = titleLabel + } + + func discoverUserBySkillName(skillName: String) { + + discoverUsers(masterSkills: [skillName], learningSkills: [], discoveredUserSortStyle: .LastSignIn, failureHandler: { (reason, errorMessage) in + defaultFailureHandler(reason, errorMessage) + + }, completion: { discoveredUsers in + self.discoveredMasterUsers = discoveredUsers + + dispatch_async(dispatch_get_main_queue()) { + } + }) + + discoverUsers(masterSkills: [], learningSkills: [skillName], discoveredUserSortStyle: .LastSignIn, failureHandler: { (reason, errorMessage) in + defaultFailureHandler(reason, errorMessage) + + }, completion: { discoveredUsers in + self.discoveredLearningUsers = discoveredUsers + + dispatch_async(dispatch_get_main_queue()) { + } + }) + } + + 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/Yep/ViewControllers/SkillPage/SkillHomeViewControllerExtension.swift b/Yep/ViewControllers/SkillPage/SkillHomeViewControllerExtension.swift new file mode 100644 index 00000000..b478149b --- /dev/null +++ b/Yep/ViewControllers/SkillPage/SkillHomeViewControllerExtension.swift @@ -0,0 +1,84 @@ +// +// SkillPageTableViewController.swift +// Yep +// +// Created by kevinzhow on 15/5/6. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + + +extension SkillHomeViewController: UITableViewDelegate { + + + // MARK: - Table view data source + + func numberOfSectionsInTableView(tableView: UITableView) -> Int { + // #warning Potentially incomplete method implementation. + // Return the number of sections. + return 0 + } + + 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. + } + */ + +} \ No newline at end of file diff --git a/Yep/Views/SkillHomeHeaderView/SkillHomeHeaderView.swift b/Yep/Views/SkillHomeHeaderView/SkillHomeHeaderView.swift new file mode 100644 index 00000000..f866f300 --- /dev/null +++ b/Yep/Views/SkillHomeHeaderView/SkillHomeHeaderView.swift @@ -0,0 +1,71 @@ +// +// SkillHomeHeaderView.swift +// Yep +// +// Created by kevinzhow on 15/5/6. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class SkillHomeHeaderView: UIView { + + lazy var headerImageView: UIImageView = { + + var tempImageView = UIImageView(frame: CGRectZero) + + tempImageView.contentMode = UIViewContentMode.ScaleAspectFill + tempImageView.clipsToBounds = true + + return tempImageView; + + }() + + lazy var masterButton: UIButton = { + var button = createSkillHomeButtonWithText("Master", 100, YepConfig.skillHomeHeaderButtonHeight) + return button + }() + + lazy var learningButton: UIButton = { + var button = createSkillHomeButtonWithText("Learning", 100, YepConfig.skillHomeHeaderButtonHeight) + return button + }() + + override init(frame: CGRect) { + super.init(frame: frame) + setup() + } + + required init(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setup() + } + + + func setup() { + headerImageView.image = UIImage(named: "Cover3") + self.addSubview(headerImageView) + self.addSubview(masterButton) + self.addSubview(learningButton) + self.backgroundColor = UIColor.lightGrayColor() + } + + + override func layoutSubviews() { + headerImageView.frame = self.bounds + + masterButton.frame = CGRectMake(0, self.frame.height - YepConfig.skillHomeHeaderButtonHeight, self.frame.size.width/2.0, YepConfig.skillHomeHeaderButtonHeight) + + learningButton.frame = CGRectMake(masterButton.frame.size.width, self.frame.height - YepConfig.skillHomeHeaderButtonHeight, self.frame.size.width/2.0, YepConfig.skillHomeHeaderButtonHeight) + } + + /* + // Only override drawRect: if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + override func drawRect(rect: CGRect) { + // Drawing code + } + */ + + +} diff --git a/Yep/Views/SkillHomeSectionButton/SkillHomeSectionButton.swift b/Yep/Views/SkillHomeSectionButton/SkillHomeSectionButton.swift new file mode 100644 index 00000000..6cfee6c3 --- /dev/null +++ b/Yep/Views/SkillHomeSectionButton/SkillHomeSectionButton.swift @@ -0,0 +1,22 @@ +// +// SkillHomeSectionButton.swift +// Yep +// +// Created by kevinzhow on 15/5/6. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +func createSkillHomeButtonWithText(text: String, width: CGFloat, height: CGFloat) -> UIButton { + + var button = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton + button.frame = CGRectMake(0, 0, width, height) + button.setTitle(text, forState: UIControlState.Normal) + button.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal) + button.backgroundColor = UIColor.whiteColor() + button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + button.titleLabel?.font = UIFont.systemFontOfSize(16.0) + return button + +}