Skip to content

Commit

Permalink
Better code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
onevcat committed Jan 30, 2021
1 parent 1b2eb05 commit 9fa6a83
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions Sources/SwiftUI/KFImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9fa6a83

Please sign in to comment.