Skip to content

Commit

Permalink
Add CLImagePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
yackle committed Jan 20, 2014
1 parent 5f76aba commit b6552dc
Show file tree
Hide file tree
Showing 47 changed files with 3,615 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ DerivedData

#CocoaPods
Pods
Podfile.lock
*.xcworkspace
develop
14 changes: 14 additions & 0 deletions CLImageViewerKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,18 @@ Pod::Spec.new do |s|
a.source_files = 'Classes/CLColorPickerView/*.{h,m}'
a.dependency 'CLImageViewerKit/UIViewFrame'
end



s.subspec 'CLImagePicker' do |a|
a.source_files = 'Classes/CLImagePicker/**/*.{h,m}'
a.public_header_files = 'Classes/CLImagePicker/*/*.h'
a.resources = 'Classes/CLImagePicker/**/*.xib', 'Classes/CLImagePicker/**/*.bundle'
a.dependency 'CLImageViewerKit/UIViewFrame'
a.dependency 'CLImageViewerKit/UIImageUtility'
a.dependency 'CLImageViewerKit/CLZoomingImageView'
a.dependency 'CLImageViewerKit/CLCacheManager'
a.dependency 'CLImageEditor'
end

end
45 changes: 45 additions & 0 deletions Classes/CLImagePicker/CLImagePicker.bundle/CLAssetCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12F45" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="" id="aXN-tV-dSw" customClass="CLAssetCell">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="FKa-or-buA">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="jDJ-HU-C6z">
<rect key="frame" x="18" y="0.0" width="32" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" image="CLImagePicker.bundle/images/btn_selected_off">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" image="CLImagePicker.bundle/images/btn_selected_on"/>
<connections>
<action selector="pushedSelectBtn:" destination="aXN-tV-dSw" eventType="touchUpInside" id="Xwg-RV-VfG"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="_imageView" destination="FKa-or-buA" id="gkN-Zh-HYR"/>
<outlet property="_selectBtn" destination="jDJ-HU-C6z" id="MdV-qg-VGH"/>
</connections>
</collectionViewCell>
</objects>
<resources>
<image name="CLImagePicker.bundle/images/btn_selected_off" width="16" height="16"/>
<image name="CLImagePicker.bundle/images/btn_selected_on" width="16" height="16"/>
</resources>
</document>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions Classes/CLImagePicker/CLImagePickerBundle/CLImagePickerBundle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// CLImagePickerBundle.h
//
// Created by sho yakushiji on 2014/01/17.
// Copyright (c) 2014年 CALACULU. All rights reserved.
//

#import <Foundation/Foundation.h>

@class CLImageEditor;
@protocol CLImagePickerBundleDelegate;

@interface CLImagePickerBundle : NSObject

+ (void)setDelegate:(id<CLImagePickerBundleDelegate>)delegate;
+ (void)setBundleName:(NSString*)bundleName;


+ (NSString*)bundleName;
+ (NSBundle*)bundle;
+ (UIImage*)imageNamed:(NSString*)path;
+ (CLImageEditor*)imageEditor;

@end


@protocol CLImagePickerBundleDelegate <NSObject>
@optional
- (CLImageEditor*)imageEditorForImagePicker;

@end
92 changes: 92 additions & 0 deletions Classes/CLImagePicker/CLImagePickerBundle/CLImagePickerBundle.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// CLImagePickerBundle.m
//
// Created by sho yakushiji on 2014/01/17.
// Copyright (c) 2014年 CALACULU. All rights reserved.
//

#import "CLImagePickerBundle.h"

#import <CLImageEditor.h>

@interface CLImagePickerBundle()
@property (nonatomic, weak) id<CLImagePickerBundleDelegate> delegate;
@property (nonatomic, strong) NSString *bundleName;
@end

@implementation CLImagePickerBundle

#pragma mark - singleton pattern

static id _sharedInstance = nil;

+ (CLImagePickerBundle*)instance
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedInstance = [[self alloc] init];
});
return _sharedInstance;
}

+ (id)allocWithZone:(NSZone *)zone
{
@synchronized(self) {
if (_sharedInstance == nil) {
_sharedInstance = [super allocWithZone:zone];
return _sharedInstance;
}
}
return nil;
}

- (id)copyWithZone:(NSZone *)zone
{
return self;
}

- (id)init
{
self = [super init];
if (self) {
self.bundleName = @"CLImagePicker";
}
return self;
}

#pragma mark- claas methods

+ (void)setDelegate:(id<CLImagePickerBundleDelegate>)delegate
{
self.instance.delegate = delegate;
}

+ (void)setBundleName:(NSString*)bundleName
{
self.instance.bundleName = bundleName;
}

+ (NSString*)bundleName
{
return self.instance.bundleName;
}

+ (NSBundle*)bundle
{
return [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:self.bundleName ofType:@"bundle"]];
}

+ (UIImage*)imageNamed:(NSString*)path
{
return [UIImage imageNamed:[NSString stringWithFormat:@"%@.bundle/%@", self.bundleName, path]];
}

+ (CLImageEditor*)imageEditor
{
if([self.instance.delegate respondsToSelector:@selector(imageEditorForImagePicker)]){
return [self.instance.delegate imageEditorForImagePicker];
}
return [CLImageEditor new];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// CLImagePickerController.h
//
// Created by sho yakushiji on 2014/01/09.
// Copyright (c) 2014年 CALACULU. All rights reserved.
//

#import <UIKit/UIKit.h>

@protocol CLImagePickerControllerDelegate;


@interface CLImagePickerController : UIViewController
{
IBOutlet __weak UICollectionView *_collectionView;
IBOutlet __weak UINavigationBar *_navigationBar;
}
@property (nonatomic, weak) id<CLImagePickerControllerDelegate> delegate;

- (void)setSelectedURLs:(NSArray*)selectedURLs;

- (IBAction)pushedDoneBtn:(id)sender;
- (IBAction)pushedCancelBtn:(id)sender;

@end



@protocol CLImagePickerControllerDelegate <NSObject>
@required

- (void)imagePickerController:(CLImagePickerController *)picker didTouchOriginalImage:(UIImage*)image withAssetURL:(NSURL*)url;
- (void)imagePickerController:(CLImagePickerController *)picker didEditImage:(UIImage*)image withAssetURL:(NSURL*)url;
- (void)imagePickerController:(CLImagePickerController *)picker didRemoveEdittedImageWithAssetURL:(NSURL*)url;

- (BOOL)imagePickerController:(CLImagePickerController *)picker isEdittedImageWithAssetURL:(NSURL*)url;


- (UIImage*)imagePickerController:(CLImagePickerController *)picker thumnailImageForAssetURL:(NSURL*)url;
- (UIImage*)imagePickerController:(CLImagePickerController *)picker fullScreenImageForAssetURL:(NSURL*)url;

- (void)imagePickerController:(CLImagePickerController *)picker didFinishPickingMediaWithSelectedAssetURLs:(NSArray*)selectedURLs;

@optional
- (void)imagePickerControllerDidCancel:(CLImagePickerController *)picker;

@end
Loading

0 comments on commit b6552dc

Please sign in to comment.