You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This Swift package provides a wrapper view around the existing **SwiftUI**`Image view` which adds support for showing and caching remote images.
8
8
In addition you can specify a loading and error view.
9
9
10
+
You can display images from a specific URL or from the iCloud (through a `PHAsset` identifier).
11
+
10
12
## Installation
11
13
12
14
Add this Swift package in Xcode using its Github repository url. (File > Swift Packages > Add Package Dependency...)
13
15
14
16
## How to use
15
17
16
-
Just pass your remote image url and `ViewBuilder`s for the error, image and loading state to the initializer. That's it 🎉
18
+
Just pass a remote image url or the local identifier of a `PHAsset` and `ViewBuilder`s for the error, image and loading state to the initializer. That's it 🎉
17
19
18
20
Clear the image cache through `RemoteImageService.cache.removeAllObjects()`.
19
21
20
-
## TODO
22
+
## Examples
21
23
22
-
- Load iCloud images (through local identifier)
24
+
The following code truly highlights the **simplicity** of this view:
23
25
24
-
## Example
26
+
URL example:
27
+
```swift
28
+
let url =URL(string: "https://images.unsplash.com/photo-1524419986249-348e8fa6ad4a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80")!
25
29
26
-
The following code truly highlights the **simplicity** of this view:
30
+
RemoteImage(type: .url(url), errorView: { error in
31
+
Text(error.localizedDescription)
32
+
}, imageView: { image in
33
+
image
34
+
.resizable()
35
+
.aspectRatio(contentMode: .fit)
36
+
}, loadingView: {
37
+
Text("Loading ...")
38
+
})
39
+
```
27
40
41
+
PHAsset example:
28
42
```swift
43
+
44
+
RemoteImage(type: .phAsset(localIdentifier: "541D4013-D51C-463C-AD85-0A1E4EA838FD"), errorView: { error in
45
+
Text(error.localizedDescription)
46
+
}, imageView: { image in
47
+
image
48
+
.resizable()
49
+
.aspectRatio(contentMode: .fit)
50
+
}, loadingView: {
51
+
Text("Loading ...")
52
+
})
53
+
```
54
+
55
+
## Migration from 0.1.0 -> 1.0.0
56
+
57
+
The `url parameter` was refactored to a `type parameter` which makes it easy to fetch images at a URL or from the iCloud.
58
+
59
+
Change
60
+
```swift
61
+
# Version 0.1.0
29
62
let url =URL(string: "https://images.unsplash.com/photo-1524419986249-348e8fa6ad4a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80")!
30
63
31
64
RemoteImage(url: url, errorView: { error in
@@ -38,3 +71,19 @@ RemoteImage(url: url, errorView: { error in
38
71
Text("Loading ...")
39
72
})
40
73
```
74
+
75
+
to
76
+
```swift
77
+
# Version 1.0.0
78
+
let url =URL(string: "https://images.unsplash.com/photo-1524419986249-348e8fa6ad4a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80")!
79
+
80
+
RemoteImage(type: .url(url), errorView: { error in
0 commit comments