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

PLAYRTS-5562 Open player if media highlight section as only one media #496

Merged
merged 2 commits into from
Jun 19, 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
9 changes: 9 additions & 0 deletions Application/Sources/Content/Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ protocol SectionProperties {
var supportsEdition: Bool { get }
var emptyType: EmptyContentView.`Type` { get }
var hasHighlightedItem: Bool { get }
var couldHaveHighlightedItem: Bool { get }

var displayedShow: SRGShow? { get }
#if os(iOS)
Expand Down Expand Up @@ -298,6 +299,10 @@ private extension Content {
presentation.type == .showPromotion
}

var couldHaveHighlightedItem: Bool {
presentation.type == .highlight
}

var displayedShow: SRGShow? {
show
}
Expand Down Expand Up @@ -678,6 +683,10 @@ private extension Content {
false
}

var couldHaveHighlightedItem: Bool {
false
}

var displayedShow: SRGShow? {
if case let .availableEpisodes(show) = configuredSection {
show
Expand Down
2 changes: 2 additions & 0 deletions Application/Sources/Content/PageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ extension PageViewController: UICollectionViewDelegate {
if case let .show(show) = highlightedItem {
let pageViewController = PageViewController(id: .show(show))
navigationController.pushViewController(pageViewController, animated: true)
} else if case let .media(media) = highlightedItem {
play_presentMediaPlayer(with: media, position: nil, airPlaySuggestions: true, fromPushNotification: false, animated: true, completion: nil)
} else {
let sectionViewController = SectionViewController(section: section.wrappedValue, filter: model.id)
navigationController.pushViewController(sectionViewController, animated: true)
Expand Down
4 changes: 3 additions & 1 deletion Application/Sources/Content/PageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,9 @@ private extension PageViewModel {
.map { items in
guard let firstItem = items.first else { return Row(section: section, items: []) }

let highlightedItem = section.properties.hasHighlightedItem ? firstItem : nil
let highlightedItem = section.properties.hasHighlightedItem ? firstItem :
section.properties.couldHaveHighlightedItem && items.count == 1 ? firstItem : nil

let item = Item(.item(.highlight(highlight, item: highlightedItem)), in: section)
return Row(section: section, items: [item])
}
Expand Down
2 changes: 2 additions & 0 deletions Application/Sources/UI/Views/HighlightCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ struct HighlightCell: View {
private func action() {
if case let .show(show) = item {
navigateToShow(show)
} else if case let .media(media) = item {
navigateToMedia(media)
} else {
navigateToSection(section, filter: filter)
}
Expand Down