refactor get logo image, color

This commit is contained in:
nixzhu
2015-11-18 17:41:05 +08:00
parent a49c87d2ab
commit 67f7ace1fe
2 changed files with 21 additions and 10 deletions
+8
View File
@@ -401,6 +401,14 @@ enum MessageSocialWorkType: Int {
case GithubRepo = 0
case DribbbleShot = 1
case InstagramMedia = 2
var accountName: String {
switch self {
case .GithubRepo: return "github"
case .DribbbleShot: return "dribbble"
case .InstagramMedia: return "instagram"
}
}
}
class MessageSocialWork: Object {
@@ -49,29 +49,32 @@ class ChatLeftSocialWorkCell: UICollectionViewCell {
var socialWorkImageURL: NSURL?
switch socialWork.type {
guard let
socialWorkType = MessageSocialWorkType(rawValue: socialWork.type),
socialAccount = SocialAccount(rawValue: socialWorkType.accountName)
else {
return
}
case MessageSocialWorkType.GithubRepo.rawValue:
logoImageView.image = UIImage(named: socialAccount.iconName)
logoImageView.tintColor = socialAccount.tintColor
logoImageView.image = UIImage(named: "icon_github")
switch socialWorkType {
case MessageSocialWorkType.DribbbleShot.rawValue:
case .GithubRepo:
break
logoImageView.image = UIImage(named: "icon_dribbble")
case .DribbbleShot:
if let string = socialWork.dribbbleShot?.imageURLString {
socialWorkImageURL = NSURL(string: string)
}
case MessageSocialWorkType.InstagramMedia.rawValue:
logoImageView.image = UIImage(named: "icon_instagram")
case .InstagramMedia:
if let string = socialWork.instagramMedia?.imageURLString {
socialWorkImageURL = NSURL(string: string)
}
default:
break
}
if let URL = socialWorkImageURL {