mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-03 18:56:14 +00:00
Add UnreadCountDisplay enum for unread count setting — show count, show dot, hide.
This commit is contained in:
1 parent
8cff640ec1
commit
c71be49190
1 file changed
+38
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user