Skip to content

Commit

Permalink
✨ feat: Enhance app icon and status bar functionality
Browse files Browse the repository at this point in the history
Add a new app icon and improve the status bar icon update logic.
The status bar icon now reflects the current playback state,
providing a clearer user experience.
  • Loading branch information
samzong committed Jan 5, 2025
1 parent 1bf5ef7 commit e8b71c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)

if let button = statusItem?.button {
button.title = "🤡"
button.target = self
button.action = #selector(toggleMenu)
button.imagePosition = .imageLeft
updateStatusBarIcon()
}

setupMenu()
Expand Down Expand Up @@ -151,9 +152,19 @@ class AppDelegate: NSObject, NSApplicationDelegate {
playPauseItem.title = playerManager.isPlaying ? NSLocalizedString("Pause", comment: "") : NSLocalizedString("Play", comment: "")
}

updateStatusBarIcon()
updatePlayModeMenuItems()
}

private func updateStatusBarIcon() {
if let button = statusItem?.button {
let configuration = NSImage.SymbolConfiguration(pointSize: 18, weight: .regular)
let symbolName = playerManager.isPlaying ? "headphones.circle.fill" : "headphones.circle"
let icon = NSImage(systemSymbolName: symbolName, accessibilityDescription: "Music")?.withSymbolConfiguration(configuration)
button.image = icon
}
}

@objc func togglePlayPause() {
if playerManager.isPlaying {
playerManager.pause()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"size" : "512x512"
},
{
"filename" : "music-good.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e8b71c3

Please sign in to comment.