-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathAsyncImageLoadOptions+toSDWebImageOptions.swift
More file actions
70 lines (55 loc) · 1.39 KB
/
AsyncImageLoadOptions+toSDWebImageOptions.swift
File metadata and controls
70 lines (55 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// AsyncImageLoadOptions+toSDWebImageOptions.swift
// NitroWebImage
//
// Created by Marc Rousavy on 30.06.25.
//
import Foundation
import SDWebImage
extension AsyncImageLoadOptions {
func toSDWebImageOptions() -> SDWebImageOptions {
var options: SDWebImageOptions = []
switch priority {
case .default, .none:
break
case .low:
options.insert(.lowPriority)
case .high:
options.insert(.highPriority)
}
if forceRefresh == true {
options.insert(.refreshCached)
}
if continueInBackground == true {
options.insert(.continueInBackground)
}
if allowInvalidSSLCertificates == true {
options.insert(.allowInvalidSSLCertificates)
}
if scaleDownLargeImages == true {
options.insert(.scaleDownLargeImages)
}
if queryMemoryDataSync == true {
options.insert(.queryMemoryDataSync)
}
if queryDiskDataSync == true {
options.insert(.queryDiskDataSync)
}
if decodeImage == false {
options.insert(.avoidDecodeImage)
}
if progressive == true {
options.insert(.progressiveLoad)
}
return options
}
func toSDWebImageContext() -> [SDWebImageContextOption: Any] {
var context: [SDWebImageContextOption: Any] = [:]
if let cacheKey {
context[.cacheKeyFilter] = SDWebImageCacheKeyFilter { _ in
return cacheKey
}
}
return context
}
}