Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status bar style is being overridden after a popover is displayed #2

Closed
ShezHsky opened this issue Dec 28, 2021 · 9 comments · Fixed by #5
Closed

Status bar style is being overridden after a popover is displayed #2

ShezHsky opened this issue Dec 28, 2021 · 9 comments · Fixed by #5
Assignees
Labels
bug Something isn't working fixed The problem was fixed!

Comments

@ShezHsky
Copy link
Contributor

Howdy,

While integrating this library into an app (thanks for the work on this by the way!), I noticed the status bar is disappearing when presenting sheets. It looks like the offender is around the use of a second UIWindow to draw the popovers, as this now receives priority for status bar styling preferences. This is evident when a popover is first shown as, especially from a sheet, the status bar returns to its default colouring once the second window is prepared - meaning it blends in with the background. Future presentations will then be stuck with the status bar styling from the second window, which usually means no status bar for sheets (except in dark mode).

I've added a commit to my fork to demonstrate the issue inside the sample app, however as the sample app already prepared the secondary window the status bar is always hidden at presentation time. To make life easier, here's a quick video:

Popovers.mov

I had a quick 15 min stab at this but didn't find a quick win. My line of thinking was to remove the window when no more popovers are being displayed as a mitigation step, so the status bar is available for future sheet presentations/once the popover is dismissed. There might be a fancier way forward by rendering the popovers onto an overlayed view controller instead of a window, but that seems like a fairly large change (and may come with its own bugs!).

While I'll give one of the above another go in due course (i.e. post holidays), I'm raising it here in case anyone else bumps into this issue/fancies giving it a go, or if there's other ideas to consider to address this. Cheers

@aheze
Copy link
Owner

aheze commented Dec 28, 2021

@ShezHsky thanks for raising the issue! I’ll take a look.

@aheze aheze added the bug Something isn't working label Dec 28, 2021
@aheze aheze self-assigned this Dec 28, 2021
@aheze
Copy link
Owner

aheze commented Dec 28, 2021

Interesting, it does seem to be a problem with the presented window. Working on it.

@aheze
Copy link
Owner

aheze commented Dec 28, 2021

@aheze
Copy link
Owner

aheze commented Dec 28, 2021

Setting isHidden = true on the window stops the window from stealing the status bar focus. But of course, nothing shows up...

Popover.sheet.status.bar.mov

@ShezHsky
Copy link
Contributor Author

ShezHsky commented Dec 29, 2021

Yep makes sense - my first thought would be to change its visibility in tandem with whether there are any popovers to present, so the status bar returns to normal programming once all popovers have been dismissed.

An alternative approach I took a quick stab at this afternoon was attempting to present the view controller containing the popover within the same window. I've pushed a rough attempt at the idea to my fork, this might also help your other question (#3) as you can ask the window for it's scene via windowScene. I'll keep at it but you might have some follow on ideas/warnings from this!

@aheze
Copy link
Owner

aheze commented Dec 29, 2021

Woah, nice! Thanks again. I'll check it out.

@aheze
Copy link
Owner

aheze commented Dec 29, 2021

Cool approach. There's some weird animations currently but should be fixable. I'll do some more testing with the view controllers and see if there's any drawbacks.

Btw thanks for WindowReader! Looks like exactly what I was missing.

@aheze
Copy link
Owner

aheze commented Dec 29, 2021

Similar problem here: https://stackoverflow.com/questions/59837705/stop-overlay-uiwindow-from-controlling-the-status-bar

In the meantime I'll add a bounty to that stack overflow question. There could be some random property that you need to set or whatever...

Screenshot of the post: Stop overlay UIWindow from controlling the status bar

@aheze aheze closed this as completed in #5 Jan 5, 2022
aheze pushed a commit that referenced this issue Jan 18, 2022
@aheze aheze added the fixed The problem was fixed! label Apr 29, 2022
@aheze
Copy link
Owner

aheze commented Jul 25, 2022

Seems like there's a private API that can help with this...

/// Private API overrides for status bar appearance
/// http://www.openradar.me/15573442
/// http://www.openradar.me/30064691
/// https://openradar.appspot.com/23677818
@objc(_canAffectStatusBarAppearance)
private var canAffectStatusBarAppearance: Bool {
    false
}

from omaralbeik/Drops#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed The problem was fixed!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants