File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Example/SDWebImageSwiftUIDemo Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ struct DetailView: View {
13
13
let url : String
14
14
let animated : Bool
15
15
@State var progress : CGFloat = 1
16
+ @State var isAnimating : Bool = true
16
17
17
18
var body : some View {
18
19
VStack {
@@ -24,7 +25,7 @@ struct DetailView: View {
24
25
Spacer ( )
25
26
HStack {
26
27
if animated {
27
- AnimatedImage ( url: URL ( string: url) , options: [ . progressiveLoad] )
28
+ AnimatedImage ( url: URL ( string: url) , options: [ . progressiveLoad] , isAnimating : $isAnimating )
28
29
. onProgress ( perform: { ( receivedSize, expectedSize) in
29
30
// SwiftUI engine itself ensure the main queue dispatch
30
31
if ( expectedSize >= 0 ) {
@@ -35,6 +36,9 @@ struct DetailView: View {
35
36
} )
36
37
. resizable ( )
37
38
. scaledToFit ( )
39
+ . navigationBarItems ( trailing: Button ( isAnimating ? " Stop " : " Start " ) {
40
+ self . isAnimating. toggle ( )
41
+ } )
38
42
} else {
39
43
WebImage ( url: URL ( string: url) , options: [ . progressiveLoad] )
40
44
. onProgress ( perform: { ( receivedSize, expectedSize) in
You can’t perform that action at this time.
0 commit comments