mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 14:03:41 +00:00
Fix stream picker
This commit is contained in:
parent
95296b34b5
commit
8d7cebd908
@ -11,47 +11,30 @@ struct StreamControl: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Group {
|
Group {
|
||||||
#if os(macOS)
|
#if !os(tvOS)
|
||||||
Picker("", selection: $player.streamSelection) {
|
Picker("", selection: $player.streamSelection) {
|
||||||
ForEach(InstancesModel.all) { instance in
|
if !availableStreamsByKind.values.isEmpty {
|
||||||
let instanceStreams = availableStreamsForInstance(instance)
|
let kinds = Array(availableStreamsByKind.keys).sorted { $0 < $1 }
|
||||||
if !instanceStreams.values.isEmpty {
|
|
||||||
let kinds = Array(instanceStreams.keys).sorted { $0 < $1 }
|
|
||||||
|
|
||||||
Section(header: Text(instance.longDescription)) {
|
ForEach(kinds, id: \.self) { key in
|
||||||
ForEach(kinds, id: \.self) { key in
|
ForEach(availableStreamsByKind[key] ?? []) { stream in
|
||||||
ForEach(instanceStreams[key] ?? []) { stream in
|
Text(stream.description).tag(Stream?.some(stream))
|
||||||
Text(stream.description).tag(Stream?.some(stream))
|
|
||||||
}
|
|
||||||
|
|
||||||
if kinds.count > 1 {
|
|
||||||
Divider()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if os(macOS)
|
||||||
|
if kinds.count > 1 {
|
||||||
|
Divider()
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.disabled(player.isLoadingAvailableStreams)
|
.disabled(player.isLoadingAvailableStreams)
|
||||||
|
#if os(iOS)
|
||||||
#elseif os(iOS)
|
.frame(minWidth: 110)
|
||||||
Picker("", selection: $player.streamSelection) {
|
.fixedSize(horizontal: true, vertical: true)
|
||||||
ForEach(InstancesModel.all) { instance in
|
.disabled(player.isLoadingAvailableStreams)
|
||||||
let instanceStreams = availableStreamsForInstance(instance)
|
#endif
|
||||||
if !instanceStreams.values.isEmpty {
|
|
||||||
let kinds = Array(instanceStreams.keys).sorted { $0 < $1 }
|
|
||||||
|
|
||||||
ForEach(kinds, id: \.self) { key in
|
|
||||||
ForEach(instanceStreams[key] ?? []) { stream in
|
|
||||||
Text(stream.description).tag(Stream?.some(stream))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.frame(minWidth: 110)
|
|
||||||
.fixedSize(horizontal: true, vertical: true)
|
|
||||||
.disabled(player.isLoadingAvailableStreams)
|
|
||||||
#else
|
#else
|
||||||
Button {
|
Button {
|
||||||
presentingButtonHintAlert = true
|
presentingButtonHintAlert = true
|
||||||
@ -78,10 +61,8 @@ struct StreamControl: View {
|
|||||||
.frame(alignment: .trailing)
|
.frame(alignment: .trailing)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func availableStreamsForInstance(_ instance: Instance) -> [Stream.Kind: [Stream]] {
|
private var availableStreamsByKind: [Stream.Kind: [Stream]] {
|
||||||
let streams = streams.filter { $0.instance == instance }.filter { player.backend.canPlay($0) }
|
Dictionary(grouping: streams, by: \.kind!)
|
||||||
|
|
||||||
return Dictionary(grouping: streams, by: \.kind!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var streams: [Stream] {
|
var streams: [Stream] {
|
||||||
|
Loading…
Reference in New Issue
Block a user