Skip to content

Commit

Permalink
Merge branch 'release/0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaoj committed Aug 15, 2014
2 parents ec49764 + 18e9676 commit 2bdee60
Show file tree
Hide file tree
Showing 38 changed files with 790 additions and 149 deletions.
6 changes: 3 additions & 3 deletions BSImagePicker.podspec
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -9,12 +9,12 @@ Pod::Spec.new do |s|
s.license = "MIT"
s.author = { "Joakim Gyllström" => "[email protected]" }
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",
Expand Down
82 changes: 58 additions & 24 deletions BSImagePicker.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
<string>BSImagePicker</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>3DC0F6DD-BC5C-46F5-9A37-FECD8B9F1B11</key>
<key>DF1E81D5DDD90A1D12FA649A155BB8370AC65668</key>
<string>ssh://github.com/mikaoj/BSImagePicker.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>BSImagePicker.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>3DC0F6DD-BC5C-46F5-9A37-FECD8B9F1B11</key>
<key>DF1E81D5DDD90A1D12FA649A155BB8370AC65668</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/mikaoj/BSImagePicker.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>3DC0F6DD-BC5C-46F5-9A37-FECD8B9F1B11</string>
<string>DF1E81D5DDD90A1D12FA649A155BB8370AC65668</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>3DC0F6DD-BC5C-46F5-9A37-FECD8B9F1B11</string>
<string>DF1E81D5DDD90A1D12FA649A155BB8370AC65668</string>
<key>IDESourceControlWCCName</key>
<string>MultipleImagePicker</string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

@interface BSZoomInAnimator : NSObject <UIViewControllerAnimatedTransitioning>
@interface BSExpandAnimator : NSObject <UIViewControllerAnimatedTransitioning>

@end
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -56,7 +56,7 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

@interface BSZoomOutAnimator : NSObject <UIViewControllerAnimatedTransitioning>
@interface BSShrinkAnimator : NSObject <UIViewControllerAnimatedTransitioning>

@end
Original file line number Diff line number Diff line change
Expand Up @@ -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 <UIViewControllerContextTransitioning>)transitionContext {
return 0.3;
Expand All @@ -49,7 +49,7 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)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);
Expand All @@ -68,7 +68,7 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
@implementation BSCollectionController (BSItemsModel)

- (void)didUpdateModel:(id<BSItemsModel>)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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@

#import "BSPhotosController+BSItemsModel.h"
#import "BSCollectionController+BSItemsModel.h"
#import "BSTableController+BSItemsModel.h"
#import "BSPhotosController+PrivateMethods.h"
#import <AssetsLibrary/AssetsLibrary.h>

@implementation BSPhotosController (BSItemsModel)

- (void)didUpdateModel:(id<BSItemsModel>)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];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ - (void)finishButtonPressed:(id)sender {
if(![[BSImagePickerSettings sharedSetting] keepSelection]) {
[self.collectionModel clearSelection];
}

[self dismissViewControllerAnimated:YES completion:nil];
}

- (void)albumButtonPressed:(id)sender {
Expand All @@ -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
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) <UITableViewDataSource, UITableViewDelegate>
@end
@interface BSTableController (BSItemsModel) <BSItemsModelDelegate>

@end
Original file line number Diff line number Diff line change
@@ -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<BSItemsModel>)aModel {
[self.tableView reloadData];
}

@end
Original file line number Diff line number Diff line change
@@ -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) <UITableViewDelegate, UITableViewDataSource>

@end
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -35,28 +36,28 @@ - (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;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
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
@end
5 changes: 5 additions & 0 deletions BSImagePicker/Category/UIViewController+MultipleImagePicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading

0 comments on commit 2bdee60

Please sign in to comment.