From d8cac26ee7779236e14aa60cf1dfd2f704099955 Mon Sep 17 00:00:00 2001 From: Jackie Date: Fri, 6 Jan 2017 17:26:50 +0800 Subject: [PATCH 01/34] Using AutoLayout for progressView since [UIScreen mainScreen].bounds is orientation-dependent in iOS8 --- Classes/IDMZoomingScrollView.m | 40 ++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index f7a4ea21..34e95938 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -48,18 +48,8 @@ - (id)initWithPhotoBrowser:(IDMPhotoBrowser *)browser { _photoImageView.backgroundColor = [UIColor clearColor]; [self addSubview:_photoImageView]; - CGRect screenBound = [[UIScreen mainScreen] bounds]; - CGFloat screenWidth = screenBound.size.width; - CGFloat screenHeight = screenBound.size.height; - - if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || - [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) { - screenWidth = screenBound.size.height; - screenHeight = screenBound.size.width; - } - // Progress view - _progressView = [[DACircularProgressView alloc] initWithFrame:CGRectMake((screenWidth-35.)/2., (screenHeight-35.)/2, 35.0f, 35.0f)]; + _progressView = [[DACircularProgressView alloc] initWithFrame:CGRectZero]; [_progressView setProgress:0.0f]; _progressView.tag = 101; _progressView.thicknessRatio = 0.1; @@ -67,6 +57,34 @@ - (id)initWithPhotoBrowser:(IDMPhotoBrowser *)browser { _progressView.trackTintColor = browser.trackTintColor ? self.photoBrowser.trackTintColor : [UIColor colorWithWhite:0.2 alpha:1]; _progressView.progressTintColor = browser.progressTintColor ? self.photoBrowser.progressTintColor : [UIColor colorWithWhite:1.0 alpha:1]; [self addSubview:_progressView]; + [_progressView addConstraint:[NSLayoutConstraint constraintWithItem:_progressView + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1.0 + constant:35]]; + [_progressView addConstraint:[NSLayoutConstraint constraintWithItem:_progressView + attribute:NSLayoutAttributeHeight + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1.0 + constant:35]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:_progressView + attribute:NSLayoutAttributeCenterX + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeCenterX + multiplier:1.0 + constant:0.0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:_progressView + attribute:NSLayoutAttributeCenterY + relatedBy:NSLayoutRelationEqual + toItem:self + attribute:NSLayoutAttributeCenterY + multiplier:1.0 + constant:0.0]]; // Setup self.backgroundColor = [UIColor clearColor]; From f9e1eaa7f03696c977e68c8f6aca78913fad3ffb Mon Sep 17 00:00:00 2001 From: Jackie Date: Fri, 6 Jan 2017 17:35:41 +0800 Subject: [PATCH 02/34] Set progressView translatesAutoresizingMaskIntoConstraints to NO; --- Classes/IDMZoomingScrollView.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index 34e95938..8e11ef46 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -50,6 +50,7 @@ - (id)initWithPhotoBrowser:(IDMPhotoBrowser *)browser { // Progress view _progressView = [[DACircularProgressView alloc] initWithFrame:CGRectZero]; + _progressView.translatesAutoresizingMaskIntoConstraints = NO; [_progressView setProgress:0.0f]; _progressView.tag = 101; _progressView.thicknessRatio = 0.1; From 47d4cd1684400390a440c336b789b3bb9534d8c5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 8 Jan 2017 12:23:17 +1100 Subject: [PATCH 03/34] added: custom image failure --- Classes/IDMPhoto.m | 2 +- Classes/IDMPhotoBrowser.h | 2 ++ Classes/IDMPhotoBrowser.m | 3 ++- Classes/IDMZoomingScrollView.m | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Classes/IDMPhoto.m b/Classes/IDMPhoto.m index 3f033065..e18ddee8 100644 --- a/Classes/IDMPhoto.m +++ b/Classes/IDMPhoto.m @@ -145,8 +145,8 @@ - (void)loadUnderlyingImageAndNotify { } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { if (image) { self.underlyingImage = image; - [self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO]; } + [self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO]; }]; } else { diff --git a/Classes/IDMPhotoBrowser.h b/Classes/IDMPhotoBrowser.h index cd2e5f42..e5632581 100644 --- a/Classes/IDMPhotoBrowser.h +++ b/Classes/IDMPhotoBrowser.h @@ -88,4 +88,6 @@ // Get IDMPhoto at index - (id)photoAtIndex:(NSUInteger)index; +// Override this to specify custom image failure response +-(void)displayImageFailure:(UIImageView*)imageView; @end diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index dcc289d4..6c647155 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -925,6 +925,8 @@ - (void)loadAdjacentPhotosIfNecessary:(id)photo { } } +-(void)displayImageFailure:(UIImageView*)imageView {} + #pragma mark - IDMPhoto Loading Notification - (void)handleIDMPhotoLoadingDidEndNotification:(NSNotification *)notification { @@ -1379,5 +1381,4 @@ - (void)animateView:(UIView *)view toFrame:(CGRect)frame completion:(void (^)(vo }]; } } - @end diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index f7a4ea21..3ea4a052 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -151,6 +151,8 @@ - (void)setProgress:(CGFloat)progress forPhoto:(IDMPhoto*)photo { // Image failed so just show black! - (void)displayImageFailure { [_progressView removeFromSuperview]; + [_photoBrowser displayImageFailure:_photoImageView]; + [self setNeedsLayout]; } #pragma mark - Setup From d4f4018d2f0d05aabc9ed2579336b0310e378eab Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 8 Jan 2017 19:00:37 +1100 Subject: [PATCH 04/34] fixed: custom image failure can now be overriden in IDMPhotoBrowserDelegate --- Classes/IDMPhotoBrowser.h | 3 +-- Classes/IDMPhotoBrowser.m | 8 ++++++-- Classes/IDMZoomingScrollView.m | 2 -- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Classes/IDMPhotoBrowser.h b/Classes/IDMPhotoBrowser.h index e5632581..41168b5b 100644 --- a/Classes/IDMPhotoBrowser.h +++ b/Classes/IDMPhotoBrowser.h @@ -24,6 +24,7 @@ - (void)photoBrowser:(IDMPhotoBrowser *)photoBrowser willDismissAtPageIndex:(NSUInteger)index; - (void)photoBrowser:(IDMPhotoBrowser *)photoBrowser didDismissActionSheetWithButtonIndex:(NSUInteger)buttonIndex photoIndex:(NSUInteger)photoIndex; - (IDMCaptionView *)photoBrowser:(IDMPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index; +- (void)photoBrowser:(IDMPhotoBrowser *)photoBrowser imageFailed:(NSUInteger)index; @end // IDMPhotoBrowser @@ -88,6 +89,4 @@ // Get IDMPhoto at index - (id)photoAtIndex:(NSUInteger)index; -// Override this to specify custom image failure response --(void)displayImageFailure:(UIImageView*)imageView; @end diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index 6c647155..14eb1738 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -925,8 +925,6 @@ - (void)loadAdjacentPhotosIfNecessary:(id)photo { } } --(void)displayImageFailure:(UIImageView*)imageView {} - #pragma mark - IDMPhoto Loading Notification - (void)handleIDMPhotoLoadingDidEndNotification:(NSNotification *)notification { @@ -940,6 +938,12 @@ - (void)handleIDMPhotoLoadingDidEndNotification:(NSNotification *)notification { } else { // Failed to load [page displayImageFailure]; + if ([_delegate respondsToSelector:@selector(photoBrowser:imageFailed:)]) { + NSUInteger pageIndex = PAGE_INDEX(page); + [_delegate photoBrowser:self imageFailed:pageIndex]; + } + // make sure the page is completely updated + [page setNeedsLayout]; } } } diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index 3ea4a052..f7a4ea21 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -151,8 +151,6 @@ - (void)setProgress:(CGFloat)progress forPhoto:(IDMPhoto*)photo { // Image failed so just show black! - (void)displayImageFailure { [_progressView removeFromSuperview]; - [_photoBrowser displayImageFailure:_photoImageView]; - [self setNeedsLayout]; } #pragma mark - Setup From 30a5cb890c95014082e027046edfa7e5e7a05b16 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 8 Jan 2017 21:19:23 +1100 Subject: [PATCH 05/34] added: imageview for better failure customisation --- Classes/IDMPhotoBrowser.h | 3 ++- Classes/IDMPhotoBrowser.m | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Classes/IDMPhotoBrowser.h b/Classes/IDMPhotoBrowser.h index 41168b5b..832c66ff 100644 --- a/Classes/IDMPhotoBrowser.h +++ b/Classes/IDMPhotoBrowser.h @@ -12,6 +12,7 @@ #import "IDMPhoto.h" #import "IDMPhotoProtocol.h" #import "IDMCaptionView.h" +#import "IDMTapDetectingImageView.h" // Delgate @class IDMPhotoBrowser; @@ -24,7 +25,7 @@ - (void)photoBrowser:(IDMPhotoBrowser *)photoBrowser willDismissAtPageIndex:(NSUInteger)index; - (void)photoBrowser:(IDMPhotoBrowser *)photoBrowser didDismissActionSheetWithButtonIndex:(NSUInteger)buttonIndex photoIndex:(NSUInteger)photoIndex; - (IDMCaptionView *)photoBrowser:(IDMPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index; -- (void)photoBrowser:(IDMPhotoBrowser *)photoBrowser imageFailed:(NSUInteger)index; +- (void)photoBrowser:(IDMPhotoBrowser *)photoBrowser imageFailed:(NSUInteger)index imageView:(IDMTapDetectingImageView *)imageView; @end // IDMPhotoBrowser diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index 14eb1738..5d2c8ccd 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -938,9 +938,9 @@ - (void)handleIDMPhotoLoadingDidEndNotification:(NSNotification *)notification { } else { // Failed to load [page displayImageFailure]; - if ([_delegate respondsToSelector:@selector(photoBrowser:imageFailed:)]) { + if ([_delegate respondsToSelector:@selector(photoBrowser:imageFailed:imageView:)]) { NSUInteger pageIndex = PAGE_INDEX(page); - [_delegate photoBrowser:self imageFailed:pageIndex]; + [_delegate photoBrowser:self imageFailed:pageIndex imageView:page.photoImageView]; } // make sure the page is completely updated [page setNeedsLayout]; From 08fbdc70bd8f9a3088527cbb34f9743cafbac1a4 Mon Sep 17 00:00:00 2001 From: kjen93 Date: Tue, 10 Jan 2017 15:58:15 +0300 Subject: [PATCH 06/34] Use actual interface orientation instead of the device one to fix misplaced progress view when orientations do not match Progress view is misplaced when the device is in landscape orientation, but application does not support it. --- Classes/IDMZoomingScrollView.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index f7a4ea21..7fa5877d 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -52,8 +52,7 @@ - (id)initWithPhotoBrowser:(IDMPhotoBrowser *)browser { CGFloat screenWidth = screenBound.size.width; CGFloat screenHeight = screenBound.size.height; - if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || - [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) { + if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) { screenWidth = screenBound.size.height; screenHeight = screenBound.size.width; } From a903573a3ad263debd71992b99c20b7d7faa0d07 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 19 Jan 2017 21:13:31 +1100 Subject: [PATCH 07/34] fixed: caption position is now correctly positioned at the bottom despite size --- Classes/IDMCaptionView.m | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Classes/IDMCaptionView.m b/Classes/IDMCaptionView.m index 7bd3a49a..c28ea8b8 100644 --- a/Classes/IDMCaptionView.m +++ b/Classes/IDMCaptionView.m @@ -52,21 +52,11 @@ - (CGSize)sizeThatFits:(CGSize)size { /*CGSize textSizeOLD = [_label.text sizeWithFont:_label.font constrainedToSize:CGSizeMake(size.width - labelPadding*2, maxHeight) lineBreakMode:_label.lineBreakMode];*/ - - NSString *text = _label.text; + CGFloat width = size.width - labelPadding*2; - UIFont *font = _label.font; - - NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:text - attributes:@{NSFontAttributeName: font}]; - - CGRect rect = [attributedText boundingRectWithSize:(CGSize){width, maxHeight} - options:NSStringDrawingUsesLineFragmentOrigin - context:nil]; - - CGSize textSize = rect.size; - return CGSizeMake(size.width, textSize.height + labelPadding * 2); + CGFloat height = [_label sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)].height; + return CGSizeMake(size.width, height + labelPadding * 2); } - (void)setupCaption { From 68615687d6f40f50fecfb070abd2d0c759e9025f Mon Sep 17 00:00:00 2001 From: Eduardo Callado Date: Tue, 31 Jan 2017 16:01:03 -0200 Subject: [PATCH 08/34] Update SDWebImage method name --- Classes/IDMPhoto.m | 4 ++-- IDMPhotoBrowser.podspec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/IDMPhoto.m b/Classes/IDMPhoto.m index 3f033065..ccfae6cb 100644 --- a/Classes/IDMPhoto.m +++ b/Classes/IDMPhoto.m @@ -137,12 +137,12 @@ - (void)loadUnderlyingImageAndNotify { } else if (_photoURL) { // Load async from web (using SDWebImageManager) SDWebImageManager *manager = [SDWebImageManager sharedManager]; - [manager downloadImageWithURL:_photoURL options:SDWebImageRetryFailed|SDWebImageHandleCookies progress:^(NSInteger receivedSize, NSInteger expectedSize) { + [manager loadImageWithURL:_photoURL options:SDWebImageRetryFailed|SDWebImageHandleCookies progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) { CGFloat progress = ((CGFloat)receivedSize)/((CGFloat)expectedSize); if (self.progressUpdateBlock) { self.progressUpdateBlock(progress); } - } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { if (image) { self.underlyingImage = image; [self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO]; diff --git a/IDMPhotoBrowser.podspec b/IDMPhotoBrowser.podspec index 1770ffef..a735b33e 100644 --- a/IDMPhotoBrowser.podspec +++ b/IDMPhotoBrowser.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "IDMPhotoBrowser" s.summary = "Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more." - s.version = "1.10.1" + s.version = "1.10.2" s.homepage = "https://github.com/ideaismobile/IDMPhotoBrowser" s.license = { :type => 'MIT', :file => 'LICENSE.txt' } s.author = { "Eduardo Callado" => "eduardo_tasker@hotmail.com" } - s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.10.1" } + s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.10.2" } s.platform = :ios, '8.0' s.source_files = 'Classes/*.{h,m}' s.resources = 'Classes/IDMPhotoBrowser.bundle', 'Classes/IDMPBLocalizations.bundle' From b5cf4f62cd48ddd34a058f0065fb836602e1f30d Mon Sep 17 00:00:00 2001 From: Eduardo Callado Date: Fri, 3 Feb 2017 12:39:15 -0200 Subject: [PATCH 09/34] Fix SDWebImage dependency --- IDMPhotoBrowser.podspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IDMPhotoBrowser.podspec b/IDMPhotoBrowser.podspec index a735b33e..386d8947 100644 --- a/IDMPhotoBrowser.podspec +++ b/IDMPhotoBrowser.podspec @@ -1,17 +1,17 @@ Pod::Spec.new do |s| s.name = "IDMPhotoBrowser" s.summary = "Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more." - s.version = "1.10.2" + s.version = "1.11" s.homepage = "https://github.com/ideaismobile/IDMPhotoBrowser" s.license = { :type => 'MIT', :file => 'LICENSE.txt' } s.author = { "Eduardo Callado" => "eduardo_tasker@hotmail.com" } - s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.10.2" } + s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.11" } s.platform = :ios, '8.0' s.source_files = 'Classes/*.{h,m}' s.resources = 'Classes/IDMPhotoBrowser.bundle', 'Classes/IDMPBLocalizations.bundle' s.framework = 'MessageUI', 'QuartzCore', 'SystemConfiguration', 'MobileCoreServices', 'Security' s.requires_arc = true - s.dependency 'SDWebImage' + s.dependency 'SDWebImage', '4.0.0' s.dependency 'DACircularProgress' s.dependency 'pop' end \ No newline at end of file From aedb45081a5a2d0df0b437f6d3a37bd2591f24b4 Mon Sep 17 00:00:00 2001 From: yukitoto Date: Fri, 10 Feb 2017 18:59:48 +0900 Subject: [PATCH 10/34] enable customize action button image --- Classes/IDMPhotoBrowser.h | 1 + Classes/IDMPhotoBrowser.m | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Classes/IDMPhotoBrowser.h b/Classes/IDMPhotoBrowser.h index c062aee3..2429d89a 100644 --- a/Classes/IDMPhotoBrowser.h +++ b/Classes/IDMPhotoBrowser.h @@ -40,6 +40,7 @@ @property (nonatomic, strong) NSArray *actionButtonTitles; @property (nonatomic, weak) UIImage *leftArrowImage, *leftArrowSelectedImage; @property (nonatomic, weak) UIImage *rightArrowImage, *rightArrowSelectedImage; +@property (nonatomic, weak) UIImage *actionButtonImage, *actionButtonSelectedImage; // View customization @property (nonatomic) BOOL displayDoneButton; diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index b326f491..b28c407f 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -131,7 +131,7 @@ @implementation IDMPhotoBrowser // Properties @synthesize displayDoneButton = _displayDoneButton, displayToolbar = _displayToolbar, displayActionButton = _displayActionButton, displayCounterLabel = _displayCounterLabel, useWhiteBackgroundColor = _useWhiteBackgroundColor, doneButtonImage = _doneButtonImage; -@synthesize leftArrowImage = _leftArrowImage, rightArrowImage = _rightArrowImage, leftArrowSelectedImage = _leftArrowSelectedImage, rightArrowSelectedImage = _rightArrowSelectedImage; +@synthesize leftArrowImage = _leftArrowImage, rightArrowImage = _rightArrowImage, leftArrowSelectedImage = _leftArrowSelectedImage, rightArrowSelectedImage = _rightArrowSelectedImage, actionButtonImage = _actionButtonImage, actionButtonSelectedImage = _actionButtonSelectedImage; @synthesize displayArrowButton = _displayArrowButton, actionButtonTitles = _actionButtonTitles; @synthesize arrowButtonsChangePhotosAnimated = _arrowButtonsChangePhotosAnimated; @synthesize forceHideStatusBar = _forceHideStatusBar; @@ -662,9 +662,16 @@ - (void)viewDidLoad { _counterButton = [[UIBarButtonItem alloc] initWithCustomView:_counterLabel]; // Action Button - _actionButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction + if(_actionButtonImage != nil && _actionButtonSelectedImage != nil) { + _actionButton = [[UIBarButtonItem alloc] initWithCustomView:[self customToolbarButtonImage:_actionButtonImage + imageSelected:_actionButtonSelectedImage + action:@selector(actionButtonPressed:)]]; + } + else { + _actionButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(actionButtonPressed:)]; + } // Gesture _panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognized:)]; From 83ba41f2a1ab8a10da98da916887d0825796fcc6 Mon Sep 17 00:00:00 2001 From: Eduardo Callado Date: Sun, 12 Feb 2017 15:57:22 -0200 Subject: [PATCH 11/34] Bump version --- IDMPhotoBrowser.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IDMPhotoBrowser.podspec b/IDMPhotoBrowser.podspec index 386d8947..19234c3f 100644 --- a/IDMPhotoBrowser.podspec +++ b/IDMPhotoBrowser.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "IDMPhotoBrowser" s.summary = "Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more." - s.version = "1.11" + s.version = "1.11.1" s.homepage = "https://github.com/ideaismobile/IDMPhotoBrowser" s.license = { :type => 'MIT', :file => 'LICENSE.txt' } s.author = { "Eduardo Callado" => "eduardo_tasker@hotmail.com" } - s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.11" } + s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.11.1" } s.platform = :ios, '8.0' s.source_files = 'Classes/*.{h,m}' s.resources = 'Classes/IDMPhotoBrowser.bundle', 'Classes/IDMPBLocalizations.bundle' From 96a8de1be33290f5c3242e023e198f49308f5540 Mon Sep 17 00:00:00 2001 From: CocoaBob Date: Mon, 27 Feb 2017 15:08:27 -0500 Subject: [PATCH 12/34] Fixed a bug that maxDoubleTapZoomScale is larger than maxScale, so that double tap zoom out never works in some cases. --- Classes/IDMZoomingScrollView.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index 7fa5877d..419ce4fd 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -198,13 +198,16 @@ - (void)setMaxMinZoomScalesForCurrentBounds { // on high resolution screens we have double the pixel density, so we will be seeing every pixel if we limit the // maximum zoom scale to 0.5. if ([UIScreen instancesRespondToSelector:@selector(scale)]) { - maxDoubleTapZoomScale = maxDoubleTapZoomScale / [[UIScreen mainScreen] scale]; - - if (maxDoubleTapZoomScale < minScale) { - maxDoubleTapZoomScale = minScale * 2; + maxDoubleTapZoomScale = maxDoubleTapZoomScale / [[UIScreen mainScreen] scale]; + + if (maxDoubleTapZoomScale < minScale) { + maxDoubleTapZoomScale = minScale * 2; } } + // Make sure maxDoubleTapZoomScale isn't larger than maxScale + maxDoubleTapZoomScale = MIN(maxDoubleTapZoomScale, maxScale); + // Set self.maximumZoomScale = maxScale; self.minimumZoomScale = minScale; From edfa0718db9edf3c169246ed0a9ff3fc21ebc793 Mon Sep 17 00:00:00 2001 From: Leo Lobato Date: Mon, 11 Nov 2013 14:28:21 -0200 Subject: [PATCH 13/34] Add support for overriding IDMCaptionView Expose label so it can be used by subclasses setupCaption. --- Classes/IDMCaptionView.h | 3 +++ Classes/IDMCaptionView.m | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Classes/IDMCaptionView.h b/Classes/IDMCaptionView.h index a4bf2991..e63e1a76 100644 --- a/Classes/IDMCaptionView.h +++ b/Classes/IDMCaptionView.h @@ -11,6 +11,9 @@ @interface IDMCaptionView : UIView +@property (nonatomic, strong) UILabel *label; +@property (nonatomic, strong, readonly) id photo; + // Init - (id)initWithPhoto:(id)photo; diff --git a/Classes/IDMCaptionView.m b/Classes/IDMCaptionView.m index 7bd3a49a..b6d823c7 100644 --- a/Classes/IDMCaptionView.m +++ b/Classes/IDMCaptionView.m @@ -13,14 +13,17 @@ static const CGFloat labelPadding = 10; // Private -@interface IDMCaptionView () { - id _photo; - UILabel *_label; -} +@interface IDMCaptionView () + +@property (nonatomic, strong, readwrite) id photo; + @end @implementation IDMCaptionView +@synthesize label = _label; +@synthesize photo = _photo; + - (id)initWithPhoto:(id)photo { CGRect screenBound = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenBound.size.width; From 4b3ccf959df33e29c61f7c2a171585e79771e82a Mon Sep 17 00:00:00 2001 From: Konstantin Snegov Date: Wed, 3 May 2017 15:09:23 +0300 Subject: [PATCH 14/34] Issue 147 - Done button margin and size --- Classes/IDMPhotoBrowser.h | 2 ++ Classes/IDMPhotoBrowser.m | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Classes/IDMPhotoBrowser.h b/Classes/IDMPhotoBrowser.h index 7b5dafab..397a0d4b 100644 --- a/Classes/IDMPhotoBrowser.h +++ b/Classes/IDMPhotoBrowser.h @@ -49,6 +49,8 @@ @property (nonatomic) BOOL useWhiteBackgroundColor; @property (nonatomic, weak) UIImage *doneButtonImage; @property (nonatomic, weak) UIColor *trackTintColor, *progressTintColor; +@property (nonatomic, assign) CGFloat doneButtonRightInset, doneButtonTopInset; +@property (nonatomic, assign) CGSize doneButtonSize; @property (nonatomic, weak) UIImage *scaleImage; diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index 070c6a1d..7a4e4a32 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -189,6 +189,10 @@ - (id)init { _scaleImage = nil; _isdraggingPhoto = NO; + + _doneButtonRightInset = 20.f; + _doneButtonTopInset = 30.f; + _doneButtonSize = CGSizeMake(55.f, 26.f); if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) { self.automaticallyAdjustsScrollViewInsets = NO; @@ -611,6 +615,7 @@ - (void)viewDidLoad { _doneButton.layer.cornerRadius = 3.0f; _doneButton.layer.borderColor = [UIColor colorWithWhite:0.9 alpha:0.9].CGColor; _doneButton.layer.borderWidth = 1.0f; + _doneButtonSize = _doneButtonImage.size; } else { [_doneButton setImage:_doneButtonImage forState:UIControlStateNormal]; @@ -1120,7 +1125,7 @@ - (CGRect)frameForDoneButtonAtOrientation:(UIInterfaceOrientation)orientation { // if ([self isLandscape:orientation]) screenWidth = screenBound.size.height; - return CGRectMake(screenWidth - 75, 30, 55, 26); + return CGRectMake(screenWidth - self.doneButtonRightInset - self.doneButtonSize.width, self.doneButtonTopInset, self.doneButtonSize.width, self.doneButtonSize.height); } - (CGRect)frameForCaptionView:(IDMCaptionView *)captionView atIndex:(NSUInteger)index { From 46146404721ddfd15b6b30a167aacd147238c2eb Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Mon, 22 May 2017 02:12:47 +0300 Subject: [PATCH 15/34] fix using SDWebImageManager fix code style, fix using old method for downloadImageWithURL: --- Classes/IDMPhoto.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/IDMPhoto.m b/Classes/IDMPhoto.m index adbb5a08..03e838b0 100644 --- a/Classes/IDMPhoto.m +++ b/Classes/IDMPhoto.m @@ -136,19 +136,19 @@ - (void)loadUnderlyingImageAndNotify { [self performSelectorInBackground:@selector(loadImageFromFileAsync) withObject:nil]; } else if (_photoURL) { // Load async from web (using SDWebImageManager) - SDWebImageManager *manager = [SDWebImageManager sharedManager]; - [manager loadImageWithURL:_photoURL options:SDWebImageRetryFailed|SDWebImageHandleCookies progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) { + [[SDWebImageManager sharedManager] downloadImageWithURL:_photoURL options:SDWebImageRetryFailed|SDWebImageHandleCookies progress:^(NSInteger receivedSize, NSInteger expectedSize) { CGFloat progress = ((CGFloat)receivedSize)/((CGFloat)expectedSize); + if (self.progressUpdateBlock) { self.progressUpdateBlock(progress); } - } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { if (image) { self.underlyingImage = image; } + [self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO]; }]; - } else { // Failed - no source self.underlyingImage = nil; From 10e25deb61b6d85ed13aa1edbed05c5bdc0962cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Qu=C3=A9r=C3=A9?= Date: Tue, 23 May 2017 10:56:28 +0200 Subject: [PATCH 16/34] Typo fix in Readme --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index 1159dabb..5549275a 100644 --- a/README.markdown +++ b/README.markdown @@ -20,6 +20,7 @@ We've added both user experience and technical features inspired by Facebook's a ## Screenshots [![Alt][screenshot1_thumb]][screenshot1] [![Alt][screenshot2_thumb]][screenshot2] [![Alt][screenshot3_thumb]][screenshot3] [![Alt][screenshot4_thumb]][screenshot4] [![Alt][screenshot5_thumb]][screenshot5] + [screenshot1_thumb]: https://raw.github.com/appkraft/IDMPhotoBrowser/master/Screenshots/idmphotobrowser_thumb1.png [screenshot1]: https://raw.github.com/appkraft/IDMPhotoBrowser/master/Screenshots/idmphotobrowser_ss1.png [screenshot2_thumb]: https://raw.github.com/appkraft/IDMPhotoBrowser/master/Screenshots/idmphotobrowser_thumb2.png From e9fa1cfc21c5dc6d0d2dd55bce422c9e94419882 Mon Sep 17 00:00:00 2001 From: Eduardo Callado Date: Wed, 24 May 2017 21:02:24 -0300 Subject: [PATCH 17/34] Update Podfile.lock --- Demo/Podfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Demo/Podfile.lock b/Demo/Podfile.lock index 27e4fccb..08ad9620 100644 --- a/Demo/Podfile.lock +++ b/Demo/Podfile.lock @@ -1,9 +1,9 @@ PODS: - DACircularProgress (2.3.1) - pop (1.0.9) - - SDWebImage (3.8.2): - - SDWebImage/Core (= 3.8.2) - - SDWebImage/Core (3.8.2) + - SDWebImage (4.0.0): + - SDWebImage/Core (= 4.0.0) + - SDWebImage/Core (4.0.0) DEPENDENCIES: - DACircularProgress @@ -13,8 +13,8 @@ DEPENDENCIES: SPEC CHECKSUMS: DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71 pop: f667631a5108a2e60d9e8797c9b32ddaf2080bce - SDWebImage: '098e97e6176540799c27e804c96653ee0833d13c' + SDWebImage: 76a6348bdc74eb5a55dd08a091ef298e56b55e41 PODFILE CHECKSUM: 7c9b8bb160246eb04b56feab0ec4a8fb149d5fa3 -COCOAPODS: 1.1.1 +COCOAPODS: 1.2.0 From eaced5b527297d7b0616fa557c8bc44888d96de0 Mon Sep 17 00:00:00 2001 From: Eduardo Callado Date: Wed, 24 May 2017 21:02:45 -0300 Subject: [PATCH 18/34] Fix SDWebImageManager method call --- Classes/IDMPhoto.m | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Classes/IDMPhoto.m b/Classes/IDMPhoto.m index 03e838b0..a2959d5c 100644 --- a/Classes/IDMPhoto.m +++ b/Classes/IDMPhoto.m @@ -136,19 +136,20 @@ - (void)loadUnderlyingImageAndNotify { [self performSelectorInBackground:@selector(loadImageFromFileAsync) withObject:nil]; } else if (_photoURL) { // Load async from web (using SDWebImageManager) - [[SDWebImageManager sharedManager] downloadImageWithURL:_photoURL options:SDWebImageRetryFailed|SDWebImageHandleCookies progress:^(NSInteger receivedSize, NSInteger expectedSize) { - CGFloat progress = ((CGFloat)receivedSize)/((CGFloat)expectedSize); - - if (self.progressUpdateBlock) { - self.progressUpdateBlock(progress); - } - } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (image) { - self.underlyingImage = image; - } - - [self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO]; - }]; + + [[SDWebImageManager sharedManager] loadImageWithURL:_photoURL options:SDWebImageRetryFailed progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) { + CGFloat progress = ((CGFloat)receivedSize)/((CGFloat)expectedSize); + + if (self.progressUpdateBlock) { + self.progressUpdateBlock(progress); + } + } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (image) { + self.underlyingImage = image; + } + + [self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO]; + }]; } else { // Failed - no source self.underlyingImage = nil; From bfbfa03562ea38f094bbd7094d18e763a06fca01 Mon Sep 17 00:00:00 2001 From: Eduardo Callado Date: Wed, 24 May 2017 21:04:29 -0300 Subject: [PATCH 19/34] Bump version --- IDMPhotoBrowser.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IDMPhotoBrowser.podspec b/IDMPhotoBrowser.podspec index 19234c3f..764a3592 100644 --- a/IDMPhotoBrowser.podspec +++ b/IDMPhotoBrowser.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "IDMPhotoBrowser" s.summary = "Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more." - s.version = "1.11.1" + s.version = "1.11.2" s.homepage = "https://github.com/ideaismobile/IDMPhotoBrowser" s.license = { :type => 'MIT', :file => 'LICENSE.txt' } s.author = { "Eduardo Callado" => "eduardo_tasker@hotmail.com" } - s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.11.1" } + s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.11.2" } s.platform = :ios, '8.0' s.source_files = 'Classes/*.{h,m}' s.resources = 'Classes/IDMPhotoBrowser.bundle', 'Classes/IDMPBLocalizations.bundle' From 1ab16d66c7f885e55ebc3e59d799f4f944631ded Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 25 May 2017 19:54:58 +1000 Subject: [PATCH 20/34] fixed: incorrect done button position --- Classes/IDMPhotoBrowser.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index 7a4e4a32..125785fa 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -615,7 +615,7 @@ - (void)viewDidLoad { _doneButton.layer.cornerRadius = 3.0f; _doneButton.layer.borderColor = [UIColor colorWithWhite:0.9 alpha:0.9].CGColor; _doneButton.layer.borderWidth = 1.0f; - _doneButtonSize = _doneButtonImage.size; + _doneButtonSize = _doneButton.frame.size; } else { [_doneButton setImage:_doneButtonImage forState:UIControlStateNormal]; From 9c1d745ca24e745499dfb54b7d6a872210918fa3 Mon Sep 17 00:00:00 2001 From: Eduardo Callado Date: Fri, 26 May 2017 23:36:56 -0300 Subject: [PATCH 21/34] Bump version --- IDMPhotoBrowser.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IDMPhotoBrowser.podspec b/IDMPhotoBrowser.podspec index 764a3592..028b1b30 100644 --- a/IDMPhotoBrowser.podspec +++ b/IDMPhotoBrowser.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "IDMPhotoBrowser" s.summary = "Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more." - s.version = "1.11.2" + s.version = "1.11.3" s.homepage = "https://github.com/ideaismobile/IDMPhotoBrowser" s.license = { :type => 'MIT', :file => 'LICENSE.txt' } s.author = { "Eduardo Callado" => "eduardo_tasker@hotmail.com" } - s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.11.2" } + s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.11.3" } s.platform = :ios, '8.0' s.source_files = 'Classes/*.{h,m}' s.resources = 'Classes/IDMPhotoBrowser.bundle', 'Classes/IDMPBLocalizations.bundle' From aafd79f777d5ff85c27555cae41359f227eb03fa Mon Sep 17 00:00:00 2001 From: Leon Keijzer Date: Wed, 28 Jun 2017 10:37:51 +0200 Subject: [PATCH 22/34] Fixed a typo in dutch translations --- Classes/IDMPBLocalizations.bundle/nl.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/IDMPBLocalizations.bundle/nl.lproj/Localizable.strings b/Classes/IDMPBLocalizations.bundle/nl.lproj/Localizable.strings index d448ed08..87f699ea 100644 --- a/Classes/IDMPBLocalizations.bundle/nl.lproj/Localizable.strings +++ b/Classes/IDMPBLocalizations.bundle/nl.lproj/Localizable.strings @@ -14,7 +14,7 @@ "Dismiss" = "Annuleer"; /* No comment provided by engineer. */ -"Done" = "Klaae"; +"Done" = "Klaar"; /* No comment provided by engineer. */ "Email" = "E-mail"; From ec5c46ed3192c39a601ce25db2e225e27ac657de Mon Sep 17 00:00:00 2001 From: Ahmet Alsan Date: Fri, 25 Aug 2017 11:12:31 +0300 Subject: [PATCH 23/34] add turkish localization --- .../tr.lproj/Localizable.strings | Bin 0 -> 2408 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100755 Classes/IDMPBLocalizations.bundle/tr.lproj/Localizable.strings diff --git a/Classes/IDMPBLocalizations.bundle/tr.lproj/Localizable.strings b/Classes/IDMPBLocalizations.bundle/tr.lproj/Localizable.strings new file mode 100755 index 0000000000000000000000000000000000000000..ad7bdb3e1548cd2d3047e771380857594bf315d1 GIT binary patch literal 2408 zcmcJR-A>y;5QT?Zp2Erv5>k_*-nHVY1%arlNVE^&Vh1epr#OX%2k%wY_B*p#?Ya;N zA*{%bJv+PS%$c9$@1Kz!T47&o!TpN+j8AQITl2oO6_z_|tio1d`EDETTEE6R=c&eL zi0#luwr>ObXeIV5>{H$fJLVeL+r1?xmTvoi-#*^LJ;!$f#tKxOca3drH|#F#hqZos z;U^ZXuX&%ba)YJid*XWKC&ig-DIC4a8kG-u zR}NcWU7)mbU%Q`j6m$-H=DE+&cSSl!<&EdO8}sXF9n@1riGR+cM6;4O`$Jx!WSwDt z1#jk8UzjI;enUm1NKfpIjnTLz*0Q%~6S8`-MDHoFs}I*;7oclWR6ZZZzNR`=Z?EZi zO_Gw1*SF<&u9D1c@xLd$+g|$S8^5jh(W!b2#q~BPTt|? ztUqT0#c7zjB2A$@@;Gr$Gd)sdXILL+3kcL)!KVll^_NBn{k?g5i3-6 z)blZm6t6P;z=T^-@0zuJ&$>%c?%x5h#YRmc mkLpP#>eZ=tY Date: Fri, 25 Aug 2017 11:26:11 +0300 Subject: [PATCH 24/34] typo fix --- .../tr.lproj/Localizable.strings | Bin 2408 -> 2408 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Classes/IDMPBLocalizations.bundle/tr.lproj/Localizable.strings b/Classes/IDMPBLocalizations.bundle/tr.lproj/Localizable.strings index ad7bdb3e1548cd2d3047e771380857594bf315d1..eeb43040aa09d4556b3f9f068e59508644cc6151 100755 GIT binary patch delta 20 ccmaDM^g?Ju67%GDOi7dNShzNyW1htd09)w?@c;k- delta 30 jcmaDM^g?Ju5;JEALn1>i2v4qMikxi6!nOGv^DI^Xm+}d4 From 1f26c0b2d5bfaac4af9bd18ae1d3addf3b434dbe Mon Sep 17 00:00:00 2001 From: Simon Matsepura Date: Tue, 12 Sep 2017 12:34:24 +0300 Subject: [PATCH 25/34] Update IDMPhotoBrowser.podspec 'SDWebImage', '4.0.0' -> 'SDWebImage', '4.1.0' In new version fixed some crashes. --- IDMPhotoBrowser.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IDMPhotoBrowser.podspec b/IDMPhotoBrowser.podspec index 028b1b30..66e8b049 100644 --- a/IDMPhotoBrowser.podspec +++ b/IDMPhotoBrowser.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.resources = 'Classes/IDMPhotoBrowser.bundle', 'Classes/IDMPBLocalizations.bundle' s.framework = 'MessageUI', 'QuartzCore', 'SystemConfiguration', 'MobileCoreServices', 'Security' s.requires_arc = true - s.dependency 'SDWebImage', '4.0.0' + s.dependency 'SDWebImage', '4.1.0' s.dependency 'DACircularProgress' s.dependency 'pop' - end \ No newline at end of file + end From 6ee97706b3f77fcea4d255dff516a8213643be60 Mon Sep 17 00:00:00 2001 From: Arnold Tang Date: Sun, 24 Sep 2017 23:03:36 +0800 Subject: [PATCH 26/34] Add iOS11 Smart Invert Support --- Classes/IDMPhotoBrowser.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index 125785fa..68bf5396 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -375,6 +375,11 @@ - (void)performPresentAnimation { resizableImageView.clipsToBounds = YES; resizableImageView.contentMode = _senderViewForAnimation ? _senderViewForAnimation.contentMode : UIViewContentModeScaleAspectFill; resizableImageView.backgroundColor = [UIColor clearColor]; + if (@available(iOS 11.0, *)) { + resizableImageView.accessibilityIgnoresInvertColors = YES; + } else { + // Fallback on earlier versions + } [_applicationWindow addSubview:resizableImageView]; _senderViewForAnimation.hidden = YES; @@ -432,6 +437,11 @@ - (void)performCloseAnimationWithScrollView:(IDMZoomingScrollView*)scrollView { resizableImageView.contentMode = _senderViewForAnimation ? _senderViewForAnimation.contentMode : UIViewContentModeScaleAspectFill; resizableImageView.backgroundColor = [UIColor clearColor]; resizableImageView.clipsToBounds = YES; + if (@available(iOS 11.0, *)) { + resizableImageView.accessibilityIgnoresInvertColors = YES; + } else { + // Fallback on earlier versions + } [_applicationWindow addSubview:resizableImageView]; self.view.hidden = YES; From c57ca8595548d050f2808ded43b9c72a8579193d Mon Sep 17 00:00:00 2001 From: Arnold Tang Date: Sun, 24 Sep 2017 23:18:38 +0800 Subject: [PATCH 27/34] Add iOS11 Smart Invert Support --- Classes/IDMZoomingScrollView.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index 419ce4fd..974f149f 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -46,6 +46,11 @@ - (id)initWithPhotoBrowser:(IDMPhotoBrowser *)browser { _photoImageView = [[IDMTapDetectingImageView alloc] initWithFrame:CGRectZero]; _photoImageView.tapDelegate = self; _photoImageView.backgroundColor = [UIColor clearColor]; + if (@available(iOS 11.0, *)) { + _photoImageView.accessibilityIgnoresInvertColors = YES; + } else { + // Fallback on earlier versions + } [self addSubview:_photoImageView]; CGRect screenBound = [[UIScreen mainScreen] bounds]; From e9465c51d9a01505c4a3eef23b525c372f67c163 Mon Sep 17 00:00:00 2001 From: xiaoming Date: Wed, 25 Oct 2017 10:52:48 +0800 Subject: [PATCH 28/34] add access request --- Demo/PhotoBrowserDemo/PhotoBrowserDemo-Info.plist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Demo/PhotoBrowserDemo/PhotoBrowserDemo-Info.plist b/Demo/PhotoBrowserDemo/PhotoBrowserDemo-Info.plist index aeadc90e..5cdb1d51 100644 --- a/Demo/PhotoBrowserDemo/PhotoBrowserDemo-Info.plist +++ b/Demo/PhotoBrowserDemo/PhotoBrowserDemo-Info.plist @@ -2,6 +2,8 @@ + NSPhotoLibraryAddUsageDescription + need to access your photo Library CFBundleDevelopmentRegion en CFBundleDisplayName From 265bb65bb7a3c64d3a95ce99f80db639b608ee51 Mon Sep 17 00:00:00 2001 From: Simon Matsepura Date: Fri, 10 Nov 2017 12:20:35 +0300 Subject: [PATCH 29/34] Update IDMPhotoBrowser.podspec --- IDMPhotoBrowser.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IDMPhotoBrowser.podspec b/IDMPhotoBrowser.podspec index 66e8b049..b2e724f4 100644 --- a/IDMPhotoBrowser.podspec +++ b/IDMPhotoBrowser.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.resources = 'Classes/IDMPhotoBrowser.bundle', 'Classes/IDMPBLocalizations.bundle' s.framework = 'MessageUI', 'QuartzCore', 'SystemConfiguration', 'MobileCoreServices', 'Security' s.requires_arc = true - s.dependency 'SDWebImage', '4.1.0' + s.dependency 'SDWebImage' s.dependency 'DACircularProgress' s.dependency 'pop' end From c28028997d88ca9a1cb5725507590160ae0678af Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 27 Nov 2017 18:06:25 +1100 Subject: [PATCH 30/34] Add iPhone X support Safe areas are calculated for toolbar, done button and photo frame. This accounts for orientation and fall back for pre-iOS 11 devices. --- Classes/IDMPhotoBrowser.m | 46 ++++- Classes/IDMUtils.h | 12 ++ Classes/IDMUtils.m | 52 +++++ .../project.pbxproj | 183 +++++++++++++++++- Demo/PhotoBrowserDemoTests/IDMUtilsTest.m | 115 +++++++++++ Demo/PhotoBrowserDemoTests/Info.plist | 22 +++ .../PhotoBrowserDemoTests.m | 15 ++ 7 files changed, 436 insertions(+), 9 deletions(-) create mode 100644 Classes/IDMUtils.h create mode 100644 Classes/IDMUtils.m create mode 100644 Demo/PhotoBrowserDemoTests/IDMUtilsTest.m create mode 100644 Demo/PhotoBrowserDemoTests/Info.plist create mode 100644 Demo/PhotoBrowserDemoTests/PhotoBrowserDemoTests.m diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index 125785fa..8549f3a4 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -9,6 +9,7 @@ #import #import "IDMPhotoBrowser.h" #import "IDMZoomingScrollView.h" +#import "IDMUtils.h" #import "pop/POP.h" @@ -62,6 +63,7 @@ @interface IDMPhotoBrowser () { BOOL _viewIsActive; // active as in it's in the view heirarchy BOOL _autoHide; NSInteger _initalPageIndex; + CGFloat _statusBarHeight; BOOL _isdraggingPhoto; @@ -190,8 +192,11 @@ - (id)init { _isdraggingPhoto = NO; + _statusBarHeight = 20.f; _doneButtonRightInset = 20.f; - _doneButtonTopInset = 30.f; + // relative to status bar and safeAreaInsets + _doneButtonTopInset = 10.f; + _doneButtonSize = CGSizeMake(55.f, 26.f); if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]) { @@ -478,8 +483,19 @@ - (CGRect)animationFrameForImage:(UIImage *)image presenting:(BOOL)presenting sc CGSize imageSize = image.size; - CGFloat maxWidth = CGRectGetWidth(_applicationWindow.bounds); - CGFloat maxHeight = CGRectGetHeight(_applicationWindow.bounds); + CGRect bounds = _applicationWindow.bounds; + // adjust bounds as the photo browser does + if (@available(iOS 11.0, *)) { + // use the windows safe area inset + UIWindow *window = [UIApplication sharedApplication].keyWindow; + UIEdgeInsets insets = UIEdgeInsetsMake(_statusBarHeight, 0, 0, 0); + if (window != NULL) { + insets = window.safeAreaInsets; + } + bounds = [self adjustForSafeArea:bounds adjustForStatusBar:NO forInsets:insets]; + } + CGFloat maxWidth = CGRectGetWidth(bounds); + CGFloat maxHeight = CGRectGetHeight(bounds); CGRect animationFrame = CGRectZero; @@ -497,7 +513,6 @@ - (CGRect)animationFrameForImage:(UIImage *)image presenting:(BOOL)presenting sc if (!presenting) { animationFrame.origin.y += scrollView.frame.origin.y; } - return animationFrame; } @@ -1078,6 +1093,7 @@ - (CGRect)frameForPagingScrollView { CGRect frame = self.view.bounds; frame.origin.x -= PADDING; frame.size.width += (2 * PADDING); + frame = [self adjustForSafeArea:frame adjustForStatusBar:false]; return frame; } @@ -1116,16 +1132,18 @@ - (CGRect)frameForToolbarAtOrientation:(UIInterfaceOrientation)orientation { if ([self isLandscape:orientation]) height = 32; - return CGRectMake(0, self.view.bounds.size.height - height, self.view.bounds.size.width, height); + CGRect rtn = CGRectMake(0, self.view.bounds.size.height - height, self.view.bounds.size.width, height); + rtn = [self adjustForSafeArea:rtn adjustForStatusBar:true]; + return rtn; } - (CGRect)frameForDoneButtonAtOrientation:(UIInterfaceOrientation)orientation { CGRect screenBound = self.view.bounds; CGFloat screenWidth = screenBound.size.width; - // if ([self isLandscape:orientation]) screenWidth = screenBound.size.height; - - return CGRectMake(screenWidth - self.doneButtonRightInset - self.doneButtonSize.width, self.doneButtonTopInset, self.doneButtonSize.width, self.doneButtonSize.height); + CGRect rtn = CGRectMake(screenWidth - self.doneButtonRightInset - self.doneButtonSize.width, self.doneButtonTopInset, self.doneButtonSize.width, self.doneButtonSize.height); + rtn = [self adjustForSafeArea:rtn adjustForStatusBar:true]; + return rtn; } - (CGRect)frameForCaptionView:(IDMCaptionView *)captionView atIndex:(NSUInteger)index { @@ -1137,6 +1155,18 @@ - (CGRect)frameForCaptionView:(IDMCaptionView *)captionView atIndex:(NSUInteger) return captionFrame; } +- (CGRect)adjustForSafeArea:(CGRect)rect adjustForStatusBar:(BOOL)adjust { + if (@available(iOS 11.0, *)) { + return [self adjustForSafeArea:rect adjustForStatusBar:adjust forInsets:self.view.safeAreaInsets]; + } + UIEdgeInsets insets = UIEdgeInsetsMake(_statusBarHeight, 0, 0, 0); + return [self adjustForSafeArea:rect adjustForStatusBar:adjust forInsets:insets]; +} + +- (CGRect)adjustForSafeArea:(CGRect)rect adjustForStatusBar:(BOOL)adjust forInsets:(UIEdgeInsets) insets { + return [IDMUtils adjustRect:rect forSafeAreaInsets:insets forBounds:self.view.bounds adjustForStatusBar:adjust statusBarHeight:_statusBarHeight]; +} + #pragma mark - UIScrollView Delegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { diff --git a/Classes/IDMUtils.h b/Classes/IDMUtils.h new file mode 100644 index 00000000..933bad40 --- /dev/null +++ b/Classes/IDMUtils.h @@ -0,0 +1,12 @@ +// +// IDMUtils.h +// PhotoBrowserDemo +// +// Created by Oliver ONeill on 2/12/17. +// + +#import + +@interface IDMUtils : NSObject ++ (CGRect)adjustRect:(CGRect)rect forSafeAreaInsets:(UIEdgeInsets)insets forBounds:(CGRect)bounds adjustForStatusBar:(BOOL)adjust statusBarHeight:(int)statusBarHeight; +@end diff --git a/Classes/IDMUtils.m b/Classes/IDMUtils.m new file mode 100644 index 00000000..10eea0a3 --- /dev/null +++ b/Classes/IDMUtils.m @@ -0,0 +1,52 @@ +// +// IDMUtils.m +// PhotoBrowserDemo +// +// Created by Oliver ONeill on 2/12/17. +// + +#import "IDMUtils.h" + +@implementation IDMUtils +/** + * Adjust a rect to be moved into a safe area specified by `insets`. + * + * NOTE: this does not cover all cases. Given a rect it will reposition it if it + * falls into an unsafe area according to `insets` and `bounds`. When + * `adjustForStatusBar` is true, the rect y position will be based from the edge + * of the safe area, otherwise it will be based from zero. This allows views to + * sit behind the status bar. Status bar height is also used + * to keep positioning consistent when toggling the status bar on and off + */ ++ (CGRect)adjustRect:(CGRect)rect forSafeAreaInsets:(UIEdgeInsets)insets forBounds:(CGRect)bounds adjustForStatusBar:(BOOL)adjust statusBarHeight:(int)statusBarHeight { + BOOL isLeft = rect.origin.x <= insets.left; + // If the safe area is not specified via insets we should fall back to the + // status bar height + CGFloat insetTop = insets.top > 0 ? insets.top : statusBarHeight; + // Don't adjust for y positioning when adjustForStatusBar is false + BOOL isAtTop = (rect.origin.y <= insetTop); + BOOL isRight = rect.origin.x + rect.size.width >= bounds.size.width - insets.right; + BOOL isAtBottom = rect.origin.y + rect.size.height >= bounds.size.height - insets.bottom; + if ((isLeft) && (isRight)) { + rect.origin.x += insets.left; + rect.size.width -= insets.right + insets.left; + } else if (isLeft) { + rect.origin.x += insets.left; + } else if (isRight) { + rect.origin.x -= insets.right; + } + // if we're adjusting for status bar then we should move the view out of + // the inset + if ((adjust) && (isAtTop) && (isAtBottom)) { + rect.origin.y += insetTop; + rect.size.height -= insets.bottom + insetTop; + } else if ((adjust) && (isAtTop)) { + rect.origin.y += insetTop; + } else if ((isAtTop) && (isAtBottom)) { + rect.size.height -= insets.bottom; + } else if (isAtBottom) { + rect.origin.y -= insets.bottom; + } + return rect; +} +@end diff --git a/Demo/PhotoBrowserDemo.xcodeproj/project.pbxproj b/Demo/PhotoBrowserDemo.xcodeproj/project.pbxproj index 792fdeed..5d9c8df1 100644 --- a/Demo/PhotoBrowserDemo.xcodeproj/project.pbxproj +++ b/Demo/PhotoBrowserDemo.xcodeproj/project.pbxproj @@ -22,6 +22,9 @@ 5736E0DD544CC84515494E76 /* libPods-PhotoBrowserDemo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 64F5714840012BFE47F8331B /* libPods-PhotoBrowserDemo.a */; }; 727988B1187B3B5400966C66 /* IDMPBLocalizations.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 727988B0187B3B5400966C66 /* IDMPBLocalizations.bundle */; }; 727988B7187B3CF100966C66 /* IDMPhotoBrowser.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 727988B6187B3CF100966C66 /* IDMPhotoBrowser.podspec */; }; + 7D2B79B81FD2501300F2094F /* IDMUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2B79B71FD2501200F2094F /* IDMUtils.m */; }; + 7D2B79C01FD25B7600F2094F /* PhotoBrowserDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2B79BF1FD25B7600F2094F /* PhotoBrowserDemoTests.m */; }; + 7D2B79C81FD25BF300F2094F /* IDMUtilsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2B79C71FD25BF300F2094F /* IDMUtilsTest.m */; }; D114BB411A32269C00E677FE /* Launch Screen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D114BB401A32269C00E677FE /* Launch Screen.xib */; }; D1574968178DB94900B0211A /* IDMCaptionView.m in Sources */ = {isa = PBXBuildFile; fileRef = D157494F178DB94900B0211A /* IDMCaptionView.m */; }; D1574969178DB94900B0211A /* IDMPhoto.m in Sources */ = {isa = PBXBuildFile; fileRef = D1574951178DB94900B0211A /* IDMPhoto.m */; }; @@ -54,6 +57,16 @@ D1FA3A911805C340000FFE18 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D1FA3A901805C340000FFE18 /* Security.framework */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 7D2B79C21FD25B7600F2094F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4C6F978414AF734800F8389A /* Project object */; + proxyType = 1; + remoteGlobalIDString = 4C6F978C14AF734800F8389A; + remoteInfo = PhotoBrowserDemo; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ 4C6F978D14AF734900F8389A /* PhotoBrowserDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PhotoBrowserDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4C6F979114AF734900F8389A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; @@ -73,6 +86,14 @@ 64F5714840012BFE47F8331B /* libPods-PhotoBrowserDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PhotoBrowserDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 727988B0187B3B5400966C66 /* IDMPBLocalizations.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = IDMPBLocalizations.bundle; sourceTree = ""; }; 727988B6187B3CF100966C66 /* IDMPhotoBrowser.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = IDMPhotoBrowser.podspec; path = ../../IDMPhotoBrowser.podspec; sourceTree = ""; }; + 7D2B79B61FD2501200F2094F /* IDMUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IDMUtils.h; sourceTree = ""; }; + 7D2B79B71FD2501200F2094F /* IDMUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IDMUtils.m; sourceTree = ""; }; + 7D2B79BD1FD25B7600F2094F /* PhotoBrowserDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PhotoBrowserDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 7D2B79BF1FD25B7600F2094F /* PhotoBrowserDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PhotoBrowserDemoTests.m; sourceTree = ""; }; + 7D2B79C11FD25B7600F2094F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7D2B79C71FD25BF300F2094F /* IDMUtilsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IDMUtilsTest.m; sourceTree = ""; }; + 7D7D66691E09D6D400410A67 /* IDMBrowserDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IDMBrowserDelegate.h; sourceTree = ""; }; + 7D7D666A1E09D6DA00410A67 /* IDMPhotoDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IDMPhotoDataSource.h; sourceTree = ""; }; D00FA320EEACA8C835D9D626 /* Pods-PhotoBrowserDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PhotoBrowserDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PhotoBrowserDemo/Pods-PhotoBrowserDemo.debug.xcconfig"; sourceTree = ""; }; D11464B61802FFC4005B7BC3 /* IDMPBConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IDMPBConstants.h; sourceTree = ""; }; D114BB401A32269C00E677FE /* Launch Screen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "Launch Screen.xib"; sourceTree = ""; }; @@ -136,6 +157,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 7D2B79BA1FD25B7600F2094F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -147,6 +175,7 @@ 4C6F97CA14AF75D300F8389A /* Sample Photos */, D19D825517E8D40700A5859E /* Custom Images */, 4C6F979814AF734900F8389A /* Supporting Files */, + 7D2B79BE1FD25B7600F2094F /* PhotoBrowserDemoTests */, 4C6F979014AF734900F8389A /* Frameworks */, 4C6F978E14AF734900F8389A /* Products */, 6D1B0039D6199AD450E98829 /* Pods */, @@ -157,6 +186,7 @@ isa = PBXGroup; children = ( 4C6F978D14AF734900F8389A /* PhotoBrowserDemo.app */, + 7D2B79BD1FD25B7600F2094F /* PhotoBrowserDemoTests.xctest */, ); name = Products; sourceTree = ""; @@ -231,6 +261,16 @@ name = Pods; sourceTree = ""; }; + 7D2B79BE1FD25B7600F2094F /* PhotoBrowserDemoTests */ = { + isa = PBXGroup; + children = ( + 7D2B79BF1FD25B7600F2094F /* PhotoBrowserDemoTests.m */, + 7D2B79C71FD25BF300F2094F /* IDMUtilsTest.m */, + 7D2B79C11FD25B7600F2094F /* Info.plist */, + ); + path = PhotoBrowserDemoTests; + sourceTree = ""; + }; D1574931178DB94900B0211A /* IDMPhotoBrowser */ = { isa = PBXGroup; children = ( @@ -241,6 +281,9 @@ D1574951178DB94900B0211A /* IDMPhoto.m */, D1574953178DB94900B0211A /* IDMPhotoBrowser.h */, D1574954178DB94900B0211A /* IDMPhotoBrowser.m */, + 7D2B79B61FD2501200F2094F /* IDMUtils.h */, + 7D2B79B71FD2501200F2094F /* IDMUtils.m */, + 7D7D666A1E09D6DA00410A67 /* IDMPhotoDataSource.h */, D1574955178DB94900B0211A /* IDMPhotoProtocol.h */, D1574956178DB94900B0211A /* IDMTapDetectingImageView.h */, D1574957178DB94900B0211A /* IDMTapDetectingImageView.m */, @@ -296,6 +339,24 @@ productReference = 4C6F978D14AF734900F8389A /* PhotoBrowserDemo.app */; productType = "com.apple.product-type.application"; }; + 7D2B79BC1FD25B7600F2094F /* PhotoBrowserDemoTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7D2B79C41FD25B7600F2094F /* Build configuration list for PBXNativeTarget "PhotoBrowserDemoTests" */; + buildPhases = ( + 7D2B79B91FD25B7600F2094F /* Sources */, + 7D2B79BA1FD25B7600F2094F /* Frameworks */, + 7D2B79BB1FD25B7600F2094F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 7D2B79C31FD25B7600F2094F /* PBXTargetDependency */, + ); + name = PhotoBrowserDemoTests; + productName = PhotoBrowserDemoTests; + productReference = 7D2B79BD1FD25B7600F2094F /* PhotoBrowserDemoTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -307,6 +368,11 @@ 4C6F978C14AF734800F8389A = { LastSwiftMigration = 0810; }; + 7D2B79BC1FD25B7600F2094F = { + CreatedOnToolsVersion = 9.1; + ProvisioningStyle = Automatic; + TestTargetID = 4C6F978C14AF734800F8389A; + }; }; }; buildConfigurationList = 4C6F978714AF734800F8389A /* Build configuration list for PBXProject "PhotoBrowserDemo" */; @@ -324,6 +390,7 @@ projectRoot = ""; targets = ( 4C6F978C14AF734800F8389A /* PhotoBrowserDemo */, + 7D2B79BC1FD25B7600F2094F /* PhotoBrowserDemoTests */, ); }; /* End PBXProject section */ @@ -361,6 +428,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 7D2B79BB1FD25B7600F2094F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -391,7 +465,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; F88445D630091F1AA9A2F89A /* [CP] Copy Pods Resources */ = { @@ -416,6 +490,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 7D2B79B81FD2501300F2094F /* IDMUtils.m in Sources */, D1574968178DB94900B0211A /* IDMCaptionView.m in Sources */, D1A9ED541DEB685F00C238DA /* MenuViewController.swift in Sources */, D1574969178DB94900B0211A /* IDMPhoto.m in Sources */, @@ -427,8 +502,25 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 7D2B79B91FD25B7600F2094F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7D2B79C81FD25BF300F2094F /* IDMUtilsTest.m in Sources */, + 7D2B79C01FD25B7600F2094F /* PhotoBrowserDemoTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 7D2B79C31FD25B7600F2094F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4C6F978C14AF734800F8389A /* PhotoBrowserDemo */; + targetProxy = 7D2B79C21FD25B7600F2094F /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ 4C6F97AC14AF734900F8389A /* Debug */ = { isa = XCBuildConfiguration; @@ -560,6 +652,86 @@ }; name = Release; }; + 7D2B79C51FD25B7600F2094F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ALWAYS_SEARCH_USER_PATHS = NO; + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = PhotoBrowserDemoTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.appkraft.PhotoBrowserDemoTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PhotoBrowserDemo.app/PhotoBrowserDemo"; + }; + name = Debug; + }; + 7D2B79C61FD25B7600F2094F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ALWAYS_SEARCH_USER_PATHS = NO; + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = PhotoBrowserDemoTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = com.appkraft.PhotoBrowserDemoTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PhotoBrowserDemo.app/PhotoBrowserDemo"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -581,6 +753,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 7D2B79C41FD25B7600F2094F /* Build configuration list for PBXNativeTarget "PhotoBrowserDemoTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7D2B79C51FD25B7600F2094F /* Debug */, + 7D2B79C61FD25B7600F2094F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 4C6F978414AF734800F8389A /* Project object */; diff --git a/Demo/PhotoBrowserDemoTests/IDMUtilsTest.m b/Demo/PhotoBrowserDemoTests/IDMUtilsTest.m new file mode 100644 index 00000000..cfbdb9c7 --- /dev/null +++ b/Demo/PhotoBrowserDemoTests/IDMUtilsTest.m @@ -0,0 +1,115 @@ +// +// IDMUtilsTest.m +// PhotoBrowserDemoTests +// +// Created by Oliver ONeill on 2/12/17. +// + +#import +#import "IDMUtils.h" + +@interface IDMUtilsTest : XCTestCase + +@end + +@implementation IDMUtilsTest + +- (void)setUp { + [super setUp]; +} + +- (void)tearDown { + [super tearDown]; +} + +- (void)testAdjustRectForSafeAreaInsets { + // given + CGRect rect = CGRectMake(0, 0, 100, 200); + CGRect bounds = rect; + UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 10, 10); + BOOL adjust = YES; + int statusBarHeight = 0; + // when + CGRect result = [IDMUtils adjustRect:rect forSafeAreaInsets:insets forBounds:bounds adjustForStatusBar:adjust statusBarHeight:statusBarHeight]; + // then + // since its moved 10 down and 10 to the left, the width and height are then + // decreased by 20 + CGRect expected = CGRectMake(10, 10, 80, 180); + XCTAssert(CGRectEqualToRect(result, expected)); +} + +- (void)testAdjustRectForSafeAreaInsetsDoesntModifyGivenZeroInsets { + // given + CGRect rect = CGRectMake(0, 0, 100, 200); + CGRect bounds = rect; + // no inset changes + UIEdgeInsets insets = UIEdgeInsetsZero; + BOOL adjust = YES; + int statusBarHeight = 0; + // when + CGRect result = [IDMUtils adjustRect:rect forSafeAreaInsets:insets forBounds:bounds adjustForStatusBar:adjust statusBarHeight:statusBarHeight]; + // then + // since there were no insets, the result should not change the rect + XCTAssert(CGRectEqualToRect(result, rect)); +} + +- (void)testAdjustRectForSafeAreaInsetsWithSmallBounds { + // given + CGRect rect = CGRectMake(0, 0, 100, 200); + // small bounds should not affect the view + CGRect bounds = CGRectMake(10, 10, 10, 20); + UIEdgeInsets insets = UIEdgeInsetsZero; + BOOL adjust = YES; + int statusBarHeight = 0; + // when + CGRect result = [IDMUtils adjustRect:rect forSafeAreaInsets:insets forBounds:bounds adjustForStatusBar:adjust statusBarHeight:statusBarHeight]; + // then + XCTAssert(CGRectEqualToRect(result, rect)); +} + +- (void)testAdjustRectForSafeAreaInsetsWithoutStatusBarAdjustment { + // given + CGRect rect = CGRectMake(0, 0, 100, 200); + CGRect bounds = CGRectMake(0, 0, 100, 200); + UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 10, 10); + BOOL adjust = NO; + int statusBarHeight = 0; + // when + CGRect result = [IDMUtils adjustRect:rect forSafeAreaInsets:insets forBounds:bounds adjustForStatusBar:adjust statusBarHeight:statusBarHeight]; + // then + // since its moved 10 down and 10 to the left, the width and height are then + // decreased by 20 + CGRect expected = CGRectMake(10, 0, 80, 190); + XCTAssert(CGRectEqualToRect(result, expected)); +} + +- (void)testAdjustRectForSafeAreaInsetsShiftsViewsUpInsteadOfResize { + // given + CGRect rect = CGRectMake(0, 20, 100, 200); + CGRect bounds = CGRectMake(0, 0, 100, 200); + UIEdgeInsets insets = UIEdgeInsetsMake(10, 10, 10, 10); + BOOL adjust = NO; + int statusBarHeight = 0; + // when + CGRect result = [IDMUtils adjustRect:rect forSafeAreaInsets:insets forBounds:bounds adjustForStatusBar:adjust statusBarHeight:statusBarHeight]; + // then + // the view was moved up by 10 on the y axis to move above the inset + CGRect expected = CGRectMake(10, 10, 80, 200); + XCTAssert(CGRectEqualToRect(result, expected)); +} + +- (void)testAdjustRectForSafeAreaInsetsUsesStatusBarHeight { + // given + CGRect rect = CGRectMake(0, 0, 100, 200); + CGRect bounds = CGRectMake(0, 0, 100, 200); + UIEdgeInsets insets = UIEdgeInsetsZero; + BOOL adjust = YES; + int statusBarHeight = 10; + // when + CGRect result = [IDMUtils adjustRect:rect forSafeAreaInsets:insets forBounds:bounds adjustForStatusBar:adjust statusBarHeight:statusBarHeight]; + // then + // the view is moved down by 10 and the height is decreased + CGRect expected = CGRectMake(0, 10, 100, 190); + XCTAssert(CGRectEqualToRect(result, expected)); +} +@end diff --git a/Demo/PhotoBrowserDemoTests/Info.plist b/Demo/PhotoBrowserDemoTests/Info.plist new file mode 100644 index 00000000..6c40a6cd --- /dev/null +++ b/Demo/PhotoBrowserDemoTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/Demo/PhotoBrowserDemoTests/PhotoBrowserDemoTests.m b/Demo/PhotoBrowserDemoTests/PhotoBrowserDemoTests.m new file mode 100644 index 00000000..32f07286 --- /dev/null +++ b/Demo/PhotoBrowserDemoTests/PhotoBrowserDemoTests.m @@ -0,0 +1,15 @@ +// +// PhotoBrowserDemoTests.m +// PhotoBrowserDemoTests +// +// Created by Oliver ONeill on 2/12/17. +// + +#import + +@interface PhotoBrowserDemoTests : XCTestCase + +@end + +@implementation PhotoBrowserDemoTests +@end From 520697aa6be4522497376aebc81d45f3f39acdd2 Mon Sep 17 00:00:00 2001 From: GaoYu Date: Wed, 13 Dec 2017 14:56:22 +0800 Subject: [PATCH 31/34] chore: drag & drop photo --- Classes/IDMZoomingScrollView.h | 2 +- Classes/IDMZoomingScrollView.m | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Classes/IDMZoomingScrollView.h b/Classes/IDMZoomingScrollView.h index 4651735c..9b820be2 100644 --- a/Classes/IDMZoomingScrollView.h +++ b/Classes/IDMZoomingScrollView.h @@ -15,7 +15,7 @@ @class IDMPhotoBrowser, IDMPhoto, IDMCaptionView; -@interface IDMZoomingScrollView : UIScrollView { +@interface IDMZoomingScrollView : UIScrollView { IDMPhotoBrowser *__weak _photoBrowser; id _photo; diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index 419ce4fd..165312f3 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -48,6 +48,12 @@ - (id)initWithPhotoBrowser:(IDMPhotoBrowser *)browser { _photoImageView.backgroundColor = [UIColor clearColor]; [self addSubview:_photoImageView]; + //Add darg&drop in iOS 11 + if (@available(iOS 11.0, *)) { + UIDragInteraction *drag = [[UIDragInteraction alloc] initWithDelegate: self]; + [_photoImageView addInteraction:drag]; + } + CGRect screenBound = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenBound.size.width; CGFloat screenHeight = screenBound.size.height; @@ -93,6 +99,12 @@ - (void)prepareForReuse { self.captionView = nil; } +#pragma mark - Drag & Drop + +- (NSArray *)dragInteraction:(UIDragInteraction *)interaction itemsForBeginningSession:(id)session NS_AVAILABLE_IOS(11.0) { + return @[[[UIDragItem alloc] initWithItemProvider:[[NSItemProvider alloc] initWithObject:_photoImageView.image]]]; +} + #pragma mark - Image // Get and display image From e52cc2acde767d2b4b2ead09a8a03fa64c232604 Mon Sep 17 00:00:00 2001 From: Jackie Date: Mon, 27 Jul 2020 17:34:26 +0800 Subject: [PATCH 32/34] Update podspec --- IDMPhotoBrowser.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IDMPhotoBrowser.podspec b/IDMPhotoBrowser.podspec index b2e724f4..b82909d7 100644 --- a/IDMPhotoBrowser.podspec +++ b/IDMPhotoBrowser.podspec @@ -5,8 +5,8 @@ Pod::Spec.new do |s| s.homepage = "https://github.com/ideaismobile/IDMPhotoBrowser" s.license = { :type => 'MIT', :file => 'LICENSE.txt' } s.author = { "Eduardo Callado" => "eduardo_tasker@hotmail.com" } - s.source = { :git => "https://github.com/ideaismobile/IDMPhotoBrowser.git", :tag => "1.11.3" } - s.platform = :ios, '8.0' + s.source = { :git => "https://github.com/jackie-li/IDMPhotoBrowser.git", :tag => "1.11.3" } + s.platform = :ios, '10.3' s.source_files = 'Classes/*.{h,m}' s.resources = 'Classes/IDMPhotoBrowser.bundle', 'Classes/IDMPBLocalizations.bundle' s.framework = 'MessageUI', 'QuartzCore', 'SystemConfiguration', 'MobileCoreServices', 'Security' From 48569c863d1a1c99bec55cc2acfc3c08ab2b0cd3 Mon Sep 17 00:00:00 2001 From: Jackie Date: Mon, 27 Jul 2020 18:18:12 +0800 Subject: [PATCH 33/34] Callback to main thread to avoid crash issue due to use UI API in background --- Classes/IDMPhotoBrowser.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/IDMPhotoBrowser.m b/Classes/IDMPhotoBrowser.m index 9cd39f32..a71d43a0 100644 --- a/Classes/IDMPhotoBrowser.m +++ b/Classes/IDMPhotoBrowser.m @@ -1071,7 +1071,9 @@ - (void)configurePage:(IDMZoomingScrollView *)page forIndex:(NSUInteger)index { __block __weak IDMPhoto *photo = (IDMPhoto*)page.photo; __weak IDMZoomingScrollView* weakPage = page; photo.progressUpdateBlock = ^(CGFloat progress){ - [weakPage setProgress:progress forPhoto:photo]; + dispatch_async(dispatch_get_main_queue(), ^{ + [weakPage setProgress:progress forPhoto:photo]; + }); }; } From 1c7004d4c3553f95bb6f1621a519bb24f89b615d Mon Sep 17 00:00:00 2001 From: Jackie Date: Mon, 27 Jul 2020 18:18:50 +0800 Subject: [PATCH 34/34] Remove unused code --- Classes/IDMZoomingScrollView.m | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Classes/IDMZoomingScrollView.m b/Classes/IDMZoomingScrollView.m index c3dc4f51..7a9b7caf 100644 --- a/Classes/IDMZoomingScrollView.m +++ b/Classes/IDMZoomingScrollView.m @@ -59,15 +59,6 @@ - (id)initWithPhotoBrowser:(IDMPhotoBrowser *)browser { [_photoImageView addInteraction:drag]; } - CGRect screenBound = [[UIScreen mainScreen] bounds]; - CGFloat screenWidth = screenBound.size.width; - CGFloat screenHeight = screenBound.size.height; - - if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) { - screenWidth = screenBound.size.height; - screenHeight = screenBound.size.width; - } - // Progress view _progressView = [[DACircularProgressView alloc] initWithFrame:CGRectZero]; _progressView.translatesAutoresizingMaskIntoConstraints = NO;