mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Fix tvOS controls overlay buttons
This commit is contained in:
@@ -91,6 +91,13 @@ struct ControlsOverlay: View {
|
||||
#if os(tvOS)
|
||||
.padding(.horizontal, 40)
|
||||
#endif
|
||||
|
||||
#if os(tvOS)
|
||||
Text("Press and hold remote button to open captions and quality menus")
|
||||
.frame(maxWidth: 400)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
#endif
|
||||
}
|
||||
.frame(maxHeight: overlayHeight)
|
||||
#if os(tvOS)
|
||||
@@ -105,7 +112,7 @@ struct ControlsOverlay: View {
|
||||
|
||||
private var overlayHeight: Double {
|
||||
#if os(tvOS)
|
||||
contentSize.height + 50.0
|
||||
contentSize.height + 80.0
|
||||
#else
|
||||
contentSize.height
|
||||
#endif
|
||||
@@ -255,9 +262,7 @@ struct ControlsOverlay: View {
|
||||
.modifier(ControlBackgroundModifier())
|
||||
.mask(RoundedRectangle(cornerRadius: 3))
|
||||
#else
|
||||
Button {
|
||||
presentingButtonHintAlert = true
|
||||
} label: {
|
||||
ControlsOverlayButton(focusedField: $focusedField, field: .qualityProfile) {
|
||||
Text(player.qualityProfileSelection?.description ?? "Automatic")
|
||||
.lineLimit(1)
|
||||
.frame(maxWidth: 320)
|
||||
@@ -309,7 +314,7 @@ struct ControlsOverlay: View {
|
||||
.modifier(ControlBackgroundModifier())
|
||||
.mask(RoundedRectangle(cornerRadius: 3))
|
||||
#else
|
||||
StreamControl(presentingButtonHintAlert: $presentingButtonHintAlert)
|
||||
StreamControl(focusedField: $focusedField)
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -339,9 +344,7 @@ struct ControlsOverlay: View {
|
||||
.modifier(ControlBackgroundModifier())
|
||||
.mask(RoundedRectangle(cornerRadius: 3))
|
||||
#else
|
||||
Button {
|
||||
presentingButtonHintAlert = true
|
||||
} label: {
|
||||
ControlsOverlayButton(focusedField: $focusedField, field: .captions) {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "text.bubble")
|
||||
if let captions = captionsBinding.wrappedValue {
|
||||
|
@@ -1,14 +1,16 @@
|
||||
import SwiftUI
|
||||
|
||||
struct StreamControl: View {
|
||||
@Binding var presentingButtonHintAlert: Bool
|
||||
#if os(tvOS)
|
||||
var focusedField: FocusState<ControlsOverlay.Field?>.Binding?
|
||||
|
||||
init(focusedField: FocusState<ControlsOverlay.Field?>.Binding?) {
|
||||
self.focusedField = focusedField
|
||||
}
|
||||
#endif
|
||||
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
|
||||
init(presentingButtonHintAlert: Binding<Bool> = .constant(false)) {
|
||||
_presentingButtonHintAlert = presentingButtonHintAlert
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
#if !os(tvOS)
|
||||
@@ -36,9 +38,7 @@ struct StreamControl: View {
|
||||
.disabled(player.isLoadingAvailableStreams)
|
||||
#endif
|
||||
#else
|
||||
Button {
|
||||
presentingButtonHintAlert = true
|
||||
} label: {
|
||||
ControlsOverlayButton(focusedField: focusedField!, field: .stream) {
|
||||
Text(player.streamSelection?.shortQuality ?? "loading")
|
||||
.frame(maxWidth: 320)
|
||||
}
|
||||
@@ -51,7 +51,6 @@ struct StreamControl: View {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
.transaction { t in t.animation = .none }
|
||||
.onChange(of: player.streamSelection) { selection in
|
||||
guard let selection = selection else { return }
|
||||
@@ -72,7 +71,11 @@ struct StreamControl: View {
|
||||
|
||||
struct StreamControl_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
StreamControl()
|
||||
.injectFixtureEnvironmentObjects()
|
||||
#if os(tvOS)
|
||||
StreamControl(focusedField: .none)
|
||||
.injectFixtureEnvironmentObjects()
|
||||
#else
|
||||
StreamControl()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user