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: 6 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 (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-26T15:14:58.000Z (over 1 year ago)
- Last Synced: 2024-12-30T22:20:45.800Z (6 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
[](https://github.com/leoz/CachedImage/actions/workflows/swift.yml)
[](https://swiftpackageindex.com/leoz/CachedImage)
[](https://swiftpackageindex.com/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.