import {
  CameraFacing,
  useImagePickerContext,
} from '../../providers/ImagePickerProvider'

interface UseImagePickerReturns {
  /**
   * Opens the camera to take a photo.
   */
  openCamera: (cameraFacing?: CameraFacing) => Promise<File>
  /**
   * Opens the gallery to select an image.
   */
  openGallery: () => Promise<File>
}

export function useImagePicker(): UseImagePickerReturns {
  const {openCamera, openGallery} = useImagePickerContext()

  return {
    openCamera,
    openGallery,
  }
}
