Skip to content

Commit

Permalink
PLAYNEXT-832 Fix hero stage title and subtitle (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyby authored Oct 17, 2024
1 parent c317d60 commit e551c9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
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

0 comments on commit e551c9a

Please sign in to comment.