mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7de3111f9b
Summary: This change adds automated tests for the New Architecture Examples page in RNTester. It also updates the NativeComponentExample to make sure that iOS and Android behaves in the same way and in a reliable way. ## Changelog: [Internal] - Adds Pull Request resolved: https://github.com/facebook/react-native/pull/46541 Test Plan: * Android: https://github.com/user-attachments/assets/65ead328-9c4f-4e0f-8b9b-992ffb584566 * iOS: https://github.com/user-attachments/assets/412a4f68-c9c9-4ff2-a3e9-ae7194deef77 Reviewed By: cortinico Differential Revision: D62879289 Pulled By: cipolleschi fbshipit-source-id: 59e15f48f5995b18fd8b3ee24aca726b93e04d9f
89 lines
2.5 KiB
Plaintext
89 lines
2.5 KiB
Plaintext
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <React/RCTLog.h>
|
|
#import <React/RCTUIManager.h>
|
|
#import <React/RCTViewManager.h>
|
|
#import "RNTLegacyView.h"
|
|
#import "RNTMyNativeViewComponentView.h"
|
|
#import "UIView+ColorOverlays.h"
|
|
|
|
@interface RNTMyLegacyNativeViewManager : RCTViewManager
|
|
|
|
@end
|
|
|
|
@implementation RNTMyLegacyNativeViewManager
|
|
|
|
+ (BOOL)requiresMainQueueSetup
|
|
{
|
|
return NO;
|
|
}
|
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(color, backgroundColor, UIColor)
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(opacity, alpha, CGFloat)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onColorChanged, RCTBubblingEventBlock)
|
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(cornerRadius, CGFloat, RNTLegacyView)
|
|
{
|
|
view.clipsToBounds = true;
|
|
NSNumber *cornerRadius = (NSNumber *)json;
|
|
view.layer.cornerRadius = [cornerRadius floatValue];
|
|
}
|
|
|
|
RCT_EXPORT_METHOD(changeBackgroundColor : (nonnull NSNumber *)reactTag color : (NSString *)color)
|
|
{
|
|
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
if (UIView *view = [RNTMyLegacyNativeViewManager getViewByTag:viewRegistry reactTag:reactTag]) {
|
|
[view setBackgroundColorWithColorString:color];
|
|
}
|
|
}];
|
|
}
|
|
|
|
RCT_EXPORT_METHOD(addOverlays : (nonnull NSNumber *)reactTag overlayColors : (NSArray *)overlayColors)
|
|
{
|
|
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
if (UIView *view = [RNTMyLegacyNativeViewManager getViewByTag:viewRegistry reactTag:reactTag]) {
|
|
[view addColorOverlays:overlayColors];
|
|
}
|
|
}];
|
|
}
|
|
|
|
RCT_EXPORT_METHOD(removeOverlays : (nonnull NSNumber *)reactTag)
|
|
{
|
|
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
if (UIView *view = [RNTMyLegacyNativeViewManager getViewByTag:viewRegistry reactTag:reactTag]) {
|
|
[view removeOverlays];
|
|
}
|
|
}];
|
|
}
|
|
|
|
+ (UIView *)getViewByTag:(NSDictionary<NSNumber *, UIView *> *)viewRegistry reactTag:(nonnull NSNumber *)reactTag
|
|
{
|
|
UIView *view = viewRegistry[reactTag];
|
|
if (!view || ![view isKindOfClass:[RNTLegacyView class]]) {
|
|
RCTLogError(@"Cannot find RNTLegacyView with tag #%@", reactTag);
|
|
return NULL;
|
|
}
|
|
return view;
|
|
}
|
|
|
|
- (UIView *)view
|
|
{
|
|
RNTLegacyView *view = [[RNTLegacyView alloc] init];
|
|
return view;
|
|
}
|
|
|
|
- (NSDictionary *)constantsToExport
|
|
{
|
|
return @{@"PI" : @3.14};
|
|
}
|
|
@end
|