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

Issue with APP_INITIALIZER and NativeScript Theme: Core V2 #66

Open
jessorlisa opened this issue May 6, 2022 · 0 comments
Open

Issue with APP_INITIALIZER and NativeScript Theme: Core V2 #66

jessorlisa opened this issue May 6, 2022 · 0 comments

Comments

@jessorlisa
Copy link

jessorlisa commented May 6, 2022

Environment

  • Node.js: v16
  • Android SDK: 30
  • JDK 11
  • Xcode: 13.3.1
  • CocoaPods 1.11.2
  • CLI: latest nativescript@8.2.2
  • Cross-platform modules: @nativescript/core@8.1.5
  • Android Runtime: @nativescript/android@8.1.1
  • iOS Runtime: @nativescript/ios@6.5.5 (JSC!)
  • Angular: @angular/core@13.2.5
  • Plugin(s):
    ├── @nativescript/theme@3.0.2

Describe the bug
The Theme.setMode() from the NativeScript Theme plugin stops working when an async APP_INITIALIZER is used.

To Reproduce
Steps to reproduce:

  • Clone the sample project
  • run npm run android or npm run ios (the home component will show some theme/system appearance details)
  • tap "Change app theme" and choose the opposite theme to your current device setting, the theme changes correctly for now, but
    Problem 1: as you can see Application.systemAppearance() now shows a wrong value (e.g. "dark", even if the device is in light mode)
  • Close the app (not only put it to background)
  • Restart the app ...
    Problem 2: The app theme is back to auto, although it is set to a specific mode in the AppComponent

But if you disable the APP_INITIALIZER by removing the APP_INITIALIZER from the providers array in app.module.ts everything is working just fine.

Expected behavior
Theme.setMode() is working despite the use of APP_INITIALIZER.

Sample project
https://github.com/jessorlisa/demo-issues-nativescript-ng/tree/issue/set-theme

Additional context
My first suspicion was that something was amiss with the theme but then I could narrow it down to the APP_INITIALIZER.

Any thoughts? Help?

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

1 participant