-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
App is changing from Light to Dark Theme after Webpack HMR #289
Comments
@Tyler-V Any news on this? We're having the same problem. I want to cut Dark Mode short and make sure the system setting won't override the app's theme. |
@csimpi I have not found a solution for this, the only other option I can think of if it affects the actual production built app is to create a custom theme and override the dark theme that is applied by importing the nativescript prebuilt themes to use the same light theme. |
After testing I can confirm this issue is isolated to Android and only during debugging after the first HMR, this issue thankfully does not exist in production on the built mobile app. As a temporary solution, you can modify your
|
I have this happening seemingly at random with release builds also. Phone : OnePlus 6T, Android 10 Dependecies:
|
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA in the ticket additional context I've tried every possible option to disable dark mode completely which works when the application is built but resets as you've stated during HMR. I think the only way to disable dark theme if using the nativescript core themes is to create a custom theme / mixin where the dark theme color values are set to the light theme values although I have not tested this. This is strictly found in HMR on Android as you stated and does not impact production, just makes it a pain to continuously restart debugging if you are dealing with small text changes that may not show up against the dark theme based on your project. |
This comment was marked as abuse.
This comment was marked as abuse.
It happens in production also. main.tns.ts :
App_Resources\Android\values-v29\styles.xml :
App_Resources\Android\values\colors.xml :
|
This comment was marked as abuse.
This comment was marked as abuse.
No sure what you mean by too late. I have this in my app.scss
if that what you are referring to? And yes Im calling the forceLightTheme() in app.module.tns.ts
the node_modules/@nativescript/theme/package.json says : |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA - No and its difficult to get it to happen and unfortunately I don't have an Android 10 phone myself. |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA - I repeatedly opened the app, then closed or supended it, did something else on the phone, then opened the app again and once in a while, although rarely, it would open with the dark mode theme. |
I am experiencing a similar problem when I have the app running on the device and I change the display mode setting to dark-mode (tested on an Samsung Galaxy 9+). The colours will change to dark-mode but
If you remove setting the mode to
|
I'm running: I've tried all the solutions, that can be found regarding this topic. @jalberto-ghub solution came close but wasn't consistent. Probably due the timeout. From time to time the dark mode would appear. I also tried force-dark-allowed with "ns clean" and rebuilding everything. I also tried setting the MODE_NIGHT_NO enum in onCreate/onStart in the android activity itself. The only solution through the various threads, that worked consistently for me, was the following.
and called the method in RadSidedrawer's - loaded method. |
Environment
Describe the bug
I am trying to ensure the app remains in light mode. When I am debugging I set my phone settings to enable dark mode. I then debug the app and initially it appears in light mode however when webpack reloads on a change during development, it then appears to apply the dark theme.
To Reproduce
ns debug android
on my connected Pixel 5 (Android 11)Expected behavior
Dark mode should remain disabled and the ns-dark theme should not apply.
Additional context
I have tried the following to ensure dark mode does not apply, none prevent the app from changing from light to dark on HMR.
<item name="android:forceDarkAllowed">false</item
> instyles.xml (values-v29)
<page-router-outlet>
Theme.setMode(Theme.Light);
manually onngOnInit
in the app component and main.tsThe text was updated successfully, but these errors were encountered: