mirror of
https://github.com/yattee/yattee.git
synced 2025-11-22 14:41:19 +00:00
Change the Trending menu command to be completely hidden when the feature flag is disabled, rather than just being disabled and still visible in the UI.
93 lines
2.6 KiB
Swift
93 lines
2.6 KiB
Swift
import Foundation
|
|
import SwiftUI
|
|
|
|
struct MenuCommands: Commands {
|
|
@Binding var model: MenuModel
|
|
|
|
var body: some Commands {
|
|
openVideosMenu
|
|
navigationMenu
|
|
playbackMenu
|
|
}
|
|
|
|
private var openVideosMenu: some Commands {
|
|
CommandGroup(after: .newItem) {
|
|
Button("Open Videos...") { NavigationModel.shared.presentingOpenVideos = true }
|
|
.keyboardShortcut("t")
|
|
}
|
|
}
|
|
|
|
private var navigationMenu: some Commands {
|
|
CommandGroup(before: .windowSize) {
|
|
Button("Home") {
|
|
setTabSelection(.home)
|
|
}
|
|
.keyboardShortcut("1")
|
|
|
|
Button("Subscriptions") {
|
|
setTabSelection(.subscriptions)
|
|
}
|
|
.disabled(subscriptionsDisabled)
|
|
.keyboardShortcut("2")
|
|
|
|
Button("Popular") {
|
|
setTabSelection(.popular)
|
|
}
|
|
.disabled(!AccountsModel.shared.app.supportsPopular)
|
|
.keyboardShortcut("3")
|
|
|
|
if FeatureFlags.trendingEnabled {
|
|
Button("Trending") {
|
|
setTabSelection(.trending)
|
|
}
|
|
.keyboardShortcut("4")
|
|
}
|
|
|
|
Button("Search") {
|
|
setTabSelection(.search)
|
|
}
|
|
.keyboardShortcut("f")
|
|
|
|
Divider()
|
|
}
|
|
}
|
|
|
|
private func setTabSelection(_ tabSelection: NavigationModel.TabSelection) {
|
|
NavigationModel.shared.sidebarSectionChanged.toggle()
|
|
NavigationModel.shared.tabSelection = tabSelection
|
|
}
|
|
|
|
private var subscriptionsDisabled: Bool {
|
|
!(AccountsModel.shared.app.supportsSubscriptions && AccountsModel.shared.signedIn)
|
|
}
|
|
|
|
private var playbackMenu: some Commands {
|
|
CommandMenu("Playback") {
|
|
Button((PlayerModel.shared.isPlaying) ? "Pause" : "Play") {
|
|
PlayerModel.shared.togglePlay()
|
|
}
|
|
.disabled(PlayerModel.shared.currentItem.isNil)
|
|
.keyboardShortcut("p")
|
|
|
|
Button("Play Next") {
|
|
PlayerModel.shared.advanceToNextItem()
|
|
}
|
|
.disabled(PlayerModel.shared.queue.isEmpty)
|
|
.keyboardShortcut("s")
|
|
|
|
Button(togglePlayerLabel) {
|
|
PlayerModel.shared.togglePlayer()
|
|
}
|
|
.keyboardShortcut("p", modifiers: [.command, .shift])
|
|
}
|
|
}
|
|
|
|
private var togglePlayerLabel: String {
|
|
#if os(macOS)
|
|
"Show Player"
|
|
#else
|
|
PlayerModel.shared.presentingPlayer ? "Hide Player" : "Show Player"
|
|
#endif
|
|
}
|
|
}
|