mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-13 14:56:03 +10:00
refactor get logo image, color
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user