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] StatusBarColor with AppThemeBinding doesn't reflect changes of light/dark mode on the fly #2306

Open
2 tasks done
RsZoli opened this issue Oct 28, 2024 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working unverified

Comments

@RsZoli
Copy link

RsZoli commented Oct 28, 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 the StatusBarColor with AppThemeBinding, changes of light/dark mode doesn't get reflected on the fly!

The page needs to be navigated to once more for the changes to take effect!

Screen_Recording_20241028_1000142.mp4

Expected Behavior

Changes should take effect on the fly!

Steps To Reproduce

  1. Open and run solution from reproduction repository.
  2. Click the button titled "StatusbarBehavior repro 3" and observe the bug.

Link to public reproduction project repository

https://github.com/RsZoli/GitHubRepros

Environment

  • .NET MAUI CommunityToolkit: 9.1.0
  • OS: Windows 11 22631.4317
  • .NET MAUI:
    android 34.0.138/8.0.100 SDK 8.0.400, VS 17.11.35327.3
    ios 18.0.8303/8.0.100 SDK 8.0.400, VS 17.11.35327.3
    maui-windows 8.0.82/8.0.100 SDK 8.0.400, VS 17.11.35327.3

Anything else?

No response

@RsZoli RsZoli added bug Something isn't working unverified labels Oct 28, 2024
@jakob-bmd
Copy link

I created another repo based on @jfversluis MauiToolkitStatusBarBehaviorSample:

https://github.com/jakob-bmd/MauiToolkitStatusBarBehaviorAppThemeBindingBug/tree/main

Steps To Reproduce
GIVEN: user is in mainpage of the app
WHEN: changing the android OS Theme to (e.g.) black and navigating back to the app
THEN: the statusbar stays white

Image

Expected Behavior
the color of the statusbar should change immediately with the OS theme change

Additional Info
The statusbar color changes correctly, when hotreload takes place

Environment

  • .NET MAUI CommunityToolkit: 9.1.1
  • MauiVersion 8.0.93
  • Android 33

@vniehues
Copy link

My current (crude) workaround is subscribing to the RequestedThemeChanged event and manually setting the colors and styles but I feel like this functionality should be in the Behavior itself.

        Application.Current.RequestedThemeChanged += (sender, args) =>
        {
            switch (args.RequestedTheme)
            {
                case AppTheme.Dark:
                    StatusBar.SetColor(Application.Current.Resources["OffBlack"] as Color);
                    StatusBar.SetStyle(StatusBarStyle.LightContent);
                    break;
                case AppTheme.Light:
                case AppTheme.Unspecified:
                    StatusBar.SetColor(Colors.White);
                    StatusBar.SetStyle(StatusBarStyle.DarkContent);
                    break;
            }
        };

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

No branches or pull requests

3 participants