Git Product home page Git Product logo

sdwebimageswiftui's Introduction

SDWebImageSwiftUI

CI Status Version License Platform Carthage compatible SwiftPM compatible

What's for

This is an experimental project for SDWebImage.

It aims to ensure the following function available for users and try to do some experiments for Swift platform.

  • Swift Package Manager integration
  • SwiftUI compatibility
  • Swift source code compatibility

Note we do not guarantee the public API stable for current status. Since SwiftUI is a new platform for us, we need to investigate the API design.

Requirements

  • Xcode 11+
  • iOS 13+
  • macOS 10.15+
  • tvOS 13+
  • watchOS 6+
  • Swift 5.1+

Installation

CocoaPods

SDWebImageSwiftUI is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SDWebImageSwiftUI'

Carthage

SDWebImageSwiftUI is available through Carthage.

github "SDWebImage/SDWebImageSwiftUI"

Swift Package Manager

SDWebImageSwiftUI is available through Swift Package Manager.

let package = Package(
    dependencies: [
        .package(url: "https://github.com/SDWebImage/SDWebImageSwiftUI.git", from: "0.1")
    ],
)

Usage

  • Using WebImage to load network image

It supports the placeholder and detail options control for image loading as SDWebImage.

Note: Unlike UIImageView in UIKit, SwiftUI's Image does not support animation. This WebImage using Image for internal implementation and supports static image format only.

var body: some View {
    WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"))
        .resizable()
        .scaledToFit()
        .frame(width: 300, height: 300, alignment: .center)
}
  • Using AnimatedImage to play animation
var body: some View {
    AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"))
    .scaledToFit()
    AnimatedImage(data: try! Data(contentsOf: URL(fileURLWithPath: "/tmp/foo.webp")))
    .scaledToFill()
}

Note: AnimatedImage supports both image url or image data for animated image format. Which use the SDWebImage's Animated ImageView for internal implementation.

Demo

To run the example using SwiftUI, following the steps:

cd Example
pod install

Then open the Xcode Workspace to run the demo application.

Screenshot

Author

DreamPiggy

License

SDWebImageSwiftUI is available under the MIT license. See the LICENSE file for more info.

sdwebimageswiftui's People

Contributors

cozzin avatar dreampiggy avatar

Stargazers

 avatar

Watchers

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