This commit is contained in:
Brent Simmons committed 2026-11-12 13:48:46 -08:00
commit 90aaf2e632
15 files changed
+157 -17

No files matched your search

+13 -1
View File
@@ -120,6 +120,9 @@ final class ArticleViewController: UIViewController {
override var keyCommands: [UIKeyCommand]? {
return keyboardManager.keyCommands
}
override var canBecomeFirstResponder: Bool {
true
}
override func viewDidLoad() {
super.viewDidLoad()
@@ -412,10 +415,19 @@ final class ArticleViewController: UIViewController {
coordinator.navigateToTimeline()
}
@objc func scrollLineDown(_ sender: Any?) {
currentWebViewController?.scrollLineDown()
}
@objc func scrollLineUp(_ sender: Any?) {
currentWebViewController?.scrollLineUp()
}
// MARK: API
// Focus this view controller rather than the web view, since the web view is replaced on each article change.
func focus() {
currentWebViewController?.focus()
becomeFirstResponder()
}
func canScrollDown() -> Bool {
+19 -5
View File
@@ -22,6 +22,8 @@ import Images
final class WebViewController: UIViewController {
private static let arrowKeyScrollDistance: CGFloat = 60
private struct MessageName {
static let imageWasClicked = "imageWasClicked"
static let imageWasShown = "imageWasShown"
@@ -222,10 +224,6 @@ final class WebViewController: UIViewController {
}
}
func focus() {
webView?.becomeFirstResponder()
}
func canScrollDown() -> Bool {
guard let webView = webView else { return false }
return webView.scrollView.contentOffset.y < finalScrollPosition(scrollingUp: false)
@@ -242,8 +240,16 @@ final class WebViewController: UIViewController {
}
let overlap = 2 * UIFont.systemFont(ofSize: UIFont.systemFontSize).lineHeight * windowScene.screen.scale
let scrollDistance = webView.scrollView.layoutMarginsGuide.layoutFrame.height - overlap
scroll(up: scrollingUp, distance: scrollDistance)
}
private func scroll(up scrollingUp: Bool, distance scrollDistance: CGFloat) {
guard let webView else {
return
}
let scrollToY: CGFloat = {
let scrollDistance = webView.scrollView.layoutMarginsGuide.layoutFrame.height - overlap
let fullScroll = webView.scrollView.contentOffset.y + (scrollingUp ? -scrollDistance : scrollDistance)
let final = finalScrollPosition(scrollingUp: scrollingUp)
return (scrollingUp ? fullScroll > final : fullScroll < final) ? fullScroll : final
@@ -262,6 +268,14 @@ final class WebViewController: UIViewController {
scrollPage(up: true)
}
func scrollLineDown() {
scroll(up: false, distance: Self.arrowKeyScrollDistance)
}
func scrollLineUp() {
scroll(up: true, distance: Self.arrowKeyScrollDistance)
}
func hideClickedImage() {
webView?.evaluateJavaScript("hideClickedImage();")
}
+16 -1
View File
@@ -29,8 +29,11 @@ enum KeyboardType: String, Sendable {
switch type {
case .sidebar:
_keyCommands.append(contentsOf: KeyboardManager.hardcodeFeedKeyCommands())
case .timeline, .detail:
case .timeline:
_keyCommands.append(contentsOf: KeyboardManager.hardcodeArticleKeyCommands())
case .detail:
_keyCommands.append(contentsOf: KeyboardManager.hardcodeArticleKeyCommands())
_keyCommands.append(contentsOf: KeyboardManager.hardcodeDetailKeyCommands())
default:
break
}
@@ -215,4 +218,16 @@ private extension KeyboardManager {
return keys
}
static func hardcodeDetailKeyCommands() -> [UIKeyCommand] {
var keys = [UIKeyCommand]()
let scrollDownTitle = NSLocalizedString("Scroll Down", comment: "Scroll Down")
keys.append(KeyboardManager.createKeyCommand(title: scrollDownTitle, action: "scrollLineDown:", input: UIKeyCommand.inputDownArrow, modifiers: []))
let scrollUpTitle = NSLocalizedString("Scroll Up", comment: "Scroll Up")
keys.append(KeyboardManager.createKeyCommand(title: scrollUpTitle, action: "scrollLineUp:", input: UIKeyCommand.inputUpArrow, modifiers: []))
return keys
}
}
+11
View File
@@ -13,6 +13,9 @@ final class RootSplitViewController: UISplitViewController {
var coordinator: SceneCoordinator!
/// True during rotation, window resizes, and background snapshots, when UIKit changes the display mode on its own.
private(set) var isTransitioningSize = false
override var prefersStatusBarHidden: Bool {
return coordinator.prefersStatusBarHidden
}
@@ -26,6 +29,14 @@ final class RootSplitViewController: UISplitViewController {
coordinator.resetFocus()
}
override func viewWillTransition(to size: CGSize, with transitionCoordinator: UIViewControllerTransitionCoordinator) {
isTransitioningSize = true
super.viewWillTransition(to: size, with: transitionCoordinator)
transitionCoordinator.animate(alongsideTransition: nil) { [weak self] _ in
self?.isTransitioningSize = false
}
}
/// Show a column for programmatic navigation.
/// Pass `bypassDisplayModeRestriction: true` for user-initiated navigation, so it can
/// reveal a column the display-mode suppression below would otherwise keep hidden.
+8 -5
View File
@@ -95,7 +95,6 @@ struct SidebarItemNode: Hashable, Sendable {
var isTimelineViewControllerPending = false
var isArticleViewControllerPending = false
private var hasReportedIgnoredTap = false
/// `Bool` to track whether a refresh is scheduled.
private var isNavigationBarSubtitleRefreshScheduled: Bool = false
@@ -1242,13 +1241,11 @@ struct SidebarItemNode: Hashable, Sendable {
}
/// Selecting the current article while the article view isn’t showing does nothing, which is never expected.
/// Log it once per launch to the Errors log.
/// <https://github.com/Ranchero-Software/NetNewsWire/issues/5516>
private func reportIgnoredSelection(of article: Article?) {
guard let article, !hasReportedIgnoredTap, isRootSplitCollapsed, !isArticleViewControllerShowing else {
guard let article, isRootSplitCollapsed, !isArticleViewControllerShowing else {
return
}
hasReportedIgnoredTap = true
let selectedItemCount = mainTimelineViewController?.collectionView?.indexPathsForSelectedItems?.count ?? 0
let navigationStackDepth = mainTimelineViewController?.navigationController?.viewControllers.count ?? 0
@@ -1846,7 +1843,13 @@ extension SceneCoordinator: UISplitViewControllerDelegate {
}
func splitViewController(_ svc: UISplitViewController, willChangeTo displayMode: UISplitViewController.DisplayMode) {
AppDefaults.splitViewPreferredDisplayMode = displayMode.rawValue
// Save only user-initiated changes. UIKit also changes the display mode during
// rotation, window resizes, and background snapshots, and those must not be saved.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/5524>
let isSceneActive = svc.view.window?.windowScene?.activationState == .foregroundActive
if isSceneActive && !svc.isCollapsed && !rootSplitViewController.isTransitioningSize {
AppDefaults.splitViewPreferredDisplayMode = displayMode.rawValue
}
mainTimelineViewController?.updateToolbarProgressView(for: displayMode)
}