52 lines
1.3 KiB
Swift
52 lines
1.3 KiB
Swift
import SwiftUI
|
|
|
|
public struct MenuBarContentView: View {
|
|
@Environment(AppModel.self) private var model
|
|
@Environment(\.openWindow) private var openWindow
|
|
|
|
public init() {}
|
|
|
|
public var body: some View {
|
|
Button {
|
|
openWindow(id: "main")
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
} label: {
|
|
Label("Show BearWave", systemImage: "macwindow")
|
|
}
|
|
|
|
Divider()
|
|
|
|
if model.settings.showMenuBarExtraDetails {
|
|
Text(model.playback.currentStation?.name ?? "BearWave")
|
|
Text(model.playback.state.title)
|
|
}
|
|
|
|
Button(model.playback.isPlaying ? "Pause" : "Play") {
|
|
model.playback.togglePlayPause()
|
|
}
|
|
.disabled(model.playback.currentStation == nil)
|
|
|
|
Button("Resume") {
|
|
model.resumeLastStation()
|
|
}
|
|
.disabled(!model.library.canResume)
|
|
|
|
if !model.library.favorites.isEmpty {
|
|
Divider()
|
|
ForEach(model.library.favorites.prefix(6)) { station in
|
|
Button(station.name) {
|
|
model.play(station)
|
|
}
|
|
}
|
|
}
|
|
|
|
Divider()
|
|
|
|
Button("Quit BearWave") {
|
|
model.quit()
|
|
NSApp.terminate(nil)
|
|
}
|
|
.keyboardShortcut("q")
|
|
}
|
|
}
|