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

package com.volcengine.reactnative.vertc;

import android.content.Context;
import android.widget.FrameLayout;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.RCTEventEmitter;

public class VertcView extends FrameLayout {
  public String viewId;
  public boolean hasRegister = false;
  
  public VertcView(Context context) {
    super(context);
  }
  
  public void setViewId(String viewId) {
    this.viewId = viewId;  
    this.hasRegister = true;
    this.emitOnLoad();
    com.volcengine.VolcApiEngine.view.VolcViewManager.putViewById(viewId, this);
  }

  public void emitOnLoad() {
    WritableMap event = Arguments.createMap();
    ReactContext reactContext = (ReactContext)getContext();
    reactContext
      .getJSModule(RCTEventEmitter.class)
      .receiveEvent(getId(), "vertcLoad", event);
  }
}
