Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,11 @@ SharedColor whiteColor() {
return color;
}

// [macOS
// Select by graphics backend, not host OS: C++ also builds on Apple hosts.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This comment is a bit too agent-context-window driven.

SharedColor defaultForegroundTextColor() {
return {hostPlatformDefaultForegroundTextColor()};
}
// macOS]

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ inline Color hostPlatformColorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t
return (a & 0xff) << 24 | (r & 0xff) << 16 | (g & 0xff) << 8 | (b & 0xff);
}

// [macOS
inline Color hostPlatformDefaultForegroundTextColor() {
return hostPlatformColorFromRGBA(0, 0, 0, 255);
}
// macOS]

inline Color hostPlatformColorFromComponents(ColorComponents components)
{
float ratio = 255;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ inline Color hostPlatformColorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t
return (a & 0xff) << 24 | (r & 0xff) << 16 | (g & 0xff) << 8 | (b & 0xff);
}

// [macOS
inline Color hostPlatformDefaultForegroundTextColor() {
return hostPlatformColorFromRGBA(0, 0, 0, 255);
}
// macOS]

inline Color hostPlatformColorFromComponents(ColorComponents components)
{
float ratio = 255;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ namespace HostPlatformColor {
NO_DESTROY static const facebook::react::Color UndefinedColor = Color();
} // namespace HostPlatformColor

Color hostPlatformDefaultForegroundTextColor(); // [macOS]

inline Color hostPlatformColorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{
float ratio = 255;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import <Foundation/Foundation.h>
#import <React/RCTUIKit.h> // [macOS]
#import <objc/runtime.h>
#import <react/renderer/graphics/Color.h> // [macOS]
#import <react/renderer/graphics/RCTPlatformColorUtils.h>
#import <react/utils/ManagedObjectWrapper.h>
#import <string>
Expand Down Expand Up @@ -50,7 +49,7 @@

namespace {

bool UIColorIsP3ColorSpace(const std::shared_ptr<void> &uiColor)

Check warning on line 52 in packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm

View workflow job for this annotation

GitHub Actions / Build RNTester / macos, static

unused function 'UIColorIsP3ColorSpace' [-Wunused-function]
{
RCTPlatformColor *color = unwrapManagedObject(uiColor); // [macOS]
CGColorSpaceRef colorSpace = CGColorGetColorSpace(color.CGColor);
Expand Down Expand Up @@ -345,10 +344,11 @@
}

// [macOS
SharedColor defaultForegroundTextColor() {
static SharedColor color = [] {
Color hostPlatformDefaultForegroundTextColor()
{
static Color color = [] {
std::vector<std::string> items = {"labelColor"};
return SharedColor(Color::createSemanticColor(items));
return Color::createSemanticColor(items);
}();
return color;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@

#include <gtest/gtest.h>

// [macOS
TEST(ColorTest, testDefaultForegroundTextColorIsDefined) {
using namespace facebook::react;
auto color = defaultForegroundTextColor();

EXPECT_TRUE(color);
EXPECT_NE(color, clearColor());
}
// macOS]

TEST(ColorTest, testColorConversion) {
using namespace facebook::react;
{
Expand Down
Loading