Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAYNEXT-832 Fix hero stage title and subtitle #520

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Application/Sources/UI/Helpers/MediaDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import SRGAppearanceSwift
case date
/// Time information emphasis
case time
/// Title information emphasis
case title
}

static func title(for media: SRGMedia, style: Style) -> String? {
Expand All @@ -32,6 +34,8 @@ import SRGAppearanceSwift
}
case .date, .time:
media.title
case .title:
media.title
}
}

Expand Down Expand Up @@ -59,6 +63,12 @@ import SRGAppearanceSwift
} else {
return formattedTime(for: media)
}
case .title:
if let show = media.show, !areRedundant(media: media, show: show) {
return show.title
} else {
return summary(for: media)
}
}
}

Expand Down Expand Up @@ -243,7 +253,7 @@ import SRGAppearanceSwift
}

private static func areRedundant(media: SRGMedia, show: SRGShow) -> Bool {
media.title.lowercased() == show.title.lowercased()
media.title.lowercased().contains(show.title.lowercased())
}

private static func shouldDisplayExpirationDate(for media: SRGMedia) -> Bool {
Expand Down
4 changes: 2 additions & 2 deletions Application/Sources/UI/Views/HeroMediaCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ struct HeroMediaCell: View {

private var subtitle: String? {
guard let media else { return nil }
return MediaDescription.subtitle(for: media, style: .show)
return MediaDescription.subtitle(for: media, style: .title)
}

private var title: String? {
guard let media else { return nil }
return MediaDescription.title(for: media, style: .show)
return MediaDescription.title(for: media, style: .title)
}

var body: some View {
Expand Down