Skip to content

Commit

Permalink
iOS 16 - tvOS 16 - Xcode 14 (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyby authored Sep 9, 2022
1 parent 957e96c commit 7cfa371
Show file tree
Hide file tree
Showing 62 changed files with 274 additions and 209 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "playback_speed.pdf",
"idiom" : "iphone"
},
{
"filename" : "playback_speed 1.pdf",
"idiom" : "ipad"
},
{
"filename" : "playback_speed-2.pdf",
"idiom" : "car"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions Application/Sources/Application/Navigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension UIViewController {

controller.publisher(for: \.continuousPlaybackUpcomingMedia)
.sink { upcomingMedia in
guard let upcomingMedia = upcomingMedia else { return }
guard let upcomingMedia else { return }

let labels = SRGAnalyticsHiddenEventLabels()
labels.source = AnalyticsSource.automatic.rawValue
Expand All @@ -60,7 +60,7 @@ extension UIViewController {
controller.playMedia(media, at: position, withPreferredSettings: nil)
present(letterboxViewController, animated: animated) {
SRGAnalyticsTracker.shared.trackPageView(withTitle: AnalyticsPageTitle.player.rawValue, levels: [AnalyticsPageLevel.play.rawValue])
if let completion = completion {
if let completion {
completion()
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ extension UIViewController {
Banner.showError(error)
}
} receiveValue: { [weak self] media in
guard let self = self else { return }
guard let self else { return }
self.play_presentMediaPlayer(with: media, position: nil, airPlaySuggestions: true, fromPushNotification: false, animated: animated) { _ in
let labels = SRGAnalyticsHiddenEventLabels()
labels.source = notification.showURN ?? AnalyticsSource.notification.rawValue
Expand Down Expand Up @@ -233,11 +233,11 @@ extension UIViewController {
case let .media(media):
play_presentMediaPlayer(with: media, position: nil, airPlaySuggestions: true, fromPushNotification: false, animated: animated, completion: nil)
case let .show(show):
guard let navigationController = navigationController else { return }
guard let navigationController else { return }
let showViewController = SectionViewController.showViewController(for: show)
navigationController.pushViewController(showViewController, animated: animated)
case let .topic(topic):
guard let navigationController = navigationController else { return }
guard let navigationController else { return }
let pageViewController = PageViewController(id: .topic(topic))
navigationController.pushViewController(pageViewController, animated: animated)
case let .download(download):
Expand Down
2 changes: 1 addition & 1 deletion Application/Sources/Bridges/SwiftMessagesBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class SwiftMessagesBridge: NSObject {
presentationController = presentationController?.parent
}

if let presentationController = presentationController {
if let presentationController {
config.presentationContext = .viewController(presentationController)
}

Expand Down
12 changes: 6 additions & 6 deletions Application/Sources/CarPlay/CarPlayList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private extension CarPlayList {
}

private static func playingPublisher(for mediaUrn: String?) -> AnyPublisher<Bool, Never> {
if let mediaUrn = mediaUrn {
if let mediaUrn {
return nowPlayingMediaPublisher()
.map { $0.map(\.urn).contains(mediaUrn) }
.eraseToAnyPublisher()
Expand Down Expand Up @@ -175,7 +175,7 @@ private extension CarPlayList {
}

private static func nowPlayingMedia(for controller: SRGLetterboxController?) -> [SRGMedia] {
guard let controller = controller else { return [] }
guard let controller else { return [] }

var medias: Set<SRGMedia> = []
if let mainMedia = controller.play_mainMedia {
Expand All @@ -189,8 +189,8 @@ private extension CarPlayList {

private static func nowPlayingMediaPublisher() -> AnyPublisher<[SRGMedia], Never> {
return SRGLetterboxService.shared.publisher(for: \.controller)
.map { controller -> AnyPublisher<[SRGMedia], Never> in
if let controller = controller {
.map { controller in
if let controller {
return NotificationCenter.default.weakPublisher(for: .SRGLetterboxMetadataDidChange, object: controller)
.map { notification in
let controller = notification.object as? SRGLetterboxController
Expand Down Expand Up @@ -266,7 +266,7 @@ private extension CarPlayList {
}
.switchToLatest()
.map { liveMediaDataList in
let items = liveMediaDataList.map { liveMediaData -> CPListItem in
let items = liveMediaDataList.map { liveMediaData in
let item = CPListItem(text: liveMediaData.media.channel?.title, detailText: nil, image: Self.logoImage(for: liveMediaData.media))
item.accessoryType = .none
item.handler = { _, completion in
Expand Down Expand Up @@ -350,7 +350,7 @@ private extension Publisher where Output == [SRGMedia] {
}
.switchToLatest()
.map { mediaDataList in
let items = mediaDataList.map { mediaData -> CPListItem in
let items = mediaDataList.map { mediaData in
let item = CPListItem(text: MediaDescription.title(for: mediaData.media, style: .show),
// Keep same media item height with a detail text in any cases.
detailText: MediaDescription.subtitle(for: mediaData.media, style: .show) ?? " ",
Expand Down
6 changes: 3 additions & 3 deletions Application/Sources/CarPlay/CarPlayNowPlayingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private extension CarPlayNowPlayingController {
}

private static func playbackRateButton(for interfaceController: CPInterfaceController) -> CPNowPlayingButton {
return CPNowPlayingImageButton(image: UIImage(systemName: "speedometer")!) { _ in
return CPNowPlayingImageButton(image: UIImage(named: "playback_speed", in: nil, compatibleWith: UITraitCollection(userInterfaceIdiom: .carPlay))!) { _ in
interfaceController.pushTemplate(CPListTemplate.playbackRate, animated: true) { _, _ in }
}
}
Expand Down Expand Up @@ -85,8 +85,8 @@ private extension CarPlayNowPlayingController {

private static func nowPlayingPropertiesPublisher(interfaceController: CPInterfaceController) -> AnyPublisher<NowPlayingProperties, Never> {
return SRGLetterboxService.shared.publisher(for: \.controller)
.map { controller -> AnyPublisher<NowPlayingProperties, Never> in
if let controller = controller {
.map { controller in
if let controller {
return Publishers.CombineLatest3(
controller.mediaPlayerController.publisher(for: \.timeRange),
NotificationCenter.default.weakPublisher(for: .SRGLetterboxPlaybackStateDidChange, object: controller),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class CarPlayPlaybackSpeedController {
guard let controller = SRGLetterboxService.shared.controller else { return [] }
let items = controller.supportedPlaybackRates
.map(\.floatValue)
.map { playbackRate -> CPListItem in
.map { playbackRate in
let item = CPListItem(
text: Self.text(forPlaybackRate: playbackRate, controller: controller),
detailText: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class CarPlayTemplateListController {
}
.receive(on: DispatchQueue.main)
.sink { [weak template] state in
guard let template = template else { return }
guard let template else { return }
switch state {
case let .failed(error: error):
template.emptyViewSubtitleVariants = [error.localizedDescription]
Expand Down
30 changes: 15 additions & 15 deletions Application/Sources/Content/PageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final class PageViewController: UIViewController {

#if os(iOS)
private static func showByDateViewController(radioChannel: RadioChannel?, date: Date?) -> UIViewController {
if let radioChannel = radioChannel {
if let radioChannel {
return CalendarViewController(radioChannel: radioChannel, date: date)
}
else if !ApplicationConfiguration.shared.isTvGuideUnavailable {
Expand Down Expand Up @@ -141,12 +141,12 @@ final class PageViewController: UIViewController {
}

let globalHeaderViewRegistration = UICollectionView.SupplementaryRegistration<HostSupplementaryView<TitleView>>(elementKind: Header.global.rawValue) { [weak self] view, _, _ in
guard let self = self else { return }
guard let self else { return }
view.content = TitleView(text: self.globalHeaderTitle)
}

let sectionHeaderViewRegistration = UICollectionView.SupplementaryRegistration<HostSupplementaryView<SectionHeaderView>>(elementKind: UICollectionView.elementKindSectionHeader) { [weak self] view, _, indexPath in
guard let self = self else { return }
guard let self else { return }
let snapshot = self.dataSource.snapshot()
let section = snapshot.sectionIdentifiers[indexPath.section]
view.content = SectionHeaderView(section: section, pageId: self.model.id)
Expand All @@ -170,14 +170,14 @@ final class PageViewController: UIViewController {
#if os(iOS)
model.$serviceMessage
.sink { serviceMessage in
guard let serviceMessage = serviceMessage else { return }
guard let serviceMessage else { return }
Banner.show(with: .error, message: serviceMessage.text, image: nil, sticky: true)
}
.store(in: &cancellables)

NotificationCenter.default.weakPublisher(for: UIAccessibility.voiceOverStatusDidChangeNotification)
.sink { [weak self] _ in
guard let self = self, self.play_isViewCurrent else { return }
guard let self, self.play_isViewCurrent else { return }
self.updateNavigationBar(animated: true)
}
.store(in: &cancellables)
Expand Down Expand Up @@ -330,25 +330,25 @@ extension PageViewController: UICollectionViewDelegate {
case let .media(media):
play_presentMediaPlayer(with: media, position: nil, airPlaySuggestions: true, fromPushNotification: false, animated: true, completion: nil)
case let .show(show):
if let navigationController = navigationController {
if let navigationController {
let showViewController = SectionViewController.showViewController(for: show)
navigationController.pushViewController(showViewController, animated: true)
}
case let .topic(topic):
if let navigationController = navigationController {
if let navigationController {
let pageViewController = PageViewController(id: .topic(topic))
navigationController.pushViewController(pageViewController, animated: true)
}
case .highlight:
if let navigationController = navigationController {
if let navigationController {
let sectionViewController = SectionViewController(section: section.wrappedValue, filter: model.id)
navigationController.pushViewController(sectionViewController, animated: true)
}
default:
()
}
case .more:
if let navigationController = navigationController {
if let navigationController {
let sectionViewController = SectionViewController(section: section.wrappedValue, filter: model.id)
navigationController.pushViewController(sectionViewController, animated: true)
}
Expand Down Expand Up @@ -431,13 +431,13 @@ extension PageViewController: PlayApplicationNavigation {
switch applicationSectionInfo.applicationSection {
case .showByDate:
let date = applicationSectionInfo.options?[ApplicationSectionOptionKey.showByDateDateKey] as? Date
if let navigationController = navigationController {
if let navigationController {
let showByDateViewController = Self.showByDateViewController(radioChannel: radioChannel, date: date)
navigationController.pushViewController(showByDateViewController, animated: false)
}
return true
case .showAZ:
if let navigationController = navigationController {
if let navigationController {
let initialSectionId = applicationSectionInfo.options?[ApplicationSectionOptionKey.showAZIndexKey] as? String
let showsViewController = SectionViewController.showsViewController(forChannelUid: radioChannel?.uid, initialSectionId: initialSectionId)
navigationController.pushViewController(showsViewController, animated: false)
Expand Down Expand Up @@ -479,14 +479,14 @@ extension PageViewController: SRGAnalyticsViewTracking {

extension PageViewController: ShowAccessCellActions {
func openShowAZ() {
if let navigationController = navigationController {
if let navigationController {
let showsViewController = SectionViewController.showsViewController(forChannelUid: radioChannel?.uid)
navigationController.pushViewController(showsViewController, animated: true)
}
}

func openShowByDate() {
if let navigationController = navigationController {
if let navigationController {
let showByDateViewController = Self.showByDateViewController(radioChannel: radioChannel, date: nil)
navigationController.pushViewController(showByDateViewController, animated: true)
}
Expand All @@ -495,7 +495,7 @@ extension PageViewController: ShowAccessCellActions {

extension PageViewController: SectionHeaderViewAction {
fileprivate func openSection(sender: Any?, event: OpenSectionEvent?) {
if let event = event, let navigationController = navigationController {
if let event, let navigationController {
let sectionViewController = SectionViewController(section: event.section.wrappedValue, filter: model.id)
navigationController.pushViewController(sectionViewController, animated: true)
}
Expand Down Expand Up @@ -620,7 +620,7 @@ private extension PageViewController {
}
}

guard let self = self else { return nil }
guard let self else { return nil }

let snapshot = self.dataSource.snapshot()
let section = snapshot.sectionIdentifiers[sectionIndex]
Expand Down
2 changes: 1 addition & 1 deletion Application/Sources/Content/PageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ final class PageViewModel: Identifiable, ObservableObject {
trigger.signal(activatedBy: TriggerId.reload),
ApplicationSignal.wokenUp()
.filter { [weak self] in
guard let self = self else { return false }
guard let self else { return false }
return self.state.sections.isEmpty
}
)
Expand Down
8 changes: 4 additions & 4 deletions Application/Sources/Content/Publishers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ extension SRGDataProvider {
Future<[String], Error> { promise in
let sortDescriptor = NSSortDescriptor(keyPath: \SRGHistoryEntry.date, ascending: false)
SRGUserData.current!.history.historyEntries(matching: nil, sortedWith: [sortDescriptor]) { historyEntries, error in
if let error = error {
if let error {
promise(.failure(error))
}
else {
Expand All @@ -114,7 +114,7 @@ extension SRGDataProvider {

func resumePlaybackPublisher(pageSize: UInt = SRGDataProviderDefaultPageSize, paginatedBy paginator: Trigger.Signal?, filter: SectionFiltering?) -> AnyPublisher<[SRGMedia], Error> {
func playbackPositions(for historyEntries: [SRGHistoryEntry]?) -> OrderedDictionary<String, TimeInterval> {
guard let historyEntries = historyEntries else { return [:] }
guard let historyEntries else { return [:] }

var playbackPositions = OrderedDictionary<String, TimeInterval>()
for historyEntry in historyEntries {
Expand All @@ -131,7 +131,7 @@ extension SRGDataProvider {
Future<OrderedDictionary<String, TimeInterval>, Error> { promise in
let sortDescriptor = NSSortDescriptor(keyPath: \SRGHistoryEntry.date, ascending: false)
SRGUserData.current!.history.historyEntries(matching: nil, sortedWith: [sortDescriptor]) { historyEntries, error in
if let error = error {
if let error {
promise(.failure(error))
}
else {
Expand Down Expand Up @@ -161,7 +161,7 @@ extension SRGDataProvider {
Future<[String], Error> { promise in
let sortDescriptor = NSSortDescriptor(keyPath: \SRGPlaylistEntry.date, ascending: false)
SRGUserData.current!.playlists.playlistEntriesInPlaylist(withUid: SRGPlaylistUid.watchLater.rawValue, matching: nil, sortedWith: [sortDescriptor]) { playlistEntries, error in
if let error = error {
if let error {
promise(.failure(error))
}
else {
Expand Down
2 changes: 1 addition & 1 deletion Application/Sources/Content/SectionShowHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private extension View {

enum SectionShowHeaderViewSize {
static func recommended(for section: Content.Section, show: SRGShow?, layoutWidth: CGFloat, horizontalSizeClass: UIUserInterfaceSizeClass) -> NSCollectionLayoutSize {
if let show = show {
if let show {
let fittingSize = CGSize(width: layoutWidth, height: UIView.layoutFittingExpandedSize.height)
let size = SectionShowHeaderView(section: section, show: show).adaptiveSizeThatFits(in: fittingSize, for: horizontalSizeClass)
return NSCollectionLayoutSize(widthDimension: .absolute(layoutWidth), heightDimension: .absolute(size.height))
Expand Down
Loading

0 comments on commit 7cfa371

Please sign in to comment.