From 7cbb80847a9d8c8eacb141f485fb7c7a3dc2f1b3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 21 Aug 2022 16:28:30 +0200 Subject: [PATCH] Minor quality profiles UI improvements (fix #272) --- Model/Stream.swift | 19 +++++++++++++++++-- Shared/Player/Controls/ControlsOverlay.swift | 6 +++--- Shared/Player/StreamControl.swift | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Model/Stream.swift b/Model/Stream.swift index 507e9b36..2f08c78f 100644 --- a/Model/Stream.swift +++ b/Model/Stream.swift @@ -108,6 +108,16 @@ class Stream: Equatable, Hashable, Identifiable { lhs.sortOrder < rhs.sortOrder } + var description: String { + switch self { + case .webm: + return "WebM" + + default: + return rawValue.uppercased() + } + } + static func from(_ string: String) -> Self { let lowercased = string.lowercased() @@ -172,8 +182,13 @@ class Stream: Equatable, Hashable, Identifiable { } var description: String { - let formatString = format == .unknown ? "" : " (\(format.rawValue))" - return "\(quality)\(formatString) - \(instance?.description ?? "")" + let instanceString = instance.isNil ? "" : " - (\(instance!.description))" + return "\(resolutionAndFormat)\(instanceString)" + } + + var resolutionAndFormat: String { + let formatString = format == .unknown ? "" : " (\(format.description))" + return "\(quality)\(formatString)" } var assets: [AVURLAsset] { diff --git a/Shared/Player/Controls/ControlsOverlay.swift b/Shared/Player/Controls/ControlsOverlay.swift index e1428f61..7cbb3586 100644 --- a/Shared/Player/Controls/ControlsOverlay.swift +++ b/Shared/Player/Controls/ControlsOverlay.swift @@ -245,7 +245,7 @@ struct ControlsOverlay: View { Menu { qualityProfilePicker } label: { - Text(player.qualityProfileSelection?.description ?? "Auto") + Text(player.qualityProfileSelection?.description ?? "Automatic") .frame(maxWidth: 240) } .transaction { t in t.animation = .none } @@ -259,7 +259,7 @@ struct ControlsOverlay: View { Button { presentingButtonHintAlert = true } label: { - Text(player.qualityProfileSelection?.description ?? "Auto") + Text(player.qualityProfileSelection?.description ?? "Automatic") .lineLimit(1) .frame(maxWidth: 320) } @@ -298,7 +298,7 @@ struct ControlsOverlay: View { Menu { StreamControl() } label: { - Text(player.streamSelection?.shortQuality ?? "loading") + Text(player.streamSelection?.resolutionAndFormat ?? "loading") .frame(width: 140, height: 40) .foregroundColor(.primary) } diff --git a/Shared/Player/StreamControl.swift b/Shared/Player/StreamControl.swift index c62c7e0d..92ada954 100644 --- a/Shared/Player/StreamControl.swift +++ b/Shared/Player/StreamControl.swift @@ -92,5 +92,6 @@ struct StreamControl: View { struct StreamControl_Previews: PreviewProvider { static var previews: some View { StreamControl() + .injectFixtureEnvironmentObjects() } }