Usage

Pause and resume a camera preview.

tsx
// Pause and resume a camera preview.
import { Button, Camera, ref, type CameraHandle } from 'kuito';

function Scanner() {
  // A plain ref holds the handle; cameraRef() adds ready and error signals.
  const camera = ref<CameraHandle>();

  return (
    <>
      <Camera ref={camera} flex={1} />
      <Button onPress={() => void camera.current?.pausePreview()}>Pause</Button>
      <Button onPress={() => void camera.current?.resumePreview()}>Resume</Button>
    </>
  );
}

Type declaration

ts
export type CameraHandle = NativeViewHandle<CameraMethods>;

Members 14

NameTypeRequiredDescription
idreadonlystringYes—
parentreadonlyElementHandleYes—
childrenreadonlyElementHandle[]Yes—
focus() => voidYes—
blur() => voidYes—
setProperty<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => voidYesSets a native prop on the view now, until its binding writes it again.
addEventListener(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;}) => voidYes—
removeEventListener(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => voidYes—
dispatchEvent(event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => booleanYesSends an event through the tree, capture to bubble, as a native one travels: a KuitoCustomEvent, or any object with a type. False when a listener called preventDefault() on a cancelable event.
takePicture(options?: PictureOptions) => Promise<CameraPicture>YesTakes a picture with the current flash; the view must be ready.
startRecording(options?: RecordingOptions) => Promise<CameraRecording>YesStarts recording, in video mode. Resolves with the video once the recording ends: stopRecording, maxDuration, the app leaving the foreground, or the view unmounting.
stopRecording() => Promise<CameraRecording>YesEnds the recording, and resolves with the same video startRecording does.
pausePreview() => Promise<void>YesFreezes the preview and stops the camera, keeping the view.
resumePreview() => Promise<void>Yes—
focus — method signatures

Signatures

ts
(): void

Parameters

No parameters.

Returns

void

blur — method signatures

Signatures

ts
(): void

Parameters

No parameters.

Returns

void

setProperty — method signatures

Signatures

ts
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): void

Type parameters

NameConstraintDefault
Kkeyof ElementProperties—

Parameters

NameTypeRequiredDescription
keyKYes—
valueElementProperties[K]Yes—

Returns

void

addEventListener — method signatures

Signatures

ts
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): void

Parameters

NameTypeRequiredDescription
typestringYes—
fn(e: KuitoNativeEvent) => voidYes—
optionsboolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;}No—

Returns

void

removeEventListener — method signatures

Signatures

ts
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): void

Parameters

NameTypeRequiredDescription
typestringYes—
fn(e: KuitoNativeEvent) => voidYes—
optionsboolean | { capture?: boolean;}No—

Returns

void

dispatchEvent — method signatures

Signatures

ts
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): boolean

Parameters

NameTypeRequiredDescription
event{ type: string; bubbles?: boolean; cancelable?: boolean;}Yes—

Returns

boolean

takePicture — method signatures

Signatures

ts
(options?: PictureOptions): Promise<CameraPicture>

Parameters

NameTypeRequiredDescription
optionsSpecPictureOptionsNo—

Returns

Promise<SpecCameraPicture>

startRecording — method signatures

Signatures

ts
(options?: RecordingOptions): Promise<CameraRecording>

Parameters

NameTypeRequiredDescription
optionsSpecRecordingOptionsNo—

Returns

Promise<SpecCameraRecording>

stopRecording — method signatures

Signatures

ts
(): Promise<CameraRecording>

Parameters

No parameters.

Returns

Promise<SpecCameraRecording>

pausePreview — method signatures

Signatures

ts
(): Promise<void>

Parameters

No parameters.

Returns

Promise<void>

resumePreview — method signatures

Signatures

ts
(): Promise<void>

Parameters

No parameters.

Returns

Promise<void>

Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.