Skip to content

[macOS] Add dynamic color support directly to NSColor#2138

Merged
mischreiber merged 2 commits intomicrosoft:mainfrom
mischreiber:NSColor+Extensions
Mar 7, 2025
Merged

[macOS] Add dynamic color support directly to NSColor#2138
mischreiber merged 2 commits intomicrosoft:mainfrom
mischreiber:NSColor+Extensions

Conversation

@mischreiber
Copy link
Copy Markdown
Collaborator

@mischreiber mischreiber commented Mar 7, 2025

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

Creates a new extension on NSColor that adds dynamic color support, similar to the equivalent methods in UIColor+Extensions.swift.

These changes will be important for FluentTheme integration, which is almost ready :)

New:

  • Create an NSColor with explicit light and dark variants.
  • Fetch these values back on demand.
  • Add test UI to the demo app to validate this.

Verification

Verified that the new dynamic colors work as expected:

  • The light method always returns the light value.
  • The dark method returns either dark if it exists, or light if not.
  • Otherwise, the color will draw according to the current NSAppearance as expected. This includes redrawing when the system appearance changes.
Visual Verification
Before After
dark light

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@mischreiber mischreiber requested a review from a team as a code owner March 7, 2025 06:18
@mischreiber mischreiber merged commit f4a41a6 into microsoft:main Mar 7, 2025
7 checks passed
@mischreiber mischreiber deleted the NSColor+Extensions branch March 7, 2025 21:48
@joannaquu joannaquu mentioned this pull request Apr 4, 2025
12 tasks
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