Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/c-villain/remoteasyncimage

Remote AsyncImage on pure SwiftUI
https://github.com/c-villain/remoteasyncimage

asyncimage swiftui

Last synced: about 2 months ago
JSON representation

Remote AsyncImage on pure SwiftUI

Awesome Lists containing this project

README

        

# RemoteAsyncImage on SwiftUI

RemoteAsyncImage is a view that asynchronously loads and displays an image.

However, native AsyncImage is available from iOS 15 and don't have a cache.

## Requirements

- iOS 13.0

## Installation

#### Swift Package Manager

To integrate ```RemoteAsyncImage``` into your project using SwiftPM add the following to your `Package.swift`:

```swift
dependencies: [
.package(url: "https://github.com/c-villain/RemoteAsyncImage", from: "0.1.0"),
],
```
or via [XcodeGen](https://github.com/yonaskolb/XcodeGen) insert into your `project.yml`:

```yaml
name: YourProjectName
options:
deploymentTarget:
iOS: 13.0
packages:
RemoteAsyncImage:
url: https://github.com/c-villain/RemoteAsyncImage
from: 0.1.0
targets:
YourTarget:
type: application
...
dependencies:
- package: RemoteAsyncImage
```

## Usage

```swift
import RemoteAsyncImage

struct YourView: View {

@Environment(\.imageCache) var cache: ImageCache

var body: some View {
let url = URL(
string: "https://experience-ireland.s3.amazonaws.com/thumbs2/d07258d8-4274-11e9-9c68-02b782d69cda.800x600.jpg"
)

return VStack {
RemoteAsyncImage(
url: url,
cache: self.cache
)
.placeholder {
Text("Loading ...")
}
.resizable()
.scaledToFill()
.frame(width: 104, height: 144)
.clipped()

RemoteAsyncImage(
url: url
)
.placeholder {
Text("Loading ...")
}
.resizable()
.scaledToFill()
.frame(width: 104, height: 144)
.clipped()


RemoteAsyncImage(
url: url,
placeholder: {
Text("Loading ...")
}
)
.resizable()
.scaledToFill()
.frame(width: 104, height: 144)
.clipped()

RemoteAsyncImage(url: urlPig) {
Text("Loading ...")
}
.resizable()
.scaledToFill()
.frame(width: 104, height: 144)
.clipped()

}
}
}
```