NativeScript / NativeScript/angular

Issue with APP_INITIALIZER and NativeScript Theme: Core V2

オープン
#66 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
55
フォーク
13
平均マージ
16分
マージ済み PR(30日)
1

説明

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?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、リンクされたサンプルプロジェクトを npm run android または npm run ios で実行し、次に app.module.ts の APP_INITIALIZER プロバイダーがある場合とない場合の動作を比較します。AppComponent で参照されているテーマ設定を確認し、アプリの再起動後も Theme.setMode() が選択したモードと正しい Application.systemAppearance() の値を保持することを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend, mobile-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。