Skip to content

Commit

Permalink
Implemented Subspec for Remote Fetch Support
Browse files Browse the repository at this point in the history
  • Loading branch information
iDevid committed Jul 21, 2020
1 parent c2e6a0e commit 983b278
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ use_frameworks!

target 'Demo' do
pod 'ImageViewer.swift', :path => './../'
end
pod 'ImageViewer.swift/Fetcher', :path => './../'
end
18 changes: 10 additions & 8 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
PODS:
- ImageViewer.swift (3.0):
- ImageViewer.swift (3.0)
- ImageViewer.swift/Fetcher (3.0):
- SDWebImage
- SDWebImage (5.3.3):
- SDWebImage/Core (= 5.3.3)
- SDWebImage/Core (5.3.3)
- SDWebImage (5.8.4):
- SDWebImage/Core (= 5.8.4)
- SDWebImage/Core (5.8.4)

DEPENDENCIES:
- ImageViewer.swift (from `./../`)
- ImageViewer.swift/Fetcher (from `./../`)

SPEC REPOS:
trunk:
Expand All @@ -17,9 +19,9 @@ EXTERNAL SOURCES:
:path: "./../"

SPEC CHECKSUMS:
ImageViewer.swift: a8ddca1afeea736c557ba44ce5c220d829922c8a
SDWebImage: 51ab1ce3ebd20dec6665ae8ba25c928da323db41
ImageViewer.swift: 5a7de1366351c307023daf71f907dedee968b5d0
SDWebImage: cf6922231e95550934da2ada0f20f2becf2ceba9

PODFILE CHECKSUM: 3cb622a244c4948f6d66f0aaa9d36294c3ab7fe1
PODFILE CHECKSUM: e724d0d4011b46b198571c9f9ed6734d40b74bc4

COCOAPODS: 1.8.4
COCOAPODS: 1.9.3
8 changes: 6 additions & 2 deletions ImageViewer.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Pod::Spec.new do |s|
}
s.source_files = 'Sources/*'
s.requires_arc = true
s.dependency 'SDWebImage'
s.ios.deployment_target = '10.0'
s.swift_versions = ['4.0','4.2','5.0']
s.license = {
Expand All @@ -26,4 +25,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
LICENSE
}
end

s.default_subspecs = :none
s.subspec 'Fetcher' do |cs|
cs.dependency 'SDWebImage'
end
end
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ Using [cocoapods](https://cocoapods.org)
pod 'ImageViewer.swift', '~> 3.0'
```

If you need remote image fetching:

```ruby
pod 'ImageViewer.swift', '~> 3.0'
pod 'ImageViewer.swift/Fetcher', '~> 3.0'
```

## How to use it

The simplest way to to use this is by using the [imageView.setupImageViewer()](https://github.com/michaelhenry/MHFacebookImageViewer/blob/master/Example/Demo/BasicViewController.swift#L11)
Expand Down
2 changes: 2 additions & 0 deletions Sources/ImageItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import UIKit

public enum ImageItem {
case image(UIImage?)
#if canImport(SDWebImage)
case url(URL, placeholder: UIImage?)
#endif
}
4 changes: 4 additions & 0 deletions Sources/ImageViewerController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import UIKit
#if canImport(SDWebImage)
import SDWebImage
#endif

protocol ImageViewerControllerDelegate:class {
func imageViewerDidClose(_ imageViewer: ImageViewerController)
Expand Down Expand Up @@ -90,6 +92,7 @@ class ImageViewerController:UIViewController, UIGestureRecognizerDelegate {
case .image(let img):
imageView.image = img
imageView.layoutIfNeeded()
#if canImport(SDWebImage)
case .url(let url, let placeholder):
imageView.sd_setImage(
with: url,
Expand All @@ -102,6 +105,7 @@ class ImageViewerController:UIViewController, UIGestureRecognizerDelegate {
}
}
}
#endif
default:
break
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/UIImageView_Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension UIImageView {
setup(datasource: nil, options: options, from: from)
}

#if canImport(SDWebImage)
public func setupImageViewer(
url:URL,
initialIndex:Int = 0,
Expand All @@ -39,6 +40,7 @@ extension UIImageView {
options: options,
from: from)
}
#endif

public func setupImageViewer(
images:[UIImage],
Expand All @@ -57,6 +59,7 @@ extension UIImageView {
from: from)
}

#if canImport(SDWebImage)
public func setupImageViewer(
urls:[URL],
initialIndex:Int = 0,
Expand All @@ -74,6 +77,7 @@ extension UIImageView {
options: options,
from: from)
}
#endif

public func setupImageViewer(
datasource:ImageDataSource,
Expand Down

0 comments on commit 983b278

Please sign in to comment.