Skip to content

Commit

Permalink
Make filters an optional module
Browse files Browse the repository at this point in the history
  • Loading branch information
利辺羅エルネスト committed Feb 20, 2014
1 parent 48c61ea commit 7b09490
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 96 deletions.
2 changes: 1 addition & 1 deletion NBUImagePicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Pod::Spec.new do |s|

s.subspec 'Image' do |sub|
sub.source_files = 'Source/Image/*.{h,m}'
sub.dependency 'NBUImagePicker/Filters'
sub.dependency 'NBUImagePicker/MediaInfo'
end

Expand All @@ -68,6 +67,7 @@ Pod::Spec.new do |s|
sub.dependency 'NBUImagePicker/Camera'
sub.dependency 'NBUImagePicker/Image'
sub.dependency 'NBUImagePicker/Gallery'
sub.dependency 'NBUImagePicker/Resources'
end

s.subspec 'Resources' do |sub|
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ Manually specify only the components you need:
pod 'NBUImagePicker/Camera' # AVFoundation-based camera
pod 'NBUImagePicker/Assets' # AssetsLibrary and custom path asset selection
pod 'NBUImagePicker/Filters' # CoreImage and GPUImage filters' wrapping
pod 'NBUImagePicker/Image' # Croping
pod 'NBUImagePicker/Gallery' # Image preview
pod 'NBUImagePicker/Picker' # Combinations of the modules above
pod 'NBUImagePicker/Picker' # Combinations of the modules above except for filters
```

##License
Expand Down
94 changes: 2 additions & 92 deletions Source/Gallery/NBUGalleryThumbnailView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="852601116">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">1316</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUIImageView" id="366613159">
Expand All @@ -41,7 +41,6 @@
<object class="NSPSMatrix" key="NSFrameMatrix"/>
<string key="NSFrameSize">{75, 75}</string>
<reference key="NSSuperview" ref="852601116"/>
<reference key="NSWindow"/>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSCustomResource" key="IBUIImage">
Expand All @@ -52,8 +51,6 @@
</array>
<object class="NSPSMatrix" key="NSFrameMatrix"/>
<string key="NSFrameSize">{75, 75}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="366613159"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
Expand Down Expand Up @@ -127,94 +124,7 @@
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">ActiveView</string>
<string key="superclassName">NBUView</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="doubleTapped:">id</string>
<string key="swiped:">id</string>
<string key="tapped:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="doubleTapped:">
<string key="name">doubleTapped:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="swiped:">
<string key="name">swiped:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="tapped:">
<string key="name">tapped:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">noContentsView</string>
<string key="NS.object.0">UIView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">noContentsView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">noContentsView</string>
<string key="candidateClassName">UIView</string>
</object>
</object>
<object class="NSMutableDictionary" key="toManyOutletInfosByName">
<string key="NS.key.0">dynamicHeightSubviews</string>
<object class="IBToManyOutletInfo" key="NS.object.0">
<string key="name">dynamicHeightSubviews</string>
<string key="candidateClassName">UIView</string>
<string key="collectionClassName">NSMutableArray</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/ActiveView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NBUGalleryThumbnailView</string>
<string key="superclassName">ActiveView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">tapped:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">tapped:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">tapped:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">imageView</string>
<string key="NS.object.0">UIImageView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">imageView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">imageView</string>
<string key="candidateClassName">UIImageView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NBUGalleryThumbnailView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NBUView</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NBUView.h</string>
</object>
</object>
</array>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">YES</bool>
Expand Down
2 changes: 2 additions & 0 deletions Source/Image/NBUEditImageViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ typedef void (^NBUEditImageResultBlock)(UIImage * image);

/// @name Outlets

#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
/// The optional NBUPresetFilterView.
@property (weak, nonatomic) IBOutlet NBUPresetFilterView * filterView;
#endif

/// The optional NBUCropView.
@property (weak, nonatomic) IBOutlet NBUCropView * cropView;
Expand Down
16 changes: 16 additions & 0 deletions Source/Image/NBUEditImageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ - (void)viewDidLoad
{
[super viewDidLoad];

#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
// Configure filterView
if (!_filterView)
{
Expand All @@ -53,6 +54,7 @@ - (void)viewDidLoad
_filterView.filters = self.filters;
_filterView.workingSize = _workingSize;
}
#endif

// Configure cropView
if (!_cropView)
Expand All @@ -66,6 +68,7 @@ - (void)viewDidLoad
}
}

#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
- (void)setFilters:(NSArray *)filters
{
_filters = filters;
Expand Down Expand Up @@ -97,6 +100,7 @@ - (NSArray *)filters
}
return _filters;
}
#endif

- (void)objectUpdated:(NSDictionary *)userInfo
{
Expand All @@ -108,11 +112,13 @@ - (void)objectUpdated:(NSDictionary *)userInfo
_cropView.image = self.image;
}

#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
// Or just filterView
else
{
_filterView.image = self.image;
}
#endif
}

- (UIImage *)editedImage
Expand All @@ -126,11 +132,13 @@ - (UIImage *)editedImage
image = _cropView.image;
}

#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
// Or from filterView
else
{
image = _filterView.image;
}
#endif

// Set to target size?
if (!CGSizeEqualToSize(_cropTargetSize, CGSizeZero))
Expand All @@ -151,12 +159,14 @@ - (void)setMediaInfo:(NBUMediaInfo *)mediaInfo

self.object = mediaInfo.originalImage;

#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
// Restore state
NBUFilter * filter = mediaInfo.attributes[NBUMediaInfoFiltersKey];
if (filter)
{
_filterView.currentFilter = filter;
}
#endif
}

- (NBUMediaInfo *)mediaInfo
Expand All @@ -166,12 +176,14 @@ - (NBUMediaInfo *)mediaInfo
{
_mediaInfo.attributes[NBUMediaInfoCropRectKey] = [NSValue valueWithCGRect:_cropView.currentCropRect];
}
#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
if (_filterView)
{
NBUFilter * currentFilter = _filterView.currentFilter;
if (currentFilter)
_mediaInfo.attributes[NBUMediaInfoFiltersKey] = currentFilter;
}
#endif

return _mediaInfo;
}
Expand All @@ -197,13 +209,17 @@ - (void)apply:(id)sender
{
if (_resultBlock)
{
#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
_filterView.activityView.hidden = NO;
#endif
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
UIImage * processedImage = self.editedImage;
dispatch_async(dispatch_get_main_queue(), ^
{
#ifdef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
_filterView.activityView.hidden = YES;
#endif
_resultBlock(processedImage);
});
});
Expand Down
9 changes: 7 additions & 2 deletions Source/Picker/NBUImagePickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ - (void)setOptions:(NBUImagePickerOptions)options
options |= NBUImagePickerOptionDisableCamera;
}

// Filters not available?
#ifndef COCOAPODS_POD_AVAILABLE_NBUImagePicker_Filters
NBULogDebug(@"Options: Filters not available.");
options |= NBUImagePickerOptionDisableFilters;
#endif

NBULogInfo(@"Picker options: %x", options);
_options = options;

Expand Down Expand Up @@ -511,8 +517,7 @@ - (NBUEditMultiImageViewController *)editController
450.0 * scale);

// Manually call viewDidLoad
// [_editController viewDidLoad];
#warning
// [_editController viewDidLoad]; <- No longer needed it seems
}

return _editController;
Expand Down

0 comments on commit 7b09490

Please sign in to comment.