Provides links&functions based on capacitor-camera
.
The Camera
link serves as a container for link structures representing records inside deep.
You need only one container link per deep instance.
import Camera, { createContainer } from "@deep-foundation/capacitor-camera";
const CameraPermissions = await getCameraPermissions();
Camera
to store Camera data:const containerLinkId = await createContainer(deep)
You can also create it manually inside your deepcase client. Open Insert menu, search for and then insert "Camera" type link.
Capture a new photo.
const photo = await Camera.takePhoto(options?);
Upload the array of captured photos to deep database.
await Camera.uploadPhotos({ deep, containerLinkId, photos });
// To upload one photo pass it inside an array. [photo]
Pick a new photo.
const galleryPhotos = await Camera.pickGalleryPhotos(options?);
Upload the array of picked photos to deep database.
await Camera.uploadGallery({ deep, containerLinkId, galleryPhotos });
Download all existing images made by this camera package as an array.
const images = await downloadImages(deep);
import { WithCapacitorCamera, CapacitorCamera, useCamera, useGallery, usePermissions, useContainer } from "@deep-foundation/capacitor-camera";
function Page() {
return <CapacitorCamera deep={useDeep()} />
}
You will see basic ui with all package functionality.
Alternatively you can use WithCapacitorCamera Component like that:
<WithCapacitorCamera deep={yourDeepInstance} containerLinkId={yourContainerLinkId}>
<CapacitorCamera />
</WithCapacitorCamera>
useCamera() hook for taking a new photo with the camera. Automatically uploads new photos into your deep instance.
const { photos, newPhoto } = useCamera({ deep, containerLinkId });
useGallery() hook for picking photos from gallery. Automatically uploads picked photos into your deep instance.
const { galleryPhotos, pickPhotosFromGallery } = useGallery({ deep, containerLinkId });
useContainer() hook to get existing or create a new container link ID.
const containerLinkId = useContainer(deep);
usePermissions() hook to manage camera and gallery permissions on mobile devices.
const { cameraPermissions, getPermissions } = usePermissions();
Feel free to contribute. Please fork the repository and submit a pull request for any bugs, improvements, or features.