Add iOS setting for enabling swipe to next/previous articles. Off for new users, but true by default for existing users.

This commit is contained in:
Brent Simmons committed 2026-11-12 13:48:34 -08:00
1 parent 175cb0436d
commit 859bbe5476
6 files changed
+68 -2

No files matched your search

+1
View File
@@ -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")
+12
View File
@@ -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
]
+1
View File
@@ -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() {
+11 -1
View File
@@ -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 {
+35
View File
@@ -552,6 +552,40 @@
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="Sw1-pe-Cel" customClass="VibrantBasicTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="1004" width="374" height="51.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Sw1-pe-Cel" id="Sw1-pe-Cnt">
<rect key="frame" x="0.0" y="0.0" width="374" height="51.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="749" text="Enable Horizontal Swipe to Previous and Next Article" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Sw1-pe-Lbl">
<rect key="frame" x="20" y="15" width="265" height="21.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Sw1-pe-Swt" userLabel="Enable Horizontal Swipe to Previous and Next Article">
<rect key="frame" x="293" y="12" width="63" height="28"/>
<color key="onTintColor" name="primaryAccentColor"/>
<connections>
<action selector="switchSwipeToNextPreviousArticle:" destination="a0p-rk-skQ" eventType="valueChanged" id="Sw1-pe-Act"/>
</connections>
</switch>
</subviews>
<constraints>
<constraint firstItem="Sw1-pe-Swt" firstAttribute="leading" secondItem="Sw1-pe-Lbl" secondAttribute="trailing" constant="8" symbolic="YES" id="Sw1-pe-C01"/>
<constraint firstItem="Sw1-pe-Lbl" firstAttribute="top" secondItem="Sw1-pe-Cnt" secondAttribute="topMargin" id="Sw1-pe-C02"/>
<constraint firstAttribute="bottomMargin" secondItem="Sw1-pe-Lbl" secondAttribute="bottom" id="Sw1-pe-C03"/>
<constraint firstAttribute="trailingMargin" secondItem="Sw1-pe-Swt" secondAttribute="trailing" id="Sw1-pe-C04"/>
<constraint firstItem="Sw1-pe-Swt" firstAttribute="centerY" secondItem="Sw1-pe-Cnt" secondAttribute="centerY" id="Sw1-pe-C05"/>
<constraint firstItem="Sw1-pe-Lbl" firstAttribute="leading" secondItem="Sw1-pe-Cnt" secondAttribute="leadingMargin" id="Sw1-pe-C06"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="label" destination="Sw1-pe-Lbl" id="Sw1-pe-Out"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="WR6-xo-ty2" customClass="VibrantTableViewCell" customModule="NetNewsWire" customModuleProvider="target">
<rect key="frame" x="20" y="1004" width="374" height="92"/>
<autoresizingMask key="autoresizingMask"/>
@@ -875,6 +909,7 @@
<outlet property="confirmMarkAllAsReadSwitch" destination="UOo-9z-IuL" id="yLZ-Kf-wDt"/>
<outlet property="showPreviewInTimelineContextMenuSwitch" destination="pTc-Mp-c04" id="pTc-Mp-c14"/>
<outlet property="enableJavaScriptSwitch" destination="Djo-HE-LWS" id="muL-I5-eDE"/>
<outlet property="swipeToNextPreviousArticleSwitch" destination="Sw1-pe-Swt" id="Sw1-pe-Ot2"/>
<outlet property="grayscaleIconsSwitch" destination="Gry-s4-Swt" id="Gry-o1-Out"/>
<outlet property="groupByFeedSwitch" destination="JNi-Wz-RbU" id="TwH-Kd-o6N"/>
<outlet property="openLinksInNetNewsWire" destination="dhR-L2-PX3" id="z1b-pX-bwG"/>
+8 -1
View File
@@ -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
}