SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.09k stars 214 forks source link

Documentation code produces errors #282

Closed richpressler closed 7 months ago

richpressler commented 7 months ago

The code in the documentation:

WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic")) { image in
        image.resizable() // Control layout like SwiftUI.AsyncImage, you must use this modifier or the view will use the image bitmap size
    } placeholder: {
            Rectangle().foregroundColor(.gray)
    }

Already produces the errors that Trailing closure passed to parameter of type 'Binding<Bool>' that does not accept a closure - it seems that WebImage() does not accept a trailing closure when given a url: parameter. Additionally, there is an error regarding placeholder: { ... } being an extraneous trailing closure. Without the added closures, using some onSuccess and onFailure handlers, the images seem to download fine, but nothing renders, because that seems to be handled in those closures that aren't working. What's going on here? I've tried 2.2.3 and 2.0.0

dreampiggy commented 7 months ago

This is the v3.0.0 syntax, use v3.0.0-beta.2 or above

For 2.x syntax, check the history tag for README 😂 https://github.com/SDWebImage/SDWebImageSwiftUI/tree/2.x

richpressler commented 7 months ago

Yep, that's all it was. Swift package manager grabs the 2.x.x version. Not going to use beta versions in prod so this solves my issue