Skip to content

Commit

Permalink
Add usePlaceholderAsFailure to show placeholder in case of image lo…
Browse files Browse the repository at this point in the history
…ading failure
  • Loading branch information
paul-han committed Mar 7, 2024
1 parent 55dbd80 commit 4887e94
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/NukeUI/LazyImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public final class LazyImageView: _PlatformBaseView {
}
}

public var usePlaceholderAsFailure = true

private var placeholderViewConstraints: [NSLayoutConstraint] = []

// MARK: Failure View
Expand Down Expand Up @@ -323,7 +325,11 @@ public final class LazyImageView: _PlatformBaseView {
case let .success(response):
display(response.container, isFromMemory: isSync)
case .failure:
setFailureViewHidden(false)
if usePlaceholderAsFailure {
setPlaceholderViewHidden(false)
} else {
setFailureViewHidden(false)
}
}

imageTask = nil
Expand Down

0 comments on commit 4887e94

Please sign in to comment.