Skip to content

Defer adding done button during peeks #20

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

Merged
merged 1 commit into from
Apr 20, 2016
Merged
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
3 changes: 3 additions & 0 deletions BFRImageViewController/BFRImageViewController.h
Original file line number Diff line number Diff line change
@@ -13,6 +13,9 @@
/*! Initializes an instance of @C BFRImageViewController from the image source provided. The array can contain a mix of @c NSURL, @c UIImage, @c PHAsset, or @c NSStrings of URLS. This can be a mix of all these types, or just one. */
- (instancetype)initWithImageSource:(NSArray *)images;

/*! Initializes an instance of @C BFRImageViewController from the image source provided. The array can contain a mix of @c NSURL, @c UIImage, @c PHAsset, or @c NSStrings of URLS. This can be a mix of all these types, or just one. Additionally, this customizes the user interface to defer showing some of its user interface elements, such as the close button, until it's been fully popped.*/
- (instancetype)initForPeekWithImageSource:(NSArray *)images;

/*! Assigning YES to this property will make the background transparent. */
@property (nonatomic, getter=isUsingTransparentBackground) BOOL useTransparentBackground;

26 changes: 23 additions & 3 deletions BFRImageViewController/BFRImageViewController.m
Original file line number Diff line number Diff line change
@@ -26,6 +26,9 @@ @interface BFRImageViewController () <UIPageViewControllerDataSource>
/*! The button that sticks to the top left of the view that is responsible for dismissing this view controller. */
@property (strong, nonatomic) UIButton *doneButton;

/*! This will determine whether to change certain behaviors for 3D touch considerations based on its value. */
@property (nonatomic, getter=isBeingUsedFor3DTouch) BOOL usedFor3DTouch;

@end

@implementation BFRImageViewController
@@ -44,6 +47,20 @@ - (instancetype)initWithImageSource:(NSArray *)images {
return self;
}

- (instancetype)initForPeekWithImageSource:(NSArray *)images {
self = [super init];

if (self) {
NSAssert(images.count > 0, @"You must supply at least one image source to use this class.");
self.images = images;
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
self.enableDoneButton = YES;
self.usedFor3DTouch = YES;
}

return self;
}

#pragma mark - View Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
@@ -54,8 +71,10 @@ - (void)viewDidLoad {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
}

//Viewer done button setup
[self setupDoneButton];
//Add chrome to UI now if we aren't waiting to be peeked into
if (!self.isBeingUsedFor3DTouch) {
[self addChromeToUI];
}

//Setup image view controllers
self.imageViewControllers = [NSMutableArray new];
@@ -83,7 +102,7 @@ - (void)viewDidLoad {
[self registerNotifcations];
}

- (void)setupDoneButton {
- (void)addChromeToUI {
if (self.enableDoneButton) {
UIImage *crossImage = [UIImage imageNamed:@"cross"];
self.doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
@@ -142,6 +161,7 @@ - (void)dismiss {
- (void)handlePop {
self.view.backgroundColor = [UIColor blackColor];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
[self addChromeToUI];
}

- (void)handleDoneAction {