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 @@ -277,7 +277,7 @@ - (CGFloat)effectiveFontSizeMultiplier

- (RCTPlatformColor *)effectiveForegroundColor // [macOS]
{
RCTPlatformColor *effectiveForegroundColor = _foregroundColor ?: [RCTPlatformColor blackColor]; // [macOS]
RCTPlatformColor *effectiveForegroundColor = _foregroundColor ?: [RCTTextAttributes defaultForegroundColor]; // [macOS]

if (!isnan(_opacity)) {
effectiveForegroundColor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ - (instancetype)initWithFrame:(CGRect)frame
_textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self];

self.backgroundColor = [RCTPlatformColor clearColor]; // [macOS]
self.textColor = [RCTPlatformColor blackColor]; // [macOS]
self.textColor = [RCTPlatformColor labelColor]; // [macOS]
// This line actually removes 5pt (default value) left and right padding in UITextView.
#if !TARGET_OS_OSX // [macOS]
self.textContainer.lineFragmentPadding = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ - (void)enforceTextAttributesIfNeeded

NSDictionary<NSAttributedStringKey, id> *textAttributes = [[_textAttributes effectiveTextAttributes] mutableCopy];
if ([textAttributes valueForKey:NSForegroundColorAttributeName] == nil) {
[textAttributes setValue:[RCTPlatformColor blackColor] forKey:NSForegroundColorAttributeName]; // [macOS]
[textAttributes setValue:[RCTPlatformColor labelColor] forKey:NSForegroundColorAttributeName]; // [macOS]
}

backedTextInputView.defaultTextAttributes = textAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ TextAttributes TextAttributes::defaultTextAttributes() {
static auto textAttributes = [] {
auto textAttributes = TextAttributes{};
// Non-obvious (can be different among platforms) default text attributes.
textAttributes.foregroundColor = blackColor();
textAttributes.foregroundColor = defaultForegroundTextColor(); // [macOS]
textAttributes.backgroundColor = clearColor();
textAttributes.fontSize = 14.0;
textAttributes.fontSizeMultiplier = 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ SharedColor colorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
SharedColor clearColor();
SharedColor blackColor();
SharedColor whiteColor();
SharedColor defaultForegroundTextColor(); // [macOS]

#ifdef RN_SERIALIZABLE_STATE
inline folly::dynamic toDynamic(const SharedColor& sharedColor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#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 @@ -342,6 +343,16 @@ int32_t ColorFromUIColor(const std::shared_ptr<void> &uiColor)
return Color(wrapManagedObject(semanticColor));
}

// [macOS
SharedColor defaultForegroundTextColor() {
static SharedColor color = [] {
std::vector<std::string> items = {"labelColor"};
return SharedColor(Color::createSemanticColor(items));
}();
return color;
}
// macOS]

} // namespace facebook::react

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex

inline static RCTPlatformColor *RCTEffectiveForegroundColorFromTextAttributes(const TextAttributes &textAttributes) // [macOS]
{
RCTPlatformColor *effectiveForegroundColor = RCTUIColorFromSharedColor(textAttributes.foregroundColor) ? RCTUIColorFromSharedColor(textAttributes.foregroundColor) : [RCTPlatformColor blackColor]; // [macOS]
RCTPlatformColor *effectiveForegroundColor = RCTUIColorFromSharedColor(textAttributes.foregroundColor) ?: [RCTPlatformColor labelColor]; // [macOS]

if (!isnan(textAttributes.opacity)) {
effectiveForegroundColor = [effectiveForegroundColor
Expand Down
Loading