mirror of
https://github.com/jellyfin/Swiftfin.git
synced 2024-11-27 16:20:25 +00:00
fix blurhashes
This commit is contained in:
parent
b45ff520b2
commit
8840ca4995
@ -8,6 +8,8 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
// https://github.com/woltapp/blurhash/tree/master/Swift
|
||||
|
||||
public extension UIImage {
|
||||
convenience init?(blurHash: String, size: CGSize, punch: Float = 1) {
|
||||
guard blurHash.count >= 6 else { return nil }
|
||||
|
@ -55,7 +55,11 @@ public extension BaseItemDto {
|
||||
}
|
||||
|
||||
if imgURL.queryParameters?[ImageType.backdrop.rawValue] == nil {
|
||||
return imageBlurHashes?.backdrop?[imgTag] ?? "001fC^"
|
||||
if itemType == .episode {
|
||||
return imageBlurHashes?.backdrop?.values.first ?? "001fC^"
|
||||
} else {
|
||||
return imageBlurHashes?.backdrop?[imgTag] ?? "001fC^"
|
||||
}
|
||||
} else {
|
||||
return imageBlurHashes?.primary?[imgTag] ?? "001fC^"
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
import NukeUI
|
||||
import SwiftUI
|
||||
|
||||
// TODO: update multiple sources so that multiple blurhashes can be taken, clean up
|
||||
|
||||
struct ImageView: View {
|
||||
|
||||
@State
|
||||
@ -34,24 +36,10 @@ struct ImageView: View {
|
||||
|
||||
// TODO: fix placeholder hash view
|
||||
@ViewBuilder
|
||||
private func placeholderView() -> some View {
|
||||
// Image(uiImage: UIImage(blurHash: blurhash, size: CGSize(width: 8, height: 8)) ??
|
||||
// UIImage(blurHash: "001fC^", size: CGSize(width: 8, height: 8))!)
|
||||
// .resizable()
|
||||
|
||||
#if os(tvOS)
|
||||
ZStack {
|
||||
Color.black.ignoresSafeArea()
|
||||
|
||||
ProgressView()
|
||||
}
|
||||
#else
|
||||
ZStack {
|
||||
Color.gray.ignoresSafeArea()
|
||||
|
||||
ProgressView()
|
||||
}
|
||||
#endif
|
||||
private var placeholderView: some View {
|
||||
Image(uiImage: UIImage(blurHash: blurhash, size: CGSize(width: 12, height: 12)) ??
|
||||
UIImage(blurHash: "001fC^", size: CGSize(width: 12, height: 12))!)
|
||||
.resizable()
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@ -73,9 +61,9 @@ struct ImageView: View {
|
||||
if let image = state.image {
|
||||
image
|
||||
} else if state.error != nil {
|
||||
failureImage().onAppear { sources.removeFirst() }
|
||||
placeholderView.onAppear { sources.removeFirst() }
|
||||
} else {
|
||||
placeholderView()
|
||||
placeholderView
|
||||
}
|
||||
}
|
||||
.pipeline(ImagePipeline(configuration: .withDataCache))
|
||||
|
@ -24,7 +24,8 @@ struct PortraitHeaderOverlayView: View {
|
||||
|
||||
// MARK: Portrait Image
|
||||
|
||||
ImageView(src: viewModel.item.portraitHeaderViewURL(maxWidth: 130))
|
||||
ImageView(src: viewModel.item.portraitHeaderViewURL(maxWidth: 130),
|
||||
bh: viewModel.item.getPrimaryImageBlurHash())
|
||||
.portraitPoster(width: 130)
|
||||
.accessibilityIgnoresInvertColors()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user