Skip to content

Commit

Permalink
PLAYNEXT-704 Adapt show access to new channel presentation with actio…
Browse files Browse the repository at this point in the history
…n sheet
  • Loading branch information
mutaben committed Jan 28, 2025
1 parent c157829 commit 6d60012
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
8 changes: 3 additions & 5 deletions Application/Sources/Content/PageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ extension PageViewController: UIScrollViewDelegate {
case .showAZ:
if let navigationController {
let initialSectionId = applicationSectionInfo.options?[ApplicationSectionOptionKey.showAZIndexKey] as? String
let showsViewController = SectionViewController.showsViewController(for: .radio, channelUid: radioChannel?.uid, initialSectionId: initialSectionId)
navigationController.pushViewController(showsViewController, animated: false)
SectionViewController.openShowsViewController(for: .radio, channelUid: radioChannel?.uid, initialSectionId: initialSectionId, in: navigationController, sourceView: nil)
}
return true
default:
Expand All @@ -651,10 +650,9 @@ extension PageViewController: UIScrollViewDelegate {
}

extension PageViewController: ShowAccessCellActions {
func openShowAZ(sender _: Any?, event: ShowAccessEvent?) {
func openShowAZ(sender: Any?, event: ShowAccessEvent?) {
if let navigationController, let event {
let showsViewController = SectionViewController.showsViewController(for: event.transmission, channelUid: radioChannel?.uid)
navigationController.pushViewController(showsViewController, animated: true)
SectionViewController.openShowsViewController(for: event.transmission, channelUid: radioChannel?.uid, in: navigationController, sourceView: sender as? UIView)
}
}

Expand Down
31 changes: 23 additions & 8 deletions Application/Sources/Content/SectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,34 @@ extension SectionViewController {
}
}

static func showsViewController(for transmission: SRGTransmission, channelUid: String?, initialSectionId: String?) -> SectionViewController {
static func openShowsViewController(for transmission: SRGTransmission, channelUid: String?, initialSectionId: String?, in navigationController: UINavigationController, sourceView: UIView?) {
if transmission == .radio, let channelUid {
SectionViewController(section: .configured(.radioAllShows(channelUid: channelUid)), initialSectionId: initialSectionId)
} else if transmission == .radio, let channelUid = ApplicationConfiguration.shared.radioHomepageChannels.first?.uid {
// FIXME: Load all radio A to Z shows, not only from the first channel.
SectionViewController(section: .configured(.radioAllShows(channelUid: channelUid)), initialSectionId: initialSectionId)
navigationController.pushViewController(SectionViewController(section: .configured(.radioAllShows(channelUid: channelUid)), initialSectionId: initialSectionId), animated: true)
} else if transmission == .radio {
let radiosForAZAccess = ApplicationConfiguration.shared.radioHomepageChannels
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

let actions = radiosForAZAccess.map { (name: $0.name, uid: $0.uid) }

for action in actions {
actionSheet.addAction(UIAlertAction(title: action.name, style: .default, handler: { _ in
navigationController.pushViewController(SectionViewController(section: .configured(.radioAllShows(channelUid: action.uid)), initialSectionId: initialSectionId), animated: true)
}))
}

actionSheet.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: "Cancel button of action sheet"), style: .cancel, handler: { _ in
navigationController.dismiss(animated: true)
}))

actionSheet.popoverPresentationController?.sourceView = sourceView
navigationController.present(actionSheet, animated: true)
} else {
SectionViewController(section: .configured(.tvAllShows), initialSectionId: initialSectionId)
navigationController.pushViewController(SectionViewController(section: .configured(.tvAllShows), initialSectionId: initialSectionId), animated: true)
}
}

static func showsViewController(for transmission: SRGTransmission, channelUid: String?) -> SectionViewController {
showsViewController(for: transmission, channelUid: channelUid, initialSectionId: nil)
static func openShowsViewController(for transmission: SRGTransmission, channelUid: String?, in navigationController: UINavigationController, sourceView: UIView?) {
openShowsViewController(for: transmission, channelUid: channelUid, initialSectionId: nil, in: navigationController, sourceView: sourceView)
}
}

Expand Down

0 comments on commit 6d60012

Please sign in to comment.