@@ -27,9 +27,9 @@ A-J-Full-Screen-Image-Browser is an drop-in solution for full screen image and v
27
27
28
28
## Requirements
29
29
30
- - iOS 8 .0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
31
- - Xcode 8.3 +
32
- - Swift 3.1 +
30
+ - iOS 9 .0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
31
+ - Xcode 9.0 +
32
+ - Swift 4.0 +
33
33
34
34
## Installation
35
35
@@ -42,26 +42,21 @@ import UIKit
42
42
43
43
final class ViewController : UIViewController {
44
44
45
- lazy var images: [ImageAsyncDownloadable] = {
46
- return [SingleImage (imageURL : URL (string : " https://images.unsplash.com/photo-1445264918150-66a2371142a2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=79730c9ec106e3ccee026c648c624e5f&auto=format&fit=crop&w=3800&q=80" )! ),
47
- SingleImage (imageURL : URL (string : " https://images.unsplash.com/photo-1483086431886-3590a88317fe?ixlib=rb-0.3.5&s=96129ab02a4a277f5c27273d14323a9a&auto=format&fit=crop&w=3668&q=80" )! )]
45
+ lazy var testVideo: MediaDownloadable = {
46
+ return SingleMedia (imageURL : URL (string : " https://dummyimage.com/600&text=thumbnail" )! ,
47
+ isVideoThumbnail : true ,
48
+ videoURL : URL (string : " http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v" )! )
48
49
}()
49
50
50
- lazy var urls = [URL (string : " https://images.unsplash.com/photo-1502899576159-f224dc2349fa?ixlib=rb-0.3.5&s=4f3943a5d663f9bb062d7d380c8d6fdf&auto=format&fit=crop&w=3700&q=80" )! ,
51
- URL (string : " https://images.unsplash.com/photo-1445264918150-66a2371142a2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=79730c9ec106e3ccee026c648c624e5f&auto=format&fit=crop&w=3800&q=80" )! ]
52
-
53
- // videos are just key-value pair
54
- // key: video url
55
- // value: thumbnail url for associated video url
56
- lazy var videos = [URL (string : " http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v" )! : URL (string : " https://images.unsplash.com/photo-1502899576159-f224dc2349fa?ixlib=rb-0.3.5&s=4f3943a5d663f9bb062d7d380c8d6fdf&auto=format&fit=crop&w=3700&q=80" )! ]
57
-
58
- override func viewDidLoad () {
59
- super .viewDidLoad ()
60
- // Do any additional setup after loading the view, typically from a nib.
61
- }
51
+ lazy var media: [MediaDownloadable] = {
52
+ return [testVideo,
53
+ SingleMedia (imageURL : URL (string : " https://dummyimage.com/300" )! ),
54
+ SingleMedia (imageURL : URL (string : " https://dummyimage.com/600" )! ),
55
+ testVideo]
56
+ }()
62
57
63
58
@IBAction func onButtonTapped (_ sender : UIButton) {
64
- let vm = FullScreenImageBrowserViewModel (imageURLs : urls, videos : videos )
59
+ let vm = FullScreenImageBrowserViewModel (media : media )
65
60
let x = FullScreenImageBrowser (viewModel : vm)
66
61
present (x, animated : true , completion : nil )
67
62
}
@@ -79,14 +74,16 @@ The following code snippet shows an example how to use `AlamofireImage` to seaml
79
74
import Foundation
80
75
import AlamofireImage
81
76
82
- public class FullScreenImage : ImageAsyncDownloadable {
77
+ public class FullScreenImage : MediaDownloadable {
83
78
public var image: UIImage?
84
79
public var imageURL: URL?
80
+ public var videoURL: URL?
81
+ public var isVideoThumbnail: Bool
85
82
86
- private let downloader = ImageDownloader ()
87
-
88
- public init (imageURL : URL? ) {
83
+ public init (imageURL : URL? , isVideoThumbnail : Bool = false , videoURL : URL? = nil ) {
89
84
self .imageURL = imageURL
85
+ self .videoURL = videoURL
86
+ self .isVideoThumbnail = isVideoThumbnail
90
87
}
91
88
92
89
public func loadImageWithCompletionHandler (_ completion : @escaping (UIImage? , NSError? ) -> Void ) {
@@ -136,7 +133,7 @@ public class FullScreenImage: ImageAsyncDownloadable {
136
133
├── core
137
134
│ ├── FullScreenImageBrowser.swift
138
135
│ ├── FullScreenImageBrowserViewModel.swift
139
- │ ├── Image+AsyncDownload .swift
136
+ │ ├── MediaDownloadable .swift
140
137
│ ├── MaskImageViewer.swift
141
138
│ ├── SingleImageViewer.swift
142
139
│ └── ZoomableImageView.swift
@@ -151,7 +148,7 @@ public class FullScreenImage: ImageAsyncDownloadable {
151
148
| asset | customised static image asset for the full screen image/video browser navigation bar |
152
149
| core/FullScreenImageBrowser | manager class to be responsible for full screen image/video browser |
153
150
| core/FullScreenImageBrowserViewModel | datasource and business logic for full screen image/video browser |
154
- | core/Image+AsyncDownload | protocol to define images to be able to asynchronously download |
151
+ | core/MediaDownloadable | protocol to define images to be able to asynchronously download |
155
152
| core/MaskImageViewer | ` customised ` overlay view for full screen image/video browser |
156
153
| core/SingleImageViewer | view controller to be responsible for single image rendering on the full screen |
157
154
| core/ZoomableImageView | view to add support for image to zoom, pin, rotate, and animation |
0 commit comments