From df96c96b67bf46b0983ae0b23f0f747a58149afa Mon Sep 17 00:00:00 2001 From: Ma Shuai Date: Fri, 22 Oct 2021 17:19:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81auth=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GKPhotoBrowser/Core/GKPhotoManager.h | 6 ++++++ GKPhotoBrowser/Core/GKPhotoView.m | 5 ++++- GKPhotoBrowser/Core/GKWebImageProtocol.h | 2 ++ GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m | 8 +++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/GKPhotoBrowser/Core/GKPhotoManager.h b/GKPhotoBrowser/Core/GKPhotoManager.h index 4e98979a..58913ab8 100644 --- a/GKPhotoBrowser/Core/GKPhotoManager.h +++ b/GKPhotoBrowser/Core/GKPhotoManager.h @@ -35,6 +35,12 @@ NS_ASSUME_NONNULL_BEGIN /** 占位图 */ @property (nonatomic, strong, nullable) UIImage *placeholderImage; +/** originUrl 权限header */ +@property (nonatomic, strong, nullable) NSDictionary *originAuthToken; + +/** url 权限header */ +@property (nonatomic, strong, nullable) NSDictionary *authToken; + /************************内部使用,无需关心 ********************/ /** 图片是否加载完成 */ diff --git a/GKPhotoBrowser/Core/GKPhotoView.m b/GKPhotoBrowser/Core/GKPhotoView.m index 9b97caf0..31b9bac1 100644 --- a/GKPhotoBrowser/Core/GKPhotoView.m +++ b/GKPhotoBrowser/Core/GKPhotoView.m @@ -200,10 +200,13 @@ - (void)loadImageWithPhoto:(GKPhoto *)photo isOrigin:(BOOL)isOrigin { } NSURL *url = nil; + NSDictionary *authToken = nil; if (photo.originFinished) { url = photo.originUrl; + authToken = photo.originAuthToken; }else { url = isOrigin ? photo.originUrl : photo.url; + authToken = isOrigin ? photo.originAuthToken : photo.authToken; } if (url.absoluteString.length > 0) { @@ -269,7 +272,7 @@ - (void)loadImageWithPhoto:(GKPhoto *)photo isOrigin:(BOOL)isOrigin { }); }; - [_imageProtocol setImageForImageView:self.imageView url:url placeholderImage:placeholderImage progress:progressBlock completion:completionBlock]; + [_imageProtocol setImageForImageView:self.imageView url:url authToken:authToken placeholderImage:placeholderImage progress:progressBlock completion:completionBlock]; }else { if (self.imageView.image) { photo.finished = YES; diff --git a/GKPhotoBrowser/Core/GKWebImageProtocol.h b/GKPhotoBrowser/Core/GKWebImageProtocol.h index 880c0309..6bd05326 100644 --- a/GKPhotoBrowser/Core/GKWebImageProtocol.h +++ b/GKPhotoBrowser/Core/GKWebImageProtocol.h @@ -20,11 +20,13 @@ typedef void (^GKWebImageCompletionBlock)(UIImage * _Nullable image, NSURL * _Nu /// 为imageView设置图片 /// @param imageView imageView /// @param url 图片url +/// @param auth 图片的权限 /// @param placeholderImage 缺省图片 /// @param progressBlock 加载进度 /// @param completionBlock 完成进度 - (void)setImageForImageView:(nullable UIImageView *)imageView url:(nullable NSURL *)url + authToken:(nullable NSDictionary *)auth placeholderImage:(nullable UIImage *)placeholderImage progress:(nullable GKWebImageProgressBlock)progressBlock completion:(nullable GKWebImageCompletionBlock)completionBlock; diff --git a/GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m b/GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m index 13c394cc..76464af7 100644 --- a/GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m +++ b/GKPhotoBrowser/SDWebImage/GKSDWebImageManager.m @@ -29,7 +29,13 @@ - (Class)imageViewClass { return SDAnimatedImageView.class; } -- (void)setImageForImageView:(UIImageView *)imageView url:(NSURL *)url placeholderImage:(UIImage *)placeholderImage progress:(GKWebImageProgressBlock)progress completion:(GKWebImageCompletionBlock)completion { +- (void)setImageForImageView:(UIImageView *)imageView url:(NSURL *)url authToken:(NSDictionary *)token placeholderImage:(UIImage *)placeholderImage progress:(GKWebImageProgressBlock)progress completion:(GKWebImageCompletionBlock)completion { + + SDWebImageDownloader *manager = [SDWebImageManager sharedManager].imageLoader; + for (NSString *key in token) { + [manager setValue:[token objectForKey:key] forHTTPHeaderField:key]; + } + [imageView sd_setImageWithURL:url placeholderImage:placeholderImage options:SDWebImageRetryFailed progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) { !progress ? : progress(receivedSize, expectedSize); } completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { From c64ea4198ecde124536c39c400091a5930c6bbc9 Mon Sep 17 00:00:00 2001 From: Ma Shuai Date: Wed, 17 Nov 2021 16:00:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=8C=89=E9=92=AEUI=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GKPhotoBrowser/Core/GKPhotoBrowser.m | 12 +++--------- .../GKPhotoBrowser.bundle/icon_download.png | Bin 0 -> 354 bytes .../GKPhotoBrowser.bundle/icon_download@2x.png | Bin 0 -> 354 bytes .../GKPhotoBrowser.bundle/icon_download@3x.png | Bin 0 -> 354 bytes 4 files changed, 3 insertions(+), 9 deletions(-) create mode 100644 GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download.png create mode 100644 GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@2x.png create mode 100644 GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@3x.png diff --git a/GKPhotoBrowser/Core/GKPhotoBrowser.m b/GKPhotoBrowser/Core/GKPhotoBrowser.m index 839b9fc9..44b91cbc 100644 --- a/GKPhotoBrowser/Core/GKPhotoBrowser.m +++ b/GKPhotoBrowser/Core/GKPhotoBrowser.m @@ -437,7 +437,7 @@ - (void)layoutSubviews { pointY = self.contentView.bounds.size.height - 10 - (self.isAdaptiveSafeArea ? 0 : kSafeBottomSpace); } self.pageControl.center = CGPointMake(centerX, pointY); - self.saveBtn.center = CGPointMake(self.contentView.bounds.size.width - 50, pointY); + self.saveBtn.center = CGPointMake(self.contentView.bounds.size.width - 30, pointY - 10); } if ([self.delegate respondsToSelector:@selector(photoBrowser:willLayoutSubViews:)]) { @@ -1416,14 +1416,8 @@ - (UIPageControl *)pageControl { - (UIButton *)saveBtn { if (!_saveBtn) { UIButton *saveBtn = [UIButton new]; - saveBtn.bounds = CGRectMake(0, 0, 50, 30); - [saveBtn setTitle:@"保存" forState:UIControlStateNormal]; - [saveBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; - saveBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f]; - saveBtn.layer.cornerRadius = 5; - saveBtn.layer.masksToBounds = YES; - saveBtn.layer.borderColor = UIColor.whiteColor.CGColor; - saveBtn.layer.borderWidth = 1; + saveBtn.bounds = CGRectMake(0, 0, 20, 20); + [saveBtn setBackgroundImage:GKPhotoBrowserImage(@"icon_download") forState:UIControlStateNormal]; saveBtn.hidden = YES; [saveBtn addTarget:self action:@selector(saveBtnClick:) forControlEvents:UIControlEventTouchUpInside]; _saveBtn = saveBtn; diff --git a/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download.png b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download.png new file mode 100644 index 0000000000000000000000000000000000000000..90b712cd0744610cce58a481d6d689eebc96d2e3 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezr3(Flu_bIEGZ*dOP_pSCfH6+uJ4k zy*sTs*DY)Aa8T4Y^jg`x;M2S}(q|-$o|`St`?BwY9LKKr)n5#|1Xvse%~yEI5TYLI}fEfpF~0a@^tlcS?83{1OV@}mm~lH literal 0 HcmV?d00001 diff --git a/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@2x.png b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..90b712cd0744610cce58a481d6d689eebc96d2e3 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezr3(Flu_bIEGZ*dOP_pSCfH6+uJ4k zy*sTs*DY)Aa8T4Y^jg`x;M2S}(q|-$o|`St`?BwY9LKKr)n5#|1Xvse%~yEI5TYLI}fEfpF~0a@^tlcS?83{1OV@}mm~lH literal 0 HcmV?d00001 diff --git a/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@3x.png b/GKPhotoBrowser/GKPhotoBrowser.bundle/icon_download@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..90b712cd0744610cce58a481d6d689eebc96d2e3 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezr3(Flu_bIEGZ*dOP_pSCfH6+uJ4k zy*sTs*DY)Aa8T4Y^jg`x;M2S}(q|-$o|`St`?BwY9LKKr)n5#|1Xvse%~yEI5TYLI}fEfpF~0a@^tlcS?83{1OV@}mm~lH literal 0 HcmV?d00001 From 8ff00ec7813944b0ca5617854269f4c4edf20a8b Mon Sep 17 00:00:00 2001 From: Ma Shuai Date: Thu, 30 May 2024 15:20:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E6=8C=87=E7=A4=BA=E5=99=A8=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E9=80=82=E9=85=8D=E4=B8=80=E4=B8=8B=E7=81=B5?= =?UTF-8?q?=E5=8A=A8=E5=B2=9B=E7=9A=84=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GKPhotoBrowser/Core/GKPhotoBrowser.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GKPhotoBrowser/Core/GKPhotoBrowser.m b/GKPhotoBrowser/Core/GKPhotoBrowser.m index 44b91cbc..1928e3a0 100644 --- a/GKPhotoBrowser/Core/GKPhotoBrowser.m +++ b/GKPhotoBrowser/Core/GKPhotoBrowser.m @@ -429,7 +429,7 @@ - (void)layoutSubviews { }else { CGFloat centerX = self.contentView.bounds.size.width * 0.5f; - self.countLabel.center = CGPointMake(centerX, (KIsiPhoneX && !self.isLandscape) ? 50 : 30); + self.countLabel.center = CGPointMake(centerX, (KIsiPhoneX && !self.isLandscape) ? 65 : 30); CGFloat pointY = 0; if (self.isLandscape) { pointY = self.contentView.bounds.size.height - 20;