Skip to content

[DynamicColors] Add support for dynamic colors #4850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SaintPatrck
Copy link
Contributor

🎟️ Tracking

📔 Objective

Introduce support for dynamic colors in the application.

  • A new setting isDynamicColorsEnabled is added to SettingsDiskSource and SettingsRepository to persist and retrieve the dynamic colors preference.
  • A new flow isDynamicColorsEnabledFlow is added to track the changes of isDynamicColorsEnabled.
  • A new switch "Dynamic colors" is added in the Appearance Screen.
  • The MainState is updated with the isDynamicColorsEnabled attribute.
  • BitwardenTheme is updated to set the dynamic color.
  • The AppearanceViewModel is updated to set the isDynamicColorsEnabled.

📸 Screenshots

Coming soon!

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 40.47619% with 50 lines in your changes missing coverage. Please review.

Project coverage is 83.82%. Comparing base (899689b) to head (a9fc13d).

Files with missing lines Patch % Lines
...feature/settings/appearance/AppearanceViewModel.kt 27.58% 18 Missing and 3 partials ⚠️
...rm/feature/settings/appearance/AppearanceScreen.kt 51.85% 12 Missing and 1 partial ⚠️
...data/platform/repository/SettingsRepositoryImpl.kt 0.00% 9 Missing ⚠️
...platform/datasource/disk/SettingsDiskSourceImpl.kt 12.50% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4850      +/-   ##
==========================================
- Coverage   83.90%   83.82%   -0.08%     
==========================================
  Files         596      596              
  Lines       48460    48543      +83     
  Branches     6680     6691      +11     
==========================================
+ Hits        40659    40693      +34     
- Misses       5533     5578      +45     
- Partials     2268     2272       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

github-actions bot commented Mar 11, 2025

Logo
Checkmarx One – Scan Summary & Details1bd8d8a5-48ef-480c-bf4a-ebf45f8209b2

Great job, no security vulnerabilities found in this Pull Request

BitwardenTheme(theme = state.theme) {
BitwardenTheme(
theme = state.theme,
dynamicColor = state.isDynamicColorsEnabled,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did the design team map the colors properly?

They are not one-to-one and we can never guarantee that colors meet accessibility requirements or that everything will even work correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a warning when dynamic colors is enabled so users are aware of the risks.

The way BitwardenColorSchemes is designed gives us enough flexibility that it doesn't need to be 1:1. The only component that we're seeing issue with is the switch, which I can fix with a simple change to the attribute we're mapping to. I think, with a little bit of finesse, we can work around the other concerns of multi-tonal icons and illustrations. Kudos to you for setting it up this way.

To keep concerns separate I'm going to open different PRs with my ideas to tackle those other hurdles.

@SaintPatrck SaintPatrck force-pushed the innovation-sprint/dynamic-colors/set-enabled branch from 005adbf to 763422a Compare March 12, 2025 15:03
Copy link
Contributor

Warning

@SaintPatrck Uploading code coverage report failed. Please check the "Upload to codecov.io" step of Process Test Reports job for more details.

@SaintPatrck SaintPatrck force-pushed the innovation-sprint/dynamic-colors/set-enabled branch 5 times, most recently from f7ab014 to e0ec47e Compare March 17, 2025 22:15
@SaintPatrck SaintPatrck changed the title Add support for dynamic colors [DynamicColors] Add support for dynamic colors Mar 17, 2025
)
mutableIsDynamicColorsEnabledFlow.tryEmit(value)
}
override val isDynamicColorsEnabledFlow: Flow<Boolean?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get some spaces between these vars

@SaintPatrck SaintPatrck force-pushed the innovation-sprint/dynamic-colors/set-enabled branch from e0ec47e to fbebe6f Compare April 15, 2025 16:44
@SaintPatrck SaintPatrck changed the base branch from innovation-sprint/dynamic-colors/base to main April 15, 2025 16:45
@SaintPatrck SaintPatrck force-pushed the innovation-sprint/dynamic-colors/set-enabled branch 2 times, most recently from 5f7f328 to 1584325 Compare April 15, 2025 16:49
@@ -120,6 +124,17 @@ class FakeSettingsDiskSource : SettingsDiskSource {
get() = mutableAppThemeFlow.onSubscription {
emit(appTheme)
}
override var isDynamicColorsEnabled: Boolean?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a new line above this

This commit introduces support for dynamic colors in the application.

-   A new setting `isDynamicColorsEnabled` is added to `SettingsDiskSource` and `SettingsRepository` to persist and retrieve the dynamic colors preference.
-   A new flow `isDynamicColorsEnabledFlow` is added to track the changes of `isDynamicColorsEnabled`.
-   A new switch "Dynamic colors" is added in the Appearance Screen.
- The `MainState` is updated with the `isDynamicColorsEnabled` attribute.
- `BitwardenTheme` is updated to set the dynamic color.
- The `AppearanceViewModel` is updated to set the `isDynamicColorsEnabled`.
- Changed the toggle button switch color to `onPrimary` in the `dynamicColorScheme`.
This commit introduces a warning dialog that is displayed when the user attempts to enable dynamic colors in the appearance settings.
@SaintPatrck SaintPatrck force-pushed the innovation-sprint/dynamic-colors/set-enabled branch from 1584325 to a9fc13d Compare April 15, 2025 17:17
@SaintPatrck SaintPatrck marked this pull request as ready for review April 15, 2025 17:18
@SaintPatrck SaintPatrck requested review from brian-livefront and a team as code owners April 15, 2025 17:18
@SaintPatrck SaintPatrck marked this pull request as draft April 15, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants