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

当主题为 ThemeMode.system时, 系统自动切换黑暗模式时,导航栏不会变黑 #13

Open
Sayidssss opened this issue Nov 25, 2024 · 3 comments

Comments

@Sayidssss
Copy link

如题,当主题为 ThemeMode.system时, 系统自动切换黑暗模式时,导航栏不会变黑,

步骤:
0. 系统暗色模式关闭

  1. 先将主题设置为 system.
  2. 打开暗色模式
  3. 显示异常 导航栏为白色
    Screenshot_2024-11-25-09-40-26-59_082aea295e0e2b19157fadadca43d2cc

反过来也是一样

  1. 系统暗色模式开启
  2. 先将主题设置为 system.
  3. 关闭暗色模式
  4. 显示异常 导航栏为黑色
    Screenshot_2024-11-25-09-40-58-82_082aea295e0e2b19157fadadca43d2cc
@Kxmrg
Copy link
Owner

Kxmrg commented Nov 25, 2024

确实存在这个问题。请尝试修改common/services/global.dart文件进行修复:

@override
  void didChangePlatformBrightness() {
    super.didChangePlatformBrightness();
    if (_themeMode == ThemeMode.system) {
      refreshAppui();
      //添加本行更新导航栏
      updateNavigationBar();
    }
  }

@Sayidssss
Copy link
Author

因为 refreshAppUi有个300ms的延迟, 下面的更新导航栏,并没有起效. 我给更新导航栏也加了个延迟,现在显示效果正确了

void didChangePlatformBrightness() {
    super.didChangePlatformBrightness();
    if (_themeMode == ThemeMode.system) {
      refreshAppui();
      delayed(500, () {
        updateNavigationBar();
      });
    }
  }

@Kxmrg
Copy link
Owner

Kxmrg commented Nov 25, 2024

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants