From aa9677c66769355b20a656f3657c8b11dd3aa3d2 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 14 Nov 2026 10:51:56 -0800 Subject: [PATCH] Move Articles settings to its own screen. --- Shared/Localizable.xcstrings | 21 ++ .../MarkAsReadAlertController.swift | 2 +- iOS/SceneCoordinator.swift | 4 +- .../ArticlesSettingsViewController.swift | 148 +++++++++++++ iOS/Settings/Settings.storyboard | 208 ++---------------- iOS/Settings/SettingsViewController.swift | 90 +------- 6 files changed, 201 insertions(+), 272 deletions(-) create mode 100644 iOS/Settings/ArticlesSettingsViewController.swift diff --git a/Shared/Localizable.xcstrings b/Shared/Localizable.xcstrings index 2e3348a5c..6648f0367 100644 --- a/Shared/Localizable.xcstrings +++ b/Shared/Localizable.xcstrings @@ -559,6 +559,15 @@ "Email" : { "comment" : "Email field placeholder" }, + "Enable Full Screen Articles" : { + "comment" : "Enable Full Screen Articles" + }, + "Enable Horizontal Swipe to Previous and Next Article" : { + "comment" : "Enable Horizontal Swipe to Previous and Next Article" + }, + "Enable JavaScript" : { + "comment" : "Enable JavaScript" + }, "Enable Notifications" : { "comment" : "Notifications" }, @@ -1076,6 +1085,9 @@ "Open in Browser in Foreground" : { "comment" : "Open in Browser in Foreground menu item title" }, + "Open Links in NetNewsWire" : { + "comment" : "Open Links in NetNewsWire" + }, "Open Settings" : { "comment" : "Open Settings button" }, @@ -1380,6 +1392,9 @@ "Smart Feeds" : { "comment" : "Smart Feeds group title" }, + "Some content, such as videos and embedded social media posts, may require JavaScript to work correctly." : { + "comment" : "Some content, such as videos and embedded social media posts, may require JavaScript to work correctly." + }, "Sort Oldest to Newest" : { "comment" : "Sort Oldest to Newest" }, @@ -1438,6 +1453,9 @@ } } }, + "Tap the article top bar to enter Full Screen. Tap the top or bottom to exit." : { + "comment" : "Tap the article top bar to enter Full Screen. Tap the top or bottom to exit." + }, "Thanks to Sheila and my family; thanks to my friends in Seattle and around the globe; thanks to the ever-patient and ever-awesome NetNewsWire beta testers.\n\nThanks to [Gus Mueller](https://shapeof.com/) for [FMDB](https://github.com/ccgus/fmdb) by [Flying Meat Software](http://flyingmeat.com/). Thanks to [GitHub](https://github.com) and [Discourse](https://discourse.com) for making open source collaboration easy and fun. Thanks to [Ben Ubois](https://benubois.com/) at [Feedbin](https://feedbin.com) for all the extra help with syncing and article rendering — and [for hosting the server for the Reader view](https://feedbin.com/blog/2019/03/11/the-future-of-full-content/)." : { "comment" : "A list of credits for the app.", "isCommentAutoGenerated" : true @@ -1458,6 +1476,9 @@ "The theme “%@” has been installed." : { "comment" : "Theme installed" }, + "Theme" : { + "comment" : "Theme" + }, "Theme Error" : { "comment" : "Theme download error" }, diff --git a/iOS/MainTimeline/MarkAsReadAlertController.swift b/iOS/MainTimeline/MarkAsReadAlertController.swift index ed392a44e..a286762a6 100644 --- a/iOS/MainTimeline/MarkAsReadAlertController.swift +++ b/iOS/MainTimeline/MarkAsReadAlertController.swift @@ -56,7 +56,7 @@ extension UIBarButtonItem: MarkAsReadAlertControllerSourceType {} } let settingsAction = UIAlertAction(title: settingsTitle, style: .default) { _ in Task { @MainActor in - coordinator.showSettings(scrollToArticlesSection: true) + coordinator.showSettings(showTimelineSettings: true) } } let markAction = UIAlertAction(title: confirmTitle, style: .default, handler: completion) diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 110a7a8ab..3576723c6 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -1608,10 +1608,10 @@ struct SidebarItemNode: Hashable, Sendable { } } - func showSettings(scrollToArticlesSection: Bool = false) { + func showSettings(showTimelineSettings: Bool = false) { let settingsNavController = UIStoryboard.settings.instantiateInitialViewController() as! UINavigationController let settingsViewController = settingsNavController.topViewController as! SettingsViewController - settingsViewController.scrollToArticlesSection = scrollToArticlesSection + settingsViewController.showTimelineSettings = showTimelineSettings settingsNavController.modalPresentationStyle = .formSheet settingsViewController.presentingParentController = rootSplitViewController rootSplitViewController.present(settingsNavController, animated: true) diff --git a/iOS/Settings/ArticlesSettingsViewController.swift b/iOS/Settings/ArticlesSettingsViewController.swift new file mode 100644 index 000000000..1b6cf1614 --- /dev/null +++ b/iOS/Settings/ArticlesSettingsViewController.swift @@ -0,0 +1,148 @@ +// +// ArticlesSettingsViewController.swift +// NetNewsWire-iOS +// +// Created by Brent Simmons on 11/17/26. +// Copyright © 2026 Ranchero Software. All rights reserved. +// + +import UIKit + +final class ArticlesSettingsViewController: UITableViewController { + + private enum Row: Int, CaseIterable { + case theme + case openLinksInNetNewsWire + case enableJavaScript + case swipeToNextPreviousArticle + case enableFullScreenArticles + } + + private let openLinksInNetNewsWireSwitch = UISwitch() + private let enableJavaScriptSwitch = UISwitch() + private let swipeToNextPreviousArticleSwitch = UISwitch() + private let enableFullScreenArticlesSwitch = UISwitch() + + private let themeCell = VibrantTableViewCell(style: .value1, reuseIdentifier: nil) + + private var rows = [Row]() + private var cells = [Row: UITableViewCell]() + + init() { + super.init(style: .insetGrouped) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func viewDidLoad() { + super.viewDidLoad() + title = NSLocalizedString("Articles", comment: "Articles") + + // The Full Screen Articles row is iPhone-only. + rows = Row.allCases.filter { $0 != .enableFullScreenArticles || traitCollection.userInterfaceIdiom == .phone } + + themeCell.textLabel?.text = NSLocalizedString("Theme", comment: "Theme") + themeCell.textLabel?.adjustsFontForContentSizeCategory = true + themeCell.detailTextLabel?.adjustsFontForContentSizeCategory = true + themeCell.accessoryType = .disclosureIndicator + + cells[.theme] = themeCell + cells[.openLinksInNetNewsWire] = makeCell(switch: openLinksInNetNewsWireSwitch, + title: NSLocalizedString("Open Links in NetNewsWire", comment: "Open Links in NetNewsWire"), + footnote: nil, + action: #selector(switchOpenLinksInNetNewsWire(_:))) + cells[.enableJavaScript] = makeCell(switch: enableJavaScriptSwitch, + title: NSLocalizedString("Enable JavaScript", comment: "Enable JavaScript"), + footnote: NSLocalizedString("Some content, such as videos and embedded social media posts, may require JavaScript to work correctly.", comment: "Some content, such as videos and embedded social media posts, may require JavaScript to work correctly."), + action: #selector(switchEnableJavaScript(_:))) + cells[.swipeToNextPreviousArticle] = makeCell(switch: swipeToNextPreviousArticleSwitch, + title: NSLocalizedString("Enable Horizontal Swipe to Previous and Next Article", comment: "Enable Horizontal Swipe to Previous and Next Article"), + footnote: nil, + action: #selector(switchSwipeToNextPreviousArticle(_:))) + cells[.enableFullScreenArticles] = makeCell(switch: enableFullScreenArticlesSwitch, + title: NSLocalizedString("Enable Full Screen Articles", comment: "Enable Full Screen Articles"), + footnote: NSLocalizedString("Tap the article top bar to enter Full Screen. Tap the top or bottom to exit.", comment: "Tap the article top bar to enter Full Screen. Tap the top or bottom to exit."), + action: #selector(switchEnableFullScreenArticles(_:))) + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + themeCell.detailTextLabel?.text = ArticleThemesManager.shared.currentTheme.name + openLinksInNetNewsWireSwitch.isOn = !AppDefaults.useSystemBrowser + enableJavaScriptSwitch.isOn = AppDefaults.isArticleContentJavascriptEnabled + swipeToNextPreviousArticleSwitch.isOn = AppDefaults.articleSwipeNavigationEnabled + enableFullScreenArticlesSwitch.isOn = AppDefaults.articleFullscreenAvailable + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + tableView.selectRow(at: nil, animated: true, scrollPosition: .none) + } + + // MARK: - UITableViewDataSource + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return rows.count + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return cells[rows[indexPath.row]] ?? UITableViewCell() + } + + // MARK: - UITableViewDelegate + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + switch rows[indexPath.row] { + case .theme: + let articleThemes = UIStoryboard.settings.instantiateController(ofType: ArticleThemesTableViewController.self) + navigationController?.pushViewController(articleThemes, animated: true) + default: + tableView.selectRow(at: nil, animated: true, scrollPosition: .none) + } + } + + // MARK: - Actions + + @objc func switchOpenLinksInNetNewsWire(_ sender: UISwitch) { + AppDefaults.useSystemBrowser = !sender.isOn + } + + @objc func switchEnableJavaScript(_ sender: UISwitch) { + AppDefaults.isArticleContentJavascriptEnabled = sender.isOn + } + + @objc func switchSwipeToNextPreviousArticle(_ sender: UISwitch) { + AppDefaults.articleSwipeNavigationEnabled = sender.isOn + } + + @objc func switchEnableFullScreenArticles(_ sender: UISwitch) { + AppDefaults.articleFullscreenAvailable = sender.isOn + } +} + +// MARK: - Private + +private extension ArticlesSettingsViewController { + + /// A plain cell, rather than a vibrant one, so the footnote keeps its secondary color. + func makeCell(switch toggle: UISwitch, title: String, footnote: String?, action: Selector) -> UITableViewCell { + let cell = UITableViewCell(style: footnote == nil ? .default : .subtitle, reuseIdentifier: nil) + cell.selectionStyle = .none + cell.textLabel?.text = title + cell.textLabel?.numberOfLines = 0 + cell.textLabel?.adjustsFontForContentSizeCategory = true + if let footnote { + cell.detailTextLabel?.text = footnote + cell.detailTextLabel?.numberOfLines = 0 + cell.detailTextLabel?.font = .preferredFont(forTextStyle: .footnote) + cell.detailTextLabel?.textColor = .secondaryLabel + cell.detailTextLabel?.adjustsFontForContentSizeCategory = true + } + toggle.onTintColor = Assets.Colors.primaryAccent + toggle.addTarget(self, action: action, for: .valueChanged) + cell.accessoryView = toggle + return cell + } +} diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard index 3f8a6bc2e..49f948aa7 100644 --- a/iOS/Settings/Settings.storyboard +++ b/iOS/Settings/Settings.storyboard @@ -115,192 +115,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -337,6 +151,23 @@ + + + + + + + + + + + @@ -404,11 +235,6 @@ - - - - - diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift index 230832a3a..a748f7094 100644 --- a/iOS/Settings/SettingsViewController.swift +++ b/iOS/Settings/SettingsViewController.swift @@ -20,16 +20,16 @@ final class SettingsViewController: UITableViewController { case notifications = 0 case accounts = 1 case feeds = 2 - case articles = 3 - case moreScreens = 4 + case moreScreens = 3 } private enum MoreScreensRow: Int { case sidebar = 0 case timeline = 1 - case appearance = 2 - case troubleshooting = 3 - case help = 4 + case articles = 2 + case appearance = 3 + case troubleshooting = 4 + case help = 5 } private enum FeedsRow: Int { @@ -38,23 +38,10 @@ final class SettingsViewController: UITableViewController { case addNetNewsWireNewsFeed = 2 } - private enum ArticlesRow: Int, CaseIterable { - case theme = 0 - case openLinksInNetNewsWire = 1 - case enableJavaScript = 2 - case swipeToNextPreviousArticle = 3 - case enableFullScreenArticles = 4 - } - private weak var opmlAccount: Account? - @IBOutlet var articleThemeDetailLabel: UILabel! - @IBOutlet var showFullscreenArticlesSwitch: UISwitch! - @IBOutlet var openLinksInNetNewsWire: UISwitch! - @IBOutlet var enableJavaScriptSwitch: UISwitch! - @IBOutlet var swipeToNextPreviousArticleSwitch: UISwitch? - - var scrollToArticlesSection = false + /// Pushes the Timeline screen on appearing, so a user can turn off the Mark All as Read confirmation. + var showTimelineSettings = false weak var presentingParentController: UIViewController? override func viewDidLoad() { @@ -76,24 +63,6 @@ final class SettingsViewController: UITableViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - articleThemeDetailLabel.text = ArticleThemesManager.shared.currentTheme.name - - swipeToNextPreviousArticleSwitch?.isOn = AppDefaults.articleSwipeNavigationEnabled - - if AppDefaults.articleFullscreenAvailable { - showFullscreenArticlesSwitch.isOn = true - } else { - showFullscreenArticlesSwitch.isOn = false - } - - if AppDefaults.isArticleContentJavascriptEnabled { - enableJavaScriptSwitch.isOn = true - } else { - enableJavaScriptSwitch.isOn = false - } - - openLinksInNetNewsWire.isOn = !AppDefaults.useSystemBrowser - let buildLabel = CopyableLabel(frame: CGRect(x: 32.0, y: 0.0, width: 0.0, height: 0.0)) buildLabel.font = UIFont.systemFont(ofSize: 11.0) buildLabel.textColor = UIColor.gray @@ -103,18 +72,16 @@ final class SettingsViewController: UITableViewController { let wrapperView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.bounds.width, height: buildLabel.frame.height + 10.0)) wrapperView.addSubview(buildLabel) tableView.tableFooterView = wrapperView - } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) self.tableView.selectRow(at: nil, animated: true, scrollPosition: .none) - if scrollToArticlesSection { - tableView.scrollToRow(at: IndexPath(row: 0, section: Section.articles.rawValue), at: .top, animated: true) - scrollToArticlesSection = false + if showTimelineSettings { + showTimelineSettings = false + navigationController?.pushViewController(TimelineSettingsViewController(), animated: true) } - } // MARK: UITableView @@ -130,9 +97,6 @@ final class SettingsViewController: UITableViewController { return defaultNumberOfRows - 1 } return defaultNumberOfRows - case .articles: - // The Full Screen Articles row is iPhone-only. - return traitCollection.userInterfaceIdiom == .phone ? ArticlesRow.allCases.count : ArticlesRow.allCases.count - 1 default: return super.tableView(tableView, numberOfRowsInSection: section) } @@ -202,20 +166,14 @@ final class SettingsViewController: UITableViewController { default: break } - case .articles: - switch ArticlesRow(rawValue: indexPath.row) { - case .theme: - let articleThemes = UIStoryboard.settings.instantiateController(ofType: ArticleThemesTableViewController.self) - self.navigationController?.pushViewController(articleThemes, animated: true) - default: - break - } case .moreScreens: switch MoreScreensRow(rawValue: indexPath.row) { case .sidebar: self.navigationController?.pushViewController(SidebarSettingsViewController(), animated: true) case .timeline: self.navigationController?.pushViewController(TimelineSettingsViewController(), animated: true) + case .articles: + self.navigationController?.pushViewController(ArticlesSettingsViewController(), animated: true) case .appearance: self.navigationController?.pushViewController(AppearanceSettingsViewController(), animated: true) case .troubleshooting: @@ -258,30 +216,6 @@ final class SettingsViewController: UITableViewController { dismiss(animated: true) } - @IBAction func switchFullscreenArticles(_ sender: Any) { - if showFullscreenArticlesSwitch.isOn { - AppDefaults.articleFullscreenAvailable = true - } else { - AppDefaults.articleFullscreenAvailable = false - } - } - - @IBAction func switchBrowserPreference(_ sender: Any) { - if openLinksInNetNewsWire.isOn { - AppDefaults.useSystemBrowser = false - } else { - AppDefaults.useSystemBrowser = true - } - } - - @IBAction func switchSwipeToNextPreviousArticle(_ sender: UISwitch) { - AppDefaults.articleSwipeNavigationEnabled = sender.isOn - } - - @IBAction func switchJavaScriptPreference(_ sender: Any) { - AppDefaults.isArticleContentJavascriptEnabled = enableJavaScriptSwitch.isOn - } - // MARK: - Notifications @objc func contentSizeCategoryDidChange() {