Skip to content

Commit a93f0a9

Browse files
author
Christian Elies
committed
docs(readme): updated readme
1 parent bc122ff commit a93f0a9

File tree

1 file changed

+56
-7
lines changed

1 file changed

+56
-7
lines changed

README.md

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,64 @@
11
# RemoteImage
22

3-
[![Swift5](https://img.shields.io/badge/swift5-compatible-green.svg?longCache=true&style=flat-square)](https://developer.apple.com/swift)
4-
[![Platform](https://img.shields.io/badge/platform-iOS%20%7C%20macOS-lightgrey.svg?longCache=true&style=flat-square)](https://www.apple.com)
3+
[![Swift 5.1](https://img.shields.io/badge/swift5.1-compatible-green.svg?longCache=true&style=flat-square)](https://developer.apple.com/swift)
4+
[![Platform](https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS-lightgrey.svg?longCache=true&style=flat-square)](https://www.apple.com)
55
[![License](https://img.shields.io/badge/license-MIT-lightgrey.svg?longCache=true&style=flat-square)](https://en.wikipedia.org/wiki/MIT_License)
66

77
This Swift package provides a wrapper view around the existing **SwiftUI** `Image view` which adds support for showing and caching remote images.
88
In addition you can specify a loading and error view.
99

10+
You can display images from a specific URL or from the iCloud (through a `PHAsset` identifier).
11+
1012
## Installation
1113

1214
Add this Swift package in Xcode using its Github repository url. (File > Swift Packages > Add Package Dependency...)
1315

1416
## How to use
1517

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 🎉
1719

1820
Clear the image cache through `RemoteImageService.cache.removeAllObjects()`.
1921

20-
## TODO
22+
## Examples
2123

22-
- Load iCloud images (through local identifier)
24+
The following code truly highlights the **simplicity** of this view:
2325

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")!
2529

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+
```
2740

41+
PHAsset example:
2842
```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
2962
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")!
3063

3164
RemoteImage(url: url, errorView: { error in
@@ -38,3 +71,19 @@ RemoteImage(url: url, errorView: { error in
3871
Text("Loading ...")
3972
})
4073
```
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
81+
Text(error.localizedDescription)
82+
}, imageView: { image in
83+
image
84+
.resizable()
85+
.aspectRatio(contentMode: .fit)
86+
}, loadingView: {
87+
Text("Loading ...")
88+
})
89+
```

0 commit comments

Comments
 (0)