File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
SDWebImageSwiftUI/Classes Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,42 @@ import SwiftUI
1010import SDWebImage
1111
1212public struct AnimatedImage : UIViewRepresentable {
13- public var url : URL ?
13+ var url : URL ?
14+ var name : String ?
15+ var bundle : Bundle ?
16+ var data : Data ?
17+ var scale : Length = 0
1418
1519 public init ( url: URL ? ) {
1620 self . url = url
1721 }
1822
23+ public init ( name: String ? , bundle: Bundle ? = nil ) {
24+ self . name = name
25+ self . bundle = bundle
26+ }
27+
28+ public init ( data: Data , scale: Length = 0 ) {
29+ self . data = data
30+ self . scale = scale
31+ }
32+
1933 public func makeUIView( context: UIViewRepresentableContext < AnimatedImage > ) -> SDAnimatedImageView {
2034 SDAnimatedImageView ( )
2135 }
2236
2337 public func updateUIView( _ uiView: SDAnimatedImageView , context: UIViewRepresentableContext < AnimatedImage > ) {
24- uiView. sd_setImage ( with: url)
38+ if let url = url {
39+ uiView. sd_setImage ( with: url)
40+ return
41+ }
42+ if let name = name {
43+ uiView. image = SDAnimatedImage ( named: name, in: bundle, compatibleWith: nil )
44+ return
45+ }
46+ if let data = data {
47+ uiView. image = SDAnimatedImage ( data: data, scale: scale)
48+ return
49+ }
2550 }
2651}
You can’t perform that action at this time.
0 commit comments