Skip to content

Commit

Permalink
use protocol rather the the real model. users can define which image …
Browse files Browse the repository at this point in the history
…downloader(sdwebimage or afnetworking) to use by them self.
  • Loading branch information
shiyj committed Apr 23, 2017
1 parent 66ddd73 commit 5e66fa1
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
37 changes: 24 additions & 13 deletions MWPhotoBrowser.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,33 @@ Pod::Spec.new do |s|
:git => 'https://github.com/mwaterfall/MWPhotoBrowser.git',
:tag => '2.1.2'
}

s.platform = :ios, '7.0'
s.source_files = 'Pod/Classes/**/*'
s.resource_bundles = {
'MWPhotoBrowser' => ['Pod/Assets/*.png']
}
s.requires_arc = true
s.subspec 'core' do |core|
core.source_files = 'Pod/Classes/**/*'
core.exclude_files = 'Pod/Classes/MWPhoto.{h,m}'

core.resource_bundles = {
'MWPhotoBrowser' => ['Pod/Assets/*.png']
}
core.requires_arc = true

core.frameworks = 'ImageIO', 'QuartzCore', 'AssetsLibrary', 'MediaPlayer'
core.weak_frameworks = 'Photos'

s.frameworks = 'ImageIO', 'QuartzCore', 'AssetsLibrary', 'MediaPlayer'
s.weak_frameworks = 'Photos'
core.dependency 'MBProgressHUD'
core.dependency 'DACircularProgress', '~> 2.3'
end

s.dependency 'MBProgressHUD', '~> 0.9'
s.dependency 'DACircularProgress', '~> 2.3'
s.subspec 'SDWebImage' do |sdweb|
sdweb.source_files = 'Pod/Classes/MWPhoto.{h,m}'
sdweb.dependency 'MWPhotoBrowser/core'
# SDWebImage
# 3.7.2 contains bugs downloading local files
# https://github.com/rs/SDWebImage/issues/1109
sdweb.dependency 'SDWebImage', '~> 3.7', '!= 3.7.2'
end

# SDWebImage
# 3.7.2 contains bugs downloading local files
# https://github.com/rs/SDWebImage/issues/1109
s.dependency 'SDWebImage', '~> 3.7', '!= 3.7.2'
s.default_subspec = 'SDWebImage'

end
2 changes: 1 addition & 1 deletion Pod/Classes/MWCaptionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "MWCommon.h"
#import "MWCaptionView.h"
#import "MWPhoto.h"
#import "MWPhotoProtocol.h"

static const CGFloat labelPadding = 10;

Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/MWGridCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <UIKit/UIKit.h>
#import "MWPhoto.h"
#import "MWPhotoProtocol.h"
#import "MWGridViewController.h"

@interface MWGridCell : UICollectionViewCell {}
Expand Down
1 change: 0 additions & 1 deletion Pod/Classes/MWPhotoBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

#import <UIKit/UIKit.h>
#import "MWPhoto.h"
#import "MWPhotoProtocol.h"
#import "MWCaptionView.h"

Expand Down
6 changes: 2 additions & 4 deletions Pod/Classes/MWPhotoBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import "MWCommon.h"
#import "MWPhotoBrowser.h"
#import "MWPhotoBrowserPrivate.h"
#import "SDImageCache.h"
#import "UIImage+MWPhotoBrowser.h"

#define PADDING 10
Expand Down Expand Up @@ -96,7 +95,6 @@ - (void)dealloc {
_pagingScrollView.delegate = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self releaseAllUnderlyingPhotos:NO];
[[SDImageCache sharedImageCache] clearMemory]; // clear memory
}

- (void)releaseAllUnderlyingPhotos:(BOOL)preserveCurrent {
Expand Down Expand Up @@ -382,7 +380,7 @@ - (void)viewDidAppear:(BOOL)animated {
// Autoplay if first is video
if (!_viewHasAppearedInitially) {
if (_autoPlayOnAppear) {
MWPhoto *photo = [self photoAtIndex:_currentPageIndex];
id<MWPhoto> photo = [self photoAtIndex:_currentPageIndex];
if ([photo respondsToSelector:@selector(isVideo)] && photo.isVideo) {
[self playVideoAtIndex:_currentPageIndex];
}
Expand Down Expand Up @@ -1108,7 +1106,7 @@ - (void)updateNavigation {
_nextButton.enabled = (_currentPageIndex < numberOfPhotos - 1);

// Disable action button if there is no image or it's a video
MWPhoto *photo = [self photoAtIndex:_currentPageIndex];
id<MWPhoto> photo = [self photoAtIndex:_currentPageIndex];
if ([photo underlyingImage] == nil || ([photo respondsToSelector:@selector(isVideo)] && photo.isVideo)) {
_actionButton.enabled = NO;
_actionButton.tintColor = [UIColor clearColor]; // Tint to hide button
Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/MWZoomingScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "MWCommon.h"
#import "MWZoomingScrollView.h"
#import "MWPhotoBrowser.h"
#import "MWPhoto.h"
#import "MWPhotoProtocol.h"
#import "MWPhotoBrowserPrivate.h"
#import "UIImage+MWPhotoBrowser.h"

Expand Down

0 comments on commit 5e66fa1

Please sign in to comment.