onevcat пре 5 година
родитељ
комит
9fa6a835f2
1 измењених фајлова са 7 додато и 11 уклоњено
  1. 7 11
      Sources/SwiftUI/KFImage.swift

+ 7 - 11
Sources/SwiftUI/KFImage.swift

@@ -169,18 +169,14 @@ struct KFImageRenderer: View {
                     return
                 }
                 if !binder.loadingOrSucceeded {
-                    binder.start {
-                        self.loadingResult = $0
-                        switch $0 {
-                        case .success(let result):
+                    binder.start { result in
+                        self.loadingResult = result
+                        switch result {
+                        case .success(let value):
                             CallbackQueue.mainAsync.execute {
-                                if let duration = fadeTransitionDuration(cacheType: result.cacheType) {
-                                    withAnimation(.linear(duration: duration)) {
-                                        isLoaded = true
-                                    }
-                                } else {
-                                    isLoaded = true
-                                }
+                                let animation = fadeTransitionDuration(cacheType: value.cacheType)
+                                    .map { duration in Animation.linear(duration: duration) }
+                                withAnimation(animation) { isLoaded = true }
                             }
                         case .failure(_):
                             break