Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Wikipedia/Code/ArticleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,16 @@ class ArticleViewController: ThemeableViewController, HintPresenting, UIScrollVi
updateTableOfContentsHighlightIfNecessary()

calculateNavigationBarHiddenState(scrollView: webView.scrollView)

if #available(iOS 18.0, *) {
let velocity = scrollView.panGestureRecognizer.velocity(in: scrollView).y

if velocity < 0 { // Scrolling down
tabBarController?.setTabBarHidden(true, animated: true)
} else if velocity > 0 { // Scrolling up
tabBarController?.setTabBarHidden(false, animated: true)
}
}
}

func scrollViewDidScrollToTop(_ scrollView: UIScrollView) {
Expand Down
53 changes: 51 additions & 2 deletions Wikipedia/Code/ColumnarCollectionViewController.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Foundation
import WMF
import WMFComponents

class ColumnarCollectionViewController: ThemeableViewController, ColumnarCollectionViewLayoutDelegate, UICollectionViewDataSourcePrefetching, CollectionViewFooterDelegate, HintPresenting {
class ColumnarCollectionViewController: ThemeableViewController, ColumnarCollectionViewLayoutDelegate, UICollectionViewDataSourcePrefetching, CollectionViewFooterDelegate, HintPresenting, WMFNavigationBarHiding {
var topSafeAreaOverlayView: UIView?

var topSafeAreaOverlayHeightConstraint: NSLayoutConstraint?


enum HeaderStyle {
case sections
case exploreFeedDetail
Expand Down Expand Up @@ -383,8 +387,53 @@ class ColumnarCollectionViewController: ThemeableViewController, ColumnarCollect
return min(max(_maxViewed, percentViewed), 100)
}

// MARK: – Scroll View methods

func scrollViewDidScroll(_ scrollView: UIScrollView) {
_maxViewed = max(_maxViewed, percentViewed)

guard UIDevice.current.userInterfaceIdiom == .pad, #available(iOS 18.0, *) else { return }

let velocity = scrollView.panGestureRecognizer.velocity(in: scrollView).y
if velocity < -30 {
tabBarController?.setTabBarHidden(true, animated: true)
} else if velocity > 30 {
tabBarController?.setTabBarHidden(false, animated: true)
}

calculateNavigationBarHiddenState(scrollView: scrollView)
}

func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
handleShortContentBounce(scrollView, immediately: !decelerate)
}

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
handleShortContentBounce(scrollView, immediately: true)
}

private func handleShortContentBounce(_ scrollView: UIScrollView, immediately: Bool) {
guard UIDevice.current.userInterfaceIdiom == .pad,
#available(iOS 18.0, *) else { return }

let visibleHeight = scrollView.bounds.height
- scrollView.adjustedContentInset.top
- scrollView.adjustedContentInset.bottom
let contentHeight = scrollView.contentSize.height

if contentHeight <= visibleHeight {
let showAction = {
self.tabBarController?.setTabBarHidden(false, animated: true)
}

if immediately {
showAction()
} else {
DispatchQueue.main.async {
showAction()
}
}
}
}

// MARK: - CollectionViewFooterDelegate
Expand Down
7 changes: 2 additions & 5 deletions Wikipedia/Code/ExploreViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CocoaLumberjackSwift
import WMFComponents
import WMFData

class ExploreViewController: ColumnarCollectionViewController, ExploreCardViewControllerDelegate, CollectionViewUpdaterDelegate, ImageScaleTransitionProviding, DetailTransitionSourceProviding, MEPEventsProviding, WMFNavigationBarConfiguring, WMFNavigationBarHiding {
class ExploreViewController: ColumnarCollectionViewController, ExploreCardViewControllerDelegate, CollectionViewUpdaterDelegate, ImageScaleTransitionProviding, DetailTransitionSourceProviding, MEPEventsProviding, WMFNavigationBarConfiguring {

public var presentedContentGroupKey: String?
public var shouldRestoreScrollPosition = false
Expand Down Expand Up @@ -57,9 +57,6 @@ class ExploreViewController: ColumnarCollectionViewController, ExploreCardViewCo
return existingYirCoordinator
}

var topSafeAreaOverlayHeightConstraint: NSLayoutConstraint?
var topSafeAreaOverlayView: UIView?

private var presentingSearchResults: Bool = false

// MARK: - Lifecycle
Expand Down Expand Up @@ -348,7 +345,7 @@ class ExploreViewController: ColumnarCollectionViewController, ExploreCardViewCo
}
}

func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
logFeedImpressionAfterDelay()
}

Expand Down
5 changes: 1 addition & 4 deletions Wikipedia/Code/HistoryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import WMFData
import CocoaLumberjackSwift

@objc(WMFHistoryViewController)
class HistoryViewController: ArticleFetchedResultsViewController, WMFNavigationBarConfiguring, WMFNavigationBarHiding {

var topSafeAreaOverlayHeightConstraint: NSLayoutConstraint?
var topSafeAreaOverlayView: UIView?
class HistoryViewController: ArticleFetchedResultsViewController, WMFNavigationBarConfiguring {

// Properties needed for Profile Button

Expand Down
5 changes: 1 addition & 4 deletions Wikipedia/Code/SearchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import WMFComponents
import WMFData
import CocoaLumberjackSwift

class SearchViewController: ArticleCollectionViewController, WMFNavigationBarConfiguring, WMFNavigationBarHiding {
class SearchViewController: ArticleCollectionViewController, WMFNavigationBarConfiguring {

@objc enum EventLoggingSource: Int {
case searchTab
Expand Down Expand Up @@ -37,9 +37,6 @@ class SearchViewController: ArticleCollectionViewController, WMFNavigationBarCon
private var searchLanguageBarViewController: SearchLanguagesBarViewController?
private var needsAnimateLanguageBarMovement = false

var topSafeAreaOverlayView: UIView?
var topSafeAreaOverlayHeightConstraint: NSLayoutConstraint?

// Properties needed for Profile Button

private var _yirCoordinator: YearInReviewCoordinator?
Expand Down
Loading