mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-23 19:57:12 +10:00
Better performance on skill
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>112</string>
|
||||
<string>113</string>
|
||||
<key>Fabric</key>
|
||||
<dict>
|
||||
<key>APIKey</key>
|
||||
|
||||
@@ -13,6 +13,8 @@ enum DiscoverUserMode: Int {
|
||||
case Card
|
||||
}
|
||||
|
||||
var skillSizeCache = [String: CGRect]()
|
||||
|
||||
class DiscoverViewController: BaseViewController {
|
||||
|
||||
@IBOutlet weak var discoverCollectionView: UICollectionView!
|
||||
@@ -60,6 +62,27 @@ class DiscoverViewController: BaseViewController {
|
||||
}
|
||||
|
||||
}, completion: { discoveredUsers in
|
||||
|
||||
for user in discoveredUsers {
|
||||
|
||||
for skill in user.masterSkills {
|
||||
|
||||
let skillLocalName = skill.localName ?? ""
|
||||
|
||||
let skillID = skill.id
|
||||
|
||||
if let _ = skillSizeCache[skillID] {
|
||||
|
||||
} else {
|
||||
let rect = skillLocalName.boundingRectWithSize(CGSize(width: CGFloat(FLT_MAX), height: SkillCell.height), options: [.UsesLineFragmentOrigin, .UsesFontLeading], attributes: skillTextAttributes, context: nil)
|
||||
|
||||
skillSizeCache[skillID] = rect
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) { [weak self] in
|
||||
self?.discoveredUsers = discoveredUsers
|
||||
self?.activityIndicator.stopAnimating()
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
let skillTextAttributes = [NSFontAttributeName: UIFont.skillDiscoverTextFont()]
|
||||
|
||||
class DiscoverCardUserCell: UICollectionViewCell {
|
||||
|
||||
@IBOutlet weak var serviceImageView: UIImageView!
|
||||
@@ -22,12 +24,8 @@ class DiscoverCardUserCell: UICollectionViewCell {
|
||||
|
||||
@IBOutlet weak var userSkillsCollectionView: UICollectionView!
|
||||
|
||||
var skillSizeCache = [String: CGRect]()
|
||||
|
||||
var discoveredUser: DiscoveredUser?
|
||||
|
||||
let skillTextAttributes = [NSFontAttributeName: UIFont.skillDiscoverTextFont()]
|
||||
|
||||
let discoverCellHeight: CGFloat = 16
|
||||
|
||||
override func awakeFromNib() {
|
||||
@@ -81,15 +79,18 @@ class DiscoverCardUserCell: UICollectionViewCell {
|
||||
// }
|
||||
|
||||
usernameLabel.text = discoveredUser.nickname
|
||||
|
||||
userSkillsCollectionView.reloadData()
|
||||
|
||||
userSkillsCollectionView.reloadData()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension DiscoverCardUserCell: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
|
||||
|
||||
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
if let discoveredUser = discoveredUser {
|
||||
if discoveredUser.masterSkills.count > 4 {
|
||||
|
||||
Reference in New Issue
Block a user