diff --git a/React/Base/RCTUIKit.h b/React/Base/RCTUIKit.h index ce3208eb32b44e..3276f8028133d2 100644 --- a/React/Base/RCTUIKit.h +++ b/React/Base/RCTUIKit.h @@ -473,6 +473,8 @@ NS_INLINE CGRect CGRectValue(NSValue *value) // fabric component types // +// RCTUISlider + #if !TARGET_OS_OSX // [TODO(macOS GH#774) #define RCTUISlider UISlider #else @@ -480,11 +482,11 @@ NS_INLINE CGRect CGRectValue(NSValue *value) @end #endif // ]TODO(macOS GH#774) -// RCTUISwitch +// RCTUILabel #if !TARGET_OS_OSX // [TODO(macOS GH#774) -#define RCTUISwitch UISwitch +#define RCTUILabel UILabel #else -@interface RCTUISwitch : NSSwitch +@interface RCTUILabel : NSTextField @end #endif // ]TODO(macOS GH#774) diff --git a/React/Base/macOS/RCTUIKit.m b/React/Base/macOS/RCTUIKit.m index 8379ced4474ed7..ca25dd76e08d2c 100644 --- a/React/Base/macOS/RCTUIKit.m +++ b/React/Base/macOS/RCTUIKit.m @@ -590,3 +590,22 @@ - (NSRect)constrainBoundsRect:(NSRect)proposedBounds } @end + +// RCTUILabel + +@implementation RCTUILabel {} // [TODO(macOS GH#774) + +- (instancetype)initWithFrame:(NSRect)frameRect +{ + if (self = [super initWithFrame:frameRect]) { + [self setBezeled:NO]; + [self setDrawsBackground:NO]; + [self setEditable:NO]; + [self setSelectable:NO]; + [self setWantsLayer:YES]; + } + + return self; +} + +@end // ]TODO(macOS GH#774) diff --git a/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm b/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm index da2cba56c1a404..4f44b11b36b822 100644 --- a/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm @@ -14,7 +14,7 @@ using namespace facebook::react; @implementation RCTUnimplementedNativeComponentView { - UILabel *_label; + RCTUILabel *_label; // TODO(macOS GH#774) } - (instancetype)initWithFrame:(CGRect)frame @@ -24,9 +24,11 @@ - (instancetype)initWithFrame:(CGRect)frame _props = defaultProps; CGRect bounds = self.bounds; - _label = [[UILabel alloc] initWithFrame:bounds]; - _label.backgroundColor = [RCTUIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.3]; // TODO(macOS GH#774) + _label = [[RCTUILabel alloc] initWithFrame:bounds]; // TODO(macOS GH#774) + _label.backgroundColor = [RCTUIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.3]; +#if !TARGET_OS_OSX // [TODO(macOS GH#774) _label.layoutMargins = UIEdgeInsetsMake(12, 12, 12, 12); +#endif // ]TODO(macOS GH#774) _label.lineBreakMode = NSLineBreakByWordWrapping; _label.numberOfLines = 0; _label.textAlignment = NSTextAlignmentCenter; diff --git a/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm index 4d3313f4ced83a..fa88a630265508 100644 --- a/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm @@ -21,7 +21,7 @@ using namespace facebook::react; @implementation RCTUnimplementedViewComponentView { - UILabel *_label; + RCTUILabel *_label; // TODO(macOS GH#774) } - (instancetype)initWithFrame:(CGRect)frame @@ -30,16 +30,26 @@ - (instancetype)initWithFrame:(CGRect)frame static auto const defaultProps = std::make_shared(); _props = defaultProps; - _label = [[UILabel alloc] initWithFrame:self.bounds]; + _label = [[RCTUILabel alloc] initWithFrame:self.bounds]; // TODO(macOS GH#774) _label.backgroundColor = [RCTUIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.3]; // TODO(macOS GH#774) _label.lineBreakMode = NSLineBreakByCharWrapping; +#if !TARGET_OS_OSX // [TODO(macOS GH#774) _label.numberOfLines = 0; _label.textAlignment = NSTextAlignmentCenter; +#else + _label.alignment = NSTextAlignmentCenter; +#endif // ]TODO(macOS GH#774) _label.textColor = [RCTUIColor whiteColor]; // TODO(macOS GH#774) _label.allowsDefaultTighteningForTruncation = YES; +#if !TARGET_OS_OSX // [TODO(macOS GH#774) _label.adjustsFontSizeToFitWidth = YES; +#endif // ]TODO(macOS GH#774) +#if !TARGET_OS_OSX // [TODO(macOS GH#774) self.contentView = _label; +#else + [self.contentView addSubview:_label]; +#endif // ]TODO(macOS GH#774) } return self;