Skip to content
Merged
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 @@ -18,14 +18,14 @@

using namespace facebook::react;

static RCTUIColor *RCTUIColorFromHexString(const std::string hexString) // [macOS]
static RCTPlatformColor *RCTUIColorFromHexString(const std::string hexString) // [macOS]
{
unsigned rgbValue = 0;
NSString *colorString = [NSString stringWithCString:hexString.c_str() encoding:[NSString defaultCStringEncoding]];
NSScanner *scanner = [NSScanner scannerWithString:colorString];
[scanner setScanLocation:1]; // bypass '#' character
[scanner scanHexInt:&rgbValue];
return [RCTUIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 // [macOS]
return [RCTPlatformColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 // [macOS]
green:((rgbValue & 0xFF00) >> 8) / 255.0
blue:(rgbValue & 0xFF) / 255.0
alpha:1.0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

#import <string>

static RCTUIColor *UIColorFromHexString(const std::string hexString) // [macOS]
static RCTPlatformColor *UIColorFromHexString(const std::string hexString) // [macOS]
{
unsigned rgbValue = 0;
NSString *colorString = [NSString stringWithCString:hexString.c_str() encoding:[NSString defaultCStringEncoding]];
NSScanner *scanner = [NSScanner scannerWithString:colorString];
[scanner setScanLocation:1]; // bypass '#' character
[scanner scanHexInt:&rgbValue];
return [RCTUIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 // [macOS]
return [RCTPlatformColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 // [macOS]
green:((rgbValue & 0xFF00) >> 8) / 255.0
blue:(rgbValue & 0xFF) / 255.0
alpha:1.0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ - (instancetype)initWithTag:(NSNumber *)tag config:(NSDictionary<NSString *, id>
for (id value in outputRangeConfig) {
switch (_outputType) {
case RCTInterpolationOutputColor: {
RCTUIColor *color = [RCTConvert UIColor:value]; // [macOS]
[outputRange addObject:color ? color : [RCTUIColor whiteColor]]; // [macOS]
RCTPlatformColor *color = [RCTConvert UIColor:value]; // [macOS]
[outputRange addObject:color ? color : [RCTPlatformColor whiteColor]]; // [macOS]
break;
}
case RCTInterpolationOutputString:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RCT_EXTERN CGFloat RCTInterpolateValueInRange(
NSString *extrapolateRight);

RCT_EXTERN uint32_t
RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<RCTUIColor *> *outputRange); // [macOS]
RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<RCTPlatformColor *> *outputRange); // [macOS]

// Represents a color as a int32_t. RGB components are assumed to be in [0-255] range and alpha in [0-1] range
RCT_EXTERN uint32_t RCTColorFromComponents(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ CGFloat RCTInterpolateValueInRange(
return RCTInterpolateValue(value, inputMin, inputMax, outputMin, outputMax, extrapolateLeft, extrapolateRight);
}

uint32_t RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<RCTUIColor *> *outputRange) // [macOS]
uint32_t RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<RCTPlatformColor *> *outputRange) // [macOS]
{
NSUInteger rangeIndex = RCTFindIndexOfNearestValue(value, inputRange);
CGFloat inputMin = inputRange[rangeIndex].doubleValue;
Expand Down
12 changes: 6 additions & 6 deletions packages/react-native/Libraries/Text/RCTTextAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ extern NSString *const RCTTextAttributesTagAttributeName;
@interface RCTTextAttributes : NSObject <NSCopying>

// Color
@property (nonatomic, strong, nullable) RCTUIColor *foregroundColor; // [macOS]
@property (nonatomic, strong, nullable) RCTUIColor *backgroundColor; // [macOS]
@property (nonatomic, strong, nullable) RCTPlatformColor *foregroundColor; // [macOS]
@property (nonatomic, strong, nullable) RCTPlatformColor *backgroundColor; // [macOS]
@property (nonatomic, assign) CGFloat opacity;
// Font
@property (nonatomic, copy, nullable) NSString *fontFamily;
Expand All @@ -46,13 +46,13 @@ extern NSString *const RCTTextAttributesTagAttributeName;
@property (nonatomic, assign) NSLineBreakStrategy lineBreakStrategy;
@property (nonatomic, assign) NSLineBreakMode lineBreakMode;
// Decoration
@property (nonatomic, strong, nullable) RCTUIColor *textDecorationColor; // [macOS]
@property (nonatomic, strong, nullable) RCTPlatformColor *textDecorationColor; // [macOS]
@property (nonatomic, assign) NSUnderlineStyle textDecorationStyle;
@property (nonatomic, assign) RCTTextDecorationLineType textDecorationLine;
// Shadow
@property (nonatomic, assign) CGSize textShadowOffset;
@property (nonatomic, assign) CGFloat textShadowRadius;
@property (nonatomic, strong, nullable) RCTUIColor *textShadowColor; // [macOS]
@property (nonatomic, strong, nullable) RCTPlatformColor *textShadowColor; // [macOS]
// Special
@property (nonatomic, assign) BOOL isHighlighted;
@property (nonatomic, strong, nullable) NSNumber *tag;
Expand Down Expand Up @@ -92,8 +92,8 @@ extern NSString *const RCTTextAttributesTagAttributeName;
/**
* Foreground and background colors with opacity and right defaults.
*/
- (RCTUIColor *)effectiveForegroundColor; // [macOS]
- (RCTUIColor *)effectiveBackgroundColor; // [macOS]
- (RCTPlatformColor *)effectiveForegroundColor; // [macOS]
- (RCTPlatformColor *)effectiveBackgroundColor; // [macOS]

/**
* Text transformed per 'none', 'uppercase', 'lowercase', 'capitalize'
Expand Down
16 changes: 8 additions & 8 deletions packages/react-native/Libraries/Text/RCTTextAttributes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
@implementation RCTTextAttributes

// [macOS
+ (RCTUIColor *)defaultForegroundColor
+ (RCTPlatformColor *)defaultForegroundColor
{
return [RCTUIColor labelColor];
return [RCTPlatformColor labelColor];
}
// macOS]

Expand Down Expand Up @@ -175,7 +175,7 @@ - (NSParagraphStyle *)effectiveParagraphStyle
}

// Colors
RCTUIColor *effectiveForegroundColor = self.effectiveForegroundColor; // [macOS]
RCTPlatformColor *effectiveForegroundColor = self.effectiveForegroundColor; // [macOS]

if (_foregroundColor || !isnan(_opacity)) {
attributes[NSForegroundColorAttributeName] = effectiveForegroundColor;
Expand Down Expand Up @@ -275,9 +275,9 @@ - (CGFloat)effectiveFontSizeMultiplier
}
}

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

if (!isnan(_opacity)) {
effectiveForegroundColor =
Expand All @@ -287,16 +287,16 @@ - (RCTUIColor *)effectiveForegroundColor // [macOS]
return effectiveForegroundColor;
}

- (RCTUIColor *)effectiveBackgroundColor // [macOS]
- (RCTPlatformColor *)effectiveBackgroundColor // [macOS]
{
RCTUIColor *effectiveBackgroundColor = _backgroundColor; // ?: [[UIColor whiteColor] colorWithAlphaComponent:0]; // [macOS]
RCTPlatformColor *effectiveBackgroundColor = _backgroundColor; // ?: [[UIColor whiteColor] colorWithAlphaComponent:0]; // [macOS]

if (effectiveBackgroundColor && !isnan(_opacity)) {
effectiveBackgroundColor =
[effectiveBackgroundColor colorWithAlphaComponent:CGColorGetAlpha(effectiveBackgroundColor.CGColor) * _opacity];
}

return effectiveBackgroundColor ?: [RCTUIColor clearColor]; // [macOS]
return effectiveBackgroundColor ?: [RCTPlatformColor clearColor]; // [macOS]
}

static NSString *capitalizeText(NSString *text)
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Text/Text/RCTTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ - (void)drawRect:(CGRect)rect
if (highlightPath) {
if (!_highlightLayer) {
_highlightLayer = [CAShapeLayer layer];
_highlightLayer.fillColor = [RCTUIColor colorWithWhite:0 alpha:0.25].CGColor; // [macOS]
_highlightLayer.fillColor = [RCTPlatformColor colorWithWhite:0 alpha:0.25].CGColor; // [macOS]
[self.layer addSublayer:_highlightLayer];
}
_highlightLayer.position = _contentFrame.origin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
#if TARGET_OS_OSX // [macOS
self.hideVerticalScrollIndicator = NO;
_scrollView = [[RCTUIScrollView alloc] initWithFrame:self.bounds];
_scrollView.backgroundColor = [RCTUIColor clearColor];
_scrollView.backgroundColor = [RCTPlatformColor clearColor];
_scrollView.drawsBackground = NO;
_scrollView.borderType = NSNoBorder;
_scrollView.hasHorizontalRuler = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#endif // macOS]
@property (nonatomic, assign, readonly) BOOL dictationRecognizing;
@property (nonatomic, copy, nullable) NSString *placeholder;
@property (nonatomic, strong, nullable) RCTUIColor *placeholderColor; // [macOS]
@property (nonatomic, strong, nullable) RCTPlatformColor *placeholderColor; // [macOS]

@property (nonatomic, assign) CGFloat preferredMaxLayoutWidth;

Expand All @@ -51,8 +51,8 @@

#if TARGET_OS_OSX // [macOS
@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled;
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
@property (nonatomic, strong, nullable) RCTUIColor *cursorColor;
@property (nonatomic, strong, nullable) RCTPlatformColor *selectionColor;
@property (nonatomic, strong, nullable) RCTPlatformColor *cursorColor;
@property (nonatomic, assign) UIEdgeInsets textContainerInsets;
@property (nonatomic, copy) NSString *text;
@property (nonatomic, assign) NSTextAlignment textAlignment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ @implementation RCTUITextView {
}
#endif // macOS]

static RCTUIColor *defaultPlaceholderColor(void) // [macOS]
static RCTPlatformColor *defaultPlaceholderColor(void) // [macOS]
{
// Default placeholder color from UITextField.
return [RCTUIColor placeholderTextColor]; // [macOS]
return [RCTPlatformColor placeholderTextColor]; // [macOS]
}

- (instancetype)initWithFrame:(CGRect)frame
Expand All @@ -68,8 +68,8 @@ - (instancetype)initWithFrame:(CGRect)frame

_textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self];

self.backgroundColor = [RCTUIColor clearColor]; // [macOS]
self.textColor = [RCTUIColor blackColor]; // [macOS]
self.backgroundColor = [RCTPlatformColor clearColor]; // [macOS]
self.textColor = [RCTPlatformColor blackColor]; // [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 Expand Up @@ -149,7 +149,7 @@ - (void)setPlaceholder:(NSString *)placeholder
[self _updatePlaceholder];
}

- (void)setPlaceholderColor:(RCTUIColor *)placeholderColor // [macOS]
- (void)setPlaceholderColor:(RCTPlatformColor *)placeholderColor // [macOS]
{
_placeholderColor = placeholderColor;
[self _updatePlaceholder];
Expand All @@ -174,16 +174,16 @@ - (void)toggleGrammarChecking:(id)sender
[_textInputDelegate grammarCheckingDidChange:self.isGrammarCheckingEnabled];
}

- (void)setSelectionColor:(RCTUIColor *)selectionColor
- (void)setSelectionColor:(RCTPlatformColor *)selectionColor
{
NSMutableDictionary *selectTextAttributes = self.selectedTextAttributes.mutableCopy;
selectTextAttributes[NSBackgroundColorAttributeName] = selectionColor ?: [NSColor selectedControlColor];
self.selectedTextAttributes = selectTextAttributes.copy;
}

- (RCTUIColor*)selectionColor
- (RCTPlatformColor*)selectionColor
{
return (RCTUIColor*)self.selectedTextAttributes[NSBackgroundColorAttributeName];
return (RCTPlatformColor*)self.selectedTextAttributes[NSBackgroundColorAttributeName];
}

- (void)setCursorColor:(NSColor *)cursorColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ - (instancetype)initWithFrame:(CGRect)frame
self.hideVerticalScrollIndicator = NO;

_scrollView = [[RCTUIScrollView alloc] initWithFrame:self.bounds];
_scrollView.backgroundColor = [RCTUIColor clearColor];
_scrollView.backgroundColor = [RCTPlatformColor clearColor];
_scrollView.drawsBackground = NO;
_scrollView.borderType = NSNoBorder;
_scrollView.hasHorizontalRuler = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, copy, nullable) NSAttributedString *attributedText;
@property (nonatomic, copy, nullable) NSString *placeholder;
@property (nonatomic, strong, nullable) RCTUIColor *placeholderColor; // [macOS]
@property (nonatomic, strong, nullable) RCTPlatformColor *placeholderColor; // [macOS]
#if !TARGET_OS_OSX // [macOS]
@property (nonatomic, assign, readonly) BOOL textWasPasted;
#else // [macOS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) BOOL clearTextOnSubmit;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onSubmitEditing;
@property (nonatomic, copy) NSArray<NSDictionary *> *submitKeyEvents;
@property (nonatomic, strong, nullable) RCTUIColor *cursorColor;
@property (nonatomic, strong, nullable) RCTPlatformColor *cursorColor;
#endif // macOS]
@property (nonatomic, assign) NSInteger mostRecentEventCount;
@property (nonatomic, assign, readonly) NSInteger nativeEventCount;
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:[RCTUIColor blackColor] forKey:NSForegroundColorAttributeName]; // [macOS]
[textAttributes setValue:[RCTPlatformColor blackColor] forKey:NSForegroundColorAttributeName]; // [macOS]
}

backedTextInputView.defaultTextAttributes = textAttributes;
Expand Down Expand Up @@ -1071,7 +1071,7 @@ - (void)handleInputAccessoryDoneButton
NSMutableDictionary<NSAttributedStringKey, id> *textAttributes =
[backedTextInputView.defaultTextAttributes mutableCopy] ?: [NSMutableDictionary new];

[textAttributes setValue:backedTextInputView.placeholderColor ?: [RCTUIColor placeholderTextColor]
[textAttributes setValue:backedTextInputView.placeholderColor ?: [RCTPlatformColor placeholderTextColor]
forKey:NSForegroundColorAttributeName];

return textAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) BOOL textWasPasted;
#endif // macOS]
@property (nonatomic, assign, readonly) BOOL dictationRecognizing;
@property (nonatomic, strong, nullable) RCTUIColor *placeholderColor; // [macOS]
@property (nonatomic, strong, nullable) RCTPlatformColor *placeholderColor; // [macOS]
@property (nonatomic, assign) UIEdgeInsets textContainerInset;
#if !TARGET_OS_OSX // [macOS]
@property (nonatomic, assign, getter=isEditable) BOOL editable;
Expand All @@ -66,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled;
@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled;
@property (nonatomic, assign) BOOL enableFocusRing;
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
@property (nonatomic, strong, nullable) RCTPlatformColor *selectionColor;
@property (weak, nullable) id<RCTUITextFieldDelegate> delegate;
@property (nonatomic, assign) CGFloat pointScaleFactor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ @interface RCTUITextFieldCell : NSTextFieldCell
@property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled;
@property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled;
@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled;
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
@property (nonatomic, strong, nullable) RCTUIColor *insertionPointColor;
@property (nonatomic, strong, nullable) RCTPlatformColor *selectionColor;
@property (nonatomic, strong, nullable) RCTPlatformColor *insertionPointColor;

@end

Expand Down Expand Up @@ -298,12 +298,12 @@ - (BOOL)isGrammarCheckingEnabled
return ((RCTUITextFieldCell*)self.cell).isGrammarCheckingEnabled;
}

- (void)setSelectionColor:(RCTUIColor *)selectionColor
- (void)setSelectionColor:(RCTPlatformColor *)selectionColor
{
((RCTUITextFieldCell*)self.cell).selectionColor = selectionColor;
}

- (RCTUIColor*)selectionColor
- (RCTPlatformColor*)selectionColor
{
return ((RCTUITextFieldCell*)self.cell).selectionColor;
}
Expand All @@ -313,7 +313,7 @@ - (void)setCursorColor:(NSColor *)cursorColor
((RCTUITextFieldCell*)self.cell).insertionPointColor = cursorColor;
}

- (RCTUIColor*)cursorColor
- (RCTPlatformColor*)cursorColor
{
return ((RCTUITextFieldCell*)self.cell).insertionPointColor;
}
Expand Down Expand Up @@ -361,7 +361,7 @@ - (NSString*)placeholder // [macOS
#endif
} // macOS]

- (void)setPlaceholderColor:(RCTUIColor *)placeholderColor // [macOS]
- (void)setPlaceholderColor:(RCTPlatformColor *)placeholderColor // [macOS]
{
_placeholderColor = placeholderColor;
[self _updatePlaceholder];
Expand Down Expand Up @@ -467,7 +467,7 @@ - (void)setDisableKeyboardShortcuts:(BOOL)disableKeyboardShortcuts
NSMutableDictionary<NSAttributedStringKey, id> *textAttributes =
[_defaultTextAttributes mutableCopy] ?: [NSMutableDictionary new];

[textAttributes setValue:self.placeholderColor ?: [RCTUIColor placeholderTextColor]
[textAttributes setValue:self.placeholderColor ?: [RCTPlatformColor placeholderTextColor]
forKey:NSForegroundColorAttributeName]; // [macOS]

return textAttributes;
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native/React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Pod::Spec.new do |s|
"React/Tests/**/*",
"React/Inspector/**/*",
"React/Runtime/**/*",
"React/RCTUIKit/**/*", # [macOS]
]

# The default is use hermes, we don't have jsc installed
Expand Down Expand Up @@ -114,6 +115,7 @@ Pod::Spec.new do |s|
end
end

s.dependency "React-RCTUIKit" # [macOS]
s.dependency "React-cxxreact"
s.dependency "React-perflogger"
s.dependency "React-jsi"
Expand Down
Loading
Loading