@@ -20,7 +20,7 @@ @interface RNTMyNativeViewComponentView () <RCTRNTMyNativeViewViewProtocol>
20
20
@end
21
21
22
22
@implementation RNTMyNativeViewComponentView {
23
- UIView *_view;
23
+ RCTUIView *_view; // [macOS]
24
24
}
25
25
26
26
+ (ComponentDescriptorProvider)componentDescriptorProvider
@@ -34,34 +34,34 @@ - (instancetype)initWithFrame:(CGRect)frame
34
34
static const auto defaultProps = std::make_shared<const RNTMyNativeViewProps>();
35
35
_props = defaultProps;
36
36
37
- _view = [[UIView alloc ] init ];
38
- _view.backgroundColor = [UIColor redColor ];
37
+ _view = [[RCTUIView alloc ] init ]; // [macOS]
38
+ _view.backgroundColor = [RCTUIColor redColor ]; // [macOS]
39
39
40
40
self.contentView = _view;
41
41
}
42
42
43
43
return self;
44
44
}
45
45
46
- - (UIColor *)UIColorFromHexString : (const std::string)hexString
46
+ - (RCTUIColor *)RCTUIColorFromHexString : (const std::string)hexString // [macOS]
47
47
{
48
48
unsigned rgbValue = 0 ;
49
49
NSString *colorString = [NSString stringWithCString: hexString.c_str () encoding: [NSString defaultCStringEncoding ]];
50
50
NSScanner *scanner = [NSScanner scannerWithString: colorString];
51
51
[scanner setScanLocation: 1 ]; // bypass '#' character
52
52
[scanner scanHexInt: &rgbValue];
53
- return [UIColor colorWithRed: ((rgbValue & 0xFF0000 ) >> 16 ) / 255.0
54
- green: ((rgbValue & 0xFF00 ) >> 8 ) / 255.0
55
- blue: (rgbValue & 0xFF ) / 255.0
56
- alpha: 1.0 ];
53
+ return [RCTUIColor colorWithRed: ((rgbValue & 0xFF0000 ) >> 16 ) / 255.0 // [macOS]
54
+ green: ((rgbValue & 0xFF00 ) >> 8 ) / 255.0
55
+ blue: (rgbValue & 0xFF ) / 255.0
56
+ alpha: 1.0 ];
57
57
}
58
58
59
59
- (void )updateProps : (Props::Shared const &)props oldProps : (Props::Shared const &)oldProps
60
60
{
61
61
[super updateProps: props oldProps: oldProps];
62
62
}
63
63
64
- - (void )onChange : (UIView *)sender
64
+ - (void )onChange : (RCTUIView *)sender // [macOS]
65
65
{
66
66
// No-op
67
67
// std::dynamic_pointer_cast<const ViewEventEmitter>(_eventEmitter)
@@ -77,7 +77,7 @@ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
77
77
78
78
- (void )callNativeMethodToChangeBackgroundColor : (NSString *)colorString
79
79
{
80
- UIColor *color = [self UIColorFromHexString :std: :string ([colorString UTF8String ])];
80
+ RCTUIColor *color = [self RCTUIColorFromHexString :std: :string ([colorString UTF8String ])]; // [macOS]
81
81
_view.backgroundColor = color;
82
82
}
83
83
@end
0 commit comments