File tree 2 files changed +23
-5
lines changed
Example/SDWebImageSwiftUIDemo
SDWebImageSwiftUI/Classes
2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,24 @@ class UserSettings: ObservableObject {
17
17
#endif
18
18
}
19
19
20
+ struct ContentView5 : View {
21
+ let url : URL = URL ( string: " http://assets.sbnation.com/assets/2512203/dogflops.gif " ) !
22
+
23
+ @State private var isAnimating = false
24
+
25
+ var body : some View {
26
+ ZStack {
27
+ WebImage ( url: url, isAnimating: $isAnimating)
28
+ . pausable ( false )
29
+ Button {
30
+ isAnimating. toggle ( )
31
+ } label: {
32
+ Text ( isAnimating ? " Stop " : " Start " )
33
+ }
34
+ }
35
+ }
36
+ }
37
+
20
38
#if !os(watchOS)
21
39
struct ContentView4 : View {
22
40
var url = URL ( string: " https://github.com/SDWebImage/SDWebImageSwiftUI/assets/97430818/72d27f90-e9d8-48d7-b144-82ada828a027 " ) !
Original file line number Diff line number Diff line change @@ -132,11 +132,11 @@ public struct WebImage<Content> : View where Content: View {
132
132
if context [ . imageScaleFactor] == nil {
133
133
context [ . imageScaleFactor] = scale
134
134
}
135
- // provide animated image class if the initialized `isAnimating` is true, user can still custom the image class if they want
136
- if isAnimating . wrappedValue {
137
- if context [ . animatedImageClass ] == nil {
138
- context [ . animatedImageClass] = SDAnimatedImage . self
139
- }
135
+ // always provide animated image class to allows dynamic control
136
+ // since most cases, SDAnimatedImage should be compatible with UIImage
137
+ // user can still custom the image class if they want
138
+ if context [ . animatedImageClass] == nil {
139
+ context [ . animatedImageClass ] = SDAnimatedImage . self
140
140
}
141
141
let imageModel = WebImageModel ( )
142
142
imageModel. url = url
You can’t perform that action at this time.
0 commit comments