Merge branch 'main' into overflow-x

This commit is contained in:
Brent Simmons authored and GitHub committed 2026-10-06 11:33:03 -07:00
commit 24243041cc
32 files changed
+518 -158

No files matched your search

+6 -2
View File
@@ -118,6 +118,7 @@ let appName = "NetNewsWire"
AccountManager.shared.start()
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: AccountManager.shared)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(inspectableObjectsDidChange(_:)), name: .InspectableObjectsDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(importDownloadedTheme(_:)), name: .didEndDownloadingTheme, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(themeImportError(_:)), name: .didFailToImportThemeWithError, object: nil)
@@ -372,6 +373,10 @@ let appName = "NetNewsWire"
unreadCount = AccountManager.shared.unreadCount
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
updateDockBadge()
}
@objc func feedSettingDidChange(_ note: Notification) {
MainActor.assumeIsolated {
guard let feed = note.object as? Feed, let key = note.userInfo?[Feed.SettingUserInfoKey] as? Feed.SettingKey else {
@@ -558,8 +563,7 @@ let appName = "NetNewsWire"
// MARK: - Dock Badge
@objc func updateDockBadge() {
Task { @MainActor in
let label = unreadCount > 0 ? "\(unreadCount)" : ""
NSApplication.shared.dockTile.badgeLabel = label
NSApplication.shared.dockTile.badgeLabel = AppDefaults.shared.unreadCountDisplay.text(for: unreadCount) ?? ""
}
}
@@ -111,6 +111,7 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations
NotificationCenter.default.addObserver(self, selector: #selector(refreshProgressDidChange(_:)), name: .progressInfoDidChange, object: CombinedRefreshProgress.shared)
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(articleThemeNamesDidChangeNotification(_:)), name: .ArticleThemeNamesDidChangeNotification, object: nil)
@@ -198,6 +199,10 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations
CoalescingQueue.standard.add(self, #selector(coalescedUpdateWindowTitle))
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
updateWindowTitle()
}
@objc func coalescedUpdateWindowTitle() {
updateWindowTitle()
}
@@ -1657,6 +1662,10 @@ private extension MainWindowController {
}
func setSubtitle(_ count: Int) {
guard AppDefaults.shared.unreadCountDisplay == .count else {
window?.subtitle = ""
return
}
let localizedLabel = NSLocalizedString("%d unread", comment: "Unread")
let formattedLabel = NSString.localizedStringWithFormat(localizedLabel as NSString, count)
window?.subtitle = formattedLabel as String
@@ -44,8 +44,7 @@ final class SidebarCell: NSTableCellView {
set {
if unreadCountView.unreadCount != newValue {
unreadCountView.unreadCount = newValue
unreadCountView.isHidden = (newValue < 1)
needsLayout = true
updateUnreadCountView()
}
}
}
@@ -112,8 +111,15 @@ final class SidebarCell: NSTableCellView {
layoutWith(layout)
}
func updateUnreadCountView() {
unreadCountView.invalidateIntrinsicContentSize()
unreadCountView.needsDisplay = true
unreadCountView.isHidden = unreadCountView.unreadCountText == nil
needsLayout = true
}
override func accessibilityLabel() -> String? {
if unreadCount > 0 {
if unreadCount > 0 && AppDefaults.shared.unreadCountDisplay == .count {
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility")
return "\(name) \(unreadCount) \(unreadLabel)"
} else {
@@ -36,7 +36,7 @@ import RSCore
rTextField = rTextField.centeredVertically(in: bounds)
let unreadCountSize = unreadCountView.intrinsicContentSize
let unreadCountIsHidden = unreadCountView.unreadCount < 1
let unreadCountIsHidden = unreadCountView.unreadCountText == nil
var rUnread = NSRect.zero
if !unreadCountIsHidden {
@@ -93,6 +93,7 @@ extension Notification.Name {
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidInitialize(_:)), name: .UnreadCountDidInitialize, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(containerChildrenDidChange(_:)), name: .ChildrenDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidAddAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidDeleteAccount, object: nil)
@@ -226,6 +227,12 @@ extension Notification.Name {
}
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
applyToAvailableCells { cell, _ in
cell.updateUnreadCountView()
}
}
@objc func containerChildrenDidChange(_ note: Notification) {
rebuildTreeAndRestoreSelection()
}
@@ -844,6 +851,7 @@ private extension SidebarViewController {
cell.cellAppearance = SidebarCellAppearance(rowSizeStyle: outlineView.effectiveRowSizeStyle)
cell.name = nameFor(node)
configureUnreadCount(cell, node)
cell.updateUnreadCountView() // A reused cell may predate a display setting change
configureFavicon(cell, node)
cell.shouldShowImage = node.representedObject is SmallIconProvider
}
+38 -17
View File
@@ -52,8 +52,13 @@ final class UnreadCountView: NSView {
needsDisplay = true
}
}
var unreadCountString: String {
return unreadCount < 1 ? "" : "\(unreadCount.formatted())"
/// Text for the unread count, or nil when nothing should be drawn.
var unreadCountText: String? {
AppDefaults.shared.unreadCountDisplay.text(for: unreadCount)
}
private var showsDot: Bool {
AppDefaults.shared.unreadCountDisplay.showsDot(for: unreadCount)
}
var isSelected: Bool = false {
@@ -83,8 +88,12 @@ final class UnreadCountView: NSView {
override var intrinsicContentSize: NSSize {
if !intrinsicContentSizeIsValid {
var size = NSSize.zero
if unreadCount > 0 {
size = textSize()
if showsDot {
// Same height as a count, so the row lays out the same either way.
size.width = UnreadIndicatorView.unreadCircleDimension + Appearance.padding.left + Appearance.padding.right
size.height = textSize(Self.digitForHeight).height + Appearance.padding.top + Appearance.padding.bottom
} else if let unreadCountText {
size = textSize(unreadCountText)
size.width += (Appearance.padding.left + Appearance.padding.right)
size.height += (Appearance.padding.top + Appearance.padding.bottom)
}
@@ -102,27 +111,23 @@ final class UnreadCountView: NSView {
intrinsicContentSizeIsValid = false
}
private static var textSizeCache = [Int: NSSize]()
private static var textSizeCache = [String: NSSize]()
private func textSize() -> NSSize {
if unreadCount < 1 {
return NSSize.zero
}
if let cachedSize = UnreadCountView.textSizeCache[unreadCount] {
private func textSize(_ text: String) -> NSSize {
if let cachedSize = UnreadCountView.textSizeCache[text] {
return cachedSize
}
var size = unreadCountString.size(withAttributes: textAttributes)
var size = text.size(withAttributes: textAttributes)
size.height = ceil(size.height)
size.width = ceil(size.width)
UnreadCountView.textSizeCache[unreadCount] = size
UnreadCountView.textSizeCache[text] = size
return size
}
private func textRect() -> NSRect {
let size = textSize()
private func textRect(_ text: String) -> NSRect {
let size = textSize(text)
var r = NSRect.zero
r.size = size
r.origin.x = (bounds.maxX - Appearance.padding.right) - r.size.width
@@ -130,13 +135,29 @@ final class UnreadCountView: NSView {
return r
}
private static let digitForHeight = "0"
/// Drawn without the pill.
private func drawDot() {
let dimension = UnreadIndicatorView.unreadCircleDimension
let r = NSRect(x: (bounds.maxX - Appearance.padding.right) - dimension, y: bounds.midY - (dimension / 2.0), width: dimension, height: dimension)
let color = isSelected ? NSColor.white : NSColor.secondaryLabelColor
color.setFill()
NSBezierPath(ovalIn: r).fill()
}
override func draw(_ dirtyRect: NSRect) {
if showsDot {
drawDot()
return
}
let path = NSBezierPath(roundedRect: bounds, xRadius: Appearance.cornerRadius, yRadius: Appearance.cornerRadius)
Appearance.backgroundColor.setFill()
path.fill()
if unreadCount > 0 {
unreadCountString.draw(at: textRect().origin, withAttributes: textAttributes)
if let unreadCountText {
unreadCountText.draw(at: textRect(unreadCountText).origin, withAttributes: textAttributes)
}
}
}
@@ -11,18 +11,62 @@
<outlet property="articleTextSizePopup" destination="Z6O-Zt-V1g" id="aTS-pU-7Vg"/>
<outlet property="articleThemePopup" destination="ISO-Wu-R60" id="oI3-6W-dPa"/>
<outlet property="defaultBrowserPopup" destination="Ci4-fW-KjU" id="7Nh-nU-Sbc"/>
<outlet property="hideUnreadCountsButton" destination="uC3-hD-nRb" id="uC3-oT-lTc"/>
<outlet property="showUnreadCountDotButton" destination="uC2-dS-hRb" id="uC2-oT-lTb"/>
<outlet property="showUnreadCountsButton" destination="uC1-sH-wRb" id="uC1-oT-lTa"/>
<outlet property="view" destination="WnV-px-wCT" id="gPv-Ow-1a1"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<view id="WnV-px-wCT">
<rect key="frame" x="0.0" y="0.0" width="509" height="460"/>
<rect key="frame" x="0.0" y="0.0" width="515" height="561"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView horizontalHuggingPriority="1000" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="Ut3-yd-q6G">
<rect key="frame" x="57" y="16" width="393" height="428"/>
<rect key="frame" x="60" y="16" width="393" height="529"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f4H-6I-KoK">
<rect key="frame" x="-2" y="509" width="106" height="16"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Unread Counts:" id="wAn-gW-UJc">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uC1-sH-wRb">
<rect key="frame" x="110" y="509" width="283" height="16"/>
<buttonCell key="cell" type="radio" title="Show" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="uC1-cL-sHw">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="unreadCountDisplaySettingDidChange:" target="-2" id="uC1-aC-tNa"/>
</connections>
</button>
<button tag="1" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uC2-dS-hRb">
<rect key="frame" x="110" y="487" width="283" height="16"/>
<buttonCell key="cell" type="radio" title="Show dot" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="uC2-cL-dSh">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="unreadCountDisplaySettingDidChange:" target="-2" id="uC2-aC-tNb"/>
</connections>
</button>
<button tag="2" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uC3-hD-nRb">
<rect key="frame" x="110" y="465" width="283" height="16"/>
<buttonCell key="cell" type="radio" title="Hide" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="uC3-cL-hDn">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="unreadCountDisplaySettingDidChange:" target="-2" id="uC3-aC-tNc"/>
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="uCs-sP-rTr">
<rect key="frame" x="0.0" y="442" width="392" height="5"/>
</box>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pR2-Bf-7Fd">
<rect key="frame" x="-2" y="404" width="106" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="right" title="Article Text Size:" id="xQu-QV-91i">
@@ -270,7 +314,6 @@
<constraint firstItem="S2Z-bG-jYk" firstAttribute="trailing" secondItem="pR2-Bf-7Fd" secondAttribute="trailing" id="4wu-2O-1fb"/>
<constraint firstItem="Tdg-6Y-gvW" firstAttribute="top" secondItem="0W5-tO-S63" secondAttribute="bottom" constant="20" id="5a3-LF-TvY"/>
<constraint firstItem="0W5-tO-S63" firstAttribute="top" secondItem="UI6-sq-M15" secondAttribute="bottom" constant="8" id="5mw-aE-uy4"/>
<constraint firstItem="Z6O-Zt-V1g" firstAttribute="top" secondItem="Ut3-yd-q6G" secondAttribute="top" constant="4" id="6nC-a3-QOy"/>
<constraint firstItem="Z6O-Zt-V1g" firstAttribute="firstBaseline" secondItem="pR2-Bf-7Fd" secondAttribute="firstBaseline" id="72z-7d-9Qn"/>
<constraint firstItem="hQy-ng-ijd" firstAttribute="top" secondItem="Yrc-6Q-kx8" secondAttribute="bottom" constant="20" id="7iQ-QN-Ubh"/>
<constraint firstItem="Yrc-6Q-kx8" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="AQY-vT-qR7"/>
@@ -289,6 +332,7 @@
<constraint firstItem="Ubm-Pk-l7x" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="PXc-G4-8pH"/>
<constraint firstItem="S2Z-bG-jYk" firstAttribute="firstBaseline" secondItem="ISO-Wu-R60" secondAttribute="firstBaseline" id="QBC-MT-MY5"/>
<constraint firstAttribute="trailing" secondItem="Z6O-Zt-V1g" secondAttribute="trailing" constant="1" id="Qa5-bc-lvY"/>
<constraint firstItem="pR2-Bf-7Fd" firstAttribute="trailing" secondItem="f4H-6I-KoK" secondAttribute="trailing" id="RBF-eU-g8N"/>
<constraint firstItem="SFF-mL-yc8" firstAttribute="top" secondItem="hQy-ng-ijd" secondAttribute="bottom" constant="20" id="S01-ZA-i2d"/>
<constraint firstAttribute="trailing" secondItem="Tdg-6Y-gvW" secondAttribute="trailing" constant="1" id="SOE-le-vT8"/>
<constraint firstItem="Z6O-Zt-V1g" firstAttribute="leading" secondItem="pR2-Bf-7Fd" secondAttribute="trailing" constant="8" symbolic="YES" id="TWU-6a-gBr"/>
@@ -319,6 +363,21 @@
<constraint firstAttribute="trailing" secondItem="UI6-sq-M15" secondAttribute="trailing" id="rxC-vu-aW1"/>
<constraint firstItem="yrg-M3-Dbz" firstAttribute="firstBaseline" secondItem="wtY-Zd-Ps9" secondAttribute="firstBaseline" id="sgV-rt-nFb"/>
<constraint firstItem="SFF-mL-yc8" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="shx-wm-ygD"/>
<constraint firstItem="uC1-sH-wRb" firstAttribute="top" secondItem="Ut3-yd-q6G" secondAttribute="top" constant="4" id="uCa-tP-r01"/>
<constraint firstItem="uC1-sH-wRb" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="uCb-lD-r01"/>
<constraint firstAttribute="trailing" secondItem="uC1-sH-wRb" secondAttribute="trailing" id="uCc-tR-r01"/>
<constraint firstItem="uC2-dS-hRb" firstAttribute="top" secondItem="uC1-sH-wRb" secondAttribute="bottom" constant="6" symbolic="YES" id="uCd-tP-r02"/>
<constraint firstItem="uC2-dS-hRb" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="uCe-lD-r02"/>
<constraint firstAttribute="trailing" secondItem="uC2-dS-hRb" secondAttribute="trailing" id="uCf-tR-r02"/>
<constraint firstItem="uC3-hD-nRb" firstAttribute="top" secondItem="uC2-dS-hRb" secondAttribute="bottom" constant="6" symbolic="YES" id="uCg-tP-r03"/>
<constraint firstItem="uC3-hD-nRb" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="uCh-lD-r03"/>
<constraint firstAttribute="trailing" secondItem="uC3-hD-nRb" secondAttribute="trailing" id="uCi-tR-r03"/>
<constraint firstItem="f4H-6I-KoK" firstAttribute="firstBaseline" secondItem="uC1-sH-wRb" secondAttribute="firstBaseline" id="uCj-bL-lbl"/>
<constraint firstItem="f4H-6I-KoK" firstAttribute="leading" secondItem="Ut3-yd-q6G" secondAttribute="leading" id="uCk-lD-lbl"/>
<constraint firstItem="uCs-sP-rTr" firstAttribute="top" secondItem="uC3-hD-nRb" secondAttribute="bottom" constant="20" id="uCl-tP-sep"/>
<constraint firstItem="uCs-sP-rTr" firstAttribute="leading" secondItem="Ut3-yd-q6G" secondAttribute="leading" id="uCm-lD-sep"/>
<constraint firstAttribute="trailing" secondItem="uCs-sP-rTr" secondAttribute="trailing" constant="1" id="uCn-tR-sep"/>
<constraint firstItem="Z6O-Zt-V1g" firstAttribute="top" secondItem="uCs-sP-rTr" secondAttribute="bottom" constant="20" id="uCo-tP-z6o"/>
<constraint firstItem="wtY-Zd-Ps9" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="vaG-fM-WwJ"/>
<constraint firstItem="j0t-Wa-UTL" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" constant="22" id="xSA-4l-R2v"/>
<constraint firstAttribute="trailing" secondItem="ISO-Wu-R60" secondAttribute="trailing" constant="1" id="xaY-qS-LSN"/>
@@ -331,6 +390,7 @@
<constraint firstAttribute="bottom" secondItem="Ut3-yd-q6G" secondAttribute="bottom" constant="16" id="FVX-gg-o9H"/>
<constraint firstItem="Ut3-yd-q6G" firstAttribute="top" secondItem="WnV-px-wCT" secondAttribute="top" constant="16" id="jtz-mW-ptL"/>
</constraints>
<point key="canvasLocation" x="141.5" y="193"/>
</view>
<userDefaultsController representsSharedInstance="YES" id="mAF-gO-1PI"/>
</objects>
@@ -17,6 +17,9 @@ final class GeneralPreferencesViewController: NSViewController {
@IBOutlet var articleTextSizePopup: NSPopUpButton!
@IBOutlet var articleThemePopup: NSPopUpButton!
@IBOutlet var defaultBrowserPopup: NSPopUpButton!
@IBOutlet var showUnreadCountsButton: NSButton?
@IBOutlet var showUnreadCountDotButton: NSButton?
@IBOutlet var hideUnreadCountsButton: NSButton?
convenience init() {
self.init(nibName: "GeneralPreferencesView", bundle: nil)
@@ -49,6 +52,10 @@ final class GeneralPreferencesViewController: NSViewController {
updateArticleThemePopup()
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
updateUnreadCountDisplayButtons()
}
// MARK: - Actions
@IBAction func showThemesFolder(_ sender: Any) {
@@ -64,6 +71,13 @@ final class GeneralPreferencesViewController: NSViewController {
updateArticleThemePopup()
}
@IBAction func unreadCountDisplaySettingDidChange(_ sender: NSButton) {
guard let unreadCountDisplay = UnreadCountDisplay(rawValue: sender.tag) else {
return
}
AppDefaults.shared.unreadCountDisplay = unreadCountDisplay
}
@IBAction func browserPopUpDidChangeValue(_ sender: Any?) {
guard let menuItem = defaultBrowserPopup.selectedItem else {
return
@@ -114,11 +128,20 @@ private extension GeneralPreferencesViewController {
func commonInit() {
NotificationCenter.default.addObserver(self, selector: #selector(applicationWillBecomeActive(_:)), name: NSApplication.willBecomeActiveNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(articleThemeNamesDidChangeNotification(_:)), name: .ArticleThemeNamesDidChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
}
func updateUI() {
updateArticleThemePopup()
updateBrowserPopup()
updateUnreadCountDisplayButtons()
}
func updateUnreadCountDisplayButtons() {
let selectedTag = AppDefaults.shared.unreadCountDisplay.rawValue
for case let button? in [showUnreadCountsButton, showUnreadCountDotButton, hideUnreadCountsButton] {
button.state = button.tag == selectedTag ? .on : .off
}
}
func updateArticleThemePopup() {
@@ -403,6 +403,42 @@
}
}
},
"uC1-cL-sHw.title" : {
"comment" : "Class = \"NSButtonCell\"; title = \"Show\"; ObjectID = \"uC1-cL-sHw\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Show"
}
}
}
},
"uC2-cL-dSh.title" : {
"comment" : "Class = \"NSButtonCell\"; title = \"Show dot\"; ObjectID = \"uC2-cL-dSh\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Show dot"
}
}
}
},
"uC3-cL-hDn.title" : {
"comment" : "Class = \"NSButtonCell\"; title = \"Hide\"; ObjectID = \"uC3-cL-hDn\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Hide"
}
}
}
},
"uvx-O8-HvU.title" : {
"comment" : "Class = \"NSButtonCell\"; title = \"Open feeds in NetNewsWire\"; ObjectID = \"uvx-O8-HvU\";",
"extractionState" : "extracted_with_value",
@@ -421,6 +457,18 @@
}
}
},
"wAn-gW-UJc.title" : {
"comment" : "Class = \"NSTextFieldCell\"; title = \"Unread Counts:\"; ObjectID = \"wAn-gW-UJc\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Unread Counts:"
}
}
}
},
"xQu-QV-91i.title" : {
"comment" : "Class = \"NSTextFieldCell\"; title = \"Article Text Size:\"; ObjectID = \"xQu-QV-91i\";",
"extractionState" : "extracted_with_value",
@@ -459,4 +507,4 @@
}
},
"version" : "1.2"
}
}
+1
View File
@@ -429,6 +429,7 @@
84D35E0E2DB9F32D004AA60E /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
UnreadCountDisplay.swift,
Widget/WidgetData.swift,
Widget/WidgetDataDecoder.swift,
Widget/WidgetDeepLinks.swift,
+25
View File
@@ -0,0 +1,25 @@
//
// AppDefaults+Shared.swift
// NetNewsWire
//
// Created by Brent Simmons on 10/6/26.
//
import Foundation
private extension AppDefaults.Key {
static let unreadCountDisplay = "unreadCountDisplay"
}
extension AppDefaults {
var unreadCountDisplay: UnreadCountDisplay {
get {
UnreadCountDisplay(rawValue: UserDefaults.standard.integer(forKey: Key.unreadCountDisplay)) ?? .count
}
set {
UserDefaults.standard.set(newValue.rawValue, forKey: Key.unreadCountDisplay)
NotificationCenter.default.post(name: .unreadCountDisplaySettingDidChange, object: self)
}
}
}
+5 -2
View File
@@ -531,7 +531,7 @@
"comment" : "Here"
},
"Hide" : {
"comment" : "Hide password button"
"comment" : "Hide"
},
"Hide Read Articles" : {
"comment" : "Command"
@@ -943,7 +943,10 @@
"comment" : "Share…"
},
"Show" : {
"comment" : "Show password button"
"comment" : "Show"
},
"Show dot" : {
"comment" : "Unread Counts setting: show a dot instead of the number of unread articles"
},
"Show Feed Article" : {
"comment" : "Show Feed Article"
+38
View File
@@ -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
}
}
+6
View File
@@ -17,6 +17,12 @@ struct WidgetData: Codable {
let starredArticles: [LatestArticle]
let todayArticles: [LatestArticle]
let lastUpdateTime: Date
let unreadCountDisplay: UnreadCountDisplay?
/// Data written before this setting existed has no value, which means `.count`.
var effectiveUnreadCountDisplay: UnreadCountDisplay {
unreadCountDisplay ?? .count
}
}
struct LatestArticle: Codable, Identifiable, Hashable {
+2 -2
View File
@@ -18,7 +18,7 @@ struct WidgetDataDecoder {
let decodedWidgetData = try JSONDecoder().decode(WidgetData.self, from: Data(contentsOf: dataURL!))
return decodedWidgetData
} else {
return WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date())
return WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date(), unreadCountDisplay: nil)
}
}
@@ -29,7 +29,7 @@ struct WidgetDataDecoder {
let decoded = try JSONDecoder().decode(WidgetData.self, from: data)
return decoded
} catch {
return WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date())
return WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date(), unreadCountDisplay: nil)
}
}
+14 -1
View File
@@ -44,6 +44,12 @@ import Account
Self.logger.error("WidgetDataEncoder: unable to create folder for images")
return nil
}
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
encode()
}
/// Fire-and-forget. Sets `isRunning` synchronously so the background-task wait loop
@@ -96,6 +102,12 @@ import Account
func reloadTimelines(newData: WidgetData, existingData: WidgetData?) {
if let existingData = existingData {
if existingData.effectiveUnreadCountDisplay != newData.effectiveUnreadCountDisplay {
WidgetCenter.shared.reloadAllTimelines()
Self.logger.debug("WidgetDataEncoder: Reloading all widgets because unread count display changed")
return
}
var shouldRefreshSummary = false
if existingData.unreadArticles != newData.unreadArticles {
@@ -148,7 +160,8 @@ import Account
unreadArticles: unreadArticles,
starredArticles: starredArticles,
todayArticles: todayArticles,
lastUpdateTime: Date.now)
lastUpdateTime: Date.now,
unreadCountDisplay: AppDefaults.shared.unreadCountDisplay)
return latestData
}
+1 -1
View File
@@ -51,7 +51,7 @@ struct Provider: TimelineProvider {
let widgetData = try WidgetDataDecoder.decodeWidgetData()
entry = WidgetTimelineEntry(date: date, widgetData: widgetData)
} catch {
entry = WidgetTimelineEntry(date: date, widgetData: WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date.now))
entry = WidgetTimelineEntry(date: date, widgetData: WidgetData(totalUnreadCount: 0, totalTodayCount: 0, totalTodayUnreadCount: 0, totalStarredCount: 0, unreadArticles: [], starredArticles: [], todayArticles: [], lastUpdateTime: Date.now, unreadCountDisplay: nil))
}
let fallback = Calendar.current.date(byAdding: .minute, value: 30, to: Date.now)!
@@ -19,7 +19,7 @@ struct LockScreenSummaryWidgetView: View {
unreadImage
Text("label.text.unread", comment: "Unread")
Spacer()
Text(verbatim: entry.widgetData.totalUnreadCount.formatted())
Text(verbatim: unreadCountText)
.frame(maxWidth: .infinity, alignment: .trailing)
}
HStack(alignment: .center) {
@@ -40,6 +40,15 @@ struct LockScreenSummaryWidgetView: View {
.font(.subheadline)
}
/// Shows 0 when counts are showing, so the row doesn’t look broken.
var unreadCountText: String {
let widgetData = entry.widgetData
guard widgetData.effectiveUnreadCountDisplay == .count else {
return widgetData.effectiveUnreadCountDisplay.text(for: widgetData.totalUnreadCount) ?? ""
}
return widgetData.totalUnreadCount.formatted()
}
var starredImage: some View {
Image(systemName: "star.fill")
.resizable()
+10 -1
View File
@@ -35,7 +35,7 @@ struct TodayWidgetView: View {
Spacer()
.layoutPriority(0)
if entry.widgetData.totalTodayCount > 0 {
Text(verbatim: entry.widgetData.totalTodayUnreadCount > 0 ? "\(entry.widgetData.totalTodayCount.formatted()), \(entry.widgetData.totalTodayUnreadCount.formatted()) unread" : entry.widgetData.totalTodayCount.formatted())
Text(verbatim: countText)
.font(.caption2)
.bold()
.foregroundColor(.secondary)
@@ -56,6 +56,15 @@ struct TodayWidgetView: View {
}
}
/// The unread part is omitted unless unread counts are set to show — “3, • unread” would say nothing.
var countText: String {
let widgetData = entry.widgetData
guard widgetData.totalTodayUnreadCount > 0, widgetData.effectiveUnreadCountDisplay == .count else {
return widgetData.totalTodayCount.formatted()
}
return "\(widgetData.totalTodayCount.formatted()), \(widgetData.totalTodayUnreadCount.formatted()) unread"
}
var todayImage: some View {
Image(systemName: "sun.max.fill")
.resizable()
+2 -2
View File
@@ -33,8 +33,8 @@ struct UnreadWidgetView: View {
.layoutPriority(1)
Spacer()
.layoutPriority(0)
if entry.widgetData.totalUnreadCount - maxCount() > 0 {
Text(verbatim: entry.widgetData.totalUnreadCount.formatted())
if entry.widgetData.totalUnreadCount - maxCount() > 0, let unreadCountText = entry.widgetData.effectiveUnreadCountDisplay.text(for: entry.widgetData.totalUnreadCount) {
Text(verbatim: unreadCountText)
.font(.caption2)
.bold()
.foregroundColor(.secondary)
+1 -1
View File
@@ -107,7 +107,7 @@ struct CredentialsAccountView: View {
SecureField(Self.passwordPlaceholder, text: $password)
.textContentType(.password)
}
Button(isPasswordVisible ? NSLocalizedString("Hide", comment: "Hide password button") : NSLocalizedString("Show", comment: "Show password button")) {
Button(isPasswordVisible ? NSLocalizedString("Hide", comment: "Hide") : NSLocalizedString("Show", comment: "Show")) {
isPasswordVisible.toggle()
}
.buttonStyle(.borderless)
+7 -1
View File
@@ -55,6 +55,7 @@ import Images
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountRefreshDidFinish(_:)), name: .AccountRefreshDidFinish, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
@@ -134,7 +135,8 @@ import Images
private func updateBadge() {
assert(unreadCount == AccountManager.shared.unreadCount)
UNUserNotificationCenter.current().setBadgeCount(unreadCount)
let badgeCount = AppDefaults.shared.unreadCountDisplay == .count ? unreadCount : 0
UNUserNotificationCenter.current().setBadgeCount(badgeCount)
}
// MARK: Notifications
@@ -149,6 +151,10 @@ import Images
AppDefaults.shared.lastRefresh = Date()
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
updateBadge()
}
// MARK: - API
func manualRefresh(errorHandler: @escaping @Sendable (Error) -> Void) {
@@ -28,7 +28,7 @@ final class MainFeedCollectionHeaderReusableView: UICollectionReusableView {
override var accessibilityLabel: String? {
get {
if unreadCount > 0 {
if unreadCount > 0 && AppDefaults.shared.unreadCountDisplay == .count {
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility")
return "\(headerTitle.text ?? "") \(unreadCount) \(unreadLabel) \(expandedStateMessage) "
} else {
@@ -54,10 +54,14 @@ final class MainFeedCollectionHeaderReusableView: UICollectionReusableView {
set {
_unreadCount = newValue
updateUnreadCount()
unreadCountLabel.text = newValue.formatted()
unreadCountLabel.setUnreadCount(newValue)
}
}
private var unreadCountText: String? {
AppDefaults.shared.unreadCountDisplay.text(for: unreadCount)
}
// Mutate via setDisclosure(isExpanded:animated:) — the supplementary provider
// sets this on every dequeue and must not animate.
private(set) var disclosureExpanded = true
@@ -125,7 +129,7 @@ final class MainFeedCollectionHeaderReusableView: UICollectionReusableView {
}
func updateUnreadCount(animated: Bool = true) {
let alpha: CGFloat = (!disclosureExpanded && unreadCount > 0) ? 1 : 0
let alpha: CGFloat = (!disclosureExpanded && unreadCountText != nil) ? 1 : 0
if animated {
UIView.animate(withDuration: 0.3) {
self.unreadCountLabel.alpha = alpha
@@ -33,12 +33,9 @@ final class MainFeedCollectionViewCell: UICollectionViewCell {
}
set {
_unreadCount = newValue
if newValue == 0 {
unreadCountLabel.isHidden = true
} else {
unreadCountLabel.isHidden = false
}
unreadCountLabel.text = newValue.formatted()
unreadCountLabel.isHidden = AppDefaults.shared.unreadCountDisplay.text(for: newValue) == nil
unreadCountLabel.setUnreadCount(newValue)
setNeedsUpdateConfiguration()
}
}
@@ -60,7 +57,7 @@ final class MainFeedCollectionViewCell: UICollectionViewCell {
override var accessibilityLabel: String? {
get {
let name = feedTitle.text ?? ""
if unreadCount > 0 {
if unreadCount > 0 && AppDefaults.shared.unreadCountDisplay == .count {
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility")
return "\(name) \(unreadCount) \(unreadLabel)"
} else {
@@ -29,16 +29,20 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell {
}
set {
_unreadCount = newValue
if newValue == 0 {
unreadCountLabel.isHidden = true
} else {
unreadCountLabel.isHidden = false
let unreadCountText = unreadCountText
unreadCountLabel.isHidden = unreadCountText == nil
if unreadCountText != nil {
updateUnreadCountVisibility()
}
unreadCountLabel.text = newValue.formatted()
unreadCountLabel.setUnreadCount(newValue)
setNeedsUpdateConfiguration()
}
}
private var unreadCountText: String? {
AppDefaults.shared.unreadCountDisplay.text(for: unreadCount)
}
var iconImage: IconImage? {
didSet {
faviconView.iconImage = iconImage
@@ -76,7 +80,7 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell {
}
func updateUnreadCountVisibility(animated: Bool = true) {
let alpha: CGFloat = (!disclosureExpanded && unreadCount > 0) ? 1 : 0
let alpha: CGFloat = (!disclosureExpanded && unreadCountText != nil) ? 1 : 0
if animated {
UIView.animate {
self.unreadCountLabel.alpha = alpha
@@ -101,7 +105,7 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell {
override var accessibilityLabel: String? {
get {
let name = folderTitle.text ?? ""
if unreadCount > 0 {
if unreadCount > 0 && AppDefaults.shared.unreadCountDisplay == .count {
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility")
return "\(name) \(unreadCount) \(unreadLabel) \(expandedStateMessage)"
} else {
@@ -0,0 +1,33 @@
//
// UILabel+UnreadCount.swift
// NetNewsWire
//
// Created by Brent Simmons on 10/6/26.
//
import UIKit
extension UILabel {
/// Shows `unreadCount` per the Unread Counts setting: the number, a dot, or nothing.
/// The dot is drawn in the label’s text color.
func setUnreadCount(_ unreadCount: Int) {
let unreadCountDisplay = AppDefaults.shared.unreadCountDisplay
if unreadCountDisplay.showsDot(for: unreadCount) {
attributedText = NSAttributedString(attachment: unreadDotAttachment())
} else {
text = unreadCountDisplay.text(for: unreadCount)
}
}
}
private extension UILabel {
func unreadDotAttachment() -> NSTextAttachment {
let dimension = MainTimelineDefaultCellLayout.unreadCircleDimension
let image = Assets.Images.unreadCellIndicator.image.withRenderingMode(.alwaysTemplate)
let attachment = NSTextAttachment(image: image)
attachment.bounds = CGRect(x: 0, y: (font.capHeight - dimension) / 2, width: dimension, height: dimension)
return attachment
}
}
@@ -198,6 +198,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .htmlMetadataAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(feedIconDidBecomeAvailable(_:)), name: .feedIconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(feedSettingDidChange(_:)), name: .feedSettingDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
registerForTraitChanges([UITraitPreferredContentSizeCategory.self], target: self, action: #selector(preferredContentSizeCategoryDidChange))
}
@@ -913,6 +914,17 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
reconfigureItems(nodesToReconfigure)
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
for account in AccountManager.shared.activeAccounts {
if let headerView = findHeaderViewForAccount(account) {
headerView.unreadCount = account.unreadCount
}
}
// Only realized cells are reconfigured. Others pick up the setting when dequeued.
reconfigureItems(dataSource.snapshot().itemIdentifiers)
}
@objc func feedSettingDidChange(_ note: Notification) {
guard let feed = note.object as? Feed, let key = note.userInfo?[Feed.SettingUserInfoKey] as? Feed.SettingKey else {
return
+13 -4
View File
@@ -316,6 +316,10 @@ struct SidebarItemNode: Hashable, Sendable {
}
}
private var isTimelineUnreadCountSubtitleShown: Bool {
timelineFeed != nil && timelineUnreadCount > 0 && AppDefaults.shared.unreadCountDisplay == .count
}
private static let minimumTimelineWidth: CGFloat = 280
private static let maximumTimelineWidth: CGFloat = 440
@@ -395,6 +399,7 @@ struct SidebarItemNode: Hashable, Sendable {
NotificationCenter.default.addObserver(self, selector: #selector(importDownloadedTheme(_:)), name: .didEndDownloadingTheme, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(themeDownloadDidFail(_:)), name: .didFailToImportThemeWithError, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateNavigationBarSubtitles(_:)), name: .progressInfoDidChange, object: CombinedRefreshProgress.shared)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
NotificationCenter.default.addObserver(forName: UserDefaults.didChangeNotification, object: nil, queue: .main) { [weak self] _ in
Task { @MainActor in
@@ -702,6 +707,10 @@ struct SidebarItemNode: Hashable, Sendable {
}
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
updateNavigationBarSubtitles(nil)
}
/// Updates navigation bar subtitles in response to feed selection, unread count changes,
/// `progressInfoDidChange` notifications, and a timed refresh every
/// 60s.
@@ -713,7 +722,7 @@ struct SidebarItemNode: Hashable, Sendable {
/// - When refreshed: Feeds will display "Updated <#relative_time#>" on both iPhone and iPad.
///
/// `MainTimelineViewController`
/// - Where the unread count for the timeline is > 0, this is displayed on both iPhone and iPad.
/// - Where the unread count for the timeline is > 0 and the Unread Counts setting is Show, this is displayed on both iPhone and iPad.
/// - If the timeline count is 0, the iPhone follows the same logic as `MainFeedViewController`
/// - Specific to iPad, if the unread count is 0, the iPad will not display a subtitle. The refresh text
/// will generally be visible in the sidebar and there’s no need to display it twice.
@@ -737,7 +746,7 @@ struct SidebarItemNode: Hashable, Sendable {
}
// If unread count > 0, add unread string to timeline
if timelineFeed != nil, timelineUnreadCount > 0 {
if isTimelineUnreadCountSubtitleShown {
let localizedUnreadCount = NSLocalizedString("%i Unread", comment: "14 Unread")
let unreadCount = NSString.localizedStringWithFormat(localizedUnreadCount as NSString, timelineUnreadCount) as String
self.mainTimelineViewController?.updateNavigationBarSubtitle(unreadCount)
@@ -756,7 +765,7 @@ struct SidebarItemNode: Hashable, Sendable {
}
// If unread count > 0, add unread string to timeline
if timelineFeed != nil, timelineUnreadCount > 0 {
if isTimelineUnreadCountSubtitleShown {
let localizedUnreadCount = NSLocalizedString("%i Unread", comment: "14 Unread")
let refreshTextWithUnreadCount = NSString.localizedStringWithFormat(localizedUnreadCount as NSString, timelineUnreadCount) as String
self.mainTimelineViewController?.updateNavigationBarSubtitle(refreshTextWithUnreadCount)
@@ -774,7 +783,7 @@ struct SidebarItemNode: Hashable, Sendable {
self.mainFeedCollectionViewController?.navigationItem.subtitle = ""
}
// If unread count > 0, add unread string to timeline
if timelineFeed != nil, timelineUnreadCount > 0 {
if isTimelineUnreadCountSubtitleShown {
let localizedUnreadCount = NSLocalizedString("%i Unread", comment: "14 Unread")
let refreshTextWithUnreadCount = NSString.localizedStringWithFormat(localizedUnreadCount as NSString, timelineUnreadCount) as String
self.mainTimelineViewController?.updateNavigationBarSubtitle(refreshTextWithUnreadCount)
@@ -1,42 +0,0 @@
//
// ColorPaletteTableViewController.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 3/15/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import UIKit
final class ColorPaletteTableViewController: UITableViewController {
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return UserInterfaceColorPalette.allCases.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
let rowColorPalette = UserInterfaceColorPalette.allCases[indexPath.row]
cell.textLabel?.text = String(describing: rowColorPalette)
if rowColorPalette == AppDefaults.userInterfaceColorPalette {
cell.accessoryType = .checkmark
} else {
cell.accessoryType = .none
}
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let colorPalette = UserInterfaceColorPalette(rawValue: indexPath.row) {
AppDefaults.userInterfaceColorPalette = colorPalette
}
navigationController?.popViewController(animated: true)
}
}
+25 -50
View File
@@ -428,7 +428,7 @@
</tableViewSection>
<tableViewSection headerTitle="Appearance" id="TkH-4v-yhk">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" id="EvG-yE-gDF" customClass="VibrantBasicTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="EvG-yE-gDF" customClass="VibrantBasicTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="1152" width="374" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="EvG-yE-gDF" id="wBN-zJ-6pN">
@@ -441,24 +441,37 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Automatic" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="16m-Ns-Y8V">
<rect key="frame" x="258" y="15.5" width="77.5" height="20.5"/>
</subviews>
<constraints>
<constraint firstItem="2Fp-li-dGP" firstAttribute="leading" secondItem="wBN-zJ-6pN" secondAttribute="leadingMargin" id="g40-ob-1IK"/>
<constraint firstItem="2Fp-li-dGP" firstAttribute="centerY" secondItem="wBN-zJ-6pN" secondAttribute="centerY" id="geh-mE-9X7"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="label" destination="2Fp-li-dGP" id="gyE-t6-U2X"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="Ucd-a1-Cel" customClass="VibrantBasicTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="1203" width="374" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Ucd-a1-Cel" id="Ucd-b2-Cnt">
<rect key="frame" x="0.0" y="0.0" width="343.5" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Unread Counts" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ucd-c3-Lbl">
<rect key="frame" x="20" y="15.5" width="110" height="20.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="16m-Ns-Y8V" firstAttribute="trailing" secondItem="wBN-zJ-6pN" secondAttribute="trailingMargin" id="R1e-JV-gyn"/>
<constraint firstItem="16m-Ns-Y8V" firstAttribute="centerY" secondItem="wBN-zJ-6pN" secondAttribute="centerY" id="SXW-Hv-5bK"/>
<constraint firstItem="2Fp-li-dGP" firstAttribute="leading" secondItem="wBN-zJ-6pN" secondAttribute="leadingMargin" id="g40-ob-1IK"/>
<constraint firstItem="2Fp-li-dGP" firstAttribute="centerY" secondItem="wBN-zJ-6pN" secondAttribute="centerY" id="geh-mE-9X7"/>
<constraint firstItem="16m-Ns-Y8V" firstAttribute="leading" secondItem="2Fp-li-dGP" secondAttribute="trailing" constant="8" symbolic="YES" id="tOP-jh-wxR"/>
<constraint firstItem="Ucd-c3-Lbl" firstAttribute="leading" secondItem="Ucd-b2-Cnt" secondAttribute="leadingMargin" id="Ucd-g7-Ld1"/>
<constraint firstItem="Ucd-c3-Lbl" firstAttribute="centerY" secondItem="Ucd-b2-Cnt" secondAttribute="centerY" id="Ucd-h8-Cy2"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="detail" destination="16m-Ns-Y8V" id="Z0c-2s-usf"/>
<outlet property="label" destination="2Fp-li-dGP" id="gyE-t6-U2X"/>
<outlet property="label" destination="Ucd-c3-Lbl" id="Ucd-k1-Ol1"/>
</connections>
</tableViewCell>
</cells>
@@ -656,7 +669,7 @@
</navigationItem>
<connections>
<outlet property="articleThemeDetailLabel" destination="DUf-DZ-3Nm" id="QHN-Le-zyw"/>
<outlet property="colorPaletteDetailLabel" destination="16m-Ns-Y8V" id="zdj-Ag-ZUw"/>
<outlet property="colorPaletteCell" destination="EvG-yE-gDF" id="zdj-Ag-ZUw"/>
<outlet property="confirmMarkAllAsReadSwitch" destination="UOo-9z-IuL" id="yLZ-Kf-wDt"/>
<outlet property="enableJavaScriptSwitch" destination="Djo-HE-LWS" id="muL-I5-eDE"/>
<outlet property="groupByFeedSwitch" destination="JNi-Wz-RbU" id="TwH-Kd-o6N"/>
@@ -664,6 +677,7 @@
<outlet property="refreshClearsReadArticlesSwitch" destination="duV-CN-JmH" id="xTd-jF-Ei1"/>
<outlet property="showFullscreenArticlesSwitch" destination="2Md-2E-7Z4" id="lEN-VP-wEO"/>
<outlet property="timelineSortOrderSwitch" destination="Keq-Np-l9O" id="Zm7-HG-r5h"/>
<outlet property="unreadCountDisplayCell" destination="Ucd-a1-Cel" id="Ucd-u1-Out"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="GZq-IX-Qod" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -805,45 +819,6 @@
</objects>
<point key="canvasLocation" x="3743" y="151"/>
</scene>
<!--Color Palette-->
<scene sceneID="i2s-Vf-U8q">
<objects>
<tableViewController storyboardIdentifier="ColorPaletteTableViewController" title="Color Palette" id="4je-jl-or5" customClass="ColorPaletteTableViewController" customModule="NetNewsWire" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="insetGrouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="nt4-zl-48k">
<rect key="frame" x="0.0" y="0.0" width="414" height="746"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="lFx-ni-1UR" style="IBUITableViewCellStyleDefault" id="Dzq-cs-s7M" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="55.5" width="374" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Dzq-cs-s7M" id="eAg-RP-lRc">
<rect key="frame" x="0.0" y="0.0" width="374" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" id="lFx-ni-1UR">
<rect key="frame" x="20" y="0.0" width="334" height="51"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<sections/>
<connections>
<outlet property="dataSource" destination="4je-jl-or5" id="Dhv-6P-h0J"/>
<outlet property="delegate" destination="4je-jl-or5" id="SQg-Zw-nSl"/>
</connections>
</tableView>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yl7-jL-bYF" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="4403" y="151"/>
</scene>
</scenes>
<resources>
<namedColor name="primaryAccentColor">
+63 -6
View File
@@ -73,13 +73,17 @@ final class SettingsViewController: UITableViewController {
@IBOutlet var articleThemeDetailLabel: UILabel!
@IBOutlet var confirmMarkAllAsReadSwitch: UISwitch!
@IBOutlet var showFullscreenArticlesSwitch: UISwitch!
@IBOutlet var colorPaletteDetailLabel: UILabel!
@IBOutlet var colorPaletteCell: UITableViewCell?
@IBOutlet var unreadCountDisplayCell: UITableViewCell?
@IBOutlet var openLinksInNetNewsWire: UISwitch!
@IBOutlet var enableJavaScriptSwitch: UISwitch!
var scrollToArticlesSection = false
weak var presentingParentController: UIViewController?
private lazy var colorPalettePopUpButton = Self.makePopUpButton()
private lazy var unreadCountDisplayPopUpButton = Self.makePopUpButton()
override func viewDidLoad() {
// This hack mostly works around a bug in static tables with dynamic type. See: https://spin.atomicobject.com/2018/10/15/dynamic-type-static-uitableview/
NotificationCenter.default.removeObserver(tableView!, name: UIContentSizeCategory.didChangeNotification, object: nil)
@@ -88,12 +92,19 @@ final class SettingsViewController: UITableViewController {
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidAddAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidDeleteAccount, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleUserInterfaceColorPaletteDidUpdate(_:)), name: .userInterfaceColorPaletteDidUpdate, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleUnreadCountDisplaySettingDidChange(_:)), name: .unreadCountDisplaySettingDidChange, object: nil)
tableView.register(UINib(nibName: "SettingsComboTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsComboTableViewCell")
tableView.register(UINib(nibName: "SettingsTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsTableViewCell")
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 44
addPopUpButton(colorPalettePopUpButton, to: colorPaletteCell)
addPopUpButton(unreadCountDisplayPopUpButton, to: unreadCountDisplayCell)
updateColorPalettePopUpButton()
updateUnreadCountDisplayPopUpButton()
}
override func viewWillAppear(_ animated: Bool) {
@@ -137,8 +148,6 @@ final class SettingsViewController: UITableViewController {
enableJavaScriptSwitch.isOn = false
}
colorPaletteDetailLabel.text = String(describing: AppDefaults.userInterfaceColorPalette)
openLinksInNetNewsWire.isOn = !AppDefaults.shared.useSystemBrowser
let buildLabel = NonIntrinsicLabel(frame: CGRect(x: 32.0, y: 0.0, width: 0.0, height: 0.0))
@@ -273,9 +282,6 @@ final class SettingsViewController: UITableViewController {
default:
break
}
case .appearance:
let colorPalette = UIStoryboard.settings.instantiateController(ofType: ColorPaletteTableViewController.self)
self.navigationController?.pushViewController(colorPalette, animated: true)
case .troubleshooting:
let viewController: UIViewController? = {
switch TroubleshootingRow(rawValue: indexPath.row) {
@@ -426,6 +432,14 @@ final class SettingsViewController: UITableViewController {
tableView.reloadData()
}
@objc func handleUserInterfaceColorPaletteDidUpdate(_ notification: Notification) {
updateColorPalettePopUpButton()
}
@objc func handleUnreadCountDisplaySettingDidChange(_ notification: Notification) {
updateUnreadCountDisplayPopUpButton()
}
}
// MARK: - OPML Document Picker
@@ -453,6 +467,49 @@ extension SettingsViewController: UIDocumentPickerDelegate {
private extension SettingsViewController {
static func makePopUpButton() -> UIButton {
var configuration = UIButton.Configuration.plain()
configuration.baseForegroundColor = .secondaryLabel
let button = UIButton(configuration: configuration)
button.showsMenuAsPrimaryAction = true
button.changesSelectionAsPrimaryAction = true
return button
}
/// Auto Layout lets the button resize itself when choosing an item changes its title.
func addPopUpButton(_ button: UIButton, to cell: UITableViewCell?) {
guard let cell else {
return
}
button.translatesAutoresizingMaskIntoConstraints = false
button.setContentCompressionResistancePriority(.required, for: .horizontal)
cell.contentView.addSubview(button)
NSLayoutConstraint.activate([
button.trailingAnchor.constraint(equalTo: cell.contentView.layoutMarginsGuide.trailingAnchor),
button.centerYAnchor.constraint(equalTo: cell.contentView.centerYAnchor)
])
}
func updateColorPalettePopUpButton() {
let currentColorPalette = AppDefaults.userInterfaceColorPalette
let actions = UserInterfaceColorPalette.allCases.map { colorPalette in
UIAction(title: String(describing: colorPalette), state: colorPalette == currentColorPalette ? .on : .off) { _ in
AppDefaults.userInterfaceColorPalette = colorPalette
}
}
colorPalettePopUpButton.menu = UIMenu(children: actions)
}
func updateUnreadCountDisplayPopUpButton() {
let currentUnreadCountDisplay = AppDefaults.shared.unreadCountDisplay
let actions = UnreadCountDisplay.allCases.map { unreadCountDisplay in
UIAction(title: String(describing: unreadCountDisplay), state: unreadCountDisplay == currentUnreadCountDisplay ? .on : .off) { _ in
AppDefaults.shared.unreadCountDisplay = unreadCountDisplay
}
}
unreadCountDisplayPopUpButton.menu = UIMenu(children: actions)
}
func addFeed() {
self.dismiss(animated: true)
@@ -0,0 +1,22 @@
//
// UnreadCountDisplay+Description.swift
// NetNewsWire
//
// Created by Brent Simmons on 10/6/26.
//
import Foundation
extension UnreadCountDisplay: CustomStringConvertible {
var description: String {
switch self {
case .count:
NSLocalizedString("Show", comment: "Show")
case .dot:
NSLocalizedString("Show dot", comment: "Unread Counts setting: show a dot instead of the number of unread articles")
case .hidden:
NSLocalizedString("Hide", comment: "Hide")
}
}
}