Skip to content

Commit dbac66b

Browse files
committed
refactor: rename RCTUI typedefs to RCTPlatform
Rename typedef-only aliases from RCTUI* to RCTPlatform* prefix to distinguish them from RCTUI* types that are real subclasses on macOS. - RCTUIColor -> RCTPlatformColor - RCTUIPanGestureRecognizer -> RCTPlatformPanGestureRecognizer - RCTUIApplication -> RCTPlatformApplication Backward-compatible aliases are provided for all three.
1 parent 3c8af35 commit dbac66b

57 files changed

Lines changed: 300 additions & 288 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/react-native-test-library/ios/RCTSampleNativeComponentComponentView.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
using namespace facebook::react;
2020

21-
static RCTUIColor *RCTUIColorFromHexString(const std::string hexString) // [macOS]
21+
static RCTPlatformColor *RCTUIColorFromHexString(const std::string hexString) // [macOS]
2222
{
2323
unsigned rgbValue = 0;
2424
NSString *colorString = [NSString stringWithCString:hexString.c_str() encoding:[NSString defaultCStringEncoding]];
2525
NSScanner *scanner = [NSScanner scannerWithString:colorString];
2626
[scanner setScanLocation:1]; // bypass '#' character
2727
[scanner scanHexInt:&rgbValue];
28-
return [RCTUIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 // [macOS]
28+
return [RCTPlatformColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 // [macOS]
2929
green:((rgbValue & 0xFF00) >> 8) / 255.0
3030
blue:(rgbValue & 0xFF) / 255.0
3131
alpha:1.0];

packages/react-native-test-library/ios/RCTSampleNativeComponentViewManager.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212
#import <string>
1313

14-
static RCTUIColor *UIColorFromHexString(const std::string hexString) // [macOS]
14+
static RCTPlatformColor *UIColorFromHexString(const std::string hexString) // [macOS]
1515
{
1616
unsigned rgbValue = 0;
1717
NSString *colorString = [NSString stringWithCString:hexString.c_str() encoding:[NSString defaultCStringEncoding]];
1818
NSScanner *scanner = [NSScanner scannerWithString:colorString];
1919
[scanner setScanLocation:1]; // bypass '#' character
2020
[scanner scanHexInt:&rgbValue];
21-
return [RCTUIColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 // [macOS]
21+
return [RCTPlatformColor colorWithRed:((rgbValue & 0xFF0000) >> 16) / 255.0 // [macOS]
2222
green:((rgbValue & 0xFF00) >> 8) / 255.0
2323
blue:(rgbValue & 0xFF) / 255.0
2424
alpha:1.0];

packages/react-native/Libraries/NativeAnimation/Nodes/RCTInterpolationAnimatedNode.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ - (instancetype)initWithTag:(NSNumber *)tag config:(NSDictionary<NSString *, id>
103103
for (id value in outputRangeConfig) {
104104
switch (_outputType) {
105105
case RCTInterpolationOutputColor: {
106-
RCTUIColor *color = [RCTConvert UIColor:value]; // [macOS]
107-
[outputRange addObject:color ? color : [RCTUIColor whiteColor]]; // [macOS]
106+
RCTPlatformColor *color = [RCTConvert UIColor:value]; // [macOS]
107+
[outputRange addObject:color ? color : [RCTPlatformColor whiteColor]]; // [macOS]
108108
break;
109109
}
110110
case RCTInterpolationOutputString:

packages/react-native/Libraries/NativeAnimation/RCTAnimationUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RCT_EXTERN CGFloat RCTInterpolateValueInRange(
3434
NSString *extrapolateRight);
3535

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

3939
// Represents a color as a int32_t. RGB components are assumed to be in [0-255] range and alpha in [0-1] range
4040
RCT_EXTERN uint32_t RCTColorFromComponents(CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha);

packages/react-native/Libraries/NativeAnimation/RCTAnimationUtils.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CGFloat RCTInterpolateValueInRange(
8484
return RCTInterpolateValue(value, inputMin, inputMax, outputMin, outputMax, extrapolateLeft, extrapolateRight);
8585
}
8686

87-
uint32_t RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<RCTUIColor *> *outputRange) // [macOS]
87+
uint32_t RCTInterpolateColorInRange(CGFloat value, NSArray<NSNumber *> *inputRange, NSArray<RCTPlatformColor *> *outputRange) // [macOS]
8888
{
8989
NSUInteger rangeIndex = RCTFindIndexOfNearestValue(value, inputRange);
9090
CGFloat inputMin = inputRange[rangeIndex].doubleValue;

packages/react-native/Libraries/Text/RCTTextAttributes.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ extern NSString *const RCTTextAttributesTagAttributeName;
2525
@interface RCTTextAttributes : NSObject <NSCopying>
2626

2727
// Color
28-
@property (nonatomic, strong, nullable) RCTUIColor *foregroundColor; // [macOS]
29-
@property (nonatomic, strong, nullable) RCTUIColor *backgroundColor; // [macOS]
28+
@property (nonatomic, strong, nullable) RCTPlatformColor *foregroundColor; // [macOS]
29+
@property (nonatomic, strong, nullable) RCTPlatformColor *backgroundColor; // [macOS]
3030
@property (nonatomic, assign) CGFloat opacity;
3131
// Font
3232
@property (nonatomic, copy, nullable) NSString *fontFamily;
@@ -46,13 +46,13 @@ extern NSString *const RCTTextAttributesTagAttributeName;
4646
@property (nonatomic, assign) NSLineBreakStrategy lineBreakStrategy;
4747
@property (nonatomic, assign) NSLineBreakMode lineBreakMode;
4848
// Decoration
49-
@property (nonatomic, strong, nullable) RCTUIColor *textDecorationColor; // [macOS]
49+
@property (nonatomic, strong, nullable) RCTPlatformColor *textDecorationColor; // [macOS]
5050
@property (nonatomic, assign) NSUnderlineStyle textDecorationStyle;
5151
@property (nonatomic, assign) RCTTextDecorationLineType textDecorationLine;
5252
// Shadow
5353
@property (nonatomic, assign) CGSize textShadowOffset;
5454
@property (nonatomic, assign) CGFloat textShadowRadius;
55-
@property (nonatomic, strong, nullable) RCTUIColor *textShadowColor; // [macOS]
55+
@property (nonatomic, strong, nullable) RCTPlatformColor *textShadowColor; // [macOS]
5656
// Special
5757
@property (nonatomic, assign) BOOL isHighlighted;
5858
@property (nonatomic, strong, nullable) NSNumber *tag;
@@ -92,8 +92,8 @@ extern NSString *const RCTTextAttributesTagAttributeName;
9292
/**
9393
* Foreground and background colors with opacity and right defaults.
9494
*/
95-
- (RCTUIColor *)effectiveForegroundColor; // [macOS]
96-
- (RCTUIColor *)effectiveBackgroundColor; // [macOS]
95+
- (RCTPlatformColor *)effectiveForegroundColor; // [macOS]
96+
- (RCTPlatformColor *)effectiveBackgroundColor; // [macOS]
9797

9898
/**
9999
* Text transformed per 'none', 'uppercase', 'lowercase', 'capitalize'

packages/react-native/Libraries/Text/RCTTextAttributes.mm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
@implementation RCTTextAttributes
1919

2020
// [macOS
21-
+ (RCTUIColor *)defaultForegroundColor
21+
+ (RCTPlatformColor *)defaultForegroundColor
2222
{
23-
return [RCTUIColor labelColor];
23+
return [RCTPlatformColor labelColor];
2424
}
2525
// macOS]
2626

@@ -175,7 +175,7 @@ - (NSParagraphStyle *)effectiveParagraphStyle
175175
}
176176

177177
// Colors
178-
RCTUIColor *effectiveForegroundColor = self.effectiveForegroundColor; // [macOS]
178+
RCTPlatformColor *effectiveForegroundColor = self.effectiveForegroundColor; // [macOS]
179179

180180
if (_foregroundColor || !isnan(_opacity)) {
181181
attributes[NSForegroundColorAttributeName] = effectiveForegroundColor;
@@ -275,9 +275,9 @@ - (CGFloat)effectiveFontSizeMultiplier
275275
}
276276
}
277277

278-
- (RCTUIColor *)effectiveForegroundColor // [macOS]
278+
- (RCTPlatformColor *)effectiveForegroundColor // [macOS]
279279
{
280-
RCTUIColor *effectiveForegroundColor = _foregroundColor ?: [RCTUIColor blackColor]; // [macOS]
280+
RCTPlatformColor *effectiveForegroundColor = _foregroundColor ?: [RCTPlatformColor blackColor]; // [macOS]
281281

282282
if (!isnan(_opacity)) {
283283
effectiveForegroundColor =
@@ -287,16 +287,16 @@ - (RCTUIColor *)effectiveForegroundColor // [macOS]
287287
return effectiveForegroundColor;
288288
}
289289

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

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

299-
return effectiveBackgroundColor ?: [RCTUIColor clearColor]; // [macOS]
299+
return effectiveBackgroundColor ?: [RCTPlatformColor clearColor]; // [macOS]
300300
}
301301

302302
static NSString *capitalizeText(NSString *text)

packages/react-native/Libraries/Text/Text/RCTTextView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ - (void)drawRect:(CGRect)rect
271271
if (highlightPath) {
272272
if (!_highlightLayer) {
273273
_highlightLayer = [CAShapeLayer layer];
274-
_highlightLayer.fillColor = [RCTUIColor colorWithWhite:0 alpha:0.25].CGColor; // [macOS]
274+
_highlightLayer.fillColor = [RCTPlatformColor colorWithWhite:0 alpha:0.25].CGColor; // [macOS]
275275
[self.layer addSublayer:_highlightLayer];
276276
}
277277
_highlightLayer.position = _contentFrame.origin;

packages/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
2727
#if TARGET_OS_OSX // [macOS
2828
self.hideVerticalScrollIndicator = NO;
2929
_scrollView = [[RCTUIScrollView alloc] initWithFrame:self.bounds];
30-
_scrollView.backgroundColor = [RCTUIColor clearColor];
30+
_scrollView.backgroundColor = [RCTPlatformColor clearColor];
3131
_scrollView.drawsBackground = NO;
3232
_scrollView.borderType = NSNoBorder;
3333
_scrollView.hasHorizontalRuler = NO;

packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#endif // macOS]
3333
@property (nonatomic, assign, readonly) BOOL dictationRecognizing;
3434
@property (nonatomic, copy, nullable) NSString *placeholder;
35-
@property (nonatomic, strong, nullable) RCTUIColor *placeholderColor; // [macOS]
35+
@property (nonatomic, strong, nullable) RCTPlatformColor *placeholderColor; // [macOS]
3636

3737
@property (nonatomic, assign) CGFloat preferredMaxLayoutWidth;
3838

@@ -51,8 +51,8 @@
5151

5252
#if TARGET_OS_OSX // [macOS
5353
@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled;
54-
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
55-
@property (nonatomic, strong, nullable) RCTUIColor *cursorColor;
54+
@property (nonatomic, strong, nullable) RCTPlatformColor *selectionColor;
55+
@property (nonatomic, strong, nullable) RCTPlatformColor *cursorColor;
5656
@property (nonatomic, assign) UIEdgeInsets textContainerInsets;
5757
@property (nonatomic, copy) NSString *text;
5858
@property (nonatomic, assign) NSTextAlignment textAlignment;

0 commit comments

Comments
 (0)