Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/c-villain/remoteasyncimage
- Owner: c-villain
- License: mit
- Created: 2023-09-19T14:08:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-20T11:51:39.000Z (over 1 year ago)
- Last Synced: 2023-09-20T23:58:21.441Z (over 1 year ago)
- Topics: asyncimage, swiftui
- Language: Swift
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 RemoteAsyncImagestruct 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()
}
}
}
```