File tree Expand file tree Collapse file tree
ReactCommon/react/renderer
textlayoutmanager/platform/ios/react/renderer/textlayoutmanager Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ - (CGFloat)effectiveFontSizeMultiplier
277277
278278- (RCTPlatformColor *)effectiveForegroundColor // [macOS]
279279{
280- RCTPlatformColor *effectiveForegroundColor = _foregroundColor ?: [RCTPlatformColor blackColor ]; // [macOS]
280+ RCTPlatformColor *effectiveForegroundColor = _foregroundColor ?: [RCTTextAttributes defaultForegroundColor ]; // [macOS]
281281
282282 if (!isnan (_opacity)) {
283283 effectiveForegroundColor =
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ - (instancetype)initWithFrame:(CGRect)frame
6969 _textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc ] initWithTextView: self ];
7070
7171 self.backgroundColor = [RCTPlatformColor clearColor ]; // [macOS]
72- self.textColor = [RCTPlatformColor blackColor ]; // [macOS]
72+ self.textColor = [RCTPlatformColor labelColor ]; // [macOS]
7373 // This line actually removes 5pt (default value) left and right padding in UITextView.
7474#if !TARGET_OS_OSX // [macOS]
7575 self.textContainer .lineFragmentPadding = 0 ;
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ - (void)enforceTextAttributesIfNeeded
127127
128128 NSDictionary <NSAttributedStringKey , id > *textAttributes = [[_textAttributes effectiveTextAttributes ] mutableCopy ];
129129 if ([textAttributes valueForKey: NSForegroundColorAttributeName ] == nil ) {
130- [textAttributes setValue: [RCTPlatformColor blackColor ] forKey: NSForegroundColorAttributeName ]; // [macOS]
130+ [textAttributes setValue: [RCTPlatformColor labelColor ] forKey: NSForegroundColorAttributeName ]; // [macOS]
131131 }
132132
133133 backedTextInputView.defaultTextAttributes = textAttributes;
Original file line number Diff line number Diff line change @@ -178,7 +178,10 @@ TextAttributes TextAttributes::defaultTextAttributes() {
178178 static auto textAttributes = [] {
179179 auto textAttributes = TextAttributes{};
180180 // Non-obvious (can be different among platforms) default text attributes.
181- textAttributes.foregroundColor = blackColor ();
181+ // [macOS textAttributes.foregroundColor = blackColor();
182+ // Leave foregroundColor unset so each platform can apply a dynamic default
183+ // (e.g. labelColor) that adapts to light/dark mode.
184+ // macOS]
182185 textAttributes.backgroundColor = clearColor ();
183186 textAttributes.fontSize = 14.0 ;
184187 textAttributes.fontSizeMultiplier = 1.0 ;
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
144144
145145inline static RCTPlatformColor *RCTEffectiveForegroundColorFromTextAttributes (const TextAttributes &textAttributes) // [macOS]
146146{
147- RCTPlatformColor *effectiveForegroundColor = RCTUIColorFromSharedColor (textAttributes.foregroundColor ) ? RCTUIColorFromSharedColor (textAttributes. foregroundColor ) : [RCTPlatformColor blackColor ]; // [macOS]
147+ RCTPlatformColor *effectiveForegroundColor = RCTUIColorFromSharedColor (textAttributes.foregroundColor ) ?: [RCTPlatformColor labelColor ]; // [macOS]
148148
149149 if (!isnan (textAttributes.opacity )) {
150150 effectiveForegroundColor = [effectiveForegroundColor
@@ -182,6 +182,9 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
182182
183183 if (textAttributes.foregroundColor || !isnan (textAttributes.opacity )) {
184184 attributes[NSForegroundColorAttributeName ] = effectiveForegroundColor;
185+ } else {
186+ // [macOS] Apply dynamic default (labelColor) so text adapts to dark mode
187+ attributes[NSForegroundColorAttributeName ] = effectiveForegroundColor;
185188 }
186189
187190 if (textAttributes.backgroundColor || !isnan (textAttributes.opacity )) {
You can’t perform that action at this time.
0 commit comments