Last active
October 17, 2024 10:38
-
-
Save renganatha10/c983190f1a095a4c58754e773561f915 to your computer and use it in GitHub Desktop.
Basic Native UI component Bridging Code
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
//RCTListViewManger.h | |
#import <UIKit/UIKit.h> | |
@interface RCTNativeListView : UIView | |
@property (nonatomic) NSArray * colors; | |
@end | |
-------------------------------------------------------------------------------- | |
//RCTListViewManger.m | |
#import "RCTNativeListView.h" | |
#import "UIView+React.h" | |
@implementation RCTNativeListView | |
- (instancetype)init { | |
NSLog(@"init"); | |
self = [super init]; | |
if ( self ) { | |
[self setUp]; | |
} | |
return self; | |
} | |
- (instancetype)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
return self; | |
} | |
- (instancetype)initWithCoder:(NSCoder *)coder | |
{ | |
self = [super initWithCoder:coder]; | |
return self; | |
} | |
- (void) insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex { | |
NSLog(@"insde"); | |
[super insertReactSubview:subview atIndex:atIndex]; | |
} | |
- (void)setUp { | |
UIView * sampleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; | |
sampleView.backgroundColor = [UIColor blackColor]; | |
[self addSubview:sampleView]; | |
} | |
@end | |
-------------------------------------------------------------------------------- | |
// RCTListViewManger.h | |
#import "RCTViewManager.h" | |
#import "RCTNativeListView.h" | |
@interface RCTNativeListViewManager : RCTViewManager | |
@property (nonatomic) RCTNativeListView * nativeListView; | |
@end | |
-------------------------------------------------------------------------------- | |
// RCTListViewManger.m | |
#import "RCTNativeListViewManager.h" | |
@implementation RCTNativeListViewManager | |
RCT_EXPORT_MODULE() | |
- (instancetype)init { | |
self = [super init]; | |
if ( self ) { | |
NSLog(@"color picker manager init"); | |
self.nativeListView = [[RCTNativeListView alloc] init]; | |
} | |
return self; | |
} | |
- (UIView *)view { | |
NSLog(@"color picker manager -view method"); | |
return self.nativeListView; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Objective guildline
1)Create a ViewManager and View Class
2)Create A UIView instants (desired one) and its wrapper(again a UIView instance) Line - 45
3)override the insertReactSubviews method line - 40
NativelistView.js
output