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
8 changes: 5 additions & 3 deletions React/Base/RCTUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,20 @@ NS_INLINE CGRect CGRectValue(NSValue *value)
// fabric component types
//

// RCTUISlider

#if !TARGET_OS_OSX // [TODO(macOS GH#774)
#define RCTUISlider UISlider
#else
@interface RCTUISlider : NSSlider
@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)
19 changes: 19 additions & 0 deletions React/Base/macOS/RCTUIKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using namespace facebook::react;

@implementation RCTUnimplementedNativeComponentView {
UILabel *_label;
RCTUILabel *_label; // TODO(macOS GH#774)
}

- (instancetype)initWithFrame:(CGRect)frame
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using namespace facebook::react;

@implementation RCTUnimplementedViewComponentView {
UILabel *_label;
RCTUILabel *_label; // TODO(macOS GH#774)
}

- (instancetype)initWithFrame:(CGRect)frame
Expand All @@ -30,16 +30,26 @@ - (instancetype)initWithFrame:(CGRect)frame
static auto const defaultProps = std::make_shared<UnimplementedViewProps const>();
_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;
Expand Down