mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-17 08:46:17 +10:00
better logic for set socialWork in ProfileSocialAccount
This commit is contained in:
@@ -27,6 +27,36 @@ class ProfileSocialAccountImagesCell: UICollectionViewCell {
|
||||
return
|
||||
}
|
||||
|
||||
// 对于从左到右排列,且左边的最新,要处理数量不足的情况
|
||||
|
||||
var shots: [DribbbleWork.Shot?] = dribbbleWork.shots.map({ $0 })
|
||||
|
||||
let imageViews = [
|
||||
imageView3,
|
||||
imageView2,
|
||||
imageView1,
|
||||
]
|
||||
|
||||
// 不足补空
|
||||
if shots.count < imageViews.count {
|
||||
|
||||
let empty: [DribbbleWork.Shot?] = Array(0..<(imageViews.count - shots.count)).map({ _ in
|
||||
return nil
|
||||
})
|
||||
|
||||
shots.insertContentsOf(empty, at: 0)
|
||||
}
|
||||
|
||||
for i in 0..<imageViews.count {
|
||||
|
||||
if let shot = shots[i] {
|
||||
imageViews[i].kf_setImageWithURL(NSURL(string: shot.images.teaser)!, placeholderImage: nil, optionsInfo: MediaOptionsInfos)
|
||||
} else {
|
||||
imageViews[i].image = nil
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
let shots = dribbbleWork.shots
|
||||
|
||||
if let shot = shots[safe: 2] {
|
||||
@@ -46,6 +76,7 @@ class ProfileSocialAccountImagesCell: UICollectionViewCell {
|
||||
} else {
|
||||
imageView3.image = nil
|
||||
}
|
||||
*/
|
||||
|
||||
case .Instagram(let instagramWork):
|
||||
|
||||
@@ -53,6 +84,36 @@ class ProfileSocialAccountImagesCell: UICollectionViewCell {
|
||||
return
|
||||
}
|
||||
|
||||
// 对于从左到右排列,且左边的最新,要处理数量不足的情况
|
||||
|
||||
var medias: [InstagramWork.Media?] = instagramWork.medias.map({ $0 })
|
||||
|
||||
let imageViews = [
|
||||
imageView3,
|
||||
imageView2,
|
||||
imageView1,
|
||||
]
|
||||
|
||||
// 不足补空
|
||||
if medias.count < imageViews.count {
|
||||
|
||||
let empty: [InstagramWork.Media?] = Array(0..<(imageViews.count - medias.count)).map({ _ in
|
||||
return nil
|
||||
})
|
||||
|
||||
medias.insertContentsOf(empty, at: 0)
|
||||
}
|
||||
|
||||
for i in 0..<imageViews.count {
|
||||
|
||||
if let media = medias[i] {
|
||||
imageViews[i].kf_setImageWithURL(NSURL(string: media.images.thumbnail)!, placeholderImage: nil, optionsInfo: MediaOptionsInfos)
|
||||
} else {
|
||||
imageViews[i].image = nil
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
let medias = instagramWork.medias
|
||||
|
||||
if let media = medias[safe: 2] {
|
||||
@@ -72,6 +133,7 @@ class ProfileSocialAccountImagesCell: UICollectionViewCell {
|
||||
} else {
|
||||
imageView3.image = nil
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user