How to effectively disable Dark Mode theming in Nativescript?
Asked Answered
M

3

7

I tried to add

<key>UIUserInterfaceStyle</key>
   <string>Light</string>

to App_Resources/iOS/Info.plist

But the app still is with dark mode, even after rebuilding it and deleting hooks, node_modules and platforms.

I'm using tns preview --bundle.

Marketable answered 8/1, 2020 at 2:0 Comment(2)
With {N} theme you can switch between modes easily.Milreis
Maybe a dumb question, but is this supposed to reverse all the colors for me automatically or do I still have to code out all the dark mode styles by hand?Willner
R
12

Not sure what can be happening with your code but it is really supposed to work. I have been using it until last update (when we finally had time to handle dark mode).

You should also be able to force light mode with

import Theme from "@nativescript/theme";

Theme.setMode(Theme.Light);

Source: https://github.com/NativeScript/theme

Ruddle answered 8/1, 2020 at 8:40 Comment(3)
I would set this inside app.js? App.vue?Marketable
Sorry for the late reply here, in your main.js. The file where the app is loaded with New Vue({...}).$start();Ruddle
Unfortunately it didn't resolved... The dark mode is still being displayed.Marketable
M
1

In addition to the plist I did (with Nativescript theme installed)

Page class="ns-light"

Worked for me on iOS 13.1

Musky answered 26/1, 2020 at 21:44 Comment(4)
I need to add this in each Page of my app?Marketable
no you can do it on frame, template: ' <Frame class="ns-light"> <Home /> </Frame>' please refer to my discussion about this on the theme page here: github.com/NativeScript/theme/issues/244 And please if this worked for you mark the answer with a checkmark :)Musky
I wish it worked for me. But it didn't. :( I really don't know what is happenning. Maybe I'll need to refactor the Nativescript-Theme of this app to try to fix this.Marketable
Can you edit your original question to include: tns doctor app.scss package.json Information, I'm suspecting either your theme or ios tools or something is not updated to the certain version this stopped being a bug.Musky
D
0

put into AppDelegate

self.window?.backgroundColor = .white
            if #available(iOS 13.0, *) {
                self.window?.overrideUserInterfaceStyle = .light
            }
Dotdotage answered 8/1, 2020 at 5:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.