How to create darkmode using a switch for all screens?

I’ve made a functional code for one screen, but I’m not able to replicate it without adding a switch on each screen. It’s to do with variables, but I’ve tried and don’t know how to make it work.

I’m doing something similar, perhaps I can take a look?

Try the following logic instead. You need this for every screen.

When [ScreenX] opens:
If app variable dark mode is true:
Set the background color… etc.
else:
Set the background color… etc.