mirror of
https://github.com/yattee/yattee.git
synced 2025-11-25 02:38:29 +00:00
Improve tvOS controls overlay with single-press menus
Changed context menus from press-and-hold to single-press for better UX: - Quality profile selection - Stream quality selection - Captions selection - Audio track selection Updated ControlsOverlayButton to support tap actions via new onSelect parameter. Replaced .contextMenu modifiers with .alert for instant menu access on tvOS. Removed hint text and unnecessary 80px padding as single-press is self-evident.
This commit is contained in:
@@ -3,9 +3,11 @@ import SwiftUI
|
||||
struct StreamControl: View {
|
||||
#if os(tvOS)
|
||||
var focusedField: FocusState<ControlsOverlay.Field?>.Binding?
|
||||
@Binding var presentingStreamMenu: Bool
|
||||
|
||||
init(focusedField: FocusState<ControlsOverlay.Field?>.Binding?) {
|
||||
init(focusedField: FocusState<ControlsOverlay.Field?>.Binding?, presentingStreamMenu: Binding<Bool>) {
|
||||
self.focusedField = focusedField
|
||||
_presentingStreamMenu = presentingStreamMenu
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -45,16 +47,20 @@ struct StreamControl: View {
|
||||
.fixedSize()
|
||||
#endif
|
||||
#else
|
||||
ControlsOverlayButton(focusedField: focusedField!, field: .stream) {
|
||||
ControlsOverlayButton(
|
||||
focusedField: focusedField!,
|
||||
field: .stream,
|
||||
onSelect: { presentingStreamMenu = true }
|
||||
) {
|
||||
Text(player.streamSelection?.shortQuality ?? "loading")
|
||||
.frame(maxWidth: 320)
|
||||
}
|
||||
.contextMenu {
|
||||
.alert("Stream Quality", isPresented: $presentingStreamMenu) {
|
||||
ForEach(streams) { stream in
|
||||
Button(stream.description) { player.streamSelection = stream }
|
||||
}
|
||||
|
||||
Button("Close", role: .cancel) {}
|
||||
Button("Cancel", role: .cancel) {}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -79,7 +85,7 @@ struct StreamControl: View {
|
||||
struct StreamControl_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
#if os(tvOS)
|
||||
StreamControl(focusedField: .none)
|
||||
StreamControl(focusedField: .none, presentingStreamMenu: .constant(false))
|
||||
.injectFixtureEnvironmentObjects()
|
||||
#else
|
||||
StreamControl()
|
||||
|
||||
Reference in New Issue
Block a user