Fix Episode Selector Images (#1047)

This commit is contained in:
Ethan Pippin 2024-04-28 06:02:01 -06:00 committed by GitHub
parent 936245e414
commit 329cf0d45f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 68 additions and 46 deletions

View File

@ -20,46 +20,60 @@ extension SeriesEpisodeSelector {
let episode: BaseItemDto
var body: some View {
PosterButton(
item: episode,
type: .landscape
)
.content {
let content: String = if episode.isUnaired {
episode.airDateLabel ?? L10n.noOverviewAvailable
@ViewBuilder
private var imageOverlay: some View {
ZStack {
if episode.userData?.isPlayed ?? false {
WatchedIndicator(size: 45)
} else {
episode.overview ?? L10n.noOverviewAvailable
if (episode.userData?.playbackPositionTicks ?? 0) > 0 {
LandscapePosterProgressBar(
title: episode.progressLabel ?? L10n.continue,
progress: (episode.userData?.playedPercentage ?? 0) / 100
)
}
}
}
}
private var episodeContent: String {
if episode.isUnaired {
episode.airDateLabel ?? L10n.noOverviewAvailable
} else {
episode.overview ?? L10n.noOverviewAvailable
}
}
var body: some View {
VStack(alignment: .leading) {
Button {
guard let mediaSource = episode.mediaSources?.first else { return }
router.route(to: \.videoPlayer, OnlineVideoPlayerManager(item: episode, mediaSource: mediaSource))
} label: {
ZStack {
Color.clear
ImageView(episode.imageSource(.primary, maxWidth: 500))
.failure {
SystemImageContentView(systemName: episode.systemImage)
}
imageOverlay
}
.posterStyle(.landscape)
}
.buttonStyle(.card)
.posterShadow()
SeriesEpisodeSelector.EpisodeContent(
subHeader: episode.episodeLocator ?? .emptyDash,
header: episode.displayTitle,
content: content
content: episodeContent
)
.onSelect {
router.route(to: \.item, episode)
}
}
.imageOverlay {
ZStack {
if episode.userData?.isPlayed ?? false {
WatchedIndicator(size: 45)
} else {
if (episode.userData?.playbackPositionTicks ?? 0) > 0 {
LandscapePosterProgressBar(
title: episode.progressLabel ?? L10n.continue,
progress: (episode.userData?.playedPercentage ?? 0) / 100
)
.padding()
}
}
}
}
.onSelect {
guard let mediaSource = episode.mediaSources?.first else { return }
router.route(to: \.videoPlayer, OnlineVideoPlayerManager(item: episode, mediaSource: mediaSource))
}
}
}
}

View File

@ -41,34 +41,42 @@ extension SeriesEpisodeSelector {
}
}
private var episodeContent: String {
if episode.isUnaired {
episode.airDateLabel ?? L10n.noOverviewAvailable
} else {
episode.overview ?? L10n.noOverviewAvailable
}
}
var body: some View {
PosterButton(
item: episode,
type: .landscape
)
.content {
let content: String = if episode.isUnaired {
episode.airDateLabel ?? L10n.noOverviewAvailable
} else {
episode.overview ?? L10n.noOverviewAvailable
VStack(alignment: .leading) {
Button {
guard let mediaSource = episode.mediaSources?.first else { return }
mainRouter.route(to: \.videoPlayer, OnlineVideoPlayerManager(item: episode, mediaSource: mediaSource))
} label: {
ZStack {
Color.clear
ImageView(episode.imageSource(.primary, maxWidth: 500))
.failure {
SystemImageContentView(systemName: episode.systemImage)
}
overlayView
}
.posterStyle(.landscape)
}
SeriesEpisodeSelector.EpisodeContent(
subHeader: episode.episodeLocator ?? .emptyDash,
header: episode.displayTitle,
content: content
content: episodeContent
)
.onSelect {
router.route(to: \.item, episode)
}
}
.imageOverlay {
overlayView
}
.onSelect {
guard let mediaSource = episode.mediaSources?.first else { return }
mainRouter.route(to: \.videoPlayer, OnlineVideoPlayerManager(item: episode, mediaSource: mediaSource))
}
}
}
}