mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-14 15:26:40 +10:00
Show Skills for Test
This commit is contained in:
@@ -203,9 +203,6 @@ extension DiscoverViewController: UICollectionViewDelegate, UICollectionViewData
|
||||
performSegueWithIdentifier("showProfile", sender: indexPath)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
import UIKit
|
||||
|
||||
class DiscoverCardUserCell: UICollectionViewCell {
|
||||
|
||||
let skillCellIdentifier = "SkillCell"
|
||||
|
||||
@IBOutlet weak var avatarImageView: UIImageView!
|
||||
|
||||
@@ -18,6 +20,10 @@ class DiscoverCardUserCell: UICollectionViewCell {
|
||||
|
||||
@IBOutlet weak var userSkillsCollectionView: UICollectionView!
|
||||
|
||||
var discoveredUser: DiscoveredUser?
|
||||
|
||||
let skillTextAttributes = [NSFontAttributeName: UIFont.skillTextFont()]
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
// Initialization code
|
||||
@@ -27,11 +33,17 @@ class DiscoverCardUserCell: UICollectionViewCell {
|
||||
contentView.layer.masksToBounds = true
|
||||
avatarImageView.contentMode = UIViewContentMode.ScaleAspectFill
|
||||
avatarImageView.clipsToBounds = true
|
||||
|
||||
userSkillsCollectionView.delegate = self
|
||||
userSkillsCollectionView.dataSource = self
|
||||
|
||||
userSkillsCollectionView.registerNib(UINib(nibName: skillCellIdentifier, bundle: nil), forCellWithReuseIdentifier: skillCellIdentifier)
|
||||
}
|
||||
|
||||
func configureWithDiscoveredUser(discoveredUser: DiscoveredUser, collectionView: UICollectionView, indexPath: NSIndexPath) {
|
||||
|
||||
// let radius = min(CGRectGetWidth(avatarImageView.bounds), CGRectGetHeight(avatarImageView.bounds)) * 0.5
|
||||
self.discoveredUser = discoveredUser
|
||||
|
||||
let avatarURLString = discoveredUser.avatarURLString
|
||||
|
||||
@@ -53,6 +65,47 @@ class DiscoverCardUserCell: UICollectionViewCell {
|
||||
|
||||
usernameLabel.text = discoveredUser.nickname
|
||||
|
||||
userSkillsCollectionView.reloadData()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension DiscoverCardUserCell: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
|
||||
|
||||
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
if let discoveredUser = discoveredUser {
|
||||
return discoveredUser.masterSkills.count
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
|
||||
if let discoveredUser = discoveredUser {
|
||||
|
||||
let skillLocalName = discoveredUser.masterSkills[indexPath.row].localName ?? ""
|
||||
|
||||
let rect = skillLocalName.boundingRectWithSize(CGSize(width: CGFloat(FLT_MAX), height: SkillCell.height), options: [.UsesLineFragmentOrigin, .UsesFontLeading], attributes: skillTextAttributes, context: nil)
|
||||
|
||||
return CGSize(width: rect.width + 24, height: SkillCell.height)
|
||||
} else {
|
||||
return CGSizeZero
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
|
||||
|
||||
if let discoveredUser = discoveredUser {
|
||||
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(skillCellIdentifier, forIndexPath: indexPath) as! SkillCell
|
||||
|
||||
cell.skillLabel.text = discoveredUser.masterSkills[indexPath.row].localName ?? ""
|
||||
|
||||
return cell
|
||||
} else {
|
||||
return UICollectionViewCell()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user