Repository navigation
Conversation
The dark mode was binary: once the switch was used, the user could not go back to following the device from the interface, and "Device Dependent Dark Mode" was only read on the very first visit (no cookie yet), so the theme did not follow a device switching to dark in the evening. - Preferences: an "Appearance" choice (Default = follow the device, Light, Dark), next to the language and the time zone, instead of the "Device Dependent Dark Mode" box. It is a view of dark_mode and dark_mode_device_dependent, written back on change; self-readable and writeable. Saving the Preferences reloads the page, so the new appearance applies at once. - When the user follows the device, the theme follows it at every page load and as soon as prefers-color-scheme changes (no reload loop). - The "Dark Mode" switch of the user menu is kept and stores a choice made by hand (dark_mode and dark_mode_device_dependent = False); if the write fails, the cookie goes back to what it was, without blocking nor reloading. - The default of dark_mode_device_dependent is unchanged (False). - Tests: Python (appearance, rights, view, page reload, real HTTP session with the color_scheme cookie) and Hoot; the request pushed by the existing test is now popped after the class. Signed-off-by: Claude Perrin <klodr@users.noreply.github.com>
ljmnoonan
left a comment
There was a problem hiding this comment.
Hello @klodr, and thank you for your contribution.
I am a little bit leery of letting the system just reload the page without asking. Take filters for example: you are trying to find a specific record and have spent considerable time narrowing down your filters. Suddenly, your system decides it's bedtime and poof, the page has reloaded and you need to start all over again.
Another example: you start a sale, but the customer has not told you who he is yet. You enter some items that he wants to buy, but before you can select the customer the page reloads and you need to start all over again.
Odoo even prevents you from accidentally reloading from the front end when a form is dirty without all required fields by triggering a popup. Maybe this would be a solution; trigger a popup asking if you want to reload instead of just doing it
Overall, I think it would be a better idea to simply do what I proposed here #3458 (comment) but which I have still not gotten the time to implement. Indeed, I do not actually use 18.0 anymore, so i have no motivation to do so.
Some more comments:
Did this involve AI? If so, please read and conform to https://github.com/OCA/.github/blob/master/AI_POLICY.md
I don't know if it is an official policy or not, but I have not noticed @author: being inserted into the copyright section anywhere else. Probably best to get rid of that.
Why is dark_mode_device_dependent still existing if you now use color_scheme_mode?
Default theme should probably be renamed to System
Why
The dark mode is binary today. Once a user clicks the Dark Mode switch, there is no way back to following the device from the interface, and the Device Dependent Dark Mode box is only read on the very first visit (when there is no
color_schemecookie yet). A device that switches to dark in the evening (automatic appearance of macOS, iOS, Android) is therefore not followed.What changes
dark_modeanddark_mode_device_dependent, written back on change, self-readable and self-writeable.preference_saveis left unchanged.dark_mode_device_dependent, now sent insession_info), the theme follows it at every page load and as soon asprefers-color-schemechanges. It only reloads when the cookie differs, so there is no reload loop.dark_modeanddark_mode_device_dependent = False). If the write fails, the cookie goes back to what it was, without blocking the UI nor reloading.dark_mode_device_dependentis unchanged (False); existing users keep their settings (they see Light or Dark, or Default if they had checked the box).darkModeSwitchItem,colorSchemeServiceandenv.services.color_scheme.switchColorScheme()are kept.Version 18.0.1.1.0. Translations will go through Weblate.
Tests
web_dark_modeonly: Preferences → Dark → reloaded in dark; → Default → back to the light device theme.Related, not overlapping: #3458 (new tabs at the root URL), and the 19.0 work that follows the device on load and stores the settings in
res.users.settings.