Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leoz/cachedimage
Asynchronous Image Loading from URL in SwiftUI
https://github.com/leoz/cachedimage
asynchronous asyncimage image ios macos swift swift-package swift-package-manager swiftui
Last synced: 4 months ago
JSON representation
Asynchronous Image Loading from URL in SwiftUI
- Host: GitHub
- URL: https://github.com/leoz/cachedimage
- Owner: leoz
- License: unlicense
- Fork: true (V8tr/AsyncImage)
- Created: 2023-09-10T12:52:20.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-26T15:14:58.000Z (12 months ago)
- Last Synced: 2024-09-29T03:02:17.043Z (4 months ago)
- Topics: asynchronous, asyncimage, image, ios, macos, swift, swift-package, swift-package-manager, swiftui
- Language: Swift
- Homepage:
- Size: 5.68 MB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CachedImage
[![Build](https://github.com/leoz/CachedImage/actions/workflows/swift.yml/badge.svg?branch=master)](https://github.com/leoz/CachedImage/actions/workflows/swift.yml)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fleoz%2FCachedImage%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/leoz/CachedImage)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fleoz%2FCachedImage%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/leoz/CachedImage)
![License](https://img.shields.io/github/license/leoz/CachedImage)
## 🔭 Overview
`CachedImage` is a SwiftUI component to asynchronously load and display an image provided by its URL.
This package is based on the [AsyncImage](https://github.com/V8tr/AsyncImage) project published by [Vadim Bulavin](https://github.com/V8tr) and described in the [Asynchronous Image Loading from URL in SwiftUI](https://www.vadimbulavin.com/asynchronous-swiftui-image-loading-from-url-with-combine-and-swift/) article.
## 🛠️ Usage
### Quick Start
```swift
import CachedImagelet images = (0...20).map {
"https://picsum.photos/800/600?random=\($0)"
}
let imageURLs = images.map {
URL(string: $0)!
}struct ContentView: View {
var body: some View {
List(imageURLs, id: \.self) { url in
CachedImage(
url: url,
content: { image in
image
.resizable()
.aspectRatio(contentMode: .fit)
},
placeholder: {
Text("Loading ...")
}
)
.scaledToFit()
}
}
}
```### Demo Program
Check the demo project provided here: [Demo](./Demo/).
## ✍️ Author
[Vadim Bulavin](https://github.com/V8tr) & [Leonid Zolotarev](https://github.com/leoz)
## 📃 License
`CachedImage` is available under the Unlicense. See the [LICENSE](./LICENSE.md) file for more info.