Skip to content

Commit

Permalink
Respect layout behavior when explicit placeholder is given
Browse files Browse the repository at this point in the history
  • Loading branch information
onevcat committed Aug 10, 2022
1 parent 2231f92 commit 572abfc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Demo/Demo/Kingfisher-Demo/SwiftUIViews/SingleViewDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ struct SingleViewDemo : View {
print("err: \(e)")
}
.placeholder { progress in
ProgressView(progress)
ProgressView(progress).frame(width: 100, height: 100)
.border(Color.blue)
}
.fade(duration: index == 1 ? 0 : 1) // Do not animate for the first image. Otherwise it causes an unwanted animation when the page is shown.
.forceTransition(forceTransition)
.resizable()
.frame(width: 300, height: 300)
.cornerRadius(20)
.border(Color.red)
.shadow(radius: 5)
.frame(width: 320, height: 320)

Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftUI/KFImageRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ struct KFImageRenderer<HoldingView> : View where HoldingView: KFImageHoldingView
}
.opacity(binder.loaded ? 1.0 : 0.0)
if binder.loadedImage == nil {
Group {
ZStack {
if let placeholder = context.placeholder, let view = placeholder(binder.progress) {
Color.clear.overlay(view)
view
} else {
Color.clear
}
Expand Down

0 comments on commit 572abfc

Please sign in to comment.