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