Files
iceglass/IceGlass/Managers/StatusItemManager.swift
T
rzen 57358797e1 Add playoff round view, game numbers, goal scorer notifications, standings
- Fetch NHL standings and surface league/season game counts in the menu bar
- Prefix regular-season rows with the league-wide game number (from gameId)
- New ROUND section shows each active playoff series (matchup, series score,
  next game number + time) derived from /v1/playoff-bracket; rows always open
  the NHL series page so completed series remain clickable
- Goal notifications include scorer sweater, abbreviated name, and strength
  (PPG/SHG/EN), resolved via /v1/gamecenter/{id}/play-by-play
- Drop the per-team filter submenu and NHLTeam enum
- Regenerate AppIcon with the full 10-size macOS set (alpha preserved) so
  notifications render the app icon correctly; rename the iOS marketing PNG
  to icon-ios-1024.png
- gitignore .claude/ local tooling settings
2026-04-18 21:51:27 -04:00

76 lines
2.2 KiB
Swift

//
// StatusItemManager.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import AppKit
final class StatusItemManager: @unchecked Sendable {
private let logger = IceGlassLogger(
subsystem: Bundle.main.bundleIdentifier ?? "dev.rzen.indie.IceGlass",
category: "StatusItemManager"
)
static let shared = StatusItemManager()
var statusItem: NSStatusItem?
private init() {
DispatchQueue.main.async { [weak self] in
guard let self = self else {
AppTerminator.terminate()
return
}
self.setupStatusItem()
}
}
private func setupStatusItem() {
logger.debug("Initializing")
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
updateIcon()
}
func updateIcon() {
Task { @MainActor in
guard let button = self.statusItem?.button else { return }
guard let baseImage = NSImage(named: NSImage.Name("NHLShield")) else {
button.title = "NHL"
button.image = nil
return
}
let height = button.frame.size.height > 0 ? button.frame.size.height : 22
// Use full menu bar height; let width follow natural aspect ratio
let srcW = baseImage.size.width
let srcH = baseImage.size.height
let scale = height / srcH
let width = srcW * scale
let resizedImage = NSImage(size: NSSize(width: width, height: height))
resizedImage.lockFocus()
baseImage.draw(
in: NSRect(x: 0, y: 0, width: width, height: height),
from: NSRect(x: 0, y: 0, width: srcW, height: srcH),
operation: .copy,
fraction: 1.0
)
resizedImage.unlockFocus()
button.image = resizedImage
button.imageScaling = .scaleProportionallyDown
}
}
func updateStatusText(_ text: String) {
Task { @MainActor in
guard let button = self.statusItem?.button else { return }
button.title = text.isEmpty ? "" : " \(text)"
}
}
}