Skip to content

Fix incorrect Navigation Bar Appearance in Reader Detail screen#20363

Merged
salimbraksa merged 3 commits into
release/22.0from
task/20362-reader-nav-bar-appearance
Mar 22, 2023
Merged

Fix incorrect Navigation Bar Appearance in Reader Detail screen#20363
salimbraksa merged 3 commits into
release/22.0from
task/20362-reader-nav-bar-appearance

Conversation

@salimbraksa

@salimbraksa salimbraksa commented Mar 18, 2023

Copy link
Copy Markdown
Contributor

Fixes #20362

Description

This PR resolves a regression bug caused in this PR:

The aforementioned PR changed the Reader's navigation bar appearance from transparent to opaque. The new navigation bar appearance is inherited by all view controllers that get pushed to the same navigation controller. But one view controller should keep the transparent navigation bar appearance. And that is the ReaderDetailViewController.

This PR resolves that issue by refactoring the navigation bar appearance logic in ReaderDetailViewController. So instead of setting navigationBar.standardAppearance, I used navigationItem.standardAppearance instead.

Notes

I recommend to review each commit individually and in this order:

  1. Resolve a regression bug that was causing the nav bar appearance to appear white in posts with featured image.
  2. Update the navigation bar tintColor using its navigation item
  3. Reorganize methods and properties

Screenshots

Before After

Test Instructions

  1. Install WordPress / Jetpack and login.
  2. Enable Light Mode.
  3. Head to a Post with a Featured Image:
  4. Verify the navigation bar appearance is transparent.

Regression Notes

  1. Potential unintended areas of impact
    None.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    None.

  3. What automated tests I added (or what prevented me from doing so)
    None.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@wpmobilebot

wpmobilebot commented Mar 18, 2023

Copy link
Copy Markdown
Contributor
Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr20363-78b9db9
Version22.0
Bundle IDcom.jetpack.alpha
Commit78b9db9
App Center Buildjetpack-installable-builds #4291
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot

wpmobilebot commented Mar 18, 2023

Copy link
Copy Markdown
Contributor
WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr20363-78b9db9
Version22.0
Bundle IDorg.wordpress.alpha
Commit78b9db9
App Center BuildWPiOS - One-Offs #5266
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@mokagio

mokagio commented Mar 20, 2023

Copy link
Copy Markdown
Contributor

I'm about to start the 22.0 code freeze. This PR is not ready to land into trunk, but it seems worth leaving under the 22.0 milestone and update to point to release/22.0 once the branch is ready given it's a UI fix.

return navigationBar?.tintColor
}
set(newValue) {
// Ideally, we should be setting the navigationItem's tint color, but for some reason that didn't work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved in 4543fed

/// Flag indicating whether the navigation bar appearance needs restoration when the view disappears. Default is `false`.
///
/// Flag changes to `true` when this view changes the navigation bar tint color. In other words, when the `navBarTintColor` setter is called.
private var navigationBarAppearanceNeedsRestoration = false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in 4543fed

/// The original navigation bar tint color.
///
/// This property is used to restore the navigation bar tint color to its original value.
private var previousNavBarTintColor: UIColor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in 4543fed

navigationItem.scrollEdgeAppearance = appearance
if #available(iOS 15.0, *) {
navigationItem.compactScrollEdgeAppearance = appearance
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the navigationItem's appearance ( instead of navigationBar ) is the most important change in the PR.

@salimbraksa salimbraksa force-pushed the task/20362-reader-nav-bar-appearance branch from 4543fed to 83c68db Compare March 20, 2023 16:05
@salimbraksa salimbraksa marked this pull request as ready for review March 20, 2023 16:34
@salimbraksa salimbraksa force-pushed the task/20362-reader-nav-bar-appearance branch from 83c68db to 78b9db9 Compare March 20, 2023 16:54
@peril-wordpress-mobile

peril-wordpress-mobile Bot commented Mar 20, 2023

Copy link
Copy Markdown
Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 4 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

@salimbraksa salimbraksa requested a review from alpavanoglu March 20, 2023 16:54
@salimbraksa salimbraksa changed the base branch from trunk to release/22.0 March 20, 2023 16:54
Comment on lines +167 to +169
guard let self = self else {
return
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tidbit:
Now we can do

guard let self else {
    return
}


public func deviceDidRotate() {
guard !useCompatibilityMode else {
public func load(completion: @escaping () -> Void) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function handles a bit too much of action here. But no rush for fixing it since we need it in the hotfix

@alpavanoglu alpavanoglu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Succeeded ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Navigation Bar Appearance in Reader Detail screen

4 participants