-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This changes adds an example to RNTester to verify that the Interop Layer can process bubbling events in Fabric as it used to do in Paper. ## Changelog: [iOS][Added] - Add example in the Interop Layer to use events Reviewed By: sammy-SC Differential Revision: D43911390 fbshipit-source-id: ae75db25078669676e5a609e090f1e9674026391
- Loading branch information
1 parent
e26092a
commit c005830
Showing
5 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
packages/rn-tester/NativeComponentExample/ios/RNTLegacyView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* 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/RCTComponent.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface RNTLegacyView : UIView | ||
|
||
@property (nonatomic, copy) RCTBubblingEventBlock onColorChanged; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
34 changes: 34 additions & 0 deletions
34
packages/rn-tester/NativeComponentExample/ios/RNTLegacyView.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* 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 "RNTLegacyView.h" | ||
|
||
@implementation RNTLegacyView | ||
|
||
- (void)setBackgroundColor:(UIColor *)backgroundColor | ||
{ | ||
super.backgroundColor = backgroundColor; | ||
[self emitEvent]; | ||
} | ||
|
||
- (void)emitEvent | ||
{ | ||
if (!self.onColorChanged) { | ||
return; | ||
} | ||
CGFloat hue = 0.0; | ||
CGFloat saturation = 0.0; | ||
CGFloat brightness = 0.0; | ||
CGFloat alpha = 0.0; | ||
[self.backgroundColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha]; | ||
self.onColorChanged(@{ | ||
@"backgroundColor" : | ||
@{@"hue" : @(hue), @"saturation" : @(saturation), @"brightness" : @(brightness), @"alpha" : @(alpha)} | ||
}); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters