angular icon indicating copy to clipboard operation
angular copied to clipboard

Issue with APP_INITIALIZER and NativeScript Theme: Core V2

Open jessorlisa opened this issue 3 years ago • 0 comments

Environment

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?

jessorlisa avatar May 06 '22 11:05 jessorlisa