NativeScript / NativeScript/angular

Issue with APP_INITIALIZER and NativeScript Theme: Core V2

Đang mở
#66 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
TypeScript
Star
55
Fork
13
Merge trung bình
16 phút
Pull request đã merge (30 ngày)
1

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy dự án mẫu được liên kết với npm run android hoặc npm run ios, sau đó so sánh hành vi khi có và không có provider APP_INITIALIZER trong app.module.ts. Kiểm tra cấu hình theme được tham chiếu trong AppComponent và xác minh rằng Theme.setMode() giữ nguyên mode đã chọn và giá trị chính xác của Application.systemAppearance() sau khi khởi động lại ứng dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend, mobile-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.