Skip to content

Conversation

@DanielMorM
Copy link
Contributor

@DanielMorM DanielMorM commented Feb 4, 2026

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

This PR extends the FluentUI theming system to support customizable brand colors through GlobalTokens, enabling apps to override the default Communication Blue color palette (brand10-brand160) with their own brand colors.

New Protocol - BrandColorProviding.swift:

  • Introduces BrandColorProviding protocol with 16 brand color properties (brand10 through brand160)
  • Cross-platform support for iOS, visionOS, and macOS using PlatformColor typealias

TokenSet.swift:

  • Added methods to dynamically update/remove overrides: setOverride(:for:), setOverrides(:), removeOverride(for:), removeAllOverrides()
  • Changed valueOverrides from immutable to mutable to support runtime updates

FluentTheme.swift:

  • Added public methods for color override management: setColorOverrides(:), setColorOverride(:for:), removeColorOverride(for:), removeAllColorOverrides()
  • Added automatic didChangeTheme notification posting when modifying the shared theme

GlobalTokens.swift:

  • Added static brandColorProvider: BrandColorProviding? property
  • Updated brandSwiftUIColor(_:) to return colors from the provider when set, falling back to Communication Blue defaults

ColorProviding.swift (iOS):

  • ColorProviding now inherits from BrandColorProviding
  • setColorProvider(_:) now updates the theme in-place instead of replacing it
  • setSharedThemeColorProvider(_:) now also sets GlobalTokens.brandColorProvider

ColorProviding.swift (macOS):

  • ColorProviding now inherits from BrandColorProviding
  • Added new brand background/foreground color properties
  • Added setSharedThemeColorProvider(_:) extension method (parity with iOS)

Colors.swift (macOS):

  • Setting Colors.colorProvider now automatically calls FluentTheme.setSharedThemeColorProvider() for backward compatibility

Demo Apps:

  • Added brand color assets for green and purple themes (iOS) and demo brand colors (macOS)
  • Updated DemoColorGreenTheme, DemoColorPurpleTheme, and ObjectiveCDemoColorProviding to implement BrandColorProviding
  • Updated macOS TestColorViewController to display brand colors with toggle support

Binary change

[Pending]

Verification

  • Built and ran iOS demo app with green and purple theme switching
  • Built and ran macOS demo app with color provider toggle
  • Verified brand colors update correctly via GlobalTokens.brandSwiftUIColor()
  • Verified FluentTheme.shared color overrides update in-place
  • Verified backward compatibility: setting Colors.colorProvider on macOS updates the shared theme
  • Tested Objective-C interoperability via ObjectiveCDemoColorProviding
Visual Verification
Scenario Screenshot
Before image
After - NOT using color provider image
After - using color provider image

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@DanielMorM DanielMorM requested a review from a team as a code owner February 4, 2026 18:29
@DanielMorM DanielMorM changed the title User/damoral/extending brand colors mac os [ColorProvider] Extending brand colors override functionality to macOS Feb 4, 2026
/// MARK: BrandColorProviding

- (UIColor *)brand10 {
return [UIColor colorNamed:@"Colors/DemoGreenBrand10Color"];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you walk me through why we have these secondary definitions for brand colors in the iOS app, compared to what was already present?

switch token {
case .comm10:
return Color(hexValue: 0x061724)
return Self.brandColorProvider.map { Color($0.brand10) } ?? Color(hexValue: 0x061724)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not make global tokens conditional; there are legit scenarios where a branded app may still want to access the default comm blue colors. All overrides should happen at the theme level for this reason.

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