diff --git a/Yep/Realm/Models.swift b/Yep/Realm/Models.swift index 1e68cb7c..8afc7f9a 100644 --- a/Yep/Realm/Models.swift +++ b/Yep/Realm/Models.swift @@ -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 { diff --git a/Yep/Views/Cells/ChatLeftSocialWork/ChatLeftSocialWorkCell.swift b/Yep/Views/Cells/ChatLeftSocialWork/ChatLeftSocialWorkCell.swift index 8896d1c1..290035b7 100644 --- a/Yep/Views/Cells/ChatLeftSocialWork/ChatLeftSocialWorkCell.swift +++ b/Yep/Views/Cells/ChatLeftSocialWork/ChatLeftSocialWorkCell.swift @@ -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 {