2021-11-08 23:14:28 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct MenuCommands: Commands {
|
|
|
|
@Binding var model: MenuModel
|
|
|
|
|
|
|
|
var body: some Commands {
|
|
|
|
navigationMenu
|
|
|
|
playbackMenu
|
|
|
|
}
|
|
|
|
|
|
|
|
private var navigationMenu: some Commands {
|
2021-11-28 14:37:55 +00:00
|
|
|
CommandGroup(before: .windowSize) {
|
2021-11-08 23:14:28 +00:00
|
|
|
Button("Favorites") {
|
|
|
|
model.navigation?.tabSelection = .favorites
|
|
|
|
}
|
|
|
|
.keyboardShortcut("1")
|
|
|
|
|
|
|
|
Button("Subscriptions") {
|
|
|
|
model.navigation?.tabSelection = .subscriptions
|
|
|
|
}
|
2021-11-28 14:37:55 +00:00
|
|
|
.disabled(subscriptionsDisabled)
|
2021-11-08 23:14:28 +00:00
|
|
|
.keyboardShortcut("2")
|
|
|
|
|
|
|
|
Button("Popular") {
|
|
|
|
model.navigation?.tabSelection = .popular
|
|
|
|
}
|
|
|
|
.disabled(!(model.accounts?.app.supportsPopular ?? true))
|
|
|
|
.keyboardShortcut("3")
|
|
|
|
|
|
|
|
Button("Trending") {
|
|
|
|
model.navigation?.tabSelection = .trending
|
|
|
|
}
|
|
|
|
.keyboardShortcut("4")
|
|
|
|
|
|
|
|
Button("Search") {
|
|
|
|
model.navigation?.tabSelection = .search
|
|
|
|
}
|
|
|
|
.keyboardShortcut("f")
|
2021-11-28 14:37:55 +00:00
|
|
|
|
|
|
|
Divider()
|
2021-11-08 23:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-28 14:37:55 +00:00
|
|
|
private var subscriptionsDisabled: Bool {
|
|
|
|
!(
|
|
|
|
(model.accounts?.app.supportsSubscriptions ?? false) && model.accounts?.signedIn ?? false
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-11-08 23:14:28 +00:00
|
|
|
private var playbackMenu: some Commands {
|
|
|
|
CommandMenu("Playback") {
|
|
|
|
Button((model.player?.isPlaying ?? true) ? "Pause" : "Play") {
|
|
|
|
model.player?.togglePlay()
|
|
|
|
}
|
|
|
|
.disabled(model.player?.currentItem.isNil ?? true)
|
|
|
|
.keyboardShortcut("p")
|
|
|
|
|
|
|
|
Button("Play Next") {
|
|
|
|
model.player?.advanceToNextItem()
|
|
|
|
}
|
|
|
|
.disabled(model.player?.queue.isEmpty ?? true)
|
|
|
|
.keyboardShortcut("s")
|
|
|
|
|
|
|
|
Button((model.player?.presentingPlayer ?? true) ? "Hide Player" : "Show Player") {
|
|
|
|
model.player?.togglePlayer()
|
|
|
|
}
|
|
|
|
.keyboardShortcut("o")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|