diff --git a/BSImagePicker.podspec b/BSImagePicker.podspec index 02d5f253..6e593024 100644 --- a/BSImagePicker.podspec +++ b/BSImagePicker.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "BSImagePicker" - s.version = "0.4" + s.version = "0.5" s.summary = "BSImagePicker is a multiple image picker for iOS" s.description = <<-DESC A mix between the native iOS 7 gallery and facebooks image picker. Allows you to preview and select multiple images. @@ -9,12 +9,12 @@ Pod::Spec.new do |s| s.license = "MIT" s.author = { "Joakim Gyllström" => "joakim@backslashed.se" } s.platform = :ios, "7.0" - s.source = { :git => "https://github.com/mikaoj/BSImagePicker.git", :tag => "0.4" } + s.source = { :git => "https://github.com/mikaoj/BSImagePicker.git", :tag => "0.5" } s.source_files = "BSImagePicker/**/*.{h,m}" s.exclude_files = "BSImagePicker/Controller/BSAppDelegate.{h,m}", "BSImagePicker/Misc/main.m" s.public_header_files = "BSImagePicker/Controller/BSImagePickerController.h", "BSImagePicker/Category/UIViewController+MultipleImagePicker.h" s.requires_arc = true - s.frameworks = 'AssetsLibrary', 'UIKit' + s.frameworks = 'AssetsLibrary', 'UIKit', 'MediaPlayer' s.screenshots = ["https://cloud.githubusercontent.com/assets/4034956/3030011/c7d86756-e03b-11e3-87b8-d682142967c2.png", "https://cloud.githubusercontent.com/assets/4034956/3030009/c7d4c1b4-e03b-11e3-8cc7-bda50c85dd46.png", "https://cloud.githubusercontent.com/assets/4034956/3030010/c7d6ddd2-e03b-11e3-8c50-03f92a99e47e.png", diff --git a/BSImagePicker.xcodeproj/project.pbxproj b/BSImagePicker.xcodeproj/project.pbxproj index d4c1b8b5..788bf51e 100644 --- a/BSImagePicker.xcodeproj/project.pbxproj +++ b/BSImagePicker.xcodeproj/project.pbxproj @@ -32,7 +32,6 @@ 553EC57B1943E00B004D7B12 /* BSPreviewCollectionViewCellFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 5509A42C193010BC006E4DA1 /* BSPreviewCollectionViewCellFactory.m */; }; 553EC57C1943E025004D7B12 /* ALAssetsGroup+Equal.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9751359F9EC1A401B326 /* ALAssetsGroup+Equal.m */; }; 553EC57D1943E035004D7B12 /* BSPhotosController+BSItemsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9233DF13BD7F719BC475 /* BSPhotosController+BSItemsModel.m */; }; - 553EC57E1943E039004D7B12 /* BSPhotosController+UITableView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B91B1B9E49BA2649C2CC4 /* BSPhotosController+UITableView.m */; }; 553EC57F1943E03E004D7B12 /* BSPhotosController+PrivateMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9E67E9F4DCB27DB352AF /* BSPhotosController+PrivateMethods.m */; }; 553EC5801943E041004D7B12 /* BSPhotosController+UICollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B98E9E8546E358C4B1234 /* BSPhotosController+UICollectionView.m */; }; 553EC5811943E047004D7B12 /* BSCollectionController+UICollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9E700546299C74447B70 /* BSCollectionController+UICollectionView.m */; }; @@ -43,8 +42,10 @@ 553EC5861943E074004D7B12 /* BSCollectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B95CED0C53BD14DE767C7 /* BSCollectionController.m */; }; 553EC5871943E078004D7B12 /* BSPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B980BF19D6B2C0E05F297 /* BSPreviewController.m */; }; 553EC5881943E080004D7B12 /* UIImageViewModeScaleAspect.m in Sources */ = {isa = PBXBuildFile; fileRef = 55AD0D8D19408C7800BDC37F /* UIImageViewModeScaleAspect.m */; }; - 553EC5891943E083004D7B12 /* BSZoomInAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B90AF1CED4DE415FD931F /* BSZoomInAnimator.m */; }; - 553EC58A1943E086004D7B12 /* BSZoomOutAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B99BEDF8860AD297EE80D /* BSZoomOutAnimator.m */; }; + 553EC5891943E083004D7B12 /* BSExpandAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B90AF1CED4DE415FD931F /* BSExpandAnimator.m */; }; + 553EC58A1943E086004D7B12 /* BSShrinkAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B99BEDF8860AD297EE80D /* BSShrinkAnimator.m */; }; + 556AABA5197FCA8000D799F7 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 556AABA4197FCA8000D799F7 /* MediaPlayer.framework */; }; + 556AABA81980641500D799F7 /* BSCameraView.m in Sources */ = {isa = PBXBuildFile; fileRef = 556AABA71980641500D799F7 /* BSCameraView.m */; }; 556E0CE919017470006F8F73 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 556E0CE719017470006F8F73 /* InfoPlist.strings */; }; 556E0CF0190174E6006F8F73 /* UIViewController+MultipleImagePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A11EE018FC952D00F28CA5 /* UIViewController+MultipleImagePicker.m */; }; 556E0CF2190174E6006F8F73 /* ALAsset+Equal.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A11EE618FE75B300F28CA5 /* ALAsset+Equal.m */; }; @@ -61,6 +62,7 @@ 556E0D0B1901781B006F8F73 /* BSPhotoCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 558315E718F8436E00B54FE6 /* BSPhotoCell.h */; }; 556E0D0C1901781B006F8F73 /* BSCheckmarkView.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A11ED518FC440D00F28CA5 /* BSCheckmarkView.h */; }; 556E0D111901781B006F8F73 /* BSImagePickerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A4258718FA8E6F00EF7E8F /* BSImagePickerController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 557BD8FF1962B607007A1C38 /* BSTableController.m in Sources */ = {isa = PBXBuildFile; fileRef = 557BD8FE1962B607007A1C38 /* BSTableController.m */; }; 558315E618F8192F00B54FE6 /* BSAlbumCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 558315E518F8192F00B54FE6 /* BSAlbumCell.m */; }; 558315E918F8436E00B54FE6 /* BSPhotoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 558315E818F8436E00B54FE6 /* BSPhotoCell.m */; }; 5598296E1930ECDF00D68BD5 /* BSAssetsGroupModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 5598296D1930ECDF00D68BD5 /* BSAssetsGroupModel.m */; }; @@ -83,21 +85,23 @@ 55C3BE8818EF632D00E601DE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 55C3BE8618EF632D00E601DE /* InfoPlist.strings */; }; 55CF228F18FAD752003784D9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55C3BE6618EF632D00E601DE /* CoreGraphics.framework */; }; 55CF229118FAD757003784D9 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55CF229018FAD757003784D9 /* MessageUI.framework */; }; + 55E9AFEE1964B62A000B4699 /* BSTableController+BSItemsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E9AFED1964B62A000B4699 /* BSTableController+BSItemsModel.m */; }; + 55E9AFF11964B6B4000B4699 /* BSTableController+UITableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E9AFF01964B6B4000B4699 /* BSTableController+UITableView.m */; }; + 55E9AFF41964C470000B4699 /* BSVideoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E9AFF31964C470000B4699 /* BSVideoCell.m */; }; 55EC233D18F08F95008F5A02 /* MultipleImagePickerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C3BE8918EF632D00E601DE /* MultipleImagePickerTests.m */; }; 55EC234218F0A321008F5A02 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55EC234118F0A321008F5A02 /* AssetsLibrary.framework */; }; 55EC234518F1DB6A008F5A02 /* BSSpeechBubbleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 55EC234418F1DB6A008F5A02 /* BSSpeechBubbleView.m */; }; 55EC235118F2F873008F5A02 /* BSTriangleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 55EC235018F2F873008F5A02 /* BSTriangleView.m */; }; - BB2B90909814568BB3997E1A /* BSZoomOutAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B99BEDF8860AD297EE80D /* BSZoomOutAnimator.m */; }; + BB2B90909814568BB3997E1A /* BSShrinkAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B99BEDF8860AD297EE80D /* BSShrinkAnimator.m */; }; BB2B929FDF16F341870E5B2A /* BSPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B980BF19D6B2C0E05F297 /* BSPreviewController.m */; }; BB2B92A3E94AD0C3BF3D42D4 /* BSPhotosController+UICollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B98E9E8546E358C4B1234 /* BSPhotosController+UICollectionView.m */; }; BB2B939921EFF103FA6E1864 /* BSPhotosController+PrivateMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9E67E9F4DCB27DB352AF /* BSPhotosController+PrivateMethods.m */; }; BB2B93DC4B697E92438D302A /* BSCollectionController+UICollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9E700546299C74447B70 /* BSCollectionController+UICollectionView.m */; }; BB2B94E7BAF0BCCEEFAB30A3 /* BSCollectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B95CED0C53BD14DE767C7 /* BSCollectionController.m */; }; - BB2B94F80589BF941548F2B6 /* BSZoomInAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B90AF1CED4DE415FD931F /* BSZoomInAnimator.m */; }; + BB2B94F80589BF941548F2B6 /* BSExpandAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B90AF1CED4DE415FD931F /* BSExpandAnimator.m */; }; BB2B9726523A57B047F419A1 /* BSPhotosController+BSItemsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9233DF13BD7F719BC475 /* BSPhotosController+BSItemsModel.m */; }; BB2B992598FC83C26F7BCF0F /* ALAssetsGroup+Equal.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9751359F9EC1A401B326 /* ALAssetsGroup+Equal.m */; }; BB2B9A371C251850A91B9B5A /* BSPreviewController+UICollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B9F743F0F09AB616E3BCD /* BSPreviewController+UICollectionView.m */; }; - BB2B9AE7469076085D5B1689 /* BSPhotosController+UITableView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B91B1B9E49BA2649C2CC4 /* BSPhotosController+UITableView.m */; }; BB2B9B4E9F4BC435FF833E97 /* BSPhotosController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B98057AD855E4FEC3A858 /* BSPhotosController.m */; }; BB2B9DCAF191075A0904954F /* BSCollectionController+BSItemsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2B976AC6D4786AC6A996B0 /* BSCollectionController+BSItemsModel.m */; }; /* End PBXBuildFile section */ @@ -124,11 +128,16 @@ 5509A42819301069006E4DA1 /* BSPhotoCollectionViewCellFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSPhotoCollectionViewCellFactory.m; sourceTree = ""; }; 5509A42B193010BC006E4DA1 /* BSPreviewCollectionViewCellFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSPreviewCollectionViewCellFactory.h; sourceTree = ""; }; 5509A42C193010BC006E4DA1 /* BSPreviewCollectionViewCellFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSPreviewCollectionViewCellFactory.m; sourceTree = ""; }; + 556AABA4197FCA8000D799F7 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; + 556AABA61980641500D799F7 /* BSCameraView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSCameraView.h; sourceTree = ""; }; + 556AABA71980641500D799F7 /* BSCameraView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSCameraView.m; sourceTree = ""; }; 556E0CE119017470006F8F73 /* BSImagePickerController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BSImagePickerController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 556E0CE219017470006F8F73 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 556E0CE619017470006F8F73 /* BSImagePickerController-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BSImagePickerController-Info.plist"; sourceTree = ""; }; 556E0CE819017470006F8F73 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 556E0CEA19017470006F8F73 /* BSImagePickerController-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BSImagePickerController-Prefix.pch"; sourceTree = ""; }; + 557BD8FD1962B607007A1C38 /* BSTableController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSTableController.h; sourceTree = ""; }; + 557BD8FE1962B607007A1C38 /* BSTableController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSTableController.m; sourceTree = ""; }; 558315E418F8192F00B54FE6 /* BSAlbumCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSAlbumCell.h; sourceTree = ""; }; 558315E518F8192F00B54FE6 /* BSAlbumCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSAlbumCell.m; sourceTree = ""; }; 558315E718F8436E00B54FE6 /* BSPhotoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSPhotoCell.h; sourceTree = ""; }; @@ -165,31 +174,35 @@ 55C3BE8718EF632D00E601DE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 55C3BE8918EF632D00E601DE /* MultipleImagePickerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MultipleImagePickerTests.m; sourceTree = ""; }; 55CF229018FAD757003784D9 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; + 55E9AFEC1964B62A000B4699 /* BSTableController+BSItemsModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BSTableController+BSItemsModel.h"; sourceTree = ""; }; + 55E9AFED1964B62A000B4699 /* BSTableController+BSItemsModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BSTableController+BSItemsModel.m"; sourceTree = ""; }; + 55E9AFEF1964B6B4000B4699 /* BSTableController+UITableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BSTableController+UITableView.h"; sourceTree = ""; }; + 55E9AFF01964B6B4000B4699 /* BSTableController+UITableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BSTableController+UITableView.m"; sourceTree = ""; }; + 55E9AFF21964C470000B4699 /* BSVideoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSVideoCell.h; sourceTree = ""; }; + 55E9AFF31964C470000B4699 /* BSVideoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSVideoCell.m; sourceTree = ""; }; 55EC234118F0A321008F5A02 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; }; 55EC234318F1DB6A008F5A02 /* BSSpeechBubbleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSSpeechBubbleView.h; sourceTree = ""; }; 55EC234418F1DB6A008F5A02 /* BSSpeechBubbleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSSpeechBubbleView.m; sourceTree = ""; }; 55EC234F18F2F873008F5A02 /* BSTriangleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSTriangleView.h; sourceTree = ""; }; 55EC235018F2F873008F5A02 /* BSTriangleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSTriangleView.m; sourceTree = ""; }; BB2B9033028BA2F8F9C5F5BA /* BSPhotosController+PrivateMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BSPhotosController+PrivateMethods.h"; sourceTree = ""; }; - BB2B90AF1CED4DE415FD931F /* BSZoomInAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSZoomInAnimator.m; sourceTree = ""; }; + BB2B90AF1CED4DE415FD931F /* BSExpandAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSExpandAnimator.m; sourceTree = ""; }; BB2B90F9017BDA73DC835324 /* BSPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSPreviewController.h; sourceTree = ""; }; - BB2B90FB1A88F5ED6BE18836 /* BSZoomOutAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSZoomOutAnimator.h; sourceTree = ""; }; + BB2B90FB1A88F5ED6BE18836 /* BSShrinkAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSShrinkAnimator.h; sourceTree = ""; }; BB2B91147C9A9BC9858F630F /* BSCollectionController+BSItemsModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BSCollectionController+BSItemsModel.h"; sourceTree = ""; }; BB2B912024F6ABA0C6B81DEF /* BSCollectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSCollectionController.h; sourceTree = ""; }; - BB2B91B1B9E49BA2649C2CC4 /* BSPhotosController+UITableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BSPhotosController+UITableView.m"; sourceTree = ""; }; BB2B9233DF13BD7F719BC475 /* BSPhotosController+BSItemsModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "BSPhotosController+BSItemsModel.m"; path = "../BSCollectionController/BSPhotosController+BSItemsModel.m"; sourceTree = ""; }; BB2B95CED0C53BD14DE767C7 /* BSCollectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSCollectionController.m; sourceTree = ""; }; BB2B95FBF0CC2007FECB2C2F /* BSPreviewController+UICollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BSPreviewController+UICollectionView.h"; sourceTree = ""; }; BB2B9751359F9EC1A401B326 /* ALAssetsGroup+Equal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ALAssetsGroup+Equal.m"; sourceTree = ""; }; BB2B976AC6D4786AC6A996B0 /* BSCollectionController+BSItemsModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BSCollectionController+BSItemsModel.m"; sourceTree = ""; }; BB2B977CA5245E3C60FCCCF2 /* BSPhotosController+BSItemsModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "BSPhotosController+BSItemsModel.h"; path = "../BSCollectionController/BSPhotosController+BSItemsModel.h"; sourceTree = ""; }; - BB2B97C6BB8931E76095B11D /* BSZoomInAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSZoomInAnimator.h; sourceTree = ""; }; + BB2B97C6BB8931E76095B11D /* BSExpandAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSExpandAnimator.h; sourceTree = ""; }; BB2B98057AD855E4FEC3A858 /* BSPhotosController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSPhotosController.m; sourceTree = ""; }; BB2B980BF19D6B2C0E05F297 /* BSPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSPreviewController.m; sourceTree = ""; }; BB2B98E9E8546E358C4B1234 /* BSPhotosController+UICollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BSPhotosController+UICollectionView.m"; sourceTree = ""; }; - BB2B99BEDF8860AD297EE80D /* BSZoomOutAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSZoomOutAnimator.m; sourceTree = ""; }; + BB2B99BEDF8860AD297EE80D /* BSShrinkAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSShrinkAnimator.m; sourceTree = ""; }; BB2B9AFB1E146FCDEF4CB3CF /* ALAssetsGroup+Equal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ALAssetsGroup+Equal.h"; sourceTree = ""; }; - BB2B9B57F530FD9EA5747130 /* BSPhotosController+UITableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BSPhotosController+UITableView.h"; sourceTree = ""; }; BB2B9E67E9F4DCB27DB352AF /* BSPhotosController+PrivateMethods.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BSPhotosController+PrivateMethods.m"; sourceTree = ""; }; BB2B9E700546299C74447B70 /* BSCollectionController+UICollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BSCollectionController+UICollectionView.m"; sourceTree = ""; }; BB2B9F6CE1322BBD50645B6D /* BSCollectionController+UICollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BSCollectionController+UICollectionView.h"; sourceTree = ""; }; @@ -210,6 +223,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 556AABA5197FCA8000D799F7 /* MediaPlayer.framework in Frameworks */, 55C3BE6718EF632D00E601DE /* CoreGraphics.framework in Frameworks */, 55C3BE6918EF632D00E601DE /* UIKit.framework in Frameworks */, 55C3BE6518EF632D00E601DE /* Foundation.framework in Frameworks */, @@ -292,6 +306,7 @@ 55A11EE618FE75B300F28CA5 /* ALAsset+Equal.m */, BB2B9751359F9EC1A401B326 /* ALAssetsGroup+Equal.m */, BB2B9AFB1E146FCDEF4CB3CF /* ALAssetsGroup+Equal.h */, + 55E9AFEB1964B5C7000B4699 /* BSTableController */, BB2B95610ABCEF708B82FD10 /* BSPhotosController */, BB2B98487096DCF720E55BB5 /* BSCollectionController */, BB2B95282F0FFF83A04B49B5 /* BSPreviewController */, @@ -323,6 +338,7 @@ 55C3BE6318EF632D00E601DE /* Frameworks */ = { isa = PBXGroup; children = ( + 556AABA4197FCA8000D799F7 /* MediaPlayer.framework */, 55CF229018FAD757003784D9 /* MessageUI.framework */, 55EC234118F0A321008F5A02 /* AssetsLibrary.framework */, 55C3BE6418EF632D00E601DE /* Foundation.framework */, @@ -378,6 +394,17 @@ name = "Supporting Files"; sourceTree = ""; }; + 55E9AFEB1964B5C7000B4699 /* BSTableController */ = { + isa = PBXGroup; + children = ( + 55E9AFEC1964B62A000B4699 /* BSTableController+BSItemsModel.h */, + 55E9AFED1964B62A000B4699 /* BSTableController+BSItemsModel.m */, + 55E9AFEF1964B6B4000B4699 /* BSTableController+UITableView.h */, + 55E9AFF01964B6B4000B4699 /* BSTableController+UITableView.m */, + ); + path = BSTableController; + sourceTree = ""; + }; 55EC233718EF6AEB008F5A02 /* Controller */ = { isa = PBXGroup; children = ( @@ -391,6 +418,8 @@ BB2B912024F6ABA0C6B81DEF /* BSCollectionController.h */, BB2B980BF19D6B2C0E05F297 /* BSPreviewController.m */, BB2B90F9017BDA73DC835324 /* BSPreviewController.h */, + 557BD8FD1962B607007A1C38 /* BSTableController.h */, + 557BD8FE1962B607007A1C38 /* BSTableController.m */, ); path = Controller; sourceTree = ""; @@ -429,6 +458,10 @@ 558315E818F8436E00B54FE6 /* BSPhotoCell.m */, 55A11ED518FC440D00F28CA5 /* BSCheckmarkView.h */, 55A11ED618FC440D00F28CA5 /* BSCheckmarkView.m */, + 55E9AFF21964C470000B4699 /* BSVideoCell.h */, + 55E9AFF31964C470000B4699 /* BSVideoCell.m */, + 556AABA61980641500D799F7 /* BSCameraView.h */, + 556AABA71980641500D799F7 /* BSCameraView.m */, ); path = View; sourceTree = ""; @@ -447,8 +480,6 @@ children = ( BB2B977CA5245E3C60FCCCF2 /* BSPhotosController+BSItemsModel.h */, BB2B9233DF13BD7F719BC475 /* BSPhotosController+BSItemsModel.m */, - BB2B9B57F530FD9EA5747130 /* BSPhotosController+UITableView.h */, - BB2B91B1B9E49BA2649C2CC4 /* BSPhotosController+UITableView.m */, BB2B9E67E9F4DCB27DB352AF /* BSPhotosController+PrivateMethods.m */, BB2B9033028BA2F8F9C5F5BA /* BSPhotosController+PrivateMethods.h */, BB2B98E9E8546E358C4B1234 /* BSPhotosController+UICollectionView.m */, @@ -473,10 +504,10 @@ children = ( 55AD0D8C19408C7800BDC37F /* UIImageViewModeScaleAspect.h */, 55AD0D8D19408C7800BDC37F /* UIImageViewModeScaleAspect.m */, - BB2B90AF1CED4DE415FD931F /* BSZoomInAnimator.m */, - BB2B97C6BB8931E76095B11D /* BSZoomInAnimator.h */, - BB2B99BEDF8860AD297EE80D /* BSZoomOutAnimator.m */, - BB2B90FB1A88F5ED6BE18836 /* BSZoomOutAnimator.h */, + BB2B90AF1CED4DE415FD931F /* BSExpandAnimator.m */, + BB2B97C6BB8931E76095B11D /* BSExpandAnimator.h */, + BB2B99BEDF8860AD297EE80D /* BSShrinkAnimator.m */, + BB2B90FB1A88F5ED6BE18836 /* BSShrinkAnimator.h */, ); path = Animator; sourceTree = ""; @@ -649,9 +680,8 @@ 556E0CF4190174E6006F8F73 /* BSTriangleView.m in Sources */, 556E0CF5190174E6006F8F73 /* BSAlbumCell.m in Sources */, 553EC5771943DF8D004D7B12 /* BSImagePickerSettings.m in Sources */, - 553EC58A1943E086004D7B12 /* BSZoomOutAnimator.m in Sources */, + 553EC58A1943E086004D7B12 /* BSShrinkAnimator.m in Sources */, 553EC57D1943E035004D7B12 /* BSPhotosController+BSItemsModel.m in Sources */, - 553EC57E1943E039004D7B12 /* BSPhotosController+UITableView.m in Sources */, 553EC5791943E003004D7B12 /* BSAlbumTableViewCellFactory.m in Sources */, 553EC5871943E078004D7B12 /* BSPreviewController.m in Sources */, 556E0CF6190174E6006F8F73 /* BSPhotoCell.m in Sources */, @@ -659,7 +689,7 @@ 553EC57B1943E00B004D7B12 /* BSPreviewCollectionViewCellFactory.m in Sources */, 553EC5861943E074004D7B12 /* BSCollectionController.m in Sources */, 556E0CF7190174E6006F8F73 /* BSCheckmarkView.m in Sources */, - 553EC5891943E083004D7B12 /* BSZoomInAnimator.m in Sources */, + 553EC5891943E083004D7B12 /* BSExpandAnimator.m in Sources */, 553EC5811943E047004D7B12 /* BSCollectionController+UICollectionView.m in Sources */, 553EC5841943E058004D7B12 /* BSAssetModel.m in Sources */, 556E0CFC190174E6006F8F73 /* BSImagePickerController.m in Sources */, @@ -675,19 +705,23 @@ files = ( 55C3BE7118EF632D00E601DE /* main.m in Sources */, 558315E618F8192F00B54FE6 /* BSAlbumCell.m in Sources */, + 55E9AFF41964C470000B4699 /* BSVideoCell.m in Sources */, 559829841931625B00D68BD5 /* BSImagePickerSettings.m in Sources */, 55A4258918FA8E6F00EF7E8F /* BSImagePickerController.m in Sources */, 5509A42919301069006E4DA1 /* BSPhotoCollectionViewCellFactory.m in Sources */, 55C3BE7518EF632D00E601DE /* BSAppDelegate.m in Sources */, 55A11EE118FC952D00F28CA5 /* UIViewController+MultipleImagePicker.m in Sources */, + 55E9AFF11964B6B4000B4699 /* BSTableController+UITableView.m in Sources */, 5509A42D193010BC006E4DA1 /* BSPreviewCollectionViewCellFactory.m in Sources */, 558315E918F8436E00B54FE6 /* BSPhotoCell.m in Sources */, 55A11EE718FE75B300F28CA5 /* ALAsset+Equal.m in Sources */, 5509A423192FA2FD006E4DA1 /* BSAlbumTableViewCellFactory.m in Sources */, + 557BD8FF1962B607007A1C38 /* BSTableController.m in Sources */, 55A11ED718FC440D00F28CA5 /* BSCheckmarkView.m in Sources */, 5598296E1930ECDF00D68BD5 /* BSAssetsGroupModel.m in Sources */, 5509A41C192F9F4D006E4DA1 /* BSAssetModel.m in Sources */, 55EC234518F1DB6A008F5A02 /* BSSpeechBubbleView.m in Sources */, + 556AABA81980641500D799F7 /* BSCameraView.m in Sources */, 55EC235118F2F873008F5A02 /* BSTriangleView.m in Sources */, 55AD0D8E19408C7800BDC37F /* UIImageViewModeScaleAspect.m in Sources */, BB2B992598FC83C26F7BCF0F /* ALAssetsGroup+Equal.m in Sources */, @@ -696,12 +730,12 @@ BB2B929FDF16F341870E5B2A /* BSPreviewController.m in Sources */, BB2B93DC4B697E92438D302A /* BSCollectionController+UICollectionView.m in Sources */, BB2B9726523A57B047F419A1 /* BSPhotosController+BSItemsModel.m in Sources */, - BB2B9AE7469076085D5B1689 /* BSPhotosController+UITableView.m in Sources */, BB2B9DCAF191075A0904954F /* BSCollectionController+BSItemsModel.m in Sources */, - BB2B94F80589BF941548F2B6 /* BSZoomInAnimator.m in Sources */, - BB2B90909814568BB3997E1A /* BSZoomOutAnimator.m in Sources */, + BB2B94F80589BF941548F2B6 /* BSExpandAnimator.m in Sources */, + BB2B90909814568BB3997E1A /* BSShrinkAnimator.m in Sources */, BB2B939921EFF103FA6E1864 /* BSPhotosController+PrivateMethods.m in Sources */, BB2B92A3E94AD0C3BF3D42D4 /* BSPhotosController+UICollectionView.m in Sources */, + 55E9AFEE1964B62A000B4699 /* BSTableController+BSItemsModel.m in Sources */, BB2B9A371C251850A91B9B5A /* BSPreviewController+UICollectionView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/BSImagePicker.xcodeproj/project.xcworkspace/xcshareddata/BSImagePicker.xccheckout b/BSImagePicker.xcodeproj/project.xcworkspace/xcshareddata/BSImagePicker.xccheckout index edc77a2a..1b2213ac 100644 --- a/BSImagePicker.xcodeproj/project.xcworkspace/xcshareddata/BSImagePicker.xccheckout +++ b/BSImagePicker.xcodeproj/project.xcworkspace/xcshareddata/BSImagePicker.xccheckout @@ -10,29 +10,29 @@ BSImagePicker IDESourceControlProjectOriginsDictionary - 3DC0F6DD-BC5C-46F5-9A37-FECD8B9F1B11 + DF1E81D5DDD90A1D12FA649A155BB8370AC65668 ssh://github.com/mikaoj/BSImagePicker.git IDESourceControlProjectPath BSImagePicker.xcodeproj/project.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - 3DC0F6DD-BC5C-46F5-9A37-FECD8B9F1B11 + DF1E81D5DDD90A1D12FA649A155BB8370AC65668 ../.. IDESourceControlProjectURL ssh://github.com/mikaoj/BSImagePicker.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - 3DC0F6DD-BC5C-46F5-9A37-FECD8B9F1B11 + DF1E81D5DDD90A1D12FA649A155BB8370AC65668 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - 3DC0F6DD-BC5C-46F5-9A37-FECD8B9F1B11 + DF1E81D5DDD90A1D12FA649A155BB8370AC65668 IDESourceControlWCCName MultipleImagePicker diff --git a/BSImagePicker/Animator/BSZoomInAnimator.h b/BSImagePicker/Animator/BSExpandAnimator.h similarity index 94% rename from BSImagePicker/Animator/BSZoomInAnimator.h rename to BSImagePicker/Animator/BSExpandAnimator.h index 96c82db2..c97795dc 100644 --- a/BSImagePicker/Animator/BSZoomInAnimator.h +++ b/BSImagePicker/Animator/BSExpandAnimator.h @@ -20,6 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -@interface BSZoomInAnimator : NSObject +@interface BSExpandAnimator : NSObject @end \ No newline at end of file diff --git a/BSImagePicker/Animator/BSZoomInAnimator.m b/BSImagePicker/Animator/BSExpandAnimator.m similarity index 92% rename from BSImagePicker/Animator/BSZoomInAnimator.m rename to BSImagePicker/Animator/BSExpandAnimator.m index 00c31be8..f702c5f0 100644 --- a/BSImagePicker/Animator/BSZoomInAnimator.m +++ b/BSImagePicker/Animator/BSExpandAnimator.m @@ -20,13 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#import "BSZoomInAnimator.h" +#import "BSExpandAnimator.h" #import "BSPhotosController.h" #import "BSPhotoCell.h" #import "BSCollectionController+UICollectionView.h" #import "UIImageViewModeScaleAspect.h" -@implementation BSZoomInAnimator +@implementation BSExpandAnimator #pragma mark - UIViewControllerAnimatedTransitioning @@ -56,7 +56,7 @@ - (void)animateTransition:(id)transitionCo [scalingImage setImage:toCell.imageView.image]; //Init image scale - [scalingImage initToScaleAspectFitToFrame:CGRectMake(0, toViewController.collectionView.contentInset.top, toCell.imageView.frame.size.width, toCell.imageView.frame.size.height)]; + [scalingImage initToScaleAspectFitToFrame:CGRectMake(0, fromViewController.navigationController.navigationBar.frame.origin.y + fromViewController.navigationController.navigationBar.frame.size.height, toCell.imageView.frame.size.width, toCell.imageView.frame.size.height)]; //Add views to container view [containerView addSubview:toViewController.view]; diff --git a/BSImagePicker/Animator/BSZoomOutAnimator.h b/BSImagePicker/Animator/BSShrinkAnimator.h similarity index 93% rename from BSImagePicker/Animator/BSZoomOutAnimator.h rename to BSImagePicker/Animator/BSShrinkAnimator.h index ab25b0d1..acdcb2e7 100644 --- a/BSImagePicker/Animator/BSZoomOutAnimator.h +++ b/BSImagePicker/Animator/BSShrinkAnimator.h @@ -20,6 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -@interface BSZoomOutAnimator : NSObject +@interface BSShrinkAnimator : NSObject @end \ No newline at end of file diff --git a/BSImagePicker/Animator/BSZoomOutAnimator.m b/BSImagePicker/Animator/BSShrinkAnimator.m similarity index 93% rename from BSImagePicker/Animator/BSZoomOutAnimator.m rename to BSImagePicker/Animator/BSShrinkAnimator.m index 7a25af3a..63e31079 100644 --- a/BSImagePicker/Animator/BSZoomOutAnimator.m +++ b/BSImagePicker/Animator/BSShrinkAnimator.m @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#import "BSZoomOutAnimator.h" +#import "BSShrinkAnimator.h" #import "BSPhotosController.h" #import "BSPhotoCell.h" #import "BSCollectionController+UICollectionView.h" #import "UIImageViewModeScaleAspect.h" #import "BSItemsModel.h" -@implementation BSZoomOutAnimator +@implementation BSShrinkAnimator - (NSTimeInterval)transitionDuration:(id )transitionContext { return 0.3; @@ -49,7 +49,7 @@ - (void)animateTransition:(id)transitionCo [toCell setHidden:YES]; [fromCell.imageView setHidden:YES]; - UIImageView *iv = fromCell.imageView; // your image view + UIImageView *iv = fromCell.imageView; CGSize imageSize = iv.image.size; CGFloat imageScale = fminf(CGRectGetWidth(iv.bounds)/imageSize.width, CGRectGetHeight(iv.bounds)/imageSize.height); CGSize scaledImageSize = CGSizeMake(imageSize.width*imageScale, imageSize.height*imageScale); @@ -68,7 +68,7 @@ - (void)animateTransition:(id)transitionCo [toViewController.view setAlpha:0.0]; //Init image scale - [scalingImage initToScaleAspectFillToFrame:CGRectMake(toCell.frame.origin.x, toCell.frame.origin.y+(toViewController.collectionView.contentInset.top-2.0), toCell.frame.size.width, toCell.frame.size.height)]; + [scalingImage initToScaleAspectFillToFrame:CGRectMake(toCell.frame.origin.x, toCell.frame.origin.y+(fromViewController.navigationController.navigationBar.frame.origin.y + fromViewController.navigationController.navigationBar.frame.size.height), toCell.frame.size.width, toCell.frame.size.height)]; //Animate [UIView animateWithDuration:[self transitionDuration:transitionContext] diff --git a/BSImagePicker/Category/BSCollectionController/BSCollectionController+BSItemsModel.m b/BSImagePicker/Category/BSCollectionController/BSCollectionController+BSItemsModel.m index e71b43c5..be84f523 100644 --- a/BSImagePicker/Category/BSCollectionController/BSCollectionController+BSItemsModel.m +++ b/BSImagePicker/Category/BSCollectionController/BSCollectionController+BSItemsModel.m @@ -25,12 +25,15 @@ @implementation BSCollectionController (BSItemsModel) - (void)didUpdateModel:(id)aModel { - [self.collectionView performBatchUpdates:^{ - [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]]; - [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] - atScrollPosition:UICollectionViewScrollPositionTop - animated:YES]; - } completion:nil]; + //Since we are assuming that it is the first section that needs to be reloaded, make sure that it actually exists! + if([self.collectionView numberOfSections] > 0) { + [self.collectionView performBatchUpdates:^{ + [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]]; + [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] + atScrollPosition:UICollectionViewScrollPositionTop + animated:YES]; + } completion:nil]; + } } @end \ No newline at end of file diff --git a/BSImagePicker/Category/BSCollectionController/BSCollectionController+UICollectionView.m b/BSImagePicker/Category/BSCollectionController/BSCollectionController+UICollectionView.m index 059255a2..2a614e9c 100644 --- a/BSImagePicker/Category/BSCollectionController/BSCollectionController+UICollectionView.m +++ b/BSImagePicker/Category/BSCollectionController/BSCollectionController+UICollectionView.m @@ -96,7 +96,10 @@ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollection CGSize itemSize = CGSizeZero; if(self.collectionCellFactory) { - itemSize = [[self.collectionCellFactory class] sizeAtIndexPath:indexPath forCollectionView:collectionView withModel:self.collectionModel]; + itemSize = [[self.collectionCellFactory class] + sizeAtIndexPath:indexPath + forCollectionView:collectionView + withModel:self.collectionModel]; } return itemSize; diff --git a/BSImagePicker/Category/BSCollectionController/BSPhotosController+BSItemsModel.m b/BSImagePicker/Category/BSCollectionController/BSPhotosController+BSItemsModel.m index f3ad97a1..d493f2eb 100644 --- a/BSImagePicker/Category/BSCollectionController/BSPhotosController+BSItemsModel.m +++ b/BSImagePicker/Category/BSCollectionController/BSPhotosController+BSItemsModel.m @@ -22,19 +22,22 @@ #import "BSPhotosController+BSItemsModel.h" #import "BSCollectionController+BSItemsModel.h" +#import "BSTableController+BSItemsModel.h" +#import "BSPhotosController+PrivateMethods.h" #import @implementation BSPhotosController (BSItemsModel) - (void)didUpdateModel:(id)aModel { - if(aModel == self.tableModel) { - [self.tableView reloadData]; - - ALAssetsGroup *assetsGroup = [[self.tableModel selectedItems] firstObject]; + if(aModel == self.tableController.tableModel) { + [self.tableController didUpdateModel:aModel]; + ALAssetsGroup *assetsGroup = [[self.tableController.tableModel selectedItems] firstObject]; + [self.albumButton setTitle:[assetsGroup valueForProperty:ALAssetsGroupPropertyName] forState:UIControlStateNormal]; - [self.collectionModel setupWithParentItem:assetsGroup]; + + [self hideAlbumView]; } else { [super didUpdateModel:aModel]; } diff --git a/BSImagePicker/Category/BSPhotosController/BSPhotosController+PrivateMethods.m b/BSImagePicker/Category/BSPhotosController/BSPhotosController+PrivateMethods.m index 8b8026af..3fa0e607 100644 --- a/BSImagePicker/Category/BSPhotosController/BSPhotosController+PrivateMethods.m +++ b/BSImagePicker/Category/BSPhotosController/BSPhotosController+PrivateMethods.m @@ -43,8 +43,6 @@ - (void)finishButtonPressed:(id)sender { if(![[BSImagePickerSettings sharedSetting] keepSelection]) { [self.collectionModel clearSelection]; } - - [self dismissViewControllerAnimated:YES completion:nil]; } - (void)albumButtonPressed:(id)sender { @@ -61,7 +59,7 @@ - (void)showAlbumView { [self.navigationController.view addSubview:self.coverView]; [self.navigationController.view addSubview:self.speechBubbleView]; - CGFloat tableViewHeight = MIN(self.tableView.contentSize.height, 240); + CGFloat tableViewHeight = MIN(self.tableController.tableView.contentSize.height, 240); CGRect frame = CGRectMake(0, 0, self.speechBubbleView.frame.size.width, tableViewHeight+7); //Remember old values @@ -117,6 +115,7 @@ - (void)itemLongPressed:(UIGestureRecognizer *)recognizer { [self.previewController setCollectionModel:self.collectionModel]; [self.previewController setCurrentIndexPath:indexPath]; + [self.previewController.collectionView setContentInset:self.collectionView.contentInset]; [self.navigationController pushViewController:self.previewController animated:YES]; [recognizer setEnabled:YES]; diff --git a/BSImagePicker/Category/BSPreviewController/BSPreviewController+UICollectionView.m b/BSImagePicker/Category/BSPreviewController/BSPreviewController+UICollectionView.m index 6bdff35d..2f82e750 100644 --- a/BSImagePicker/Category/BSPreviewController/BSPreviewController+UICollectionView.m +++ b/BSImagePicker/Category/BSPreviewController/BSPreviewController+UICollectionView.m @@ -28,7 +28,7 @@ @implementation BSPreviewController (UICollectionView) - (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath { [super collectionView:collectionView didDeselectItemAtIndexPath:indexPath]; - [self.navigationItem setRightBarButtonItem:nil animated:YES]; + [self.navigationItem setRightBarButtonItem:self.emptyItem animated:YES]; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { diff --git a/BSImagePicker/Category/BSPhotosController/BSPhotosController+UITableView.h b/BSImagePicker/Category/BSTableController/BSTableController+BSItemsModel.h similarity index 90% rename from BSImagePicker/Category/BSPhotosController/BSPhotosController+UITableView.h rename to BSImagePicker/Category/BSTableController/BSTableController+BSItemsModel.h index 3afc7b84..faf1ca05 100644 --- a/BSImagePicker/Category/BSPhotosController/BSPhotosController+UITableView.h +++ b/BSImagePicker/Category/BSTableController/BSTableController+BSItemsModel.h @@ -20,7 +20,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#import "BSPhotosController.h" +#import "BSTableController.h" -@interface BSPhotosController (UITableView) -@end \ No newline at end of file +@interface BSTableController (BSItemsModel) + +@end diff --git a/BSImagePicker/Category/BSTableController/BSTableController+BSItemsModel.m b/BSImagePicker/Category/BSTableController/BSTableController+BSItemsModel.m new file mode 100644 index 00000000..df386a4d --- /dev/null +++ b/BSImagePicker/Category/BSTableController/BSTableController+BSItemsModel.m @@ -0,0 +1,31 @@ +// The MIT License (MIT) +// +// Copyright (c) 2014 Joakim Gyllström +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#import "BSTableController+BSItemsModel.h" + +@implementation BSTableController (BSItemsModel) + +- (void)didUpdateModel:(id)aModel { + [self.tableView reloadData]; +} + +@end diff --git a/BSImagePicker/Category/BSTableController/BSTableController+UITableView.h b/BSImagePicker/Category/BSTableController/BSTableController+UITableView.h new file mode 100644 index 00000000..080e364e --- /dev/null +++ b/BSImagePicker/Category/BSTableController/BSTableController+UITableView.h @@ -0,0 +1,27 @@ +// The MIT License (MIT) +// +// Copyright (c) 2014 Joakim Gyllström +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#import "BSTableController.h" + +@interface BSTableController (UITableView) + +@end diff --git a/BSImagePicker/Category/BSPhotosController/BSPhotosController+UITableView.m b/BSImagePicker/Category/BSTableController/BSTableController+UITableView.m similarity index 93% rename from BSImagePicker/Category/BSPhotosController/BSPhotosController+UITableView.m rename to BSImagePicker/Category/BSTableController/BSTableController+UITableView.m index bae4b0a6..17a900af 100644 --- a/BSImagePicker/Category/BSPhotosController/BSPhotosController+UITableView.m +++ b/BSImagePicker/Category/BSTableController/BSTableController+UITableView.m @@ -20,10 +20,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#import "BSPhotosController+UITableView.h" -#import "BSPhotosController+PrivateMethods.h" +#import "BSTableController+UITableView.h" -@implementation BSPhotosController (UITableView) +@implementation BSTableController (UITableView) + +#pragma mark - UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.tableModel numberOfSections]; @@ -35,12 +36,12 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [self.tableCellFactory cellAtIndexPath:indexPath forTableView:tableView withModel:self.tableModel]; - + if([self.tableModel isItemAtIndexPathSelected:indexPath]) { [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; [cell setSelected:YES]; } - + return cell; } @@ -48,15 +49,15 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa return [[self.tableCellFactory class] heightAtIndexPath:indexPath forModel:self.tableModel]; } +#pragma mark - UITableViewDelegate + - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { id item = [self.tableModel itemAtIndexPath:indexPath]; - + //Only set if we have choosen a new group if(![item isEqual:[self.tableModel.selectedItems firstObject]]) { [self.tableModel selectItemAtIndexPath:indexPath]; } - - [self hideAlbumView]; } -@end \ No newline at end of file +@end diff --git a/BSImagePicker/Category/UIViewController+MultipleImagePicker.h b/BSImagePicker/Category/UIViewController+MultipleImagePicker.h index dd84e069..1dc16a0f 100644 --- a/BSImagePicker/Category/UIViewController+MultipleImagePicker.h +++ b/BSImagePicker/Category/UIViewController+MultipleImagePicker.h @@ -24,6 +24,11 @@ @class ALAsset; +typedef NS_OPTIONS(NSInteger, BSAssetType) { + BSAssetTypeImage = 1 << 0, + BSAssetTypeVideo = 1 << 1 +}; + typedef void (^BSImageToggleBlock)(ALAsset *asset, BOOL select); typedef void (^BSImageGroupBlock)(NSArray *assets); diff --git a/BSImagePicker/Controller/BSAppDelegate.m b/BSImagePicker/Controller/BSAppDelegate.m index 038d178d..1688fd0d 100644 --- a/BSImagePicker/Controller/BSAppDelegate.m +++ b/BSImagePicker/Controller/BSAppDelegate.m @@ -28,6 +28,7 @@ @interface BSAppDelegate () )collectionModel { diff --git a/BSImagePicker/Controller/BSImagePickerController.h b/BSImagePicker/Controller/BSImagePickerController.h index b7999a10..842836a4 100644 --- a/BSImagePicker/Controller/BSImagePickerController.h +++ b/BSImagePicker/Controller/BSImagePickerController.h @@ -44,6 +44,11 @@ */ @property (nonatomic, copy) BSImageGroupBlock finishBlock; +/** + * What types of assets you want the picker to handle + */ +@property (nonatomic, assign) BSAssetType assetType; + /** * Set to YES to disable preview on long press */ diff --git a/BSImagePicker/Controller/BSImagePickerController.m b/BSImagePicker/Controller/BSImagePickerController.m index a5de9b59..251e1750 100644 --- a/BSImagePicker/Controller/BSImagePickerController.m +++ b/BSImagePicker/Controller/BSImagePickerController.m @@ -41,6 +41,12 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil return self; } +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + [self.imagePicker.collectionView reloadData]; +} + #pragma mark - Lazy load - (BSPhotosController *)imagePicker { @@ -85,6 +91,14 @@ - (void)setFinishBlock:(BSImageGroupBlock)finishBlock { [[BSImagePickerSettings sharedSetting] setFinishBlock:finishBlock]; } +- (BSAssetType)assetType { + return [[BSImagePickerSettings sharedSetting] assetType]; +} + +- (void)setAssetType:(BSAssetType)assetType { + [[BSImagePickerSettings sharedSetting] setAssetType:assetType]; +} + - (BOOL)previewDisabled { return [[BSImagePickerSettings sharedSetting] previewDisabled]; } diff --git a/BSImagePicker/Controller/BSPhotosController.h b/BSImagePicker/Controller/BSPhotosController.h index 9fc6f73b..6f907f61 100644 --- a/BSImagePicker/Controller/BSPhotosController.h +++ b/BSImagePicker/Controller/BSPhotosController.h @@ -24,14 +24,13 @@ #import "BSTableViewCellFactory.h" #import "BSSpeechBubbleView.h" #import "BSPreviewController.h" -#import "BSZoomOutAnimator.h" -#import "BSZoomInAnimator.h" +#import "BSShrinkAnimator.h" +#import "BSExpandAnimator.h" +#import "BSTableController.h" @interface BSPhotosController : BSCollectionController -@property (nonatomic, strong) UITableView *tableView; -@property (nonatomic, strong) id tableModel; -@property (nonatomic, strong) id tableCellFactory; +@property (nonatomic, strong) BSTableController *tableController; @property (nonatomic, strong) BSSpeechBubbleView *speechBubbleView; @property (nonatomic, strong) UIView *coverView; @@ -42,7 +41,7 @@ @property (nonatomic, strong) BSPreviewController *previewController; -@property (nonatomic, strong) BSZoomInAnimator *zoomInAnimator; -@property (nonatomic, strong) BSZoomOutAnimator *zoomOutAnimator; +@property (nonatomic, strong) BSExpandAnimator *zoomInAnimator; +@property (nonatomic, strong) BSShrinkAnimator *zoomOutAnimator; @end \ No newline at end of file diff --git a/BSImagePicker/Controller/BSPhotosController.m b/BSImagePicker/Controller/BSPhotosController.m index 01c70eb2..5c076638 100644 --- a/BSImagePicker/Controller/BSPhotosController.m +++ b/BSImagePicker/Controller/BSPhotosController.m @@ -25,7 +25,6 @@ #import "BSAlbumTableViewCellFactory.h" #import "BSPhotosController+PrivateMethods.h" #import "BSPhotosController+BSItemsModel.h" -#import "BSPhotosController+UITableView.h" #import "BSCollectionController+UICollectionView.h" #import #import "BSImagePickerSettings.h" @@ -43,7 +42,9 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil //Register identifiers [[self.collectionCellFactory class] registerCellIdentifiersForCollectionView:self.collectionView]; - [[self.tableCellFactory class] registerCellIdentifiersForTableView:self.tableView]; + + //Add table view controller + [self addChildViewController:self.tableController]; [self.collectionView setAllowsMultipleSelection:YES]; [self.collectionView setScrollEnabled:YES]; @@ -62,7 +63,6 @@ - (void)didReceiveMemoryWarning { //Release these if they aren't visible if(![self.speechBubbleView isDescendantOfView:self.navigationController.view]) { [self setSpeechBubbleView:nil]; - [self setTableView:nil]; [self setCoverView:nil]; } } @@ -124,14 +124,13 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO #pragma mark - Lazy load -- (id)tableModel { - if(!_tableModel) { - _tableModel = [[BSAssetsGroupModel alloc] init]; - [_tableModel setDelegate:self]; - [_tableModel setupWithParentItem:[[ALAssetsLibrary alloc] init]]; +- (BSTableController *)tableController { + if(!_tableController) { + _tableController = [[BSTableController alloc] init]; + [_tableController.tableModel setDelegate:self]; } - - return _tableModel; + + return _tableController; } - (UIBarButtonItem *)cancelButton { @@ -169,7 +168,7 @@ - (BSSpeechBubbleView *)speechBubbleView { if(!_speechBubbleView) { _speechBubbleView = [[BSSpeechBubbleView alloc] initWithFrame:CGRectMake(0, 0, 300, 320)]; [_speechBubbleView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin]; - [[_speechBubbleView contentView] addSubview:self.tableView]; + [[_speechBubbleView contentView] addSubview:self.tableController.tableView]; } //Set speechbubble color to match tab bar color @@ -180,23 +179,6 @@ - (BSSpeechBubbleView *)speechBubbleView { return _speechBubbleView; } -- (UITableView *)tableView { - if(!_tableView) { - _tableView = [[UITableView alloc] init]; - [_tableView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; - [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine]; - [_tableView setBackgroundColor:[UIColor clearColor]];; - [_tableView setAllowsSelection:YES]; - [_tableView setAllowsMultipleSelection:NO]; - [_tableView setDelegate:self]; - [_tableView setDataSource:self]; - - [_tableView reloadData]; - } - - return _tableView; -} - - (UIView *)coverView { if(!_coverView) { _coverView = [[UIView alloc] initWithFrame:self.navigationController.view.bounds]; @@ -210,14 +192,6 @@ - (UIView *)coverView { return _coverView; } -- (id)tableCellFactory { - if(!_tableCellFactory) { - _tableCellFactory = [[BSAlbumTableViewCellFactory alloc] init]; - } - - return _tableCellFactory; -} - - (BSPreviewController *)previewController { if(!_previewController) { _previewController = [[BSPreviewController alloc] initWithNibName:nil bundle:nil]; @@ -227,17 +201,17 @@ - (BSPreviewController *)previewController { return _previewController; } -- (BSZoomInAnimator *)zoomInAnimator { +- (BSExpandAnimator *)zoomInAnimator { if(!_zoomInAnimator) { - _zoomInAnimator = [[BSZoomInAnimator alloc] init]; + _zoomInAnimator = [[BSExpandAnimator alloc] init]; } return _zoomInAnimator; } -- (BSZoomOutAnimator *)zoomOutAnimator { +- (BSShrinkAnimator *)zoomOutAnimator { if(!_zoomOutAnimator) { - _zoomOutAnimator = [[BSZoomOutAnimator alloc] init]; + _zoomOutAnimator = [[BSShrinkAnimator alloc] init]; } return _zoomOutAnimator; diff --git a/BSImagePicker/Controller/BSPreviewController.h b/BSImagePicker/Controller/BSPreviewController.h index ede9154f..c1f7b538 100644 --- a/BSImagePicker/Controller/BSPreviewController.h +++ b/BSImagePicker/Controller/BSPreviewController.h @@ -26,5 +26,6 @@ @property (nonatomic, strong) NSIndexPath *currentIndexPath; @property (nonatomic, strong) UIBarButtonItem *checkMarkButton; +@property (nonatomic, strong) UIBarButtonItem *emptyItem; @end \ No newline at end of file diff --git a/BSImagePicker/Controller/BSPreviewController.m b/BSImagePicker/Controller/BSPreviewController.m index 6d75d19e..113feccb 100644 --- a/BSImagePicker/Controller/BSPreviewController.m +++ b/BSImagePicker/Controller/BSPreviewController.m @@ -23,10 +23,25 @@ #import "BSPreviewController.h" #import "BSPreviewCollectionViewCellFactory.h" #import "BSCheckmarkView.h" +#import +#import +#import "BSVideoCell.h" @interface BSPreviewController () +@property (nonatomic, strong) UIBarButtonItem *playButton; +@property (nonatomic, strong) UIBarButtonItem *stopButton; +@property (nonatomic, strong) UIBarButtonItem *flexibleItem; +@property (nonatomic, strong) UIToolbar *toolbar; +@property (nonatomic, strong) MPMoviePlayerController *moviePlayerController; + - (void)toggleCheckMarkForIndexPath:(NSIndexPath *)anIndexPath; +- (void)togglePlayButtonForIndexPath:(NSIndexPath *)anIndexPath; +- (void)prepareMoviePlayerForIndexPath:(NSIndexPath *)anIndexPath; + +- (void)playAction:(id)sender; +- (void)stopAction:(id)sender; +- (void)videoFinishedPlaying:(NSNotification *)notification; @end @@ -35,8 +50,7 @@ @implementation BSPreviewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { [self setAutomaticallyAdjustsScrollViewInsets:NO]; - [self.collectionView setContentInset:UIEdgeInsetsMake(64.0, 0.0, 0.0, 0.0)]; - + //Setup layout [self.collectionViewFlowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; @@ -59,8 +73,22 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + + [self.navigationItem setTitleView:self.toolbar]; + [self.navigationItem setRightBarButtonItem:self.emptyItem]; + + [self.collectionView scrollToItemAtIndexPath:self.currentIndexPath + atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally + animated:NO]; + + [self toggleCheckMarkForIndexPath:self.currentIndexPath]; + [self togglePlayButtonForIndexPath:self.currentIndexPath]; +} - [self.collectionView scrollToItemAtIndexPath:self.currentIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + + [self prepareMoviePlayerForIndexPath:self.currentIndexPath]; } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { @@ -68,7 +96,6 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO [self.collectionView performBatchUpdates:^{ [self.collectionView.collectionViewLayout invalidateLayout]; - } completion:nil]; } @@ -77,6 +104,9 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO - (void)scrollViewDidScroll:(UIScrollView *)scrollView { [self setCurrentIndexPath:[NSIndexPath indexPathForItem:round(scrollView.contentOffset.x / scrollView.frame.size.width) inSection:0]]; [self toggleCheckMarkForIndexPath:self.currentIndexPath]; + [self togglePlayButtonForIndexPath:self.currentIndexPath]; + [self.moviePlayerController stop]; + [self prepareMoviePlayerForIndexPath:self.currentIndexPath]; } #pragma mark - Lazy load @@ -91,17 +121,143 @@ - (UIBarButtonItem *)checkMarkButton { return _checkMarkButton; } +- (UIBarButtonItem *)emptyItem { + if(!_emptyItem) { + _emptyItem = [[UIBarButtonItem alloc] initWithCustomView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 25.0, 25.0)]]; + } + + return _emptyItem; +} + +- (UIBarButtonItem *)playButton { + if(!_playButton) { + _playButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(playAction:)]; + } + + return _playButton; +} + +- (UIBarButtonItem *)stopButton { + if(!_stopButton) { + _stopButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(stopAction:)]; + } + + return _stopButton; +} + +- (UIBarButtonItem *)flexibleItem { + if(!_flexibleItem) { + _flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; + } + + return _flexibleItem; +} + +- (UIToolbar *)toolbar { + if(!_toolbar) { + _toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 44.0, 44.0)]; + [_toolbar setItems:@[self.flexibleItem, self.playButton, self.flexibleItem]]; + [_toolbar sizeThatFits:CGSizeMake(44.0, 44.0)]; + [_toolbar setClipsToBounds:YES]; + [_toolbar setContentMode:UIViewContentModeCenter]; + [_toolbar setBackgroundColor:[UIColor clearColor]]; + [_toolbar setTranslucent:YES]; + [self.toolbar setBackgroundImage:[UIImage new] + forToolbarPosition:UIToolbarPositionAny + barMetrics:UIBarMetricsDefault]; + } + + return _toolbar; +} + +- (MPMoviePlayerController *)moviePlayerController { + if(!_moviePlayerController) { + _moviePlayerController = [[MPMoviePlayerController alloc] init]; + [_moviePlayerController setControlStyle:MPMovieControlStyleNone]; + [_moviePlayerController setScalingMode:MPMovieScalingModeAspectFit]; + [_moviePlayerController setAllowsAirPlay:NO]; + } + + return _moviePlayerController; +} + +#pragma mark - Give me a name + - (void)toggleCheckMarkForIndexPath:(NSIndexPath *)anIndexPath { BOOL isSelected = [self.collectionModel isItemAtIndexPathSelected:anIndexPath]; - BOOL isCheckmarkVisible = self.navigationItem.rightBarButtonItem != nil; + BOOL isCheckmarkVisible = self.navigationItem.rightBarButtonItem == self.checkMarkButton; if(isSelected != isCheckmarkVisible) { if(isSelected) { [self.navigationItem setRightBarButtonItem:self.checkMarkButton animated:YES]; } else { - [self.navigationItem setRightBarButtonItem:nil animated:YES]; + [self.navigationItem setRightBarButtonItem:self.emptyItem animated:YES]; } } } +- (void)togglePlayButtonForIndexPath:(NSIndexPath *)anIndexPath { + ALAsset *asset = [self.collectionModel itemAtIndexPath:anIndexPath]; + if([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) { + [self.toolbar setHidden:NO]; + } else { + [self.toolbar setHidden:YES]; + } +} + +- (void)prepareMoviePlayerForIndexPath:(NSIndexPath *)anIndexPath { + ALAsset *asset = [self.collectionModel itemAtIndexPath:anIndexPath]; + + if([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) { + BSVideoCell *cell = (BSVideoCell *)[self.collectionView cellForItemAtIndexPath:anIndexPath]; + [self.moviePlayerController setContentURL:asset.defaultRepresentation.url]; + [self.moviePlayerController.view setFrame:cell.imageView.bounds]; + [self.moviePlayerController prepareToPlay]; + } +} + +#pragma mark - Action + +- (void)playAction:(id)sender { + //Get Cell to play it in + BSVideoCell *cell = (BSVideoCell *)[self.collectionView cellForItemAtIndexPath:self.currentIndexPath]; + + //Listen for notifications + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(videoFinishedPlaying:) + name:MPMoviePlayerPlaybackDidFinishNotification + object:self.moviePlayerController]; + + //Add subview and play + [self.moviePlayerController.backgroundView setBackgroundColor:[self.navigationController.view backgroundColor]]; + [cell.imageView addSubview:self.moviePlayerController.view]; + [self.moviePlayerController play]; + + //Update toolbar + [self.toolbar setItems:@[self.flexibleItem, self.stopButton, self.flexibleItem]]; +} + +- (void)stopAction:(id)sender { + [self.moviePlayerController stop]; +} + +- (void)videoFinishedPlaying:(NSNotification *)notification { + //Remove notification listener + [[NSNotificationCenter defaultCenter] removeObserver:self + name:MPMoviePlayerPlaybackDidFinishNotification + object:self.moviePlayerController]; + + //Stop playback and remove view + [self.moviePlayerController stop]; + [self.moviePlayerController.view removeFromSuperview]; + + //Update toolbar + [self.toolbar setItems:@[self.flexibleItem, self.playButton, self.flexibleItem]]; + + //To prevent glitch if played a second time + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.moviePlayerController prepareToPlay]; + }); +} + @end \ No newline at end of file diff --git a/BSImagePicker/Controller/BSTableController.h b/BSImagePicker/Controller/BSTableController.h new file mode 100644 index 00000000..019cbeb1 --- /dev/null +++ b/BSImagePicker/Controller/BSTableController.h @@ -0,0 +1,32 @@ +// The MIT License (MIT) +// +// Copyright (c) 2014 Joakim Gyllström +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#import "BSItemsModel.h" +#import "BSTableViewCellFactory.h" + +@interface BSTableController : UIViewController + +@property (nonatomic, strong) UITableView *tableView; +@property (nonatomic, strong) id tableModel; +@property (nonatomic, strong) id tableCellFactory; + +@end diff --git a/BSImagePicker/Controller/BSTableController.m b/BSImagePicker/Controller/BSTableController.m new file mode 100644 index 00000000..0cbcecbe --- /dev/null +++ b/BSImagePicker/Controller/BSTableController.m @@ -0,0 +1,75 @@ +// The MIT License (MIT) +// +// Copyright (c) 2014 Joakim Gyllström +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#import "BSTableController.h" +#import +#import "BSAssetsGroupModel.h" +#import "BSAlbumTableViewCellFactory.h" +#import "BSTableController+BSItemsModel.h" +#import "BSTableController+UITableView.h" + +@implementation BSTableController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + [[self.tableCellFactory class] registerCellIdentifiersForTableView:self.tableView]; + } + + return self; +} + +#pragma mark - Lazy load + +- (id)tableModel { + if(!_tableModel) { + _tableModel = [[BSAssetsGroupModel alloc] init]; + [_tableModel setDelegate:self]; + [_tableModel setupWithParentItem:[[ALAssetsLibrary alloc] init]]; + } + + return _tableModel; +} + +- (UITableView *)tableView { + if(!_tableView) { + _tableView = [[UITableView alloc] init]; + [_tableView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; + [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine]; + [_tableView setBackgroundColor:[UIColor clearColor]];; + [_tableView setAllowsSelection:YES]; + [_tableView setAllowsMultipleSelection:NO]; + [_tableView setDelegate:self]; + [_tableView setDataSource:self]; + } + + return _tableView; +} + +- (id)tableCellFactory { + if(!_tableCellFactory) { + _tableCellFactory = [[BSAlbumTableViewCellFactory alloc] init]; + } + + return _tableCellFactory; +} + +@end diff --git a/BSImagePicker/Factory/BSPhotoCollectionViewCellFactory.m b/BSImagePicker/Factory/BSPhotoCollectionViewCellFactory.m index d5943496..3c45a983 100644 --- a/BSImagePicker/Factory/BSPhotoCollectionViewCellFactory.m +++ b/BSImagePicker/Factory/BSPhotoCollectionViewCellFactory.m @@ -23,13 +23,16 @@ #import #import "BSPhotoCollectionViewCellFactory.h" #import "BSPhotoCell.h" +#import "BSVideoCell.h" static NSString *kPhotoCellIdentifier = @"photoCellIdentifier"; +static NSString *kVideoCellIdentifier = @"videoCellIdentifier"; @implementation BSPhotoCollectionViewCellFactory + (void)registerCellIdentifiersForCollectionView:(UICollectionView *)aCollectionView { [aCollectionView registerClass:[BSPhotoCell class] forCellWithReuseIdentifier:kPhotoCellIdentifier]; + [aCollectionView registerClass:[BSVideoCell class] forCellWithReuseIdentifier:kVideoCellIdentifier]; } + (CGSize)sizeAtIndexPath:(NSIndexPath *)anIndexPath forCollectionView:(UICollectionView *)aCollectionView withModel:(id)aModel { @@ -41,10 +44,13 @@ + (CGSize)sizeAtIndexPath:(NSIndexPath *)anIndexPath forCollectionView:(UICollec CGSize thumbnailSize = CGSizeMake(CGImageGetWidth(asset.thumbnail), CGImageGetHeight(asset.thumbnail)); //We want 3 images in each row. So width should be viewWidth-(4*LEFT/RIGHT_INSET)/3 - //4*2.0 is edgeinset //Height should be adapted so we maintain the aspect ratio of thumbnail //original height / original width * new width - itemSize = CGSizeMake((aCollectionView.bounds.size.width - (4*2.0))/3.0, 100); + + UIEdgeInsets sectionInsets = [[self class] edgeInsetAtSection:anIndexPath.section forCollectionView:aCollectionView withModel:aModel]; + CGFloat minItemSpacing = [[self class] minimumItemSpacingAtSection:anIndexPath.section forCollectionView:aCollectionView withModel:aModel]; + + itemSize = CGSizeMake((aCollectionView.bounds.size.width - (sectionInsets.left + 2*minItemSpacing + sectionInsets.right))/3.0, 100); itemSize = CGSizeMake(itemSize.width, thumbnailSize.height / thumbnailSize.width * itemSize.width); } @@ -64,9 +70,22 @@ + (CGFloat)minimumItemSpacingAtSection:(NSUInteger)aSection forCollectionView:(U } - (UICollectionViewCell *)cellAtIndexPath:(NSIndexPath *)anIndexPath forCollectionView:(UICollectionView *)aCollectionView withModel:(id)aModel { - BSPhotoCell *photoCell = [aCollectionView dequeueReusableCellWithReuseIdentifier:kPhotoCellIdentifier forIndexPath:anIndexPath]; ALAsset *asset = [aModel itemAtIndexPath:anIndexPath]; + //Deque correct type of cell for the asset + BSPhotoCell *photoCell = nil; + if([[asset valueForProperty:ALAssetPropertyType] isEqual:ALAssetTypeVideo]) { + photoCell = [aCollectionView dequeueReusableCellWithReuseIdentifier:kVideoCellIdentifier forIndexPath:anIndexPath]; + if([asset valueForProperty:ALAssetPropertyDuration] != ALErrorInvalidProperty) { + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setDateFormat:@"mm:ss"]; + + [[(BSVideoCell *)photoCell durationLabel] setText:[formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[asset valueForProperty:ALAssetPropertyDuration] doubleValue]]]]; + } + } else { + photoCell = [aCollectionView dequeueReusableCellWithReuseIdentifier:kPhotoCellIdentifier forIndexPath:anIndexPath]; + } + if([asset isKindOfClass:[ALAsset class]]) { [photoCell.imageView setImage:[UIImage imageWithCGImage:asset.thumbnail]]; } diff --git a/BSImagePicker/Factory/BSPreviewCollectionViewCellFactory.m b/BSImagePicker/Factory/BSPreviewCollectionViewCellFactory.m index a77e2932..a9a1ebff 100644 --- a/BSImagePicker/Factory/BSPreviewCollectionViewCellFactory.m +++ b/BSImagePicker/Factory/BSPreviewCollectionViewCellFactory.m @@ -33,7 +33,10 @@ + (void)registerCellIdentifiersForCollectionView:(UICollectionView *)aCollection } + (CGSize)sizeAtIndexPath:(NSIndexPath *)anIndexPath forCollectionView:(UICollectionView *)aCollectionView withModel:(id)aModel { - return CGSizeMake(aCollectionView.bounds.size.width, aCollectionView.bounds.size.height-aCollectionView.contentInset.top); + UIEdgeInsets insets = aCollectionView.contentInset; + CGSize collectionSize = aCollectionView.bounds.size; + + return CGSizeMake(collectionSize.width - (insets.left + insets.right), collectionSize.height - (insets.top + insets.bottom)); } + (UIEdgeInsets)edgeInsetAtSection:(NSUInteger)aSection forCollectionView:(UICollectionView *)aCollectionView withModel:(id)aModel { @@ -49,13 +52,12 @@ + (CGFloat)minimumItemSpacingAtSection:(NSUInteger)aSection forCollectionView:(U } - (UICollectionViewCell *)cellAtIndexPath:(NSIndexPath *)anIndexPath forCollectionView:(UICollectionView *)aCollectionView withModel:(id)aModel { - BSPhotoCell *cell = (BSPhotoCell *)[aCollectionView dequeueReusableCellWithReuseIdentifier:kPhotoCellIdentifier forIndexPath:anIndexPath]; ALAsset *asset = [aModel itemAtIndexPath:anIndexPath]; if([asset isKindOfClass:[ALAsset class]]) { [cell.fadedCoverView setHidden:YES]; - [cell.checkmarkView setHidden:YES]; + [cell.checkmarkView removeFromSuperview]; [cell.imageView setContentMode:UIViewContentModeScaleAspectFit]; [cell.imageView setImage:[UIImage imageWithCGImage:asset.defaultRepresentation.fullScreenImage scale:asset.defaultRepresentation.scale orientation:(UIImageOrientation) asset.defaultRepresentation.orientation]]; } diff --git a/BSImagePicker/Model/BSAssetModel.m b/BSImagePicker/Model/BSAssetModel.m index 1d4d0c09..0fd8e4b2 100644 --- a/BSImagePicker/Model/BSAssetModel.m +++ b/BSImagePicker/Model/BSAssetModel.m @@ -22,6 +22,7 @@ #import "BSAssetModel.h" #import +#import "BSImagePickerSettings.h" @interface BSAssetModel () { id _delegate; @@ -40,9 +41,18 @@ - (void)setupWithParentItem:(id)parentItem { _assetsGroup = parentItem; NSMutableArray *mutableAssets = [[NSMutableArray alloc] initWithCapacity:_assetsGroup.numberOfAssets]; - - ALAssetsFilter *onlyPhotosFilter = [ALAssetsFilter allPhotos]; - [parentItem setAssetsFilter:onlyPhotosFilter]; + + //Set up asset filters based on what types of assets the user wants + BSAssetType assetType = [[BSImagePickerSettings sharedSetting] assetType]; + if(assetType == (BSAssetTypeImage|BSAssetTypeVideo)) { + [parentItem setAssetsFilter:[ALAssetsFilter allAssets]]; + } else if(assetType & BSAssetTypeImage) { + [parentItem setAssetsFilter:[ALAssetsFilter allPhotos]]; + } else if(assetType & BSAssetTypeVideo) { + [parentItem setAssetsFilter:[ALAssetsFilter allVideos]]; + } else { + NSAssert(false, @"Unsupported asset type"); + } [_assetsGroup enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { @@ -74,7 +84,7 @@ - (void)setDelegate:(id)delegate { #pragma mark - BSItemsModel - (NSUInteger)numberOfSections { - return 1; + return ( [self.assets count] > 0 ? 1:0 ); } - (NSUInteger)numberOfItemsInSection:(NSUInteger)aSection { diff --git a/BSImagePicker/Singleton/BSImagePickerSettings.h b/BSImagePicker/Singleton/BSImagePickerSettings.h index 030a1551..bc322700 100644 --- a/BSImagePicker/Singleton/BSImagePickerSettings.h +++ b/BSImagePicker/Singleton/BSImagePickerSettings.h @@ -46,6 +46,11 @@ */ @property (nonatomic, copy) BSImageGroupBlock finishBlock; +/** + * What types of assets you want the picker to handle + */ +@property (nonatomic, assign) BSAssetType assetType; + /** * Set to YES to disable preview on long press */ diff --git a/BSImagePicker/Singleton/BSImagePickerSettings.m b/BSImagePicker/Singleton/BSImagePickerSettings.m index 89724121..ecad7ae8 100644 --- a/BSImagePicker/Singleton/BSImagePickerSettings.m +++ b/BSImagePicker/Singleton/BSImagePickerSettings.m @@ -38,6 +38,8 @@ - (id)init { if(self = [super init]) { //Default to shitloads of images _maximumNumberOfImages = NSUIntegerMax; + + _assetType = BSAssetTypeImage; } return self; diff --git a/BSImagePicker/View/BSCameraView.h b/BSImagePicker/View/BSCameraView.h new file mode 100644 index 00000000..2ab15e53 --- /dev/null +++ b/BSImagePicker/View/BSCameraView.h @@ -0,0 +1,29 @@ +// The MIT License (MIT) +// +// Copyright (c) 2014 Joakim Gyllström +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#import + +@interface BSCameraView : UIView + +@property (nonatomic, strong) UIColor *color; + +@end diff --git a/BSImagePicker/View/BSCameraView.m b/BSImagePicker/View/BSCameraView.m new file mode 100644 index 00000000..de62d9ac --- /dev/null +++ b/BSImagePicker/View/BSCameraView.m @@ -0,0 +1,57 @@ +// The MIT License (MIT) +// +// Copyright (c) 2014 Joakim Gyllström +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#import "BSCameraView.h" + +@implementation BSCameraView + +- (void)drawRect:(CGRect)rect { + //Draw it + UIBezierPath *bezierPath = [UIBezierPath bezierPath]; + [bezierPath moveToPoint: CGPointMake(0, 2.84)]; + [bezierPath addLineToPoint: CGPointMake(0, 12.84)]; + [bezierPath addCurveToPoint: CGPointMake(2, 14.84) controlPoint1: CGPointMake(0, 14.84) controlPoint2: CGPointMake(2, 14.84)]; + [bezierPath addLineToPoint: CGPointMake(13.92, 14.84)]; + [bezierPath addCurveToPoint: CGPointMake(15.92, 12.84) controlPoint1: CGPointMake(13.92, 14.84) controlPoint2: CGPointMake(15.92, 14.84)]; + [bezierPath addLineToPoint: CGPointMake(15.92, 2.84)]; + [bezierPath addCurveToPoint: CGPointMake(13.92, 0.84) controlPoint1: CGPointMake(15.92, 0.84) controlPoint2: CGPointMake(13.92, 0.84)]; + [bezierPath addLineToPoint: CGPointMake(2, 0.84)]; + [bezierPath addCurveToPoint: CGPointMake(0, 2.84) controlPoint1: CGPointMake(2, 0.84) controlPoint2: CGPointMake(0, 0.84)]; + [bezierPath closePath]; + [bezierPath moveToPoint: CGPointMake(17.08, 10.97)]; + [bezierPath addLineToPoint: CGPointMake(22, 14.84)]; + [bezierPath addLineToPoint: CGPointMake(22, 0.84)]; + [bezierPath addLineToPoint: CGPointMake(17.08, 4.74)]; + [bezierPath addLineToPoint: CGPointMake(17.08, 10.97)]; + [bezierPath closePath]; + [bezierPath setMiterLimit:4]; + + //Scale it (22 and 16 is the original width and height) + CGFloat scale = MIN(self.bounds.size.width/22.0, self.bounds.size.height/16.0); + [bezierPath applyTransform:CGAffineTransformMakeScale(scale, scale)]; + + //Fill it + [self.color setFill]; + [bezierPath fill]; +} + +@end diff --git a/BSImagePicker/View/BSPhotoCell.m b/BSImagePicker/View/BSPhotoCell.m index 8e8dc1fe..8b6581a6 100644 --- a/BSImagePicker/View/BSPhotoCell.m +++ b/BSImagePicker/View/BSPhotoCell.m @@ -32,6 +32,8 @@ - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self.contentView addSubview:self.imageView]; + [self.imageView addSubview:self.fadedCoverView]; + [self.imageView addSubview:self.checkmarkView]; } return self; } @@ -43,13 +45,8 @@ - (void)setSelected:(BOOL)selected { - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected]; - if(selected) { - [self.imageView addSubview:self.fadedCoverView]; - [self.imageView addSubview:self.checkmarkView]; - } else { - [self.checkmarkView removeFromSuperview]; - [self.fadedCoverView removeFromSuperview]; - } + [self.fadedCoverView setHidden:!selected]; + [self.checkmarkView setHidden:!selected]; if(animated) { [UIView animateWithDuration:0.08 @@ -91,7 +88,8 @@ - (UIView *)fadedCoverView { - (BSCheckmarkView *)checkmarkView { if(!_checkmarkView) { - _checkmarkView = [[BSCheckmarkView alloc] initWithFrame:CGRectMake(self.imageView.frame.size.width-25, self.imageView.frame.size.height-25, 25, 25)]; + _checkmarkView = [[BSCheckmarkView alloc] initWithFrame:CGRectMake(self.imageView.bounds.size.width-25, self.imageView.bounds.size.height-25, 25, 25)]; + [_checkmarkView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleTopMargin]; [_checkmarkView setBackgroundColor:[UIColor clearColor]]; } diff --git a/BSImagePicker/View/BSVideoCell.h b/BSImagePicker/View/BSVideoCell.h new file mode 100644 index 00000000..a00d808e --- /dev/null +++ b/BSImagePicker/View/BSVideoCell.h @@ -0,0 +1,31 @@ +// The MIT License (MIT) +// +// Copyright (c) 2014 Joakim Gyllström +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// + +#import "BSPhotoCell.h" + +@interface BSVideoCell : BSPhotoCell + +@property (nonatomic, strong) UILabel *durationLabel; +@property (nonatomic, strong) UIView *gradientView; + +@end diff --git a/BSImagePicker/View/BSVideoCell.m b/BSImagePicker/View/BSVideoCell.m new file mode 100644 index 00000000..859f16a3 --- /dev/null +++ b/BSImagePicker/View/BSVideoCell.m @@ -0,0 +1,83 @@ +// The MIT License (MIT) +// +// Copyright (c) 2014 Joakim Gyllström +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// + +#import "BSVideoCell.h" +#import "BSCameraView.h" + +@interface BSVideoCell () + +@property (nonatomic, strong) BSCameraView *cameraView; + +@end + +@implementation BSVideoCell + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self.imageView addSubview:self.gradientView]; + [self.gradientView addSubview:self.durationLabel]; + [self.gradientView addSubview:self.cameraView]; + } + return self; +} + +- (UIView *)gradientView { + if(!_gradientView){ + _gradientView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 30)]; + [_gradientView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleBottomMargin]; + + CAGradientLayer *gradientLayer = [CAGradientLayer layer]; + [gradientLayer setFrame:_gradientView.bounds]; + [gradientLayer setColors:@[(id)[UIColor colorWithWhite:0 alpha:1.0].CGColor, + (id)[UIColor colorWithWhite:0 alpha:0.5].CGColor, + (id)[UIColor colorWithWhite:0 alpha:0.0].CGColor]]; + [_gradientView.layer insertSublayer:gradientLayer atIndex:0]; + } + + return _gradientView; +} + +- (UILabel *)durationLabel { + if(!_durationLabel) { + _durationLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, self.gradientView.bounds.size.width-10, 15)]; + [_durationLabel setTextColor:[UIColor whiteColor]]; + [_durationLabel setTextAlignment:NSTextAlignmentRight]; + [_durationLabel setFont:[UIFont systemFontOfSize:14.0]]; + } + + return _durationLabel; +} + +- (BSCameraView *)cameraView { + if(!_cameraView) { + _cameraView = [[BSCameraView alloc] initWithFrame:CGRectMake(5, 2, 40, 10)]; + [_cameraView setBackgroundColor:[UIColor clearColor]]; + [_cameraView setColor:[UIColor whiteColor]]; + } + + return _cameraView; +} + +@end diff --git a/README.md b/README.md index 29855a4f..d7b63c90 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A mix between the native iOS 7 gallery and facebooks image picker. ## Pod Put this into your Podfile: ```shell -pod 'BSImagePicker', '~> 0.4' +pod 'BSImagePicker', '~> 0.5' ``` ## Framework ### Download framework @@ -55,7 +55,7 @@ All blocks are optional and can be nil, so you could for an instance just handle Blocks are always called on the main thread. -### Customization (see BSImagePickerController.h) +### Customize (see BSImagePickerController.h) * You can disable previews by setting previewDisabled to YES. * Setting keepSelection to YES will keep your image selection after dismissing the controller. * Set maximumNumberOfImages to a value to limit selection to a certain number of images.