diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index 3f079d0f..997be260 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -419,10 +419,12 @@ class ProfileViewController: UIViewController { vc.conversation = sender as! Conversation } else if segue.identifier == "showSkillHome" { - if let cell = sender as? SkillCell { + if let skillInfo = sender as? [String: String] { let vc = segue.destinationViewController as! SkillHomeViewController vc.hidesBottomBarWhenPushed = true - vc.skillName = cell.skillLabel.text + + vc.skillID = skillInfo["skillID"] + vc.skillLocalName = skillInfo["skillLocalName"] } } else if segue.identifier == "presentOAuth" { @@ -1098,9 +1100,41 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel 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 + + var skillID: String = "" + var skillLocalName: String = "" - self.performSegueWithIdentifier("showSkillHome", sender: cell) + if let profileUser = profileUser { + + switch profileUser { + + case .DiscoveredUserType(let discoveredUser): + if indexPath.section == ProfileSection.Learning.rawValue { + let skill = discoveredUser.learningSkills[indexPath.item] + skillID = skill.id + skillLocalName = skill.localName + + } else if indexPath.section == ProfileSection.Master.rawValue { + let skill = discoveredUser.masterSkills[indexPath.item] + skillID = skill.id + skillLocalName = skill.localName + } + + case .UserType(let user): + if indexPath.section == ProfileSection.Learning.rawValue { + let userSkill = user.learningSkills[indexPath.item] + skillID = userSkill.skillID + skillLocalName = userSkill.localName + + } else if indexPath.section == ProfileSection.Master.rawValue { + let userSkill = user.masterSkills[indexPath.item] + skillID = userSkill.skillID + skillLocalName = userSkill.localName + } + } + } + + self.performSegueWithIdentifier("showSkillHome", sender: ["skillID": skillID, "skillLocalName": skillLocalName]) } else if indexPath.section == ProfileSection.SocialAccount.rawValue { diff --git a/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift b/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift index 71489199..65f378f9 100644 --- a/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift +++ b/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift @@ -43,10 +43,12 @@ class SkillHomeViewController: CustomNavigationBarViewController { return tempTableView; }() + + var skillID: String? - var skillName: String? { + var skillLocalName: String? { didSet { - self.title = skillName + self.title = skillLocalName } } @@ -110,8 +112,8 @@ class SkillHomeViewController: CustomNavigationBarViewController { learningtTableView.delegate = self learningtTableView.tag = SkillHomeState.Learning.hashValue - if let skillNameString = skillName { - discoverUserBySkillName(skillNameString) + if let skillLocalName = skillLocalName { + discoverUserBySkillName(skillLocalName) } self.headerViewHeightLayoutConstraint.constant = YepConfig.skillHomeHeaderViewHeight @@ -191,7 +193,7 @@ class SkillHomeViewController: CustomNavigationBarViewController { NSFontAttributeName: UIFont.skillHomeTextLargeFont() ] - var titleAttr = NSMutableAttributedString(string: skillName!, attributes:textAttributes) + var titleAttr = NSMutableAttributedString(string: skillLocalName ?? "", attributes:textAttributes) titleLabel.attributedText = titleAttr