mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-19 21:13:22 +01:00
Add scroll or go to next unread keyboard shortcut
This commit is contained in:
parent
18d442d901
commit
a2dda5f0f8
@ -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 {
|
||||
|
||||
|
@ -60,7 +60,7 @@ private extension KeyboardManager {
|
||||
|
||||
switch(key) {
|
||||
case "[space]":
|
||||
return " "
|
||||
return "\u{0020}"
|
||||
case "[uparrow]":
|
||||
return UIKeyCommand.inputUpArrow
|
||||
case "[downarrow]":
|
||||
|
@ -19,7 +19,9 @@ class RootSplitViewController: UISplitViewController {
|
||||
}
|
||||
|
||||
// MARK: Keyboard Shortcuts
|
||||
|
||||
@objc func scrollOrGoToNextUnread(_ sender: Any?) {
|
||||
coordinator.scrollOrGoToNextUnread()
|
||||
}
|
||||
|
||||
@objc func goToPreviousUnread(_ sender: Any?) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user