The PR for per-device theme selection has been merged. However, I'd also like to improve the extension's dark theme system before releasing it.
Currently, fof/nightmode has its own CSS that is mostly copied from flarum/core but with some changes - this CSS overrides the existing light theme when night theme is selected. The problem with this system is that it requires us to maintain a working dark theme & there are always issues and clashes with other extensions & styles. It also adds onto an existing large stylesheet file and makes it so either light or dark theme code is unused (as both are included).
The new system (FriendsOfFlarum/nightmode#36) completely gets rid of our separate stylesheet. It overrides Flarum files (safely, not the actual files but acts as if they are) and creates two CSS files -
forum-dark-ID.css (should work with other solutions, e.g. giffgaff who use
forum.css?v=ID). The dark CSS file uses Flarum's own dark theme.
The problem with this new system is that it doesn't work very well with automatic detection & per-device settings. As the CSS file that is decided to be shown is through backend, that only has access to the global user theme (not per-device, cannot detect dark theme in browser either).
My current "fix" for this is to not include either CSS file & hide the forum until the extension's JS decides which theme to load & requests that file. Another solution would be to include both files and remove one once the page has loaded - this would increase load times though, and would look weird as well.
Update 07/19: I have chosen to include both CSS files when automatic mode is chosen. The browser chooses which to render through the <link> media query (it'll still load both files, seems to be the behavior in all browsers). Per-device settings will now be set to cookies so that the web server can access them.
!!! If you want to go back to the released version after testing this out, you WILL need to revert a DB backup.
!!! It is recommended that you install this version on a TEST forum and not a live one.
Either way, I'd like some people to test this new system out (includes per-device theme settings thanks to @davwheat) before it is released.
To test this PR, please make a backup of your database, then run
composer require fof/nightmode=dev-ds/use-less-variable
php flarum migrate
If you find any bugs, please check if it has been reported in other gamification versions by looking through the existing issues @ https://github.com/FriendsOfFlarum/nightmode/issues before reporting it.