Verwendung

Capture a profile photo with the system camera UI.

Dieser Typ wird verwendet von mediaPicker.capture

tsx
// Capture a profile photo with the system camera UI.
import { Button, Image, VStack, mediaPicker, signal } from 'kuito';

export function ProfilePhoto() {
  const uri = signal<string | null>(null);
  async function capture() {
    try {
      const result = await mediaPicker.capture({ mediaTypes: ['images'] });
      if (!result.canceled) uri.value = result.assets[0]?.uri ?? null;
    } catch (error) {
      console.error('Camera unavailable', error);
    }
  }
  return (
    <VStack>
      <Button onPress={() => void capture()}>Take profile photo</Button>
      {uri.value ? <Image src={uri.value} width={96} height={96} /> : null}
    </VStack>
  );
}

Typdeklaration

ts
export type CaptureOptions = {
  /** What the picker offers: `'images'` (the default), `'videos'`, or both. */
  mediaTypes?: MediaType | MediaType[];
  /** JPEG quality of written images, 0 to 1. 1, the default, keeps the most detail. */
  quality?: number;
  /** Images wider than this are scaled down to fit, keeping their aspect ratio. In pixels. */
  maxWidth?: number;
  /** Images taller than this are scaled down to fit, keeping their aspect ratio. In pixels. */
  maxHeight?: number;
  /** iOS: crop the image, or trim the video, in the system editor before it resolves. */
  allowsEditing?: boolean;
};

Mitglieder 5

NameTypErforderlichBeschreibung
mediaTypesPickerMediaType | PickerMediaType[]NeinWhat the picker offers: 'images' (the default), 'videos', or both.
qualitynumberNeinJPEG quality of written images, 0 to 1. 1, the default, keeps the most detail.
maxWidthnumberNeinImages wider than this are scaled down to fit, keeping their aspect ratio. In pixels.
maxHeightnumberNeinImages taller than this are scaled down to fit, keeping their aspect ratio. In pixels.
allowsEditingbooleanNeiniOS: crop the image, or trim the video, in the system editor before it resolves.
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.