Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -534,20 +534,6 @@ class ReaderDetailCoordinator {
scrollToHashIfNeeded()
}

/// Show the featured image fullscreen
///
private func showFeaturedImage(_ sender: AsyncImageView) {
guard let post, let imageURL = post.featuredImage.flatMap(URL.init) else {
return
}
let lightboxVC = LightboxViewController(sourceURL: imageURL, host: MediaHost(post))
MainActor.assumeIsolated {
lightboxVC.thumbnail = sender.image
}
lightboxVC.configureZoomTransition(sourceView: sender)
viewController?.present(lightboxVC, animated: true)
}

private func followSite(completion: @escaping () -> Void) {
guard let post else {
return
Expand Down Expand Up @@ -729,12 +715,6 @@ extension ReaderDetailCoordinator: ReaderDetailHeaderViewDelegate {

}

extension ReaderDetailCoordinator: ReaderDetailFeaturedImageViewDelegate {
func didTapFeaturedImage(_ sender: AsyncImageView) {
showFeaturedImage(sender)
}
}

extension ReaderDetailCoordinator: ReaderDetailLikesViewDelegate {
func didTapLikesView() {
showLikesList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24412" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24765" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24405"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24743"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -17,7 +17,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" layoutMarginsFollowReadableWidth="YES" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9JA-VQ-zzw">
<rect key="frame" x="0.0" y="96" width="414" height="800"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Xyq-y6-zPR">
<rect key="frame" x="0.0" y="0.0" width="446" height="254.5"/>
Expand Down Expand Up @@ -134,7 +134,7 @@
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="ybg-ZD-3Ou" firstAttribute="width" secondItem="HkO-UB-8qv" secondAttribute="width" id="Flu-a4-g3F"/>
<constraint firstItem="9JA-VQ-zzw" firstAttribute="top" secondItem="Tqp-x3-yXv" secondAttribute="top" id="JMy-49-ddC"/>
<constraint firstItem="9JA-VQ-zzw" firstAttribute="top" secondItem="HkO-UB-8qv" secondAttribute="top" id="JMy-49-ddC"/>
<constraint firstItem="9JA-VQ-zzw" firstAttribute="leading" secondItem="Tqp-x3-yXv" secondAttribute="leading" id="KOc-Yv-UWy"/>
<constraint firstItem="Tqp-x3-yXv" firstAttribute="trailing" secondItem="9JA-VQ-zzw" secondAttribute="trailing" id="u3i-rm-kZv"/>
<constraint firstItem="9JA-VQ-zzw" firstAttribute="bottom" secondItem="HkO-UB-8qv" secondAttribute="bottom" id="x0z-7E-pgA"/>
Expand All @@ -149,7 +149,6 @@
<outlet property="likesContainerView" destination="qXQ-id-Ffz" id="DL3-un-wtF"/>
<outlet property="relatedPostsTableView" destination="CpT-U7-bfv" id="Ndh-H4-FlR"/>
<outlet property="scrollView" destination="9JA-VQ-zzw" id="lCO-o1-bLB"/>
<outlet property="scrollViewTopConstraint" destination="JMy-49-ddC" id="l9q-Ed-ERC"/>
<outlet property="webView" destination="iSu-TI-yew" id="DQy-Fd-C3y"/>
<outlet property="webViewHeight" destination="ywz-kG-xyW" id="q3p-wI-yeb"/>
</connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,8 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
/// Attribution view for Discovery posts
@IBOutlet weak var attributionView: ReaderCardDiscoverAttributionView!

@IBOutlet weak var scrollViewTopConstraint: NSLayoutConstraint!

private let activityIndicator = UIActivityIndicatorView(style: .medium)

/// The actual header
private let featuredImageView = ReaderDetailFeaturedImageView()

private var heroView: ReaderHeroView?

private var isNewFeaturedImageEnabled: Bool {
if #available(iOS 26, *) {
return true
} else {
return false
}
}

/// The actual header
private lazy var header = ReaderDetailHeaderHostingView()

Expand Down Expand Up @@ -128,12 +113,6 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
}
}

var currentPreferredStatusBarStyle = UIStatusBarStyle.lightContent {
didSet {
setNeedsStatusBarAppearanceUpdate()
}
}

override var hidesBottomBarWhenPushed: Bool {
set { }
get { true }
Expand Down Expand Up @@ -201,7 +180,6 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
configureNavigationBar()
applyStyles()
configureWebView()
configureLegacyFeaturedImage()
configureHeader()
configureRelatedPosts()
configureToolbar()
Expand All @@ -215,13 +193,6 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {

startObservingPost()

if #available(iOS 26, *) {
scrollViewTopConstraint?.isActive = false
scrollView.pinEdges(.top)

headerContainerView.clipsToBounds = true
}

// Fixes swipe to go back not working when leftBarButtonItem is set
navigationController?.interactivePopGestureRecognizer?.delegate = self

Expand Down Expand Up @@ -249,18 +220,10 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
super.viewWillAppear(animated)

updateLeftBarButtonItem()
setupFeaturedImage()
updateFollowButtonState()
toolbar.viewWillAppear()

if #unavailable(iOS 26) {
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) {
// Workaround for tab bar dismiss iteraction
self.navigationController?.setToolbarHidden(false, animated: animated)
}
} else {
navigationController?.setToolbarHidden(false, animated: animated)
}
navigationController?.setToolbarHidden(false, animated: animated)
}

override func viewWillDisappear(_ animated: Bool) {
Expand All @@ -270,23 +233,10 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
return
}

if !isNewFeaturedImageEnabled {
featuredImageView.viewWillDisappear()
}
toolbar.viewWillDisappear()
navigationController?.setToolbarHidden(true, animated: animated)
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)

if !isNewFeaturedImageEnabled {
coordinator.animate(alongsideTransition: { _ in
self.featuredImageView.deviceDidRotate()
})
}
}

override func accessibilityPerformEscape() -> Bool {
navigationController?.popViewController(animated: true)
return true
Expand All @@ -296,19 +246,9 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
scrollView
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)

let isCompact = traitCollection.horizontalSizeClass == .compact
headerContainerView.layer.cornerRadius = isCompact ? DesignConstants.radius(.large) : 0
headerContainerView.layer.maskedCorners = isCompact ? [.layerMaxXMinYCorner, .layerMinXMinYCorner] : []
}

func render(_ post: ReaderPost) {
configureDiscoverAttribution(post)

setupHeroView()
featuredImageView.configure(for: post, with: self)
toolbar.configure(for: post, in: self)
updateToolbarItems()
header.configure(for: post)
Expand All @@ -328,10 +268,6 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
}

navigateToCommentIfNecessary()

if !isNewFeaturedImageEnabled && !featuredImageView.isLoaded {
featuredImageView.load()
}
}

private func showPostContent(_ post: ReaderPost) {
Expand Down Expand Up @@ -557,9 +493,6 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
header.displaySetting = displaySetting
}

// Featured image view
featuredImageView.displaySetting = displaySetting

// Update Reader Post web view
if let contentForDisplay = post?.contentForDisplay() {
webView.displaySetting = displaySetting
Expand Down Expand Up @@ -615,95 +548,6 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
}
}

private func setupFeaturedImage() {
if isNewFeaturedImageEnabled {
setupHeroView()
} else {
setupLegacyFeaturedImage()
}
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

layoutHeroView()
}

private func setupHeroView() {
guard isNewFeaturedImageEnabled else {
return
}
guard let post, let imageURL = post.featuredImageURL,
!post.contentIncludesFeaturedImage() else {
return
}
if heroView == nil {
let heroView = ReaderHeroView()
heroView.configureTapGesture(in: scrollView) { [weak self] in
self?.coordinator?.didTapFeaturedImage($0)
}
view.insertSubview(heroView, belowSubview: scrollView)
self.heroView = heroView
}
if heroView?.imageURL != imageURL {
heroView?.imageURL = imageURL
heroView?.imageView.setImage(with: ImageRequest(url: imageURL, host: MediaHost(post)))
}
layoutHeroView()
}

private func layoutHeroView() {
guard let heroView else {
return
}
let contentInsetTop = heroView.imageView.frame.height + heroView.estimatedStatusBarOffset - view.safeAreaInsets.top
if contentInsetTop != scrollView.contentInset.top {
// `contentInset` is automatically adjusted to include safeAreaInsets.top
scrollView.contentInset.top = contentInsetTop
}
// DesignConstants.radius(.large) to extend a bit behind the header view
let heroViewFrame = CGRect(x: 0, y: 0, width: view.bounds.width, height: max(0, -scrollView.contentOffset.y + heroView.bottomExtensionHeight))
if heroViewFrame != heroView.frame {
heroView.frame = heroViewFrame
}
}

private func setupLegacyFeaturedImage() {
configureLegacyFeaturedImage()

featuredImageView.configure(
scrollView: scrollView,
navigationBar: navigationController?.navigationBar,
navigationItem: navigationItem
)

if !featuredImageView.isLoaded {
featuredImageView.load()
}
}

private func configureLegacyFeaturedImage() {
guard featuredImageView.superview == nil else {
return
}

if ReaderDisplaySettings.customizationEnabled {
featuredImageView.displaySetting = displaySetting
}

featuredImageView.delegate = coordinator

view.insertSubview(featuredImageView, belowSubview: scrollView)

NSLayoutConstraint.activate([
featuredImageView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
featuredImageView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
featuredImageView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0)
])

headerContainerView.translatesAutoresizingMaskIntoConstraints = false
}

private func configureHeader() {
header.displaySetting = displaySetting
header.delegate = coordinator
Expand Down Expand Up @@ -1072,7 +916,6 @@ extension ReaderDetailViewController: UIScrollViewDelegate {
toolbarHiddenDebouncer.send(false) // Scrolling up
}
lastContentOffset = currentOffset
layoutHeroView()
}

private func setNeedsToolbarHidden(_ isHidden: Bool) {
Expand Down Expand Up @@ -1215,17 +1058,6 @@ extension ReaderDetailViewController: ReaderCardDiscoverAttributionViewDelegate
}
}

// MARK: - UpdatableStatusBarStyle
extension ReaderDetailViewController: UpdatableStatusBarStyle {
func updateStatusBarStyle(to style: UIStatusBarStyle) {
guard style != currentPreferredStatusBarStyle else {
return
}

currentPreferredStatusBarStyle = style
}
}

// MARK: - Transitioning Delegate

extension ReaderDetailViewController: UIViewControllerTransitioningDelegate {
Expand Down
Loading