From 82381d51f23cab764db4984445bc67cc51dec4b5 Mon Sep 17 00:00:00 2001 From: Nikita Tuk <654070@gmail.com> Date: Sun, 9 Oct 2016 18:30:24 +0500 Subject: [PATCH 1/4] Added camera configuration object & protocol for processing controller --- DBCamera/Objects/DBCameraConfiguration.h | 16 ++++++++++++++++ DBCamera/Objects/DBCameraConfiguration.m | 15 +++++++++++++++ .../DBPhotoProcessingControllerProtocol.h | 13 +++++++++++++ Example/DBCamera.xcodeproj/project.pbxproj | 14 +++++++++++++- 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 DBCamera/Objects/DBCameraConfiguration.h create mode 100644 DBCamera/Objects/DBCameraConfiguration.m create mode 100644 DBCamera/Objects/DBPhotoProcessingControllerProtocol.h mode change 100644 => 100755 Example/DBCamera.xcodeproj/project.pbxproj diff --git a/DBCamera/Objects/DBCameraConfiguration.h b/DBCamera/Objects/DBCameraConfiguration.h new file mode 100644 index 0000000..6b2a3ba --- /dev/null +++ b/DBCamera/Objects/DBCameraConfiguration.h @@ -0,0 +1,16 @@ +// +// DBCameraConfiguration.h +// DBCamera +// +// Created by Nikita Tuk on 09/10/16. +// Copyright © 2016 PSSD - Daniele Bogo. All rights reserved. +// + +#import +#import "DBPhotoProcessingControllerProtocol.h" + +@interface DBCameraConfiguration : NSObject + +@property (nonatomic, nullable, copy) void (^configureProcessingController)(UIViewController * _Nonnull controller); + +@end diff --git a/DBCamera/Objects/DBCameraConfiguration.m b/DBCamera/Objects/DBCameraConfiguration.m new file mode 100644 index 0000000..6b696cc --- /dev/null +++ b/DBCamera/Objects/DBCameraConfiguration.m @@ -0,0 +1,15 @@ +// +// DBCameraConfiguration.m +// DBCamera +// +// Created by Nikita Tuk on 09/10/16. +// Copyright © 2016 PSSD - Daniele Bogo. All rights reserved. +// + +#import "DBCameraConfiguration.h" + +@implementation DBCameraConfiguration + + + +@end diff --git a/DBCamera/Objects/DBPhotoProcessingControllerProtocol.h b/DBCamera/Objects/DBPhotoProcessingControllerProtocol.h new file mode 100644 index 0000000..e2e0241 --- /dev/null +++ b/DBCamera/Objects/DBPhotoProcessingControllerProtocol.h @@ -0,0 +1,13 @@ +// +// DBPhotoProcessingControllerProtocol.h +// DBCamera +// +// Created by Nikita Tuk on 09/10/16. +// Copyright © 2016 PSSD - Daniele Bogo. All rights reserved. +// + +@protocol DBPhotoProcessingControllerProtocol + +@property (nonatomic, nonnull, strong, readonly) UIButton *cropButton; + +@end \ No newline at end of file diff --git a/Example/DBCamera.xcodeproj/project.pbxproj b/Example/DBCamera.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index cb2eb8c..2ea1482 --- a/Example/DBCamera.xcodeproj/project.pbxproj +++ b/Example/DBCamera.xcodeproj/project.pbxproj @@ -54,6 +54,7 @@ 9ABB69A219587983007E2B9E /* UIImage+Asset.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABB69A119587983007E2B9E /* UIImage+Asset.m */; }; 9E8E34E51AFFABC600B451B1 /* (null) in Sources */ = {isa = PBXBuildFile; }; A7CB737F1B68107B0017336F /* DBCamera.bundle in Resources */ = {isa = PBXBuildFile; fileRef = A7CB737E1B68107B0017336F /* DBCamera.bundle */; }; + ABB9D8F11DAA7D5700B64899 /* DBCameraConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = ABB9D8EE1DAA718D00B64899 /* DBCameraConfiguration.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -144,6 +145,9 @@ 9ABB69A119587983007E2B9E /* UIImage+Asset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Asset.m"; sourceTree = ""; }; 9ABDB6E6195391A500A1539D /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/InfoPlist.strings; sourceTree = ""; }; A7CB737E1B68107B0017336F /* DBCamera.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = DBCamera.bundle; path = ../../DBCamera/Localizations/DBCamera.bundle; sourceTree = ""; }; + ABB9D8ED1DAA718D00B64899 /* DBCameraConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBCameraConfiguration.h; sourceTree = ""; }; + ABB9D8EE1DAA718D00B64899 /* DBCameraConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBCameraConfiguration.m; sourceTree = ""; }; + ABB9D8F01DAA720500B64899 /* DBPhotoProcessingControllerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DBPhotoProcessingControllerProtocol.h; sourceTree = ""; }; F9DFA4FE58E901A1BE1FE253 /* Pods-DBCamera.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DBCamera.release.xcconfig"; path = "Pods/Target Support Files/Pods-DBCamera/Pods-DBCamera.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -275,6 +279,9 @@ 9A1F4A77191C20CB0084C305 /* DBCollectionViewFlowLayout.m */, 9A2237F519894BAC0084BFD7 /* DBMotionManager.h */, 9A2237F619894BAC0084BFD7 /* DBMotionManager.m */, + ABB9D8ED1DAA718D00B64899 /* DBCameraConfiguration.h */, + ABB9D8EE1DAA718D00B64899 /* DBCameraConfiguration.m */, + ABB9D8F01DAA720500B64899 /* DBPhotoProcessingControllerProtocol.h */, ); name = Objects; path = ../../DBCamera/Objects; @@ -429,7 +436,7 @@ ORGANIZATIONNAME = "PSSD - Daniele Bogo"; TargetAttributes = { 9AB5979F189BAF9A001BCAD3 = { - DevelopmentTeam = Q3SKDBM9PM; + DevelopmentTeam = 5H24V53G7B; }; }; }; @@ -517,6 +524,7 @@ buildActionMask = 2147483647; files = ( 9E8E34E51AFFABC600B451B1 /* (null) in Sources */, + ABB9D8F11DAA7D5700B64899 /* DBCameraConfiguration.m in Sources */, 9A1F4A87191C20CB0084C305 /* DBLibraryManager.m in Sources */, 189DC46C1A4DD02A005F686B /* GrayscaleContrastFilter.m in Sources */, 9A1F4A8B191C20CB0084C305 /* DBCameraGridView.m in Sources */, @@ -653,6 +661,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "DBCamera/DBCamera-Prefix.pch"; INFOPLIST_FILE = "$(SRCROOT)/DBCamera/DBCamera-Info.plist"; @@ -670,6 +680,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "DBCamera/DBCamera-Prefix.pch"; INFOPLIST_FILE = "$(SRCROOT)/DBCamera/DBCamera-Info.plist"; From a8bf47cdcb24f57f9af6fed4ba1a32e4d7031f7c Mon Sep 17 00:00:00 2001 From: Nikita Tuk <654070@gmail.com> Date: Sun, 9 Oct 2016 18:31:12 +0500 Subject: [PATCH 2/4] Passing configuration object through controllers --- .../DBCameraContainerViewController.h | 37 +++++++++++++++++-- .../DBCameraContainerViewController.m | 21 ++++++++++- .../DBCameraLibraryViewController.h | 7 +++- .../DBCameraLibraryViewController.m | 1 + .../Controllers/DBCameraSegueViewController.h | 10 ++++- .../Controllers/DBCameraSegueViewController.m | 7 +++- DBCamera/Controllers/DBCameraViewController.h | 10 +++-- DBCamera/Controllers/DBCameraViewController.m | 2 + 8 files changed, 81 insertions(+), 14 deletions(-) mode change 100644 => 100755 DBCamera/Controllers/DBCameraContainerViewController.h mode change 100644 => 100755 DBCamera/Controllers/DBCameraContainerViewController.m mode change 100644 => 100755 DBCamera/Controllers/DBCameraLibraryViewController.h mode change 100644 => 100755 DBCamera/Controllers/DBCameraLibraryViewController.m mode change 100644 => 100755 DBCamera/Controllers/DBCameraSegueViewController.h mode change 100644 => 100755 DBCamera/Controllers/DBCameraSegueViewController.m mode change 100644 => 100755 DBCamera/Controllers/DBCameraViewController.h mode change 100644 => 100755 DBCamera/Controllers/DBCameraViewController.m diff --git a/DBCamera/Controllers/DBCameraContainerViewController.h b/DBCamera/Controllers/DBCameraContainerViewController.h old mode 100644 new mode 100755 index 00c7cde..f25bbbd --- a/DBCamera/Controllers/DBCameraContainerViewController.h +++ b/DBCamera/Controllers/DBCameraContainerViewController.h @@ -10,8 +10,7 @@ #import "DBCameraDelegate.h" #import "UIViewController+UIViewController_FullScreen.h" -@class DBCameraView; -@class DBCameraViewController; +@class DBCameraView, DBCameraViewController, DBCameraConfiguration; /** * The camera settings block @@ -35,6 +34,11 @@ typedef void(^CameraSettingsBlock)(DBCameraView *cameraView, id container); */ @property (nonatomic, strong) DBCameraViewController *cameraViewController; +/** + * Contains additional configuration for camera controllers + */ +@property (nonatomic, strong) DBCameraConfiguration *cameraConfiguration; + /** * The init method with a DBCameraViewControllerDelegate * @@ -42,7 +46,7 @@ typedef void(^CameraSettingsBlock)(DBCameraView *cameraView, id container); * * @return A DBCameraContainerViewController */ -- (id) initWithDelegate:(id)delegate; +- (instancetype) initWithDelegate:(id)delegate; /** * The init method with a DBCameraViewControllerDelegate and a CameraSettingsBlock @@ -52,5 +56,30 @@ typedef void(^CameraSettingsBlock)(DBCameraView *cameraView, id container); * * @return DBCameraContainerViewController */ -- (id) initWithDelegate:(id)delegate cameraSettingsBlock:(CameraSettingsBlock)block; +- (instancetype) initWithDelegate:(id)delegate + cameraSettingsBlock:(CameraSettingsBlock)block; + +/** + * The init method with a DBCameraViewControllerDelegate and a CameraConfiguration + * + * @param delegate The DBCameraViewControllerDelegate + * @param cameraConfiguration The CameraConfiguration containing customization for controllers + * + * @return DBCameraContainerViewController + */ +- (instancetype) initWithDelegate:(id)delegate + cameraConfiguration:(DBCameraConfiguration *)cameraConfiguration; + +/** + * The init method with a DBCameraViewControllerDelegate and a CameraConfiguration + * + * @param delegate The DBCameraViewControllerDelegate + * @param cameraConfiguration The CameraConfiguration containing customization for controllers + * @param block The CameraSettingsBlock + * + * @return DBCameraContainerViewController + */ +- (instancetype) initWithDelegate:(id)delegate + cameraConfiguration:(DBCameraConfiguration *)cameraConfiguration + cameraSettingsBlock:(CameraSettingsBlock)block; @end \ No newline at end of file diff --git a/DBCamera/Controllers/DBCameraContainerViewController.m b/DBCamera/Controllers/DBCameraContainerViewController.m old mode 100644 new mode 100755 index 9712bdd..baab473 --- a/DBCamera/Controllers/DBCameraContainerViewController.m +++ b/DBCamera/Controllers/DBCameraContainerViewController.m @@ -23,20 +23,36 @@ @implementation DBCameraContainerViewController @synthesize tintColor = _tintColor; @synthesize selectedTintColor = _selectedTintColor; -- (id) initWithDelegate:(id)delegate +- (instancetype) initWithDelegate:(id)delegate { return [self initWithDelegate:delegate cameraSettingsBlock:nil]; } -- (id) initWithDelegate:(id)delegate cameraSettingsBlock:(CameraSettingsBlock)block +- (instancetype) initWithDelegate:(id)delegate cameraSettingsBlock:(CameraSettingsBlock)block { + return [self initWithDelegate:delegate cameraConfiguration:nil cameraSettingsBlock:block]; +} + +- (instancetype) initWithDelegate:(id)delegate + cameraConfiguration:(DBCameraConfiguration *)cameraConfiguration +{ + return [self initWithDelegate:delegate cameraConfiguration:cameraConfiguration cameraSettingsBlock:nil]; +} + +- (instancetype) initWithDelegate:(id)delegate + cameraConfiguration:(DBCameraConfiguration *)cameraConfiguration + cameraSettingsBlock:(CameraSettingsBlock)block +{ + self = [super init]; if ( self ) { _delegate = delegate; _settingsBlock = block; + _cameraConfiguration = cameraConfiguration; } return self; + } - (void) viewDidLoad @@ -100,6 +116,7 @@ - (DBCameraViewController *) defaultCameraViewController [_defaultCameraViewController setTintColor:self.tintColor]; if ( self.selectedTintColor ) [_defaultCameraViewController setSelectedTintColor:self.selectedTintColor]; + _defaultCameraViewController.cameraConfiguration = self.cameraConfiguration; } if ( !self.cameraViewController ) diff --git a/DBCamera/Controllers/DBCameraLibraryViewController.h b/DBCamera/Controllers/DBCameraLibraryViewController.h old mode 100644 new mode 100755 index b09a47e..75b880c --- a/DBCamera/Controllers/DBCameraLibraryViewController.h +++ b/DBCamera/Controllers/DBCameraLibraryViewController.h @@ -9,7 +9,7 @@ #import #import "DBCameraDelegate.h" -@class DBCameraSegueViewController; +@class DBCameraSegueViewController, DBCameraConfiguration; /** * DBCameraLibraryViewController @@ -30,6 +30,11 @@ */ @property (nonatomic, assign) NSUInteger libraryMaxImageSize; +/** + * Contains additional configuration for camera controllers + */ +@property (nonatomic, strong) DBCameraConfiguration *cameraConfiguration; + /** * The init method with an DBCameraContainerDelegate object * diff --git a/DBCamera/Controllers/DBCameraLibraryViewController.m b/DBCamera/Controllers/DBCameraLibraryViewController.m old mode 100644 new mode 100755 index 1ed9289..74a0597 --- a/DBCamera/Controllers/DBCameraLibraryViewController.m +++ b/DBCamera/Controllers/DBCameraLibraryViewController.m @@ -369,6 +369,7 @@ - (void) collectionView:(UICollectionView *)collectionView itemURL:(NSURL *)URL [segue enableGestures:YES]; [segue setCapturedImageMetadata:metadata]; [segue setDelegate:weakSelf.delegate]; + [segue setCameraConfiguration:weakSelf.cameraConfiguration]; [segue setCameraSegueConfigureBlock:self.cameraSegueConfigureBlock]; [weakSelf.navigationController pushViewController:segue animated:YES]; diff --git a/DBCamera/Controllers/DBCameraSegueViewController.h b/DBCamera/Controllers/DBCameraSegueViewController.h old mode 100644 new mode 100755 index a343ea2..654ea26 --- a/DBCamera/Controllers/DBCameraSegueViewController.h +++ b/DBCamera/Controllers/DBCameraSegueViewController.h @@ -9,13 +9,14 @@ #import "DBCameraBaseCropViewController.h" #import "DBCameraDelegate.h" #import "UIViewController+UIViewController_FullScreen.h" +#import "DBPhotoProcessingControllerProtocol.h" -@class DBCameraFiltersView; +@class DBCameraFiltersView, DBCameraConfiguration; /** * DBCameraSegueViewController */ -@interface DBCameraSegueViewController : DBCameraBaseCropViewController +@interface DBCameraSegueViewController : DBCameraBaseCropViewController /** * An id object compliant with the DBCameraContainerDelegate */ @@ -41,6 +42,11 @@ */ @property (nonatomic, readonly) NSIndexPath *selectedFilterIndex; +/** + * Contains additional configuration for camera controllers + */ +@property (nonatomic, strong) DBCameraConfiguration *cameraConfiguration; + /** * The init method with the captured image and thumb * diff --git a/DBCamera/Controllers/DBCameraSegueViewController.m b/DBCamera/Controllers/DBCameraSegueViewController.m old mode 100644 new mode 100755 index d6e23e0..e68537b --- a/DBCamera/Controllers/DBCameraSegueViewController.m +++ b/DBCamera/Controllers/DBCameraSegueViewController.m @@ -15,6 +15,7 @@ #import "UIImage+TintColor.h" #import "UIImage+Bundle.h" #import "GrayscaleContrastFilter.h" +#import "DBCameraConfiguration.h" #import @@ -41,7 +42,7 @@ @interface DBCameraSegueViewController () Date: Sun, 9 Oct 2016 18:31:19 +0500 Subject: [PATCH 3/4] Updated example --- Example/DBCamera/Classes/Root/RootViewController.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) mode change 100644 => 100755 Example/DBCamera/Classes/Root/RootViewController.m diff --git a/Example/DBCamera/Classes/Root/RootViewController.m b/Example/DBCamera/Classes/Root/RootViewController.m old mode 100644 new mode 100755 index a158cc6..720bc62 --- a/Example/DBCamera/Classes/Root/RootViewController.m +++ b/Example/DBCamera/Classes/Root/RootViewController.m @@ -13,6 +13,7 @@ #import "DBCameraLibraryViewController.h" #import "CustomCamera.h" #import "DBCameraGridView.h" +#import "DBCameraConfiguration.h" @interface DetailViewController : UIViewController { UIImageView *_imageView; @@ -136,8 +137,17 @@ - (void) openCamera [cameraContainer setTintColor:[UIColor redColor]]; [cameraContainer setSelectedTintColor:[UIColor yellowColor]]; */ + + + DBCameraConfiguration *configuration = [[DBCameraConfiguration alloc] init]; + configuration.configureProcessingController = ^(UIViewController * _Nonnull controller) { + + // You can hide cropButton on filter picking controller + // controller.cropButton.hidden = YES; + + }; - DBCameraContainerViewController *cameraContainer = [[DBCameraContainerViewController alloc] initWithDelegate:self]; + DBCameraContainerViewController *cameraContainer = [[DBCameraContainerViewController alloc] initWithDelegate:self cameraConfiguration:configuration]; [cameraContainer setFullScreenMode]; DemoNavigationController *nav = [[DemoNavigationController alloc] initWithRootViewController:cameraContainer]; From af7267a2c712ef24c4df46436e397574ba2a9b87 Mon Sep 17 00:00:00 2001 From: Nikita Tuk <654070@gmail.com> Date: Sun, 9 Oct 2016 18:41:12 +0500 Subject: [PATCH 4/4] Added filter bar visibility property --- DBCamera/Controllers/DBCameraSegueViewController.m | 12 ++++++++++++ .../Objects/DBPhotoProcessingControllerProtocol.h | 1 + Example/DBCamera/Classes/Root/RootViewController.m | 3 +++ 3 files changed, 16 insertions(+) diff --git a/DBCamera/Controllers/DBCameraSegueViewController.m b/DBCamera/Controllers/DBCameraSegueViewController.m index e68537b..ef440cd 100755 --- a/DBCamera/Controllers/DBCameraSegueViewController.m +++ b/DBCamera/Controllers/DBCameraSegueViewController.m @@ -396,4 +396,16 @@ - (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSIntege } } +#pragma mark - DBPhotoProcessingControllerProtocol + +- (void) setFiltersBarVisible:(BOOL)filtersBarVisible { + + if ( filtersBarVisible == NO ) { + + [self.filtersView removeFromSuperview]; + + } + +} + @end \ No newline at end of file diff --git a/DBCamera/Objects/DBPhotoProcessingControllerProtocol.h b/DBCamera/Objects/DBPhotoProcessingControllerProtocol.h index e2e0241..6cc1638 100644 --- a/DBCamera/Objects/DBPhotoProcessingControllerProtocol.h +++ b/DBCamera/Objects/DBPhotoProcessingControllerProtocol.h @@ -9,5 +9,6 @@ @protocol DBPhotoProcessingControllerProtocol @property (nonatomic, nonnull, strong, readonly) UIButton *cropButton; +@property (nonatomic, assign) BOOL filtersBarVisible; @end \ No newline at end of file diff --git a/Example/DBCamera/Classes/Root/RootViewController.m b/Example/DBCamera/Classes/Root/RootViewController.m index 720bc62..59e632b 100755 --- a/Example/DBCamera/Classes/Root/RootViewController.m +++ b/Example/DBCamera/Classes/Root/RootViewController.m @@ -145,6 +145,9 @@ - (void) openCamera // You can hide cropButton on filter picking controller // controller.cropButton.hidden = YES; + // You can disable filter bar + // controller.filtersBarVisible = NO; + }; DBCameraContainerViewController *cameraContainer = [[DBCameraContainerViewController alloc] initWithDelegate:self cameraConfiguration:configuration];