Skip to content
async image loading in SwiftUI
Branch: master
Clone or download
Callum Trounce
Callum Trounce swapped get it section.
Latest commit 8343b6b Jun 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.swiftpm/xcode added combine binding test + fixed keypath error. Jun 7, 2019
Sources/SwURL put image fetching on background thread. Jun 12, 2019
Tests added combine binding test + fixed keypath error. Jun 7, 2019
.gitignore Initial commit Jun 5, 2019
LICENSE Create LICENSE Jun 6, 2019
Package.swift no message Jun 6, 2019
README.md swapped get it section. Jun 12, 2019

README.md

SwURL

Declarative-style SwiftUI wrapper around asyncronous image views

RemoteImageView

Asyncrounously download and display images declaratively. Supports placeholders and image transitions.

In-memory caching and image fetching done in background. Currently tested with basic List as seen in Example

As everyone gets to understand SwiftUI more, this project will evolve and get more features.

Fading Transition!

Example

RemoteImageView is initialised with a URL, placeholder Image (default nil) and a .custom ImageTransitionType (default .none).

Upon initialisation, a resized image will be downloaded in the background and placeholder displayed as the image is loading, transitioning to the downloaded image when complete.

LandmarkRow is used in a List

struct LandmarkRow: View {
    var landmark: Landmark
    
    var body: some View {
        HStack {
            RemoteImageView(url: landmark.imageURL,
                            placeholderImage: Image.init("user"),
                            transition: .custom(transition: .opacity,
                                                animation: .basic(duration: 0.5, curve: .easeInOut)))
            Text(verbatim: landmark.name)
            Spacer()
        }
    }
}

Get it

SwURL is available only through Swift Package Manager

  • Open Xcode
  • Go to File > Swift Packages > Add Package Dependency...
  • Paste this Github Repo URL ( https://github.com/cmtrounce/SwURL ) into the search bar.
  • Select the SwURL repo from the search results.
  • Choose the branch/version you want to clone. The most recent release is the most stable but you can choose branches master and develop for the most up to date changes.
  • Confirm and enjoy!
You can’t perform that action at this time.