From 7a1c98bbc1dea3da0306fea6da5594f931a1d5a2 Mon Sep 17 00:00:00 2001 From: "Grant J. Butler" Date: Wed, 29 Apr 2015 16:53:21 -0400 Subject: [PATCH 1/7] Add array variants of bar button item properties. --- Pod/Classes/ios/NYTPhotosOverlayView.h | 10 ++++++++++ Pod/Classes/ios/NYTPhotosOverlayView.m | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.h b/Pod/Classes/ios/NYTPhotosOverlayView.h index e6a75fae..96281f07 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.h +++ b/Pod/Classes/ios/NYTPhotosOverlayView.h @@ -33,11 +33,21 @@ */ @property (nonatomic) UIBarButtonItem *leftBarButtonItem; +/** + * The bar button items appearing at the top left of the overlay. + */ +@property (nonatomic) NSArray *leftBarButtonItems; + /** * The bar button item appearing at the top right of the overlay. */ @property (nonatomic) UIBarButtonItem *rightBarButtonItem; +/** + * The bar button items appearing at the top right of the overlay. + */ +@property (nonatomic) NSArray *rightBarButtonItems; + /** * A view representing the caption for the photo, which will be set to full width and locked to the bottom. Can be any `UIView` object, but is expected to respond to `intrinsicContentSize` appropriately to calculate height. */ diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.m b/Pod/Classes/ios/NYTPhotosOverlayView.m index 33ad62f5..f841e401 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.m +++ b/Pod/Classes/ios/NYTPhotosOverlayView.m @@ -99,6 +99,14 @@ - (void)setLeftBarButtonItem:(UIBarButtonItem *)leftBarButtonItem { [self.navigationItem setLeftBarButtonItem:leftBarButtonItem animated:NO]; } +- (NSArray *)leftBarButtonItems { + return self.navigationItem.leftBarButtonItems; +} + +- (void)setLeftBarButtonItems:(NSArray *)leftBarButtonItems { + [self.navigationItem setLeftBarButtonItems:leftBarButtonItems animated:NO]; +} + - (UIBarButtonItem *)rightBarButtonItem { return self.navigationItem.rightBarButtonItem; } @@ -107,6 +115,14 @@ - (void)setRightBarButtonItem:(UIBarButtonItem *)rightBarButtonItem { [self.navigationItem setRightBarButtonItem:rightBarButtonItem]; } +- (NSArray *)rightBarButtonItems { + return self.rightBarButtonItems; +} + +- (void)setRightBarButtonItems:(NSArray *)rightBarButtonItems { + [self.navigationItem setRightBarButtonItems:rightBarButtonItems animated:NO]; +} + - (NSString *)title { return self.navigationItem.title; } From 8e5f21f3af8d977fe73ff61feee64fc40841a2a1 Mon Sep 17 00:00:00 2001 From: "Grant J. Butler" Date: Wed, 29 Apr 2015 16:53:35 -0400 Subject: [PATCH 2/7] Change method used for consistency. --- Pod/Classes/ios/NYTPhotosOverlayView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.m b/Pod/Classes/ios/NYTPhotosOverlayView.m index f841e401..20a27802 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.m +++ b/Pod/Classes/ios/NYTPhotosOverlayView.m @@ -112,7 +112,7 @@ - (UIBarButtonItem *)rightBarButtonItem { } - (void)setRightBarButtonItem:(UIBarButtonItem *)rightBarButtonItem { - [self.navigationItem setRightBarButtonItem:rightBarButtonItem]; + [self.navigationItem setRightBarButtonItem:rightBarButtonItem animated:NO]; } - (NSArray *)rightBarButtonItems { From 65483d7ce8a040cd142d1c111cc34cae74e281b1 Mon Sep 17 00:00:00 2001 From: "Grant J. Butler" Date: Wed, 29 Apr 2015 16:55:50 -0400 Subject: [PATCH 3/7] Add barButtonItems properties to NYTPhotosViewController. --- Pod/Classes/ios/NYTPhotosViewController.h | 10 ++++++++++ Pod/Classes/ios/NYTPhotosViewController.m | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Pod/Classes/ios/NYTPhotosViewController.h b/Pod/Classes/ios/NYTPhotosViewController.h index e519df31..83347dcf 100644 --- a/Pod/Classes/ios/NYTPhotosViewController.h +++ b/Pod/Classes/ios/NYTPhotosViewController.h @@ -50,11 +50,21 @@ extern NSString * const NYTPhotosViewControllerDidDismissNotification; */ @property (nonatomic) UIBarButtonItem *leftBarButtonItem; +/** + * The left bar button items overlaying the photo. + */ +@property (nonatomic) NSArray *leftBarButtonItems; + /** * The right bar button item overlaying the photo. */ @property (nonatomic) UIBarButtonItem *rightBarButtonItem; +/** + * The right bar button items overlaying the photo. + */ +@property (nonatomic) NSArray *rightBarButtonItems; + /** * The object that acts as the delegate of the `NYTPhotosViewController`. */ diff --git a/Pod/Classes/ios/NYTPhotosViewController.m b/Pod/Classes/ios/NYTPhotosViewController.m index 15b11d99..39510d22 100644 --- a/Pod/Classes/ios/NYTPhotosViewController.m +++ b/Pod/Classes/ios/NYTPhotosViewController.m @@ -252,6 +252,14 @@ - (void)setLeftBarButtonItem:(UIBarButtonItem *)leftBarButtonItem { self.overlayView.leftBarButtonItem = leftBarButtonItem; } +- (NSArray *)leftBarButtonItems { + return self.overlayView.leftBarButtonItems; +} + +- (void)setLeftBarButtonItems:(NSArray *)leftBarButtonItems { + self.overlayView.leftBarButtonItems = leftBarButtonItems; +} + - (UIBarButtonItem *)rightBarButtonItem { return self.overlayView.rightBarButtonItem; } @@ -260,6 +268,14 @@ - (void)setRightBarButtonItem:(UIBarButtonItem *)rightBarButtonItem { self.overlayView.rightBarButtonItem = rightBarButtonItem; } +- (NSArray *)rightBarButtonItems { + return self.overlayView.rightBarButtonItems; +} + +- (void)setRightBarButtonItems:(NSArray *)rightBarButtonItems { + self.overlayView.rightBarButtonItems = rightBarButtonItems; +} + - (void)displayPhoto:(id )photo animated:(BOOL)animated { if (![self.dataSource containsPhoto:photo]) { return; From 930bce544b64be7935fb0c68eae7603ad00a1fe7 Mon Sep 17 00:00:00 2001 From: "Grant J. Butler" Date: Wed, 29 Apr 2015 17:01:09 -0400 Subject: [PATCH 4/7] Add tests for new properties. --- Example/Tests/NYTPhotosViewControllerTests.m | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Example/Tests/NYTPhotosViewControllerTests.m b/Example/Tests/NYTPhotosViewControllerTests.m index 05a4d712..d67d1d8e 100644 --- a/Example/Tests/NYTPhotosViewControllerTests.m +++ b/Example/Tests/NYTPhotosViewControllerTests.m @@ -87,6 +87,17 @@ - (void)testLeftBarButtonItemIsNilAfterSettingToNil { XCTAssertNil(photosViewController.leftBarButtonItem); } +- (void)testLeftBarButtonItemsArePopulatedAfterInitialization { + NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos]]; + XCTAssertNotNil(photosViewController.leftBarButtonItems); +} + +- (void)testLeftBarButtonItemsAreNilAfterSettingToNil { + NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos]]; + photosViewController.leftBarButtonItems = nil; + XCTAssertNil(photosViewController.leftBarButtonItems); +} + - (void)testRightBarButtonItemIsPopulatedAfterInitialization { NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos]]; XCTAssertNotNil(photosViewController.rightBarButtonItem); @@ -98,6 +109,17 @@ - (void)testRightBarButtonItemIsNilAfterSettingToNil { XCTAssertNil(photosViewController.rightBarButtonItem); } +- (void)testRightBarButtonItemsArePopulatedAfterInitialization { + NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos]]; + XCTAssertNotNil(photosViewController.rightBarButtonItems); +} + +- (void)testRightBarButtonItemsAreNilAfterSettingToNil { + NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithPhotos:[self newTestPhotos]]; + photosViewController.rightBarButtonItems = nil; + XCTAssertNil(photosViewController.rightBarButtonItems); +} + - (void)testConvenienceInitializerAcceptsNil { XCTAssertNoThrow([[NYTPhotosViewController alloc] initWithPhotos:nil]); } From 62ab16159fab0018e654f7d4817be777698540b5 Mon Sep 17 00:00:00 2001 From: "Grant J. Butler" Date: Wed, 29 Apr 2015 17:01:23 -0400 Subject: [PATCH 5/7] Fix recursion bug. --- Pod/Classes/ios/NYTPhotosOverlayView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.m b/Pod/Classes/ios/NYTPhotosOverlayView.m index 20a27802..5f0c889d 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.m +++ b/Pod/Classes/ios/NYTPhotosOverlayView.m @@ -116,7 +116,7 @@ - (void)setRightBarButtonItem:(UIBarButtonItem *)rightBarButtonItem { } - (NSArray *)rightBarButtonItems { - return self.rightBarButtonItems; + return self.navigationItem.rightBarButtonItems; } - (void)setRightBarButtonItems:(NSArray *)rightBarButtonItems { From 6e2d66b58a6b54bb5532adc5413c8ffc9a83722a Mon Sep 17 00:00:00 2001 From: "Grant J. Butler" Date: Thu, 30 Apr 2015 14:57:56 -0400 Subject: [PATCH 6/7] Add copy. --- Pod/Classes/ios/NYTPhotosOverlayView.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/ios/NYTPhotosOverlayView.h b/Pod/Classes/ios/NYTPhotosOverlayView.h index 96281f07..968a1f2f 100644 --- a/Pod/Classes/ios/NYTPhotosOverlayView.h +++ b/Pod/Classes/ios/NYTPhotosOverlayView.h @@ -36,7 +36,7 @@ /** * The bar button items appearing at the top left of the overlay. */ -@property (nonatomic) NSArray *leftBarButtonItems; +@property (nonatomic, copy) NSArray *leftBarButtonItems; /** * The bar button item appearing at the top right of the overlay. @@ -46,7 +46,7 @@ /** * The bar button items appearing at the top right of the overlay. */ -@property (nonatomic) NSArray *rightBarButtonItems; +@property (nonatomic, copy) NSArray *rightBarButtonItems; /** * A view representing the caption for the photo, which will be set to full width and locked to the bottom. Can be any `UIView` object, but is expected to respond to `intrinsicContentSize` appropriately to calculate height. From f34e7bcf0660faae7bfef7c684393a3719d9f1bd Mon Sep 17 00:00:00 2001 From: "Grant J. Butler" Date: Thu, 30 Apr 2015 14:58:17 -0400 Subject: [PATCH 7/7] Add more copy. --- Pod/Classes/ios/NYTPhotosViewController.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/ios/NYTPhotosViewController.h b/Pod/Classes/ios/NYTPhotosViewController.h index 83347dcf..1b226004 100644 --- a/Pod/Classes/ios/NYTPhotosViewController.h +++ b/Pod/Classes/ios/NYTPhotosViewController.h @@ -53,7 +53,7 @@ extern NSString * const NYTPhotosViewControllerDidDismissNotification; /** * The left bar button items overlaying the photo. */ -@property (nonatomic) NSArray *leftBarButtonItems; +@property (nonatomic, copy) NSArray *leftBarButtonItems; /** * The right bar button item overlaying the photo. @@ -63,7 +63,7 @@ extern NSString * const NYTPhotosViewControllerDidDismissNotification; /** * The right bar button items overlaying the photo. */ -@property (nonatomic) NSArray *rightBarButtonItems; +@property (nonatomic, copy) NSArray *rightBarButtonItems; /** * The object that acts as the delegate of the `NYTPhotosViewController`.