CachedImage

0.0.8

Asynchronous Image Loading from URL in SwiftUI
leoz/CachedImage

What's New

0.0.8

2024-01-26T15:14:58Z

Full Changelog: 0.0.7...0.0.8

CachedImage

Build License

🔭 Overview

CachedImage is a SwiftUI component to asynchronously load and display an image provided by its URL.

This package is based on the AsyncImage project published by Vadim Bulavin and described in the Asynchronous Image Loading from URL in SwiftUI article.

🛠️ Usage

Quick Start

import CachedImage

let 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.

✍️ Author

Vadim Bulavin & Leonid Zolotarev

📃 License

CachedImage is available under the Unlicense. See the LICENSE file for more info.

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Nov 10 2024 19:19:18 GMT-1000 (Hawaii-Aleutian Standard Time)