From c71be49190dffb893046d4142979909f146fb983 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 6 Oct 2026 10:45:10 -0700 Subject: [PATCH] =?UTF-8?q?Add=20UnreadCountDisplay=20enum=20for=20unread?= =?UTF-8?q?=20count=20setting=20=E2=80=94=C2=A0show=20count,=20show=20dot,?= =?UTF-8?q?=20hide.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Shared/UnreadCountDisplay.swift | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Shared/UnreadCountDisplay.swift 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 + } +}