Skip to content

Add NamedColor support for macOS#819

Merged
Kyle-Ye merged 2 commits intomainfrom
named-color-macos-support
Mar 9, 2026
Merged

Add NamedColor support for macOS#819
Kyle-Ye merged 2 commits intomainfrom
named-color-macos-support

Conversation

@Kyle-Ye
Copy link
Collaborator

@Kyle-Ye Kyle-Ye commented Mar 9, 2026

Summary

  • Fix named color resolution on macOS by adding NSAppearanceName string mapping in CUICatalog.findAsset (previously only used UIAppearance strings from iOS)
  • Add isUIKitBased() guard in resolveCGColor to use correct idiom/matchTypes on non-UIKit platforms (macOS native uses idiom 0 + .appearance match type)
  • Add NamedColor example with 4 color swatches (light/dark × standard/increased contrast) and expanded asset catalog with distinct colors per appearance variant
Screenshot

Test plan

  • Verify named color resolves correctly on macOS (was previously broken)
  • Run NamedColorUITests snapshot test on both macOS and iOS
  • Verify iOS named color resolution is unchanged

@github-actions github-actions bot added bug Something isn't working platform: macOS enhancement New feature or request labels Mar 9, 2026
@Kyle-Ye Kyle-Ye force-pushed the named-color-macos-support branch from e60631c to 8cbe696 Compare March 9, 2026 17:44
@github-actions github-actions bot added the test Test related issue label Mar 9, 2026
@Kyle-Ye Kyle-Ye merged commit afdfcda into main Mar 9, 2026
7 of 8 checks passed
@Kyle-Ye Kyle-Ye deleted the named-color-macos-support branch March 9, 2026 17:55
@augmentcode
Copy link

augmentcode bot commented Mar 9, 2026

🤖 Augment PR Summary

Summary: This PR fixes named color resolution on macOS by aligning CoreUI asset lookups with AppKit appearance naming.

Changes:

  • Update CUICatalog.findAsset to map environment appearance/contrast to NSAppearanceName… strings when the catalog uses AppKit appearance names.
  • Adjust named color resolution to choose idiom/match-types based on isUIKitBased(); macOS-native paths use appearance-only matching.
  • Refine CoreUI match-type defaults to include an explicit Vision idiom match (then appearance) for Vision assets.
  • Add a new NamedColorExample view showing light/dark × standard/increased-contrast swatches.
  • Expand the example asset catalog to include distinct colors per appearance/contrast variant (including mac idiom entries).
  • Update snapshot UI tests to render the new example and re-enable the test on macOS.

Technical Notes: The macOS fix hinges on using the correct CoreUI appearance-name strings (NSAppearance vs UIAppearance) and ensuring the match-type list is non-empty on non-UIKit platforms.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 44.11765% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.49%. Comparing base (e04fe6b) to head (8cbe696).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ces/OpenSwiftUICore/Graphic/Color/NamedColor.swift 40.00% 18 Missing ⚠️
...ources/OpenSwiftUICore/Graphic/CatalogLookup.swift 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #819      +/-   ##
==========================================
+ Coverage   27.48%   27.49%   +0.01%     
==========================================
  Files         661      661              
  Lines       42425    42444      +19     
==========================================
+ Hits        11660    11671      +11     
- Misses      30765    30773       +8     

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request platform: macOS test Test related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant