From 0aff05ebd69d587b77bc52c97da64784688a2d48 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Fri, 15 May 2015 16:11:45 +0800 Subject: [PATCH] cache dribbbleWork & instagramWork from ImagesCell in ProfileViewController --- .../Profile/ProfileViewController.swift | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index eace12d8..95bc4400 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -115,6 +115,10 @@ class ProfileViewController: CustomNavigationBarViewController { typealias SocialWorkProviderInfo = [String: Bool] var socialWorkProviderInfo = SocialWorkProviderInfo() + var dribbbleWork: DribbbleWork? + var instagramWork: InstagramWork? + + let skillTextAttributes = [NSFontAttributeName: UIFont.skillTextFont()] lazy var footerCellHeight: CGFloat = { @@ -489,8 +493,32 @@ extension ProfileViewController: UICollectionViewDataSource, UICollectionViewDel let cell = collectionView.dequeueReusableCellWithReuseIdentifier(socialAccountImagesCellIdentifier, forIndexPath: indexPath) as! ProfileSocialAccountImagesCell if let socialAccount = SocialAccount(rawValue: indexPath.row) { - cell.configureWithProfileUser(profileUser, orSocialWorkProviderInfo: socialWorkProviderInfo, socialAccount: socialAccount, socialWork: nil, completion: { socialWork in + var socialWork: SocialWork? + + switch socialAccount { + + case .Dribbble: + if let dribbbleWork = dribbbleWork { + socialWork = SocialWork.Dribbble(dribbbleWork) + } + + case .Instagram: + if let instagramWork = instagramWork { + socialWork = SocialWork.Instagram(instagramWork) + } + + default: + break + } + + cell.configureWithProfileUser(profileUser, orSocialWorkProviderInfo: socialWorkProviderInfo, socialAccount: socialAccount, socialWork: socialWork, completion: { socialWork in + switch socialWork { + case .Dribbble(let dribbbleWork): + self.dribbbleWork = dribbbleWork + case .Instagram(let instagramWork): + self.instagramWork = instagramWork + } }) }