diff --git a/iOS/Detail/DetailViewController.swift b/iOS/Detail/DetailViewController.swift index 78a14b744..309d573c7 100644 --- a/iOS/Detail/DetailViewController.swift +++ b/iOS/Detail/DetailViewController.swift @@ -184,7 +184,32 @@ class DetailViewController: UIViewController { webView.becomeFirstResponder() } + func finalScrollPosition() -> CGFloat { + return webView.scrollView.contentSize.height - webView.scrollView.bounds.size.height + webView.scrollView.contentInset.bottom + } + + func canScrollDown() -> Bool { + return webView.scrollView.contentOffset.y < finalScrollPosition() + } + + func scrollPageDown() { + let scrollToY: CGFloat = { + let fullScroll = webView.scrollView.contentOffset.y + webView.scrollView.bounds.size.height + let final = finalScrollPosition() + if fullScroll < final { + return fullScroll + } else { + return final + } + }() + + let convertedPoint = self.view.convert(CGPoint(x: 0, y: 0), to: webView.scrollView) + let scrollToPoint = CGPoint(x: convertedPoint.x, y: scrollToY) + webView.scrollView.setContentOffset(scrollToPoint, animated: true) + } + } +//print("\(candidateY) : \(webView.scrollView.contentSize.height)") class ArticleActivityItemSource: NSObject, UIActivityItemSource { diff --git a/iOS/KeyboardManager.swift b/iOS/KeyboardManager.swift index 95ac2f505..b5d6742b9 100644 --- a/iOS/KeyboardManager.swift +++ b/iOS/KeyboardManager.swift @@ -60,7 +60,7 @@ private extension KeyboardManager { switch(key) { case "[space]": - return " " + return "\u{0020}" case "[uparrow]": return UIKeyCommand.inputUpArrow case "[downarrow]": diff --git a/iOS/RootSplitViewController.swift b/iOS/RootSplitViewController.swift index 43ac14043..3ea657a2a 100644 --- a/iOS/RootSplitViewController.swift +++ b/iOS/RootSplitViewController.swift @@ -19,7 +19,9 @@ class RootSplitViewController: UISplitViewController { } // MARK: Keyboard Shortcuts + @objc func scrollOrGoToNextUnread(_ sender: Any?) { + coordinator.scrollOrGoToNextUnread() } @objc func goToPreviousUnread(_ sender: Any?) { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 0ebb1e038..ae584deef 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -753,6 +753,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } + func scrollOrGoToNextUnread() { + if detailViewController?.canScrollDown() ?? false { + detailViewController?.scrollPageDown() + } else { + selectNextUnread() + } + } + func markAllAsRead(_ articles: [Article]) { guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articles, markingRead: true, undoManager: undoManager) else { return