Skip to content

Commit 731a535

Browse files
authored
[Text] Fix color defaults for light/dark mode (facebook#538)
1 parent 2d79813 commit 731a535

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Libraries/Text/RCTTextAttributes.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ - (instancetype)init
3131
_textShadowRadius = NAN;
3232
_opacity = NAN;
3333
_textTransform = RCTTextTransformUndefined;
34+
#if TARGET_OS_OSX // TODO(macOS ISS#2323203)
35+
_foregroundColor = [NSColor labelColor];
36+
#endif // TODO(macOS ISS#2323203)
3437
}
3538

3639
return self;

Libraries/Text/TextInput/Multiline/RCTUITextView.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ @implementation RCTUITextView
3030

3131
static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
3232
{
33-
// Default placeholder color from UITextField.
34-
return [RCTUIColor colorWithRed:0 green:0 blue:0.0980392 alpha:0.22]; // TODO(OSS Candidate ISS#2710739)
33+
return [RCTUIColor placeholderTextColor]; // TODO(OSS Candidate ISS#2710739)
3534
}
3635

3736
- (instancetype)initWithFrame:(CGRect)frame
@@ -227,7 +226,7 @@ - (void)setAttributedText:(NSAttributedString *)attributedText
227226
[self.textStorage setAttributedString:[NSAttributedString new]];
228227
}
229228
} else {
230-
// But if the text is preserved, we just copying the attributes from the source string.
229+
// But if the text is preserved, we just copy the attributes from the source string.
231230
if (![self.textStorage isEqualToAttributedString:attributedText]) {
232231
[self copyTextAttributesFrom:attributedText];
233232
}

Libraries/Text/TextInput/Singleline/RCTUITextField.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,11 @@ - (void)setSecureTextEntry:(BOOL)secureTextEntry
320320
if (self.placeholderColor) {
321321
[textAttributes setValue:self.placeholderColor forKey:NSForegroundColorAttributeName];
322322
} else {
323+
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
324+
[textAttributes setValue:defaultPlaceholderTextColor() forKey:NSForegroundColorAttributeName];
325+
#else
323326
[textAttributes removeObjectForKey:NSForegroundColorAttributeName];
327+
#endif // ]TODO(macOS ISS#2323203)
324328
}
325329

326330
return textAttributes;

0 commit comments

Comments
 (0)