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 {
1313 let url : String
1414 let animated : Bool
1515 @State var progress : CGFloat = 1
16+ @State var isAnimating : Bool = true
1617
1718 var body : some View {
1819 VStack {
@@ -24,7 +25,7 @@ struct DetailView: View {
2425 Spacer ( )
2526 HStack {
2627 if animated {
27- AnimatedImage ( url: URL ( string: url) , options: [ . progressiveLoad] )
28+ AnimatedImage ( url: URL ( string: url) , options: [ . progressiveLoad] , isAnimating : $isAnimating )
2829 . onProgress ( perform: { ( receivedSize, expectedSize) in
2930 // SwiftUI engine itself ensure the main queue dispatch
3031 if ( expectedSize >= 0 ) {
@@ -35,6 +36,9 @@ struct DetailView: View {
3536 } )
3637 . resizable ( )
3738 . scaledToFit ( )
39+ . navigationBarItems ( trailing: Button ( isAnimating ? " Stop " : " Start " ) {
40+ self . isAnimating. toggle ( )
41+ } )
3842 } else {
3943 WebImage ( url: URL ( string: url) , options: [ . progressiveLoad] )
4044 . onProgress ( perform: { ( receivedSize, expectedSize) in
You can’t perform that action at this time.
0 commit comments