Skip to content

Commit

Permalink
Reader: Fix blinking navigation bar on dark mode in Reader Post (#22860)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdchr committed Mar 20, 2024
2 parents 4632edf + 3c71ae1 commit 419504d
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,22 @@ class ReaderDetailFeaturedImageView: UIView, NibLoadable {
}

private func updateNavigationBar(with offset: CGFloat) {
/// Navigation bar is only updated in light interface style, so that the tint color can be reverted
/// to the original color after scrolling past the featured image.
///
/// In case of dark mode, the navigation bar tint color will always be kept white.
guard traitCollection.userInterfaceStyle == .light else {
return
}

let fullProgress = (offset / heightConstraint.constant)
let progress = fullProgress.clamp(min: 0, max: 1)

let tintColor = UIColor.interpolate(from: Styles.startTintColor,
to: Styles.endTintColor,
with: progress)

if traitCollection.userInterfaceStyle == .light {
currentStatusBarStyle = fullProgress >= 2.5 ? .darkContent : .lightContent
} else {
currentStatusBarStyle = .lightContent
}

currentStatusBarStyle = fullProgress >= 2.5 ? .darkContent : .lightContent
navBarTintColor = tintColor
}

Expand Down

0 comments on commit 419504d

Please sign in to comment.