Merge pull request #356 from LePips/various-ui-changes

This commit is contained in:
Ethan Pippin 2022-01-30 07:42:01 -08:00 committed by GitHub
commit 3131c7c651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 23 deletions

View File

@ -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 }

View File

@ -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^"
}

View File

@ -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))

View File

@ -99,7 +99,7 @@ struct ContinueWatchingView: View {
Button(role: .destructive) {
viewModel.removeItemFromResume(item)
} label: {
L10n.removeFromResume.text
Label(L10n.removeFromResume, systemImage: "minus.circle")
}
}
}

View File

@ -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()