//
//  VeUIView.m
//  rn
//
//  Created by ByteDance on 2024/3/27.
//

#import <Foundation/Foundation.h>
#import <React/RCTViewManager.h>
#import "VolcApiEngine/VolcViewManager.h"
#import "VeLivePullView.h"

@interface VeLivePullViewManager : RCTViewManager

@end

@implementation VeLivePullViewManager

+ (BOOL)requiresMainQueueSetup {
    return YES;
}

RCT_EXPORT_MODULE(VeLivePullView)

// 导出 events
RCT_EXPORT_VIEW_PROPERTY(onViewLoad, RCTBubblingEventBlock)

// 导出 events
RCT_CUSTOM_VIEW_PROPERTY(viewId, NSString, VeLivePullUIView)
{
  if (json == nil) {
    return;
  }
  
  NSString * viewId = [RCTConvert NSString:json];
  [view setViewId:viewId];
  [VolcViewManager registerView:viewId view:view];
  NSLog(@"[View] register view success viewId=%@", viewId);
}

RCT_CUSTOM_VIEW_PROPERTY(kind, NSString, VeLivePullUIView)
{
  if (json == nil) {
    return;
  }
  
//  NSString *viewKind = [RCTConvert NSString:json];
//  if ([viewKind isEqualToString:@"UIView"]) {
//    UIView *sub = [[UIView alloc] init];
//    [view insertSubview:sub atIndex:0];
//    NSLog(@"[View] insert view with kind=%@", viewKind);
//  }
}

- (VeLivePullUIView *)view
{
  VeLivePullUIView *view = [[VeLivePullUIView alloc] init];
  view.accessibilityLabel = @"VeLivePullUIView";
  NSLog(@"[View] create VeLivePullUIView success");
  return view;
}

@end
