import React from 'react';
import { requireNativeComponent, ViewProps } from 'react-native';
import type { VideoAspect, VideoResolution } from './native/ZoomVideoSdk';

/**
 * Define parameters that needed by native Zoom video view.
 */
type ZoomViewProps = {
  userId: string | null;
  sharing?: boolean;
  preview?: boolean;
  fullScreen?: boolean;
  videoAspect?: VideoAspect;
  videoResolution?: VideoResolution;
  hasMultiCamera?: boolean;
  multiCameraIndex?: string | null;
  isPiPView?: boolean;
} & ViewProps;

const NativeZoomView = requireNativeComponent<ZoomViewProps>('RNZoomView');

/**
 * Getting video view from native layer.
 */
export const ZoomView = (props: ZoomViewProps) => {
  if (!props.preview && !props.userId) return null;

  return <NativeZoomView {...props} />;
};
