Skip to content

Commit e65062c

Browse files
committed
docs: add hint on how to force Light mode
1 parent 5516b35 commit e65062c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/ui/dark-mode.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,35 @@ If you want to update your project to opt in to Force Dark, it is needed to put
4747

4848
> Note: Make sure that `uiMode` value is included in the `android:configChanges` attribute of the main application activity in the `<project>/app/App_Recoures/Android/src/main/AndroidManifest.xml` file. Ohterwise, application will crash on interacting after changing the system appearance. A complete values string would look like: `android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"`.
4949
50+
### Hint
51+
52+
Some experience that a DarkMode gets applied even though the app is not configured for dark mode nor "forceDarkAllowed" was enabled as described above.
53+
A workaround to this is to set the Theme to LightMode explicitly on startup:
54+
55+
```
56+
...
57+
import Theme from "@nativescript/theme";
58+
...
59+
60+
@Component({
61+
selector: "ns-app",
62+
templateUrl: "app.component.html",
63+
})
64+
65+
export class AppComponent implements OnInit {
66+
67+
public ngOnInit(): void {
68+
if (application.android) {
69+
try {
70+
Theme.setMode(Theme.Light);
71+
} catch (e) {
72+
console.log("Error setting Theme to light mode", e);
73+
}
74+
}
75+
}
76+
}
77+
```
78+
5079
## Dark Mode for iOS
5180

5281
Existing NativeScript applications built with version pre-6.2 won't be affected by the Dark mode for iOS - they will continue to look the same way in both modes.

0 commit comments

Comments
 (0)