@@ -111,6 +111,7 @@ final class DashboardViewController: UIViewController {
111111 configureBottomJetpackBenefitsBanner ( )
112112 observeSiteForUIUpdates ( )
113113 observeBottomJetpackBenefitsBannerVisibilityUpdates ( )
114+ observeNavigationBarHeightForStoreNameLabelVisibility ( )
114115 }
115116
116117 override func viewWillAppear( _ animated: Bool ) {
@@ -294,22 +295,6 @@ private extension DashboardViewController {
294295extension DashboardViewController : DashboardUIScrollDelegate {
295296 func dashboardUIScrollViewDidScroll( _ scrollView: UIScrollView ) {
296297 hiddenScrollView. updateFromScrollViewDidScrollEventForLargeTitleWorkaround ( scrollView)
297- showOrHideSubtitle ( offset: scrollView. contentOffset. y)
298- }
299-
300- private func showOrHideSubtitle( offset: CGFloat ) {
301- guard shouldShowStoreNameAsSubtitle else {
302- return
303- }
304- storeNameLabel. isHidden = offset > headerStackView. frame. height
305- if offset < - headerStackView. frame. height {
306- UIView . transition ( with: storeNameLabel, duration: Constants . animationDuration,
307- options: . showHideTransitionViews,
308- animations: { [ weak self] in
309- guard let self = self else { return }
310- self . storeNameLabel. isHidden = false
311- } )
312- }
313298 }
314299}
315300
@@ -464,6 +449,21 @@ private extension DashboardViewController {
464449 ServiceLocator . stores. dispatch ( action)
465450 } . store ( in: & cancellables)
466451 }
452+
453+ func observeNavigationBarHeightForStoreNameLabelVisibility( ) {
454+ navigationController? . navigationBar. publisher ( for: \. frame, options: [ . initial, . new] )
455+ . map { $0. height }
456+ . removeDuplicates ( )
457+ . sink ( receiveValue: { [ weak self] navigationBarHeight in
458+ guard let self = self else { return }
459+
460+ guard self . shouldShowStoreNameAsSubtitle else {
461+ return
462+ }
463+ self . storeNameLabel. isHidden = navigationBarHeight <= Constants . collapsedNavigationBarHeight
464+ } )
465+ . store ( in: & cancellables)
466+ }
467467}
468468
469469// MARK: Constants
@@ -476,8 +476,8 @@ private extension DashboardViewController {
476476 }
477477
478478 enum Constants {
479- static let animationDuration = 0.2
480479 static let bannerBottomMargin = CGFloat ( 8 )
481480 static let horizontalMargin = CGFloat ( 20 )
481+ static let collapsedNavigationBarHeight = CGFloat ( 44 )
482482 }
483483}
0 commit comments