Skip to content

Commit 3813aec

Browse files
committed
[refactor](multi video support): update the readme
1 parent a723d80 commit 3813aec

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

README.md

+22-25
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ A-J-Full-Screen-Image-Browser is an drop-in solution for full screen image and v
2727

2828
## Requirements
2929

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+
3333

3434
## Installation
3535

@@ -42,26 +42,21 @@ import UIKit
4242

4343
final class ViewController: UIViewController {
4444

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")!)
4849
}()
4950

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+
}()
6257

6358
@IBAction func onButtonTapped(_ sender: UIButton) {
64-
let vm = FullScreenImageBrowserViewModel(imageURLs: urls, videos: videos)
59+
let vm = FullScreenImageBrowserViewModel(media: media)
6560
let x = FullScreenImageBrowser(viewModel: vm)
6661
present(x, animated: true, completion: nil)
6762
}
@@ -79,14 +74,16 @@ The following code snippet shows an example how to use `AlamofireImage` to seaml
7974
import Foundation
8075
import AlamofireImage
8176

82-
public class FullScreenImage: ImageAsyncDownloadable {
77+
public class FullScreenImage: MediaDownloadable {
8378
public var image: UIImage?
8479
public var imageURL: URL?
80+
public var videoURL: URL?
81+
public var isVideoThumbnail: Bool
8582

86-
private let downloader = ImageDownloader()
87-
88-
public init(imageURL: URL?) {
83+
public init(imageURL: URL?, isVideoThumbnail: Bool = false, videoURL: URL? = nil) {
8984
self.imageURL = imageURL
85+
self.videoURL = videoURL
86+
self.isVideoThumbnail = isVideoThumbnail
9087
}
9188

9289
public func loadImageWithCompletionHandler(_ completion: @escaping (UIImage?, NSError?) -> Void) {
@@ -136,7 +133,7 @@ public class FullScreenImage: ImageAsyncDownloadable {
136133
├── core
137134
│   ├── FullScreenImageBrowser.swift
138135
│   ├── FullScreenImageBrowserViewModel.swift
139-
│   ├── Image+AsyncDownload.swift
136+
│   ├── MediaDownloadable.swift
140137
│   ├── MaskImageViewer.swift
141138
│   ├── SingleImageViewer.swift
142139
│   └── ZoomableImageView.swift
@@ -151,7 +148,7 @@ public class FullScreenImage: ImageAsyncDownloadable {
151148
| asset | customised static image asset for the full screen image/video browser navigation bar |
152149
| core/FullScreenImageBrowser | manager class to be responsible for full screen image/video browser |
153150
| 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 |
155152
| core/MaskImageViewer | `customised` overlay view for full screen image/video browser |
156153
| core/SingleImageViewer | view controller to be responsible for single image rendering on the full screen |
157154
| core/ZoomableImageView | view to add support for image to zoom, pin, rotate, and animation |

assets/hld.png

6.9 KB
Loading

0 commit comments

Comments
 (0)