From ca9b41ab4ef5ff9136c7c80ecea3a99873fbf060 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 14 May 2015 17:04:47 +0800 Subject: [PATCH] add InstagramMediaCell --- Yep.xcodeproj/project.pbxproj | 16 +++++ Yep/Base.lproj/Main.storyboard | 28 ++++++++- .../SocialWorkInstagramViewController.swift | 59 ++++++++++++++++++- .../InstagramMedia/InstagramMediaCell.swift | 21 +++++++ .../InstagramMedia/InstagramMediaCell.xib | 34 +++++++++++ 5 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 Yep/Views/Cells/InstagramMedia/InstagramMediaCell.swift create mode 100644 Yep/Views/Cells/InstagramMedia/InstagramMediaCell.xib diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index d3e0db3f..d78f06d2 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -144,6 +144,8 @@ 508F8FD71B01EDB400461B0B /* DribbbleShotCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508F8FD51B01EDB400461B0B /* DribbbleShotCell.swift */; }; 508F8FD81B01EDB400461B0B /* DribbbleShotCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508F8FD61B01EDB400461B0B /* DribbbleShotCell.xib */; }; 508F8FDB1B0479E700461B0B /* SocialWorkInstagramViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508F8FDA1B0479E700461B0B /* SocialWorkInstagramViewController.swift */; }; + 508F8FDE1B049ACF00461B0B /* InstagramMediaCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508F8FDC1B049ACF00461B0B /* InstagramMediaCell.swift */; }; + 508F8FDF1B049ACF00461B0B /* InstagramMediaCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 508F8FDD1B049ACF00461B0B /* InstagramMediaCell.xib */; }; 5099B9C41AB9510D002F940B /* RankView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099B9C31AB9510D002F940B /* RankView.swift */; }; 5099B9C71AB99F7B002F940B /* RegisterPickAvatarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099B9C61AB99F7B002F940B /* RegisterPickAvatarViewController.swift */; }; 5099B9C91AB9A7CB002F940B /* CameraPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5099B9C81AB9A7CB002F940B /* CameraPreviewView.swift */; }; @@ -332,6 +334,8 @@ 508F8FD51B01EDB400461B0B /* DribbbleShotCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DribbbleShotCell.swift; path = Views/Cells/DribbbleShot/DribbbleShotCell.swift; sourceTree = ""; }; 508F8FD61B01EDB400461B0B /* DribbbleShotCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = DribbbleShotCell.xib; path = Views/Cells/DribbbleShot/DribbbleShotCell.xib; sourceTree = ""; }; 508F8FDA1B0479E700461B0B /* SocialWorkInstagramViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocialWorkInstagramViewController.swift; path = ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift; sourceTree = ""; }; + 508F8FDC1B049ACF00461B0B /* InstagramMediaCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InstagramMediaCell.swift; path = Views/Cells/InstagramMedia/InstagramMediaCell.swift; sourceTree = ""; }; + 508F8FDD1B049ACF00461B0B /* InstagramMediaCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = InstagramMediaCell.xib; path = Views/Cells/InstagramMedia/InstagramMediaCell.xib; sourceTree = ""; }; 5099B9C31AB9510D002F940B /* RankView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RankView.swift; path = Views/Rank/RankView.swift; sourceTree = ""; }; 5099B9C61AB99F7B002F940B /* RegisterPickAvatarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RegisterPickAvatarViewController.swift; path = ViewControllers/Register/RegisterPickAvatarViewController.swift; sourceTree = ""; }; 5099B9C81AB9A7CB002F940B /* CameraPreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CameraPreviewView.swift; path = Views/CameraPreview/CameraPreviewView.swift; sourceTree = ""; }; @@ -678,6 +682,7 @@ 5053AD571AF83B1600B3CBFA /* ChatRightLocation */, 508F8FD21B01D04F00461B0B /* GithubRepo */, 508F8FD91B01EDBC00461B0B /* DribbbleShot */, + 508F8FE01B049AD400461B0B /* InstagramMedia */, ); name = Cells; sourceTree = ""; @@ -1101,6 +1106,15 @@ name = DribbbleShot; sourceTree = ""; }; + 508F8FE01B049AD400461B0B /* InstagramMedia */ = { + isa = PBXGroup; + children = ( + 508F8FDC1B049ACF00461B0B /* InstagramMediaCell.swift */, + 508F8FDD1B049ACF00461B0B /* InstagramMediaCell.xib */, + ); + name = InstagramMedia; + sourceTree = ""; + }; 5099B9C51AB95111002F940B /* Rank */ = { isa = PBXGroup; children = ( @@ -1360,6 +1374,7 @@ 50894D0D1AEE0177000981AF /* EditProfileColoredTitleCell.xib in Resources */, 50CDBE431ACA9B4200459CE0 /* ChatRightImageCell.xib in Resources */, 508C2AA51AD661B3002B8097 /* UserStateCell.xib in Resources */, + 508F8FDF1B049ACF00461B0B /* InstagramMediaCell.xib in Resources */, 50E114FD1ABC549300F13000 /* ContactsCell.xib in Resources */, 502AE54F1AB93175005BD199 /* ProfileHeaderCell.xib in Resources */, 0A8F54BB1AB67D11004AD60E /* LaunchScreen.xib in Resources */, @@ -1461,6 +1476,7 @@ 508F8FDB1B0479E700461B0B /* SocialWorkInstagramViewController.swift in Sources */, 5099B9C91AB9A7CB002F940B /* CameraPreviewView.swift in Sources */, 502AE5581AB932D5005BD199 /* ProfileSectionHeaderReusableView.swift in Sources */, + 508F8FDE1B049ACF00461B0B /* InstagramMediaCell.swift in Sources */, 502AE5211AB71C7E005BD199 /* BorderButton.swift in Sources */, 502AE54E1AB93175005BD199 /* ProfileHeaderCell.swift in Sources */, 50553F8F1ADB8BA200F80B59 /* ChatSectionDateCell.swift in Sources */, diff --git a/Yep/Base.lproj/Main.storyboard b/Yep/Base.lproj/Main.storyboard index c761b496..fd79b7aa 100644 --- a/Yep/Base.lproj/Main.storyboard +++ b/Yep/Base.lproj/Main.storyboard @@ -1078,7 +1078,7 @@ - + @@ -1086,8 +1086,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yep/ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift b/Yep/ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift index b751b0de..80379e80 100644 --- a/Yep/ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift +++ b/Yep/ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift @@ -10,10 +10,67 @@ import UIKit class SocialWorkInstagramViewController: UIViewController { + var socialAccount: SocialAccount? + var profileUser: ProfileUser? + + + @IBOutlet weak var instagramCollectionView: UICollectionView! + + let instagramMediaCellIdentifier = "InstagramMediaCell" + + lazy var collectionViewWidth: CGFloat = { + return CGRectGetWidth(self.instagramCollectionView.bounds) + }() + + var dribbbleShots = Array() { + didSet { + updateInstagramCollectionView() + } + } + override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. + instagramCollectionView.registerNib(UINib(nibName: instagramMediaCellIdentifier, bundle: nil), forCellWithReuseIdentifier: instagramMediaCellIdentifier) + + } + + // MARK: Actions + + func updateInstagramCollectionView() { + instagramCollectionView.reloadData() } } + +extension SocialWorkInstagramViewController: UICollectionViewDataSource, UICollectionViewDelegate { + + func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { + return 1 + } + + func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 30 + } + + func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { + + let cell = collectionView.dequeueReusableCellWithReuseIdentifier(instagramMediaCellIdentifier, forIndexPath: indexPath) as! InstagramMediaCell + + cell.imageView.image = UIImage(named: "Cover3")! + + return cell + } + + func collectionView(collectionView: UICollectionView!, layout collectionViewLayout: UICollectionViewLayout!, sizeForItemAtIndexPath indexPath: NSIndexPath!) -> CGSize { + + let width = collectionViewWidth * 0.5 + let height = width + + return CGSizeMake(width, height) + } + + func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { + + } +} \ No newline at end of file diff --git a/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.swift b/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.swift new file mode 100644 index 00000000..4e1ae304 --- /dev/null +++ b/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.swift @@ -0,0 +1,21 @@ +// +// InstagramMediaCell.swift +// Yep +// +// Created by NIX on 15/5/14. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class InstagramMediaCell: UICollectionViewCell { + + @IBOutlet weak var imageView: UIImageView! + + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + +} diff --git a/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.xib b/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.xib new file mode 100644 index 00000000..6d0316a1 --- /dev/null +++ b/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.xib @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +