From a49b0edc6887088f29579f355e0bbb1096a4d473 Mon Sep 17 00:00:00 2001 From: Brendan Perry Date: Tue, 31 Oct 2023 04:22:55 +0000 Subject: [PATCH] Prioritize backdrop image for cinematic background (#893) Co-authored-by: Brendan Perry <=> --- Shared/Extensions/JellyfinAPI/BaseItemDto+Poster.swift | 9 +++++++++ Shared/Objects/Poster.swift | 5 +++++ Swiftfin tvOS/Components/CinematicBackgroundView.swift | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Shared/Extensions/JellyfinAPI/BaseItemDto+Poster.swift b/Shared/Extensions/JellyfinAPI/BaseItemDto+Poster.swift index 36466136..1be821e6 100644 --- a/Shared/Extensions/JellyfinAPI/BaseItemDto+Poster.swift +++ b/Shared/Extensions/JellyfinAPI/BaseItemDto+Poster.swift @@ -74,4 +74,13 @@ extension BaseItemDto: Poster { ] } } + + func cinematicPosterImageSources() -> [ImageSource] { + switch type { + case .episode: + return [seriesImageSource(.backdrop, maxWidth: UIScreen.main.bounds.width)] + default: + return [imageSource(.backdrop, maxWidth: UIScreen.main.bounds.width)] + } + } } diff --git a/Shared/Objects/Poster.swift b/Shared/Objects/Poster.swift index ce9187cf..44a665f8 100644 --- a/Shared/Objects/Poster.swift +++ b/Shared/Objects/Poster.swift @@ -15,6 +15,7 @@ protocol Poster: Displayable, Hashable { func portraitPosterImageSource(maxWidth: CGFloat) -> ImageSource func landscapePosterImageSources(maxWidth: CGFloat, single: Bool) -> [ImageSource] + func cinematicPosterImageSources() -> [ImageSource] } extension Poster { @@ -22,4 +23,8 @@ extension Poster { hasher.combine(displayTitle) hasher.combine(subtitle) } + + func cinematicPosterImageSources() -> [ImageSource] { + [] + } } diff --git a/Swiftfin tvOS/Components/CinematicBackgroundView.swift b/Swiftfin tvOS/Components/CinematicBackgroundView.swift index a49f7ee2..7d4d9e78 100644 --- a/Swiftfin tvOS/Components/CinematicBackgroundView.swift +++ b/Swiftfin tvOS/Components/CinematicBackgroundView.swift @@ -26,7 +26,7 @@ struct CinematicBackgroundView: View { RotateContentView(proxy: proxy) .onChange(of: viewModel.currentItem) { newItem in proxy.update { - ImageView(newItem?.landscapePosterImageSources(maxWidth: UIScreen.main.bounds.width, single: false) ?? []) + ImageView(newItem?.cinematicPosterImageSources() ?? []) .placeholder { Color.clear }