Skip to content

Commit 912d82b

Browse files
committed
feat: change the emojis into just colored cirles and make update now bold
1 parent 6e0e1f4 commit 912d82b

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

  • src/menubar-app/Sources/SparkdockManager

src/menubar-app/Sources/SparkdockManager/main.swift

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ class SparkdockMenubarApp: NSObject, NSApplicationDelegate {
9595
}
9696
}
9797

98+
private func createStatusTitle(_ text: String, color: NSColor) -> NSAttributedString {
99+
let attachment = NSTextAttachment()
100+
101+
// Create a solid colored circle programmatically
102+
let size = NSSize(width: 12, height: 12)
103+
let coloredCircle = NSImage(size: size, flipped: false) { rect in
104+
let path = NSBezierPath(ovalIn: rect)
105+
color.setFill()
106+
path.fill()
107+
return true
108+
}
109+
110+
attachment.image = coloredCircle
111+
112+
let attributedString = NSMutableAttributedString(attachment: attachment)
113+
attributedString.append(NSAttributedString(string: " \(text)"))
114+
115+
return attributedString
116+
}
117+
98118
func applicationDidFinishLaunching(_ notification: Notification) {
99119
// Set proper activation policy for menu bar apps
100120
NSApp.setActivationPolicy(.accessory)
@@ -104,7 +124,7 @@ class SparkdockMenubarApp: NSObject, NSApplicationDelegate {
104124
setupUpdateObservers()
105125

106126
// Set initial status and check for updates
107-
statusMenuItem?.title = "Checking for updates..."
127+
statusMenuItem?.attributedTitle = createStatusTitle("Checking for updates...", color: .systemYellow)
108128
checkForUpdates()
109129
}
110130

@@ -168,9 +188,12 @@ class SparkdockMenubarApp: NSObject, NSApplicationDelegate {
168188
self.statusMenuItem = statusMenuItem
169189
menu.addItem(.separator())
170190

171-
let updateItem = NSMenuItem(title: "Update Now", action: #selector(updateNow), keyEquivalent: "")
191+
let updateItem = NSMenuItem(title: "", action: #selector(updateNow), keyEquivalent: "")
172192
updateItem.target = self
173193
updateItem.tag = MenuItemTag.updateNow.rawValue
194+
updateItem.attributedTitle = NSAttributedString(string: "Update Now", attributes: [
195+
.font: NSFont.boldSystemFont(ofSize: NSFont.systemFontSize)
196+
])
174197
menu.addItem(updateItem)
175198
updateNowMenuItem = updateItem
176199

@@ -236,7 +259,7 @@ class SparkdockMenubarApp: NSObject, NSApplicationDelegate {
236259
monitor.pathUpdateHandler = { [weak self] path in
237260
if path.status == .satisfied {
238261
DispatchQueue.main.async {
239-
self?.statusMenuItem?.title = "Checking for updates..."
262+
self?.statusMenuItem?.attributedTitle = self?.createStatusTitle("Checking for updates...", color: .systemYellow)
240263
self?.checkForUpdates()
241264
}
242265
}
@@ -253,12 +276,12 @@ class SparkdockMenubarApp: NSObject, NSApplicationDelegate {
253276
}
254277
@objc private func systemDidWake() {
255278
AppConstants.logger.info("System woke from sleep - checking for updates")
256-
statusMenuItem?.title = "Checking for updates..."
279+
statusMenuItem?.attributedTitle = createStatusTitle("Checking for updates...", color: .systemYellow)
257280
checkForUpdates()
258281
}
259282

260283
@objc private func checkForUpdatesAction() {
261-
statusMenuItem?.title = "Checking for updates..."
284+
statusMenuItem?.attributedTitle = createStatusTitle("Checking for updates...", color: .systemYellow)
262285
checkForUpdates()
263286
}
264287

@@ -324,9 +347,11 @@ class SparkdockMenubarApp: NSObject, NSApplicationDelegate {
324347
statusItem?.button?.image = loadIcon(hasUpdates: hasUpdates)
325348
statusItem?.button?.toolTip = hasUpdates ? "Sparkdock - Updates available" : "Sparkdock - Up to date"
326349

327-
let newTitle = hasUpdates ? "🔄 Updates Available" : "✅ Sparkdock is up to date"
350+
let (title, color) = hasUpdates ?
351+
("Updates Available", NSColor.systemOrange) :
352+
("Sparkdock is up to date", NSColor.systemGreen)
328353

329-
statusMenuItem?.title = newTitle
354+
statusMenuItem?.attributedTitle = createStatusTitle(title, color: color)
330355

331356
// Update the "Update Now" menu item visibility
332357
if let updateItem = updateNowMenuItem {

0 commit comments

Comments
 (0)