diff --git a/Shared/UnreadCountDisplay.swift b/Shared/UnreadCountDisplay.swift new file mode 100644 index 000000000..a77a6ad2b --- /dev/null +++ b/Shared/UnreadCountDisplay.swift @@ -0,0 +1,38 @@ +// +// UnreadCountDisplay.swift +// NetNewsWire +// +// Created by Brent Simmons on 10/6/26. +// + +import Foundation + +extension Notification.Name { + static let unreadCountDisplaySettingDidChange = Notification.Name("UnreadCountDisplaySettingDidChangeNotification") +} + +/// How unread counts are shown. +enum UnreadCountDisplay: Int, CaseIterable, Codable { + case count = 0 + case dot = 1 + case hidden = 2 + + /// Text to show for an unread count, or nil when nothing should appear. + func text(for unreadCount: Int) -> String? { + guard unreadCount > 0 else { + return nil + } + switch self { + case .count: + return unreadCount.formatted() + case .dot: + return "•" + case .hidden: + return nil + } + } + + func showsDot(for unreadCount: Int) -> Bool { + self == .dot && unreadCount > 0 + } +}