Skip to content

Commit f0e5730

Browse files
authored
Show selected filter in the Discover navigation bar (#23956)
2 parents 4b41387 + 5fd1a43 commit f0e5730

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* [*] Update site menu style on iPhone [#23944]
1717
* [*] Integrate zoom transitions in Themes, Reader [#23945, #23947]
1818
* [*] Fix an issue with site icons cropped in share extensions [#23950]
19+
* [*] Show selected filter in the Discover navigation bar [#23956]
1920
* [*] Enable fast deceleration for filters on the Discover tab [#23954]
2021
* [*] Disable universal links support for QR code login. You can only scan the codes using the app now. [#23953]
2122

WordPress/Classes/ViewRelated/Reader/Controllers/ReaderDiscoverViewController.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ class ReaderDiscoverViewController: UIViewController, ReaderDiscoverHeaderViewDe
127127
streamVC.view.pinEdges()
128128
streamVC.didMove(toParent: self)
129129

130-
navigationItem.titleView = streamVC.navigationItem.titleView // important
130+
streamVC.titleView.detailsLabel.text = selectedChannel.localizedTitle
131+
streamVC.titleView.detailsLabel.isHidden = false
132+
133+
navigationItem.titleView = streamVC.titleView // important
131134
}
132135

133136
/// TODO: (tech-debt) the app currently stores the responses from the `/discover`

WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ import AutomatticTracks
6565
return refreshControl
6666
}()
6767

68-
private let loadMoreThreashold = 4
68+
let titleView = ReaderNavigationCustomTitleView()
6969

70+
private let loadMoreThreashold = 5
7071
private let refreshInterval = 300
7172
private var cleanupAndRefreshAfterScrolling = false
7273
private let recentlyBlockedSitePostObjectIDs = NSMutableArray()
@@ -77,7 +78,6 @@ import AutomatticTracks
7778
private var indexPathForGapMarker: IndexPath?
7879
private var didSetupView = false
7980
private var didBumpStats = false
80-
@Lazy private var titleView = ReaderNavigationCustomTitleView()
8181
internal let scrollViewTranslationPublisher = PassthroughSubject<Bool, Never>()
8282
private let notificationsButtonViewModel = NotificationsButtonViewModel()
8383
private var notificationsButtonCancellable: AnyCancellable?
@@ -1660,7 +1660,7 @@ extension ReaderStreamViewController: UITableViewDelegate, JPScrollViewDelegate
16601660
func scrollViewDidScroll(_ scrollView: UIScrollView) {
16611661
layoutEmptyStateView()
16621662
processJetpackBannerVisibility(scrollView)
1663-
$titleView.value?.updateAlpha(in: scrollView)
1663+
titleView.updateAlpha(in: scrollView)
16641664
}
16651665
}
16661666

WordPress/Classes/ViewRelated/Reader/ReaderNavigationCustomTitleView.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,36 @@ import WordPressUI
44
/// A custom replacement for a navigation bar title view.
55
final class ReaderNavigationCustomTitleView: UIView {
66
let textLabel = UILabel()
7+
let detailsLabel = UILabel()
8+
private lazy var stackView = UIStackView(axis: .vertical, alignment: .center, [textLabel, detailsLabel])
79

810
override init(frame: CGRect) {
911
super.init(frame: frame)
1012

1113
textLabel.font = WPStyleGuide.navigationBarStandardFont
12-
textLabel.alpha = 0
1314

14-
// The label has to be a subview of the title view because
15-
// navigation bar doesn't seem to allow you to change the alpha
16-
// of `navigationItem.titleView` itself.
17-
addSubview(textLabel)
18-
textLabel.pinEdges()
15+
detailsLabel.font = .preferredFont(forTextStyle: .footnote)
16+
detailsLabel.textColor = .secondaryLabel
17+
detailsLabel.isHidden = true
18+
19+
addSubview(stackView)
20+
stackView.pinEdges()
1921
}
2022

2123
required init?(coder: NSCoder) {
2224
fatalError("init(coder:) has not been implemented")
2325
}
2426

27+
// The label has to be a subview of the title view because
28+
// navigation bar doesn't seem to allow you to change the alpha
29+
// of `navigationItem.titleView` itself.
2530
func updateAlpha(in scrollView: UIScrollView) {
2631
let offsetY = scrollView.contentOffset.y
2732
if offsetY < 16 {
28-
textLabel.alpha = 0
33+
stackView.alpha = 0
2934
} else {
3035
let alpha = (offsetY - 16) / 24
31-
textLabel.alpha = max(0, min(1, alpha))
36+
stackView.alpha = max(0, min(1, alpha))
3237
}
3338
}
3439
}

0 commit comments

Comments
 (0)