From 859bbe5476fc02134d2e674546126c6783a7dfd9 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Thu, 12 Nov 2026 13:48:34 -0800 Subject: [PATCH] Add iOS setting for enabling swipe to next/previous articles. Off for new users, but true by default for existing users. --- Shared/AppNotifications.swift | 1 + iOS/AppDefaults+iOS.swift | 12 ++++++++ iOS/AppDelegate.swift | 1 + iOS/Article/ArticleViewController.swift | 12 +++++++- iOS/Settings/Settings.storyboard | 35 +++++++++++++++++++++++ iOS/Settings/SettingsViewController.swift | 9 +++++- 6 files changed, 68 insertions(+), 2 deletions(-) diff --git a/Shared/AppNotifications.swift b/Shared/AppNotifications.swift index 647a3c4fe..2d281a8c1 100644 --- a/Shared/AppNotifications.swift +++ b/Shared/AppNotifications.swift @@ -14,6 +14,7 @@ extension Notification.Name { static let UserDidAddFeed = Notification.Name("UserDidAddFeedNotification") static let WebInspectorEnabledDidChange = Notification.Name("WebInspectorEnabledDidChange") static let sidebarShowsIconsDidChange = Notification.Name("SidebarShowsIconsDidChangeNotification") + static let articleSwipeNavigationEnabledDidChange = Notification.Name("ArticleSwipeNavigationEnabledDidChangeNotification") static let grayscaleIconsDidChange = Notification.Name("GrayscaleIconsDidChangeNotification") static let sidebarSmartFeedsVisibilityDidChange = Notification.Name("SidebarSmartFeedsVisibilityDidChangeNotification") static let timelineIconSizeDidChange = Notification.Name("TimelineIconSizeDidChangeNotification") diff --git a/iOS/AppDefaults+iOS.swift b/iOS/AppDefaults+iOS.swift index c1bc02e2c..8a7b66bb1 100644 --- a/iOS/AppDefaults+iOS.swift +++ b/iOS/AppDefaults+iOS.swift @@ -19,6 +19,7 @@ extension AppDefaults.Key { static let articleFullscreenEnabled = "articleFullscreenEnabled" static let confirmMarkAllAsRead = "confirmMarkAllAsRead" static let showPreviewInTimelineContextMenu = "showPreviewInTimelineContextMenu" + static let articleSwipeNavigationEnabled = "articleSwipeNavigationEnabled" static let lastRefresh = "lastRefresh" static let useSystemBrowser = "useSystemBrowser" static let hideReadFeeds = "hideReadFeeds" @@ -120,6 +121,16 @@ extension AppDefaults { } } + static var articleSwipeNavigationEnabled: Bool { + get { + UserDefaults.standard.bool(forKey: Key.articleSwipeNavigationEnabled) + } + set { + UserDefaults.standard.set(newValue, forKey: Key.articleSwipeNavigationEnabled) + NotificationCenter.default.post(name: .articleSwipeNavigationEnabledDidChange, object: nil) + } + } + static var splitViewPreferredDisplayMode: Int { get { UserDefaults.standard.integer(forKey: Key.splitViewPreferredDisplayMode) @@ -298,6 +309,7 @@ extension AppDefaults { Key.articleFullscreenEnabled: false, Key.confirmMarkAllAsRead: true, Key.showPreviewInTimelineContextMenu: false, + Key.articleSwipeNavigationEnabled: true, Key.splitViewPreferredDisplayMode: UISplitViewController.DisplayMode.oneBesideSecondary.rawValue ] diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index b4405e858..e00246afc 100644 --- a/iOS/AppDelegate.swift +++ b/iOS/AppDelegate.swift @@ -71,6 +71,7 @@ import Images let isFirstRun = AppDefaults.isFirstRun if isFirstRun { Self.logger.info("Is first run.") + AppDefaults.articleSwipeNavigationEnabled = false } if isFirstRun && !AccountManager.shared.anyAccountHasAtLeastOneFeed() { diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index 888086cda..db77ba308 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -127,6 +127,7 @@ final class ArticleViewController: UIViewController { NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange(_:)), name: UIContentSizeCategory.didChangeNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleArticleSwipeNavigationEnabledDidChange(_:)), name: .articleSwipeNavigationEnabledDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil) let appearance = UINavigationBarAppearance() @@ -182,7 +183,7 @@ final class ArticleViewController: UIViewController { pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: [:]) pageViewController.delegate = self - pageViewController.dataSource = self + updatePageViewControllerDataSource() // This code is to disallow paging if we scroll from the left edge. If this code is removed // PoppableGestureRecognizerDelegate will allow us to both navigate back and page back at the @@ -347,6 +348,15 @@ final class ArticleViewController: UIViewController { currentWebViewController?.fullReload() } + @objc func handleArticleSwipeNavigationEnabledDidChange(_ notification: Notification) { + updatePageViewControllerDataSource() + } + + /// A nil data source turns off swipe paging. `setViewControllers` still works. + func updatePageViewControllerDataSource() { + pageViewController.dataSource = AppDefaults.articleSwipeNavigationEnabled ? self : nil + } + @objc func willEnterForeground(_ note: Notification) { // The toolbar will come back on you if you don't hide it again if AppDefaults.logicalArticleFullscreenEnabled { diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard index 406a9b913..99603c5dc 100644 --- a/iOS/Settings/Settings.storyboard +++ b/iOS/Settings/Settings.storyboard @@ -552,6 +552,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -875,6 +909,7 @@ + diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift index 604d55e74..f34d57136 100644 --- a/iOS/Settings/SettingsViewController.swift +++ b/iOS/Settings/SettingsViewController.swift @@ -56,7 +56,8 @@ final class SettingsViewController: UITableViewController { case theme = 0 case openLinksInNetNewsWire = 1 case enableJavaScript = 2 - case enableFullScreenArticles = 3 + case swipeToNextPreviousArticle = 3 + case enableFullScreenArticles = 4 } private enum HelpRow: Int { @@ -80,6 +81,7 @@ final class SettingsViewController: UITableViewController { @IBOutlet var unreadCountDisplayCell: UITableViewCell? @IBOutlet var openLinksInNetNewsWire: UISwitch! @IBOutlet var enableJavaScriptSwitch: UISwitch! + @IBOutlet var swipeToNextPreviousArticleSwitch: UISwitch? @IBOutlet var sidebarShowsIconsSwitch: UISwitch? @IBOutlet var grayscaleIconsSwitch: UISwitch? @IBOutlet var showTodayFeedSwitch: UISwitch? @@ -151,6 +153,7 @@ final class SettingsViewController: UITableViewController { } showPreviewInTimelineContextMenuSwitch?.isOn = AppDefaults.showPreviewInTimelineContextMenu + swipeToNextPreviousArticleSwitch?.isOn = AppDefaults.articleSwipeNavigationEnabled if AppDefaults.articleFullscreenAvailable { showFullscreenArticlesSwitch.isOn = true @@ -448,6 +451,10 @@ final class SettingsViewController: UITableViewController { } } + @IBAction func switchSwipeToNextPreviousArticle(_ sender: UISwitch) { + AppDefaults.articleSwipeNavigationEnabled = sender.isOn + } + @IBAction func switchJavaScriptPreference(_ sender: Any) { AppDefaults.isArticleContentJavascriptEnabled = enableJavaScriptSwitch.isOn }