From c5738ee14ae1d4bb513775422f58c413fb80accb Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 15 Aug 2022 00:17:00 +0200 Subject: [PATCH] tvOS buttons hint --- Shared/Player/Controls/ControlsOverlay.swift | 25 ++++++++++++++++---- Shared/Player/StreamControl.swift | 10 +++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Shared/Player/Controls/ControlsOverlay.swift b/Shared/Player/Controls/ControlsOverlay.swift index 407931a8..e565ae02 100644 --- a/Shared/Player/Controls/ControlsOverlay.swift +++ b/Shared/Player/Controls/ControlsOverlay.swift @@ -21,6 +21,7 @@ struct ControlsOverlay: View { } @FocusState private var focusedField: Field? + @State private var presentingButtonHintAlert = false #endif var body: some View { @@ -57,7 +58,13 @@ struct ControlsOverlay: View { #endif } - Section(header: controlsHeader("Stream & Player")) { + #if os(tvOS) + let streamAndPlayerHeaderText = "Stream" + #else + let streamAndPlayerHeaderText = "Stream & Player" + #endif + + Section(header: controlsHeader(streamAndPlayerHeaderText)) { qualityButton #if os(tvOS) .focused($focusedField, equals: .stream) @@ -96,6 +103,9 @@ struct ControlsOverlay: View { } .frame(maxHeight: overlayHeight) #if os(tvOS) + .alert(isPresented: $presentingButtonHintAlert) { + Alert(title: Text("Press and hold to open this menu")) + } .onAppear { focusedField = .qualityProfile } @@ -255,14 +265,17 @@ struct ControlsOverlay: View { .modifier(ControlBackgroundModifier()) .mask(RoundedRectangle(cornerRadius: 3)) #else - Button {} label: { + Button { + presentingButtonHintAlert = true + } label: { Text(player.qualityProfileSelection?.description ?? "Auto") .lineLimit(1) .frame(maxWidth: 320) } .contextMenu { + Button("Automatic") { player.qualityProfileSelection = nil } + ForEach(qualityProfiles) { qualityProfile in - Button("Default") { player.qualityProfileSelection = nil } Button { player.qualityProfileSelection = qualityProfile } label: { @@ -306,7 +319,7 @@ struct ControlsOverlay: View { .modifier(ControlBackgroundModifier()) .mask(RoundedRectangle(cornerRadius: 3)) #else - StreamControl() + StreamControl(presentingButtonHintAlert: $presentingButtonHintAlert) #endif } @@ -336,7 +349,9 @@ struct ControlsOverlay: View { .modifier(ControlBackgroundModifier()) .mask(RoundedRectangle(cornerRadius: 3)) #else - Button {} label: { + Button { + presentingButtonHintAlert = true + } label: { HStack(spacing: 8) { Image(systemName: "text.bubble") if let captions = captionsBinding.wrappedValue { diff --git a/Shared/Player/StreamControl.swift b/Shared/Player/StreamControl.swift index 6a2fbcb4..d2ae9025 100644 --- a/Shared/Player/StreamControl.swift +++ b/Shared/Player/StreamControl.swift @@ -1,8 +1,14 @@ import SwiftUI struct StreamControl: View { + @Binding var presentingButtonHintAlert: Bool + @EnvironmentObject private var player + init(presentingButtonHintAlert: Binding = .constant(false)) { + _presentingButtonHintAlert = presentingButtonHintAlert + } + var body: some View { Group { #if os(macOS) @@ -47,7 +53,9 @@ struct StreamControl: View { .fixedSize(horizontal: true, vertical: true) .disabled(player.isLoadingAvailableStreams) #else - Button {} label: { + Button { + presentingButtonHintAlert = true + } label: { Text(player.streamSelection?.shortQuality ?? "loading") .frame(maxWidth: 320) }