// Copyright © 2022 BytePlusRTC All rights reserved.
// SPDX-License-Identifier: MIT

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

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

@interface VertcViewManager : RCTViewManager

@end

@implementation VertcViewManager

RCT_EXPORT_MODULE(VertcViewManager)

RCT_EXPORT_VIEW_PROPERTY(onViewLoad, RCTBubblingEventBlock)

RCT_CUSTOM_VIEW_PROPERTY(viewId, NSString, VertcView)
{
  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, VertcView)
{
  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);
//  }
}

- (VertcView *)view
{
  VertcView *view = [[VertcView alloc] init];
  return view;
}

@end
