Skip to content

Commit

Permalink
Improve Control Center display in presence of errors (#769)
Browse files Browse the repository at this point in the history
Co-authored-by: Samuel Défago <[email protected]>
  • Loading branch information
waliid and defagos authored Feb 26, 2024
1 parent 4098d6f commit 6e87af4
Show file tree
Hide file tree
Showing 86 changed files with 855 additions and 669 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"pins" : [
{
"identity" : "combineext",
"kind" : "remoteSourceControl",
"location" : "https://github.com/CombineCommunity/CombineExt.git",
"state" : {
"revision" : "d7b896fa9ca8b47fa7bcde6b43ef9b70bf8c1f56",
"version" : "1.8.1"
}
},
{
"identity" : "comscore-swift-package-manager",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -41,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/CommandersAct/iOSV5.git",
"state" : {
"revision" : "1350bca4163cfdd62d1508068601817d86d9f4a5",
"version" : "5.4.4"
"revision" : "c699709090afee22a2b72078d753b729218b70ba",
"version" : "5.4.5"
}
},
{
Expand Down Expand Up @@ -77,8 +86,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "f0b14e200e39921d1df720e305f11ca6acb72a17",
"version" : "13.1.1"
"revision" : "efe11bbca024b57115260709b5c05e01131470d0",
"version" : "13.2.1"
}
},
{
Expand Down Expand Up @@ -122,8 +131,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "d029d9d39c87bed85b1c50adee7c41795261a192",
"version" : "1.0.6"
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
Expand Down
6 changes: 4 additions & 2 deletions Demo/Sources/Examples/ExamplesViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ final class ExamplesViewModel: ObservableObject {
])

let cornerCaseMedias = Template.medias(from: [
URNTemplate.expired,
URNTemplate.unknown,
URLTemplate.unauthorized
URNTemplate.expired,
URLTemplate.unknown,
URLTemplate.unauthorized,
URLTemplate.unavailableMp3
])

@Published private(set) var protectedMedias = [Media]()
Expand Down
4 changes: 2 additions & 2 deletions Demo/Sources/Model/MediaDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum MediaDescription {
case disabled
}

private static var dateFormatter: DateFormatter = {
private static let dateFormatter = {
let formatter = DateFormatter()
formatter.timeZone = TimeZone(identifier: "Europe/Zurich")
formatter.dateStyle = .long
Expand All @@ -21,7 +21,7 @@ enum MediaDescription {
return formatter
}()

private static var minuteFormatter: DateComponentsFormatter = {
private static let minuteFormatter = {
let formatter = DateComponentsFormatter()
formatter.allowedUnits = .minute
formatter.unitsStyle = .short
Expand Down
9 changes: 8 additions & 1 deletion Demo/Sources/Model/Playlist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ enum Playlist {
URLTemplate.onDemandVideoHLS
]

static let videosWithOneFailingMp3Url: [Template] = [
URLTemplate.shortOnDemandVideoHLS,
URLTemplate.unavailableMp3,
URLTemplate.onDemandVideoHLS
]

static let videosWithOneFailingUrn: [Template] = [
URNTemplate.onDemandVideo,
URNTemplate.unknown,
Expand All @@ -188,6 +194,7 @@ enum Playlist {
URNTemplate.unknown,
URLTemplate.unknown,
URNTemplate.expired,
URLTemplate.unauthorized
URLTemplate.unauthorized,
URLTemplate.unavailableMp3
]
}
12 changes: 8 additions & 4 deletions Demo/Sources/Model/Template.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ enum URLTemplate {
type: .url("https://rts-vod-amd.akamaized.net/ww/13317145/f1d49f18-f302-37ce-866c-1c1c9b76a824/master.m3u8")
)
static let onDemandVideoMP4 = Template(
title: "The dig",
title: "Swiss wheelchair athlete wins top award",
description: "VOD - MP4",
// swiftlint:disable:next line_length
imageUrl: "https://www.swissinfo.ch/resource/image/47686506/landscape_ratio3x2/280/187/347ee14103b1b86184659b2fd04c69ba/8C028539EC620EFACC0BF2F61591E2F8/img_8527.jpg",
type: .url("https://media.swissinfo.ch/media/video/dddaff93-c2cd-4b6e-bdad-55f75a519480/rendition/154a844b-de1d-4854-93c1-5c61cd07e98c.mp4")
imageUrl: "https://cdn.prod.swi-services.ch/video-delivery/images/94f5f5d1-5d53-4336-afda-9198462c45d9/_.1hAGinujJ.yERGrrGNzBGCNSxmhKZT/16x9",
type: .url("https://cdn.prod.swi-services.ch/video-projects/94f5f5d1-5d53-4336-afda-9198462c45d9/localised-videos/ENG/renditions/ENG.mp4")
)
static let liveVideoHLS = Template(
title: "Couleur 3 en vidéo (live)",
Expand Down Expand Up @@ -134,6 +133,11 @@ enum URLTemplate {
description: "Content that does not exist",
type: .url("http://localhost:8123/simple/unavailable/master.m3u8")
)
static let unavailableMp3 = Template(
title: "Unavailable MP3",
description: "MP3 that does not exist",
type: .url("http://localhost:8123/simple/unavailable.mp3")
)
static let unauthorized = Template(
title: "Unauthorized URL",
description: "Content which cannot be accessed",
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Players/InlineSystemPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct InlineSystemPlayerView: View {
}

extension InlineSystemPlayerView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
22 changes: 8 additions & 14 deletions Demo/Sources/Players/PlayerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ import Foundation
import PillarboxPlayer

extension PlayerConfiguration {
static var standard: Self {
let userDefaults = UserDefaults.standard
return .init(
usesExternalPlaybackWhileMirroring: !userDefaults.presenterModeEnabled,
smartNavigationEnabled: userDefaults.smartNavigationEnabled
)
}
static let standard = Self(
usesExternalPlaybackWhileMirroring: !UserDefaults.standard.presenterModeEnabled,
smartNavigationEnabled: UserDefaults.standard.smartNavigationEnabled
)

static var externalPlaybackDisabled: Self {
let userDefaults = UserDefaults.standard
return .init(
allowsExternalPlayback: false,
smartNavigationEnabled: userDefaults.smartNavigationEnabled
)
}
static let externalPlaybackDisabled = Self(
allowsExternalPlayback: false,
smartNavigationEnabled: UserDefaults.standard.smartNavigationEnabled
)
}
2 changes: 1 addition & 1 deletion Demo/Sources/Players/PlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension PlayerView {
}

extension PlayerView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Players/SimplePlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct SimplePlayerView: View {
}

extension SimplePlayerView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Players/SystemPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension SystemPlayerView {
}

extension SystemPlayerView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Players/VanillaPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct VanillaPlayerView: View {
}

extension VanillaPlayerView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

// Workaround for FB13126425. Makes it possible to use `AVPlayer` as `@ObservableObject` to avoid memory leaks
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Search/SearchViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class SearchViewModel: ObservableObject, Refreshable {
case loadMore
}

private static var settings: SRGMediaSearchSettings = {
private static let settings = {
let settings = SRGMediaSearchSettings()
settings.aggregationsEnabled = false
return settings
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/BlurredView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct BlurredView: View {
}

extension BlurredView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/LinkView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct LinkView: View {
}

extension LinkView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/Multi/MultiView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct MultiView: View {
}

extension MultiView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/OptInView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct OptInView: View {
}

extension OptInView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/Playlist/PlaylistView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct PlaylistView: View {
}

extension PlaylistView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
1 change: 1 addition & 0 deletions Demo/Sources/Showcase/Playlist/PlaylistViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ final class PlaylistViewModel: ObservableObject, PictureInPicturePersistable {
URLTemplate.bitmovin_360,
URLTemplate.unauthorized,
URLTemplate.unknown,
URLTemplate.unavailableMp3,
URNTemplate.expired,
URNTemplate.unknown
]
Expand Down
5 changes: 5 additions & 0 deletions Demo/Sources/Showcase/ShowcaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct ShowcaseView: View {

@ViewBuilder
private func playlistsSection() -> some View {
// swiftlint:disable:previous function_body_length
// swiftlint:disable:next closure_body_length
CustomSection("Playlists") {
cell(
Expand All @@ -101,6 +102,10 @@ struct ShowcaseView: View {
title: "Videos (URLs, one failing)",
destination: .playlist(templates: Playlist.videosWithOneFailingUrl)
)
cell(
title: "Videos (URLs, one failing MP3)",
destination: .playlist(templates: Playlist.videosWithOneFailingMp3Url)
)
cell(
title: "Videos (URNs, one failing)",
destination: .playlist(templates: Playlist.videosWithOneFailingUrn)
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/Stories/StoriesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct StoriesView: View {
}

extension StoriesView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/TransitionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private extension Player {
}

extension TransitionView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/TwinsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private extension TwinsView {
}

extension TwinsView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Showcase/Wrapped/WrappedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct WrappedView: View {
}

extension WrappedView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}

#Preview {
Expand Down
4 changes: 1 addition & 3 deletions Demo/Sources/Tools/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import SwiftUI
let kPageSize: UInt = 50

extension Animation {
static var defaultLinear: Animation {
.linear(duration: 0.2)
}
static let defaultLinear = Self.linear(duration: 0.2)
}

func constant<T>(iOS: T, tvOS: T) -> T {
Expand Down
2 changes: 1 addition & 1 deletion Demo/Sources/Views/WebView~ios.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ private struct SafariWebView: UIViewControllerRepresentable {
}

extension WebView: SourceCodeViewable {
static var filePath: String { #file }
static let filePath = #file
}
17 changes: 13 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"pins" : [
{
"identity" : "combineext",
"kind" : "remoteSourceControl",
"location" : "https://github.com/CombineCommunity/CombineExt.git",
"state" : {
"revision" : "d7b896fa9ca8b47fa7bcde6b43ef9b70bf8c1f56",
"version" : "1.8.1"
}
},
{
"identity" : "comscore-swift-package-manager",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -41,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/CommandersAct/iOSV5.git",
"state" : {
"revision" : "1350bca4163cfdd62d1508068601817d86d9f4a5",
"version" : "5.4.4"
"revision" : "c699709090afee22a2b72078d753b729218b70ba",
"version" : "5.4.5"
}
},
{
Expand All @@ -59,8 +68,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "d029d9d39c87bed85b1c50adee7c41795261a192",
"version" : "1.0.6"
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/CombineCommunity/CombineExt.git", .upToNextMinor(from: "1.8.1")),
.package(url: "https://github.com/comScore/Comscore-Swift-Package-Manager.git", .upToNextMinor(from: "6.11.0")),
.package(url: "https://github.com/CommandersAct/iOSV5.git", .upToNextMinor(from: "5.4.4")),
.package(url: "https://github.com/apple/swift-collections.git", .upToNextMajor(from: "1.0.3")),
Expand Down Expand Up @@ -84,6 +85,7 @@ let package = Package(
name: "PillarboxPlayer",
dependencies: [
.target(name: "PillarboxCore"),
.product(name: "CombineExt", package: "CombineExt"),
.product(name: "DequeModule", package: "swift-collections"),
.product(name: "TimelaneCombine", package: "TimelaneCombine")
],
Expand Down
Loading

0 comments on commit 6e87af4

Please sign in to comment.