Skip to content

Latest commit

 

History

History
67 lines (59 loc) · 1.79 KB

File metadata and controls

67 lines (59 loc) · 1.79 KB

react-native-app-helpers/PictureHelper

Provides helpers for working with pictures.

Usage

import type { PictureHelper } from "react-native-app-helpers";

const pictureHelper = new PictureHelper(fileStore, permissionHelper, 0.7);

// Do NOT save to media library.
await permissionHelper.takePicture(
  false,
  async (showSettingsScreen) => {
    console.log(`Redirecting to settings screen for privacy settings as permissions were denied...`);
    await showSettingsScreen();
  },
  async () => {
    console.log(`The user cancelled.`);
  },
  async (uuid) => {
    console.log(`Imported into the file store as "${uuid}".`);
  },
);

// DO save to media library.
await permissionHelper.takePicture(
  true,
  async (showSettingsScreen) => {
    console.log(`Redirecting to settings screen for privacy settings as permissions were denied...`);
    await showSettingsScreen();
  },
  async () => {
    console.log(`The user cancelled.`);
  },
  async (uuid) => {
    console.log(`Imported into the file store as "${uuid}".`);
  },
);

await permissionHelper.selectOnePictureFromMediaLibrary(
  async (showSettingsScreen) => {
    console.log(`Redirecting to settings screen for privacy settings as permissions were denied...`);
    await showSettingsScreen();
  },
  async () => {
    console.log(`The user cancelled.`);
  },
  async (uuid) => {
    console.log(`Imported into the file store as "${uuid}".`);
  },
);

await permissionHelper.selectMultiplePicturesFromMediaLibrary(
  async (showSettingsScreen) => {
    console.log(`Redirecting to settings screen for privacy settings as permissions were denied...`);
    await showSettingsScreen();
  },
  async () => {
    console.log(`The user cancelled.`);
  },
  async (uuids) => {
    console.log(`Imported into the file store as "${uuids.join(`, `)}".`);
  },
);