Git Product home page Git Product logo

swurl's Introduction

SwURL



Build Status License: MIT contributions welcome

Declarative-style SwiftUI wrapper around asyncronous image views including smooth transitions and caching options.

Currently up to date with Xcode GM 2.

RemoteImageView

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

Flexible 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!

Configuration

Enable or disable debug logging

SwURLDebug.loggingEnabled = true

Choose between global persistent or in-memory (default) caching

SwURL.setImageCache(type: .inMemory)
SwURL.setImageCache(type: .persistent)

... or provide your own caching implementation by using ImageCacheType

SwURL.setImageCache(type: .custom(ImageCacheType))

Usage

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: .easeOut(duration: 0.5)))
            Text(verbatim: landmark.name)
            Spacer()
        }
    }
}

Available Parameters

Name Description
url URL of the remote source image.
placeholderImage (optional) Image to display whilst remote image data is being fetched and decoded.
transition (optional) transition to occur when showing the loaded image.
imageRenderingMode (optional) TemplateRenderingMode of the placeholder image (if provided) and loaded image.

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!

Contact

If you want to get in touch you can email me at [email protected] or follow/message me on Twitter https://twitter.com/ctrounce94

swurl's People

Contributors

cmtrounce avatar ygit avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.