-
Notifications
You must be signed in to change notification settings - Fork 149
[Fabric] Add macOS platform color types with comprehensive semantic colors support #2737
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Saadnajmi <[email protected]>
Co-authored-by: Saadnajmi <[email protected]>
Done! I've refactored the implementation to use a dedicated
Done! I've refactored the implementation to use a dedicated |
Co-authored-by: Saadnajmi <[email protected]>
|
@copilot can you also handle the macOS set of semantic colors, used by PlatformColor()? |
Co-authored-by: Saadnajmi <[email protected]>
Done! I've added a macOS-specific
The implementation handles fallback colors, array-based selectors, and creates Swift-style aliases. Commit: 868a823 |
Summary
This PR adds complete support for macOS-specific platform color types in the Fabric renderer. The Paper renderer already had full support for all three macOS color types, but Fabric was missing
ColorWithSystemEffectMacOSand had an incomplete set of macOS semantic colors.The implementation follows the established pattern of using a dedicated
platform/macosfolder structure to isolate macOS-specific code, similar to the approach used inreact/renderer/components/view.Background
In the Paper (legacy) renderer, we implemented conversions for three macOS-specific color types in
RCTConvert.mm:labelColor,systemBlueColor) -This PR completes the implementation for all three types with full macOS support.
Changes
1. Created dedicated macOS platform folder structure
Following the pattern established in PR #2690, macOS-specific code is isolated in
platform/macos/react/renderer/graphics/instead of using#if TARGET_OS_OSXguards in shared iOS files.2. Added
HostPlatformColor.mmin macOS platform folderContains the
UIColorFromColorWithSystemEffecthelper function that mirrors the existingRCTColorWithSystemEffectfrom the Paper renderer. It applies macOS system effects to a base color, supporting:none- NSColorSystemEffectNonepressed- NSColorSystemEffectPresseddeepPressed- NSColorSystemEffectDeepPresseddisabled- NSColorSystemEffectDisabledrollover- NSColorSystemEffectRollover3. Added
PlatformColorParser.mmin macOS platform folderComplete parser implementation supporting all three color types:
labelColor,systemBlueColor)Handles the
colorWithSystemEffectJSON structure:{ "colorWithSystemEffect": { "baseColor": <any_color_value>, "systemEffect": "pressed" } }The implementation recursively parses the base color (which can be any color type including semantic or dynamic colors) and then applies the requested system effect.
4. Added
RCTPlatformColorUtils.mmin macOS platform folder (NEW)Complete implementation of macOS semantic colors matching the Paper renderer's
RCTSemanticColorsMap. Includes:Label Colors: labelColor, secondaryLabelColor, tertiaryLabelColor, quaternaryLabelColor
Text Colors: textColor, placeholderTextColor, selectedTextColor, textBackgroundColor, selectedTextBackgroundColor, keyboardFocusIndicatorColor, unemphasizedSelectedTextColor, unemphasizedSelectedTextBackgroundColor
Content Colors: linkColor, separatorColor, selectedContentBackgroundColor, unemphasizedSelectedContentBackgroundColor
Menu Colors: selectedMenuItemTextColor
Table Colors: gridColor, headerTextColor, alternatingEvenContentBackgroundColor, alternatingOddContentBackgroundColor
Control Colors: controlAccentColor, controlColor, controlBackgroundColor, controlTextColor, disabledControlTextColor, selectedControlColor, selectedControlTextColor, alternateSelectedControlTextColor, scrubberTexturedBackgroundColor
Window Colors: windowBackgroundColor, windowFrameTextColor, underPageBackgroundColor
Highlights and Shadows: findHighlightColor, highlightColor, shadowColor
Standard Colors: systemBlueColor, systemBrownColor, systemGrayColor, systemGreenColor, systemOrangeColor, systemPinkColor, systemPurpleColor, systemRedColor, systemYellowColor, clearColor
The implementation also:
5. Updated
React-graphics.podspecModified to use platform-specific source files:
platform/ios/**/*.{m,mm,cpp,h}filesplatform/ios/**/*.{m,mm,cpp,h}andplatform/macos/**/*.{m,mm,cpp,h}filesplatform/macosto header search paths for USE_FRAMEWORKS buildsArchitecture
This approach keeps macOS-specific code cleanly separated in its own platform folder without using preprocessor guards in shared iOS files, making the codebase easier to maintain and consistent with the pattern established in other renderer components.
Testing
The implementation follows the exact same pattern as the working Paper renderer implementation in
RCTConvert.mm, ensuring behavioral parity between Paper and Fabric renderers.Fixes #2736
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.