mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
#817 (three column layout)
- Scrolling story instead of pages. - Change pages vertically only when at the top or bottom of a story.
This commit is contained in:
parent
8020865c90
commit
abe171ce80
4 changed files with 68 additions and 0 deletions
|
@ -1278,6 +1278,8 @@
|
|||
[appDelegate.feedDetailViewController redrawUnreadStory];
|
||||
// }
|
||||
|
||||
[appDelegate.detailViewController allowPagingUp:YES down:NO];
|
||||
|
||||
if (!appDelegate.storiesCollection.inSearch) {
|
||||
[self.currentStoryController becomeFirstResponder];
|
||||
}
|
||||
|
|
|
@ -128,6 +128,14 @@ class DetailViewController: DetailObjCViewController {
|
|||
/// The horizontal page view controller.
|
||||
var horizontalPageViewController: HorizontalPageViewController?
|
||||
|
||||
/// Enable paging upwards and/or downwards.
|
||||
///
|
||||
/// - Parameter up: Allow paging up to the previous story.
|
||||
/// - Parameter down: Allow paging down to the next story.
|
||||
@objc(allowPagingUp:down:) func allowPaging(up: Bool, down: Bool) {
|
||||
horizontalPageViewController?.currentController?.allowPaging(up: up, down: down)
|
||||
}
|
||||
|
||||
/// Returns the currently displayed story view controller, or `nil` if none.
|
||||
@objc var currentStoryController: StoryDetailViewController? {
|
||||
return horizontalPageViewController?.currentController?.currentController
|
||||
|
|
|
@ -1456,6 +1456,8 @@
|
|||
}
|
||||
|
||||
[self storeScrollPosition:YES];
|
||||
|
||||
[appDelegate.detailViewController allowPagingUp:atTop down:atBottom];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,33 @@ class VerticalPageViewController: UIPageViewController {
|
|||
/// The next story view controller, if it has been requested, otherwise `nil`.
|
||||
var nextController: StoryDetailViewController?
|
||||
|
||||
/// The internal scroll view that drives the page controller.
|
||||
var scrollView: UIScrollView? {
|
||||
return view.subviews.filter { $0 is UIScrollView }.first as? UIScrollView
|
||||
}
|
||||
|
||||
private var isPageUpEnabled = true
|
||||
private var isPageDownEnabled = true
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
self.scrollView?.delegate = self
|
||||
}
|
||||
|
||||
/// Updates whether paging up and/or down is enabled.
|
||||
func allowPaging(up: Bool, down: Bool) {
|
||||
isPageUpEnabled = up
|
||||
isPageDownEnabled = down
|
||||
|
||||
if !isPageUpEnabled {
|
||||
print("Page Up Disabled")
|
||||
}
|
||||
if !isPageDownEnabled {
|
||||
print("Page Down Disabled")
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear the previous and next story view controllers.
|
||||
func reset() {
|
||||
previousController = nil
|
||||
|
@ -67,3 +94,32 @@ class VerticalPageViewController: UIPageViewController {
|
|||
super.setViewControllers(viewControllers, direction: direction, animated: animated, completion: completion)
|
||||
}
|
||||
}
|
||||
|
||||
extension VerticalPageViewController: UIScrollViewDelegate {
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
print("contentOffset = \(scrollView.contentOffset.y)")
|
||||
|
||||
if !self.isPageUpEnabled {
|
||||
disableUpScroll(scrollView)
|
||||
}
|
||||
if !self.isPageDownEnabled {
|
||||
disableDownScroll(scrollView)
|
||||
}
|
||||
}
|
||||
|
||||
private func disableUpScroll(_ scrollView: UIScrollView) {
|
||||
let viewHeight = view.bounds.height
|
||||
|
||||
if scrollView.contentOffset.y < viewHeight {
|
||||
scrollView.setContentOffset(CGPoint(x: 0, y: viewHeight), animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
private func disableDownScroll(_ scrollView: UIScrollView) {
|
||||
let viewHeight = view.bounds.height
|
||||
|
||||
if scrollView.contentOffset.y > viewHeight {
|
||||
scrollView.setContentOffset(CGPoint(x: 0, y: viewHeight), animated: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue