Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding the filter bar #208

Merged
merged 4 commits into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions DBCamera/Controllers/DBCameraContainerViewController.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#import "DBCameraDelegate.h"
#import "UIViewController+UIViewController_FullScreen.h"

@class DBCameraView;
@class DBCameraViewController;
@class DBCameraView, DBCameraViewController, DBCameraConfiguration;

/**
* The camera settings block
Expand All @@ -35,14 +34,19 @@ 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
*
* @param delegate The DBCameraViewControllerDelegate
*
* @return A DBCameraContainerViewController
*/
- (id) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate;
- (instancetype) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate;

/**
* The init method with a DBCameraViewControllerDelegate and a CameraSettingsBlock
Expand All @@ -52,5 +56,30 @@ typedef void(^CameraSettingsBlock)(DBCameraView *cameraView, id container);
*
* @return DBCameraContainerViewController
*/
- (id) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate cameraSettingsBlock:(CameraSettingsBlock)block;
- (instancetype) initWithDelegate:(id<DBCameraViewControllerDelegate>)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<DBCameraViewControllerDelegate>)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<DBCameraViewControllerDelegate>)delegate
cameraConfiguration:(DBCameraConfiguration *)cameraConfiguration
cameraSettingsBlock:(CameraSettingsBlock)block;
@end
21 changes: 19 additions & 2 deletions DBCamera/Controllers/DBCameraContainerViewController.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,36 @@ @implementation DBCameraContainerViewController
@synthesize tintColor = _tintColor;
@synthesize selectedTintColor = _selectedTintColor;

- (id) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate
- (instancetype) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate
{
return [self initWithDelegate:delegate cameraSettingsBlock:nil];
}

- (id) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate cameraSettingsBlock:(CameraSettingsBlock)block
- (instancetype) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate cameraSettingsBlock:(CameraSettingsBlock)block
{
return [self initWithDelegate:delegate cameraConfiguration:nil cameraSettingsBlock:block];
}

- (instancetype) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate
cameraConfiguration:(DBCameraConfiguration *)cameraConfiguration
{
return [self initWithDelegate:delegate cameraConfiguration:cameraConfiguration cameraSettingsBlock:nil];
}

- (instancetype) initWithDelegate:(id<DBCameraViewControllerDelegate>)delegate
cameraConfiguration:(DBCameraConfiguration *)cameraConfiguration
cameraSettingsBlock:(CameraSettingsBlock)block
{

self = [super init];
if ( self ) {
_delegate = delegate;
_settingsBlock = block;
_cameraConfiguration = cameraConfiguration;
}

return self;

}

- (void) viewDidLoad
Expand Down Expand Up @@ -100,6 +116,7 @@ - (DBCameraViewController *) defaultCameraViewController
[_defaultCameraViewController setTintColor:self.tintColor];
if ( self.selectedTintColor )
[_defaultCameraViewController setSelectedTintColor:self.selectedTintColor];
_defaultCameraViewController.cameraConfiguration = self.cameraConfiguration;
}

if ( !self.cameraViewController )
Expand Down
7 changes: 6 additions & 1 deletion DBCamera/Controllers/DBCameraLibraryViewController.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
#import "DBCameraDelegate.h"

@class DBCameraSegueViewController;
@class DBCameraSegueViewController, DBCameraConfiguration;

/**
* DBCameraLibraryViewController
Expand All @@ -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
*
Expand Down
1 change: 1 addition & 0 deletions DBCamera/Controllers/DBCameraLibraryViewController.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
10 changes: 8 additions & 2 deletions DBCamera/Controllers/DBCameraSegueViewController.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DBCameraCropRect, DBCameraSegueSettings, DBCameraViewControllerSettings>
@interface DBCameraSegueViewController : DBCameraBaseCropViewController <DBPhotoProcessingControllerProtocol, DBCameraCropRect, DBCameraSegueSettings, DBCameraViewControllerSettings>
/**
* An id object compliant with the DBCameraContainerDelegate
*/
Expand All @@ -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
*
Expand Down
19 changes: 18 additions & 1 deletion DBCamera/Controllers/DBCameraSegueViewController.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "UIImage+TintColor.h"
#import "UIImage+Bundle.h"
#import "GrayscaleContrastFilter.h"
#import "DBCameraConfiguration.h"

#import <GPUImage/GPUImage.h>

Expand All @@ -41,7 +42,7 @@ @interface DBCameraSegueViewController () <UIActionSheetDelegate, UICollectionVi
}

@property (nonatomic, strong) UIView *navigationBar, *bottomBar;
@property (nonatomic, strong) UIButton *useButton, *retakeButton, *cropButton;
@property (nonatomic, strong, readwrite) UIButton *useButton, *retakeButton, *cropButton;
@property (nonatomic, strong) DBCameraLoadingView *loadingView;
@end

Expand Down Expand Up @@ -130,6 +131,10 @@ - (void)viewDidLoad

if( self.cameraSegueConfigureBlock )
self.cameraSegueConfigureBlock(self);

if ( self.cameraConfiguration.configureProcessingController ) {
self.cameraConfiguration.configureProcessingController(self);
}
}

- (void) viewWillAppear:(BOOL)animated
Expand Down Expand Up @@ -391,4 +396,16 @@ - (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSIntege
}
}

#pragma mark - DBPhotoProcessingControllerProtocol

- (void) setFiltersBarVisible:(BOOL)filtersBarVisible {

if ( filtersBarVisible == NO ) {

[self.filtersView removeFromSuperview];

}

}

@end
10 changes: 6 additions & 4 deletions DBCamera/Controllers/DBCameraViewController.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
#import "DBCameraDelegate.h"
#import "UIViewController+UIViewController_FullScreen.h"

@class DBCameraManager;
@class DBCameraView;
@class DBCameraGridView;
@class DBCameraSegueViewController;
@class DBCameraManager, DBCameraView, DBCameraGridView, DBCameraSegueViewController, DBCameraConfiguration;

/**
* DBCameraViewController
Expand Down Expand Up @@ -59,6 +56,11 @@
*/
@property (nonatomic, assign) NSUInteger libraryMaxImageSize;

/**
* Contains additional configuration for camera controllers
*/
@property (nonatomic, strong) DBCameraConfiguration *cameraConfiguration;

/**
* The init class method with a DBCameraViewControllerDelegate
*
Expand Down
2 changes: 2 additions & 0 deletions DBCamera/Controllers/DBCameraViewController.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ - (void) captureImageDidFinish:(UIImage *)image withMetadata:(NSDictionary *)met
[segue enableGestures:YES];
[segue setDelegate:self.delegate];
[segue setCapturedImageMetadata:finalMetadata];
[segue setCameraConfiguration:self.cameraConfiguration];
[segue setCameraSegueConfigureBlock:self.cameraSegueConfigureBlock];

[self.navigationController pushViewController:segue animated:YES];
Expand Down Expand Up @@ -365,6 +366,7 @@ - (void) openLibrary
[library setUseCameraSegue:self.useCameraSegue];
[library setCameraSegueConfigureBlock:self.cameraSegueConfigureBlock];
[library setLibraryMaxImageSize:self.libraryMaxImageSize];
[library setCameraConfiguration:self.cameraConfiguration];
[self.containerDelegate switchFromController:self toController:library];
}];
} else {
Expand Down
16 changes: 16 additions & 0 deletions DBCamera/Objects/DBCameraConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// DBCameraConfiguration.h
// DBCamera
//
// Created by Nikita Tuk on 09/10/16.
// Copyright © 2016 PSSD - Daniele Bogo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DBPhotoProcessingControllerProtocol.h"

@interface DBCameraConfiguration : NSObject

@property (nonatomic, nullable, copy) void (^configureProcessingController)(UIViewController <DBPhotoProcessingControllerProtocol> * _Nonnull controller);

@end
15 changes: 15 additions & 0 deletions DBCamera/Objects/DBCameraConfiguration.m
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions DBCamera/Objects/DBPhotoProcessingControllerProtocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// DBPhotoProcessingControllerProtocol.h
// DBCamera
//
// Created by Nikita Tuk on 09/10/16.
// Copyright © 2016 PSSD - Daniele Bogo. All rights reserved.
//

@protocol DBPhotoProcessingControllerProtocol <NSObject>

@property (nonatomic, nonnull, strong, readonly) UIButton *cropButton;
@property (nonatomic, assign) BOOL filtersBarVisible;

@end
14 changes: 13 additions & 1 deletion Example/DBCamera.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -144,6 +145,9 @@
9ABB69A119587983007E2B9E /* UIImage+Asset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Asset.m"; sourceTree = "<group>"; };
9ABDB6E6195391A500A1539D /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/InfoPlist.strings; sourceTree = "<group>"; };
A7CB737E1B68107B0017336F /* DBCamera.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = DBCamera.bundle; path = ../../DBCamera/Localizations/DBCamera.bundle; sourceTree = "<group>"; };
ABB9D8ED1DAA718D00B64899 /* DBCameraConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBCameraConfiguration.h; sourceTree = "<group>"; };
ABB9D8EE1DAA718D00B64899 /* DBCameraConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBCameraConfiguration.m; sourceTree = "<group>"; };
ABB9D8F01DAA720500B64899 /* DBPhotoProcessingControllerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DBPhotoProcessingControllerProtocol.h; sourceTree = "<group>"; };
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 = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -429,7 +436,7 @@
ORGANIZATIONNAME = "PSSD - Daniele Bogo";
TargetAttributes = {
9AB5979F189BAF9A001BCAD3 = {
DevelopmentTeam = Q3SKDBM9PM;
DevelopmentTeam = 5H24V53G7B;
};
};
};
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand Down
15 changes: 14 additions & 1 deletion Example/DBCamera/Classes/Root/RootViewController.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "DBCameraLibraryViewController.h"
#import "CustomCamera.h"
#import "DBCameraGridView.h"
#import "DBCameraConfiguration.h"

@interface DetailViewController : UIViewController {
UIImageView *_imageView;
Expand Down Expand Up @@ -136,8 +137,20 @@ - (void) openCamera
[cameraContainer setTintColor:[UIColor redColor]];
[cameraContainer setSelectedTintColor:[UIColor yellowColor]];
*/


DBCameraConfiguration *configuration = [[DBCameraConfiguration alloc] init];
configuration.configureProcessingController = ^(UIViewController <DBPhotoProcessingControllerProtocol> * _Nonnull controller) {

// 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];
DBCameraContainerViewController *cameraContainer = [[DBCameraContainerViewController alloc] initWithDelegate:self cameraConfiguration:configuration];
[cameraContainer setFullScreenMode];

DemoNavigationController *nav = [[DemoNavigationController alloc] initWithRootViewController:cameraContainer];
Expand Down