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

[BUG] Setting StatusBarBehavior breaks it on iOS in landscape mode #1707

Open
2 tasks done
RsZoli opened this issue Feb 22, 2024 · 6 comments
Open
2 tasks done

[BUG] Setting StatusBarBehavior breaks it on iOS in landscape mode #1707

RsZoli opened this issue Feb 22, 2024 · 6 comments
Labels
area/behaviors Issue/Discussion/PR that has to do with Behaviors bug Something isn't working

Comments

@RsZoli
Copy link

RsZoli commented Feb 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

When setting a ContentPage's StatusBarBehavior on a page like this:

<ContentPage.Behaviors>
    <toolkit:StatusBarBehavior StatusBarColor="{StaticResource Primary}" StatusBarStyle="LightContent" />
</ContentPage.Behaviors>

Navigating to another page and turn the phone to landscape mode, the result is this:

IMG_0002

However, after navigating to another page that has the StatusBarBehavior setting, there is no problem:

IMG_0003

Expected Behavior

The StatusBarBehaviour should be needed to set one time only, and have no issue after navigating from the page it has set on.

Steps To Reproduce

Please find it in my repository

Link to public reproduction project repository

https://github.com/RsZoli/GitHubRepros

Environment

- .NET MAUI CommunityToolkit: 7.0.1
- OS: iOS 16.7.5, iOS 17.3.1
- .NET MAUI: 8.0.6

Anything else?

No response

@RsZoli RsZoli added bug Something isn't working unverified labels Feb 22, 2024
@bijington
Copy link
Contributor

bijington commented Feb 23, 2024

Debugging this in my head I suspect the SizeChanged event isn't firing from the page when the orientation changes. I wonder if that is a change in MAUI?

@RsZoli Are you able to subscribe to the SizeChanged event in your page, change the orientation and see if it fires?

@RsZoli
Copy link
Author

RsZoli commented Feb 23, 2024

@bijington I have tried it, it does fire! On appearing and on orientation changing as well!

@bijington
Copy link
Contributor

@RsZoli I have tested this issue as part of the PR here: #1471 and it appears to work. Interestingly I see a status bar in landscape mode though. What iPad are you testing on?

@RsZoli
Copy link
Author

RsZoli commented Feb 25, 2024

@bijington I'm testing only on iPhones.

@vhugogarcia vhugogarcia added the area/behaviors Issue/Discussion/PR that has to do with Behaviors label Feb 26, 2024
@brendan-holly-modea
Copy link

Is this still an issue on version 8 of the community toolkit? I'm also seeing this behavior on .net7 with version 6.1 of this package, so it doesn't appear to be a new issue to version 7.0.1 of the package.

@randyburden
Copy link

I am using version 9.0.0 of the CommunityToolkit.Maui package and am also experiencing this issue.

My app is using MAUI Blazor Hybrid and once I change the status bar color on iOS, if I change to landscape mode, then I get the same reported behavior of where there is a colored rectangle at the top of the page that takes up about 45% of the width of the page. When the device rotates to a vertical orientation the issue goes away and when I rotate back to a horizontal orientation the issue appears again.

Here is an example of how I'm changing the status bar:

CommunityToolkit.Maui.Core.Platform.StatusBar.SetColor(Colors.Red);
CommunityToolkit.Maui.Core.Platform.StatusBar.SetStyle(StatusBarStyle.LightContent);

I was able fix the issue by subscribing to display info changes and calling StatusBar.UpdateBarSize like so:

#if IOS
DeviceDisplay.Current.MainDisplayInfoChanged += (sender, e) =>
{
    CommunityToolkit.Maui.Core.Platform.StatusBar.UpdateBarSize();
};
#endif

Some form of the above code should be incorporated into this library to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/behaviors Issue/Discussion/PR that has to do with Behaviors bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants