Skip to content

Commit

Permalink
fix: ios viewRegistered
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijeetverma committed Jun 7, 2024
1 parent a92d19b commit 280dc18
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions ios/HyperSdkReact.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ - (id)initWithBridge:(RCTBridge *)bridge {
self.heightHolder = [[NSMutableDictionary alloc] init];
// Hold reference to latest constraints so that they can be replaced if height is modified
self.heightConstraintHolder = [[NSMutableDictionary alloc] init];
// Hold reference to registered components
self.registeredComponents = [[NSMutableSet alloc] init];
// Hold reference to bridge so that RCTRootViews can share JS VM
self.bridge = bridge;
return self;
Expand Down Expand Up @@ -98,13 +100,13 @@ - (UIView * _Nullable)merchantViewForViewType:(NSString * _Nonnull)viewType {
// Create a SDKRootView so that we can attach width constraints once it is attached to it's parent
RCTRootView *rrv = [SDKRootView alloc];
NSString *moduleName = @"JP_003";
if ([viewType isEqual:@"HEADER"]) {
if ([viewType isEqual:@"HEADER"] && isViewRegistered(@"JuspayHeader")) {
moduleName = @"JuspayHeader";
} else if ([viewType isEqual:@"HEADER_ATTACHED"]) {
} else if ([viewType isEqual:@"HEADER_ATTACHED"] && isViewRegistered(@"JuspayHeaderAttached")) {
moduleName = @"JuspayHeaderAttached";
} else if ([viewType isEqual:@"FOOTER"]) {
} else if ([viewType isEqual:@"FOOTER"] && isViewRegistered(@"JuspayFooter")) {
moduleName = @"JuspayFooter";
} else if ([viewType isEqual:@"FOOTER_ATTACHED"]) {
} else if ([viewType isEqual:@"FOOTER_ATTACHED"] && isViewRegistered(@"JuspayFooterAttached")) {
moduleName = @"JuspayFooterAttached";
}

Expand Down Expand Up @@ -135,6 +137,13 @@ - (UIView * _Nullable)merchantViewForViewType:(NSString * _Nonnull)viewType {
return rrv;
}

- (BOOL)isViewRegistered:(NSString * _Nonnull) viewType {
if ([self.registeredComponents containsObject:viewType]){
return YES
}
return NO
}

- (void) onWebViewReady:(WKWebView *)webView {
//Ignored
}
Expand Down Expand Up @@ -272,6 +281,10 @@ -(void)stopObserving {
}
}

RCT_EXPORT_METHOD(notifyAboutRegisterComponent:(NSString *)viewType) {
[self.registeredComponents addObject:viewType];
}

RCT_EXPORT_METHOD(isInitialised:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
if (self.hyperInstance) {
resolve(self.hyperInstance.isInitialised? @true : @false);
Expand Down

0 comments on commit 280dc18

Please sign in to comment.