pass skillID to SkillHomeViewController

This commit is contained in:
nixzhu
2015-07-02 11:39:33 +08:00
parent 3fb7eaef07
commit 3406181c4c
2 changed files with 45 additions and 9 deletions
@@ -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 {
@@ -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