feat: implement global theme switcher and dark mode support#38
feat: implement global theme switcher and dark mode support#38Amadeusz-P wants to merge 1 commit into
Conversation
👷 Deploy request for aedmap pending review.Visit the deploys page to approve it
|
|
I'm open to debate here, but I don't feel this feature is needed. Goal of the app is make it zero-config driven as much as possible. After receiving more than 200+ feedback messages, no one mentioned that this feature is missing. I don't feel that codebase expansion justifies value. |
From my experience, older users are often particular about this, so adding an option to change it is a valuable accessibility update. And accessibility would also be necessary if the city plans to promote the app via social media. In fact, this is exactly why I'm submitting these PRs—my city has recently greenlit AEDs in public spaces as part of a multi-year revitalization plan. |
Which accessiblity guidelines requires this? WCAG does not.
Okey, but don't you think that system theme sync is already an easier solution for older people? |
Doesn't WCAG mention something about the ability for users to select foreground and background colors? But that's beside the point. Having a default dark theme without the ability to change it may cause a problematic situation when using a phone in direct sunlight; also, using a dark theme outside may bring problems to users with poorer eyesight. While adding this toggle does not take away from the simplicity of the app—the default is the system setting—it definitely adds to its broader usage. |
Mentions. And the ability to set this is available via system theme switcher.
I agree, but the ability is already delivered by system theme switcher.
Nope, it adds complexity, one more thing in the settings list, 349 lines added to codebase. This feature comes at the cost. And I don't think value justifies the cost here. The only real use case is when user wants to for example select light mode in app, when rest of the phone system is in dark mode. I feel it is extremely rare use case, and it does not justifies the cost. App is already WCAG-compliant. What other value besides the usecase described above, this feature delivers? |
|
@Amadeusz-P But why can't you just switch system theme in such case? |


This Pull Request introduces a global theme switcher, allowing users to toggle between Light Mode and Dark Mode. While the user-facing feature is straightforward, its implementation required a substantial amount of refactoring and underlying architecture changes ("plumbing") to ensure that theme state changes propagate cleanly across all application layers, map tiles, and custom widgets.
Key Changes & Architecture Breakdown
State Management & Plumbing for Theme Configuration
Global Theme State: Introduced a state notifier / provider to manage the user's selected theme preference across the app lifecycle.
Persistent Settings: Integrated local storage mapping to ensure the chosen theme preference persists across application restarts.
Context Propagation: Updated the root configuration (MaterialApp or equivalent) to dynamically rebuild and apply properties based on the active theme state.
UI & Component Restructuring
Widget Modernization: Refactored a large number of hardcoded color properties in existing views and dialogs to use semantic colors from Theme.of(context) (e.g., colorScheme.surface, colorScheme.onSurface).
Theme Switcher Control: Added an intuitive toggle button/option inside the user interface settings to trigger the switch.
Map Customization & Integration
Adaptive Map Styling: Connected the theme switcher to the map rendering layer. The application now swaps map source tiles or applies specialized dark/light styling configurations dynamically to match the active system mode, protecting user night vision during emergencies.
Why are there so many files changed?
To prevent a fragmented user experience, every custom card, bottom sheet, and map element had to be adapted to drop hardcoded styles and instead listen to the central theme state. This ensures strict UI consistency when flipping the toggle.
Type of Change