NativeScript / NativeScript/angular

Issue with APP_INITIALIZER and NativeScript Theme: Core V2

Aberta
#66 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Linguagem predominante
TypeScript
Estrelas
55
Forks
13
Merge médio
16min
PRs com merge (30d)
1

Descrição

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?

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece executando o projeto de exemplo vinculado com npm run android ou npm run ios e, em seguida, compare o comportamento com e sem o provider APP_INITIALIZER em app.module.ts. Inspecione a configuração do tema referenciada em AppComponent e verifique se Theme.setMode() preserva o modo selecionado e o valor correto de Application.systemAppearance() após reiniciar o app.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
angular, typescript
Domínio
frontend, mobile-dev
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
30/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.