From 09f7e55925e57435958264c381545ea0f40a5b83 Mon Sep 17 00:00:00 2001 From: kean Date: Tue, 7 Jan 2025 13:05:04 -0500 Subject: [PATCH 1/2] Show selected filter in the Discover navigation bar --- .../ReaderDiscoverViewController.swift | 5 ++++- .../ReaderStreamViewController.swift | 6 +++--- .../ReaderNavigationCustomTitleView.swift | 21 ++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderDiscoverViewController.swift b/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderDiscoverViewController.swift index 29027b99b8f2..dad7bd1eb645 100644 --- a/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderDiscoverViewController.swift +++ b/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderDiscoverViewController.swift @@ -127,7 +127,10 @@ class ReaderDiscoverViewController: UIViewController, ReaderDiscoverHeaderViewDe streamVC.view.pinEdges() streamVC.didMove(toParent: self) - navigationItem.titleView = streamVC.navigationItem.titleView // important + streamVC.titleView.detailsLabel.text = selectedChannel.localizedTitle + streamVC.titleView.detailsLabel.isHidden = false + + navigationItem.titleView = streamVC.titleView // important } /// TODO: (tech-debt) the app currently stores the responses from the `/discover` diff --git a/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift b/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift index bdb482407384..3d0ebcca28e1 100644 --- a/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift +++ b/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift @@ -65,8 +65,9 @@ import AutomatticTracks return refreshControl }() - private let loadMoreThreashold = 4 + let titleView = ReaderNavigationCustomTitleView() + private let loadMoreThreashold = 5 private let refreshInterval = 300 private var cleanupAndRefreshAfterScrolling = false private let recentlyBlockedSitePostObjectIDs = NSMutableArray() @@ -77,7 +78,6 @@ import AutomatticTracks private var indexPathForGapMarker: IndexPath? private var didSetupView = false private var didBumpStats = false - @Lazy private var titleView = ReaderNavigationCustomTitleView() internal let scrollViewTranslationPublisher = PassthroughSubject() private let notificationsButtonViewModel = NotificationsButtonViewModel() private var notificationsButtonCancellable: AnyCancellable? @@ -1660,7 +1660,7 @@ extension ReaderStreamViewController: UITableViewDelegate, JPScrollViewDelegate func scrollViewDidScroll(_ scrollView: UIScrollView) { layoutEmptyStateView() processJetpackBannerVisibility(scrollView) - $titleView.value?.updateAlpha(in: scrollView) + titleView.updateAlpha(in: scrollView) } } diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderNavigationCustomTitleView.swift b/WordPress/Classes/ViewRelated/Reader/ReaderNavigationCustomTitleView.swift index a940e26ff144..bcabed72ade3 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderNavigationCustomTitleView.swift +++ b/WordPress/Classes/ViewRelated/Reader/ReaderNavigationCustomTitleView.swift @@ -4,31 +4,36 @@ import WordPressUI /// A custom replacement for a navigation bar title view. final class ReaderNavigationCustomTitleView: UIView { let textLabel = UILabel() + let detailsLabel = UILabel() + private lazy var stackView = UIStackView(axis: .vertical, alignment: .center, [textLabel, detailsLabel]) override init(frame: CGRect) { super.init(frame: frame) textLabel.font = WPStyleGuide.navigationBarStandardFont - textLabel.alpha = 0 - // The label has to be a subview of the title view because - // navigation bar doesn't seem to allow you to change the alpha - // of `navigationItem.titleView` itself. - addSubview(textLabel) - textLabel.pinEdges() + detailsLabel.font = .preferredFont(forTextStyle: .footnote) + detailsLabel.textColor = .secondaryLabel + detailsLabel.isHidden = true + + addSubview(stackView) + stackView.pinEdges() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } + // The label has to be a subview of the title view because + // navigation bar doesn't seem to allow you to change the alpha + // of `navigationItem.titleView` itself. func updateAlpha(in scrollView: UIScrollView) { let offsetY = scrollView.contentOffset.y if offsetY < 16 { - textLabel.alpha = 0 + stackView.alpha = 0 } else { let alpha = (offsetY - 16) / 24 - textLabel.alpha = max(0, min(1, alpha)) + stackView.alpha = max(0, min(1, alpha)) } } } From 5fd1a436a0bf381ac771972b8857b382d74ec948 Mon Sep 17 00:00:00 2001 From: kean Date: Tue, 7 Jan 2025 13:07:36 -0500 Subject: [PATCH 2/2] Update release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 88f3ef15b7ef..f4ee4035594c 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -16,6 +16,7 @@ * [*] Update site menu style on iPhone [#23944] * [*] Integrate zoom transitions in Themes, Reader [#23945, #23947] * [*] Fix an issue with site icons cropped in share extensions [#23950] +* [*] Show selected filter in the Discover navigation bar [#23956] * [*] Enable fast deceleration for filters on the Discover tab [#23954]