Krizaka UI
Krizaka UI
ComposantsMédias

Media picker

Photos and videos picked from the library or the camera, as a grid of tiles with a remove button and a count.

Web · n/aMobile · ✓Bureau · n/aBêtaMédias
Domaine
Médias
Niveau de support
Bêta
Taille
Non mesurée
Qui l'utilise
Aucun produit en production ne l'importe encore
Media picker — A story's photos, tel que React Native le rend

« A story's photos », son histoire React Native à la largeur d’un téléphone — le même code sur iOS et Android.

Mobile uniquement — React Native, depuis @krizaka/ui/native/media-picker. Bêta : son API peut encore changer à une version mineure.

  • Web · n/a. The web picks files with an upload field. → File upload
  • Bureau · n/a. The Mac app picks files with the upload field and drag and drop. → File upload

Pourquoi il est là. Used by Sovkora.

Quand l’utiliser

  • The photos of a story, a post, a profile.
  • A proof of delivery for a challenge.

Quand ne pas l’utiliser

  • To film in the app itself.
  • For files on the web.À la place : File upload

Installation

Installer

npx expo install react-native-svg
npm install @krizaka/ui

Importer

import { MediaPicker } from "@krizaka/ui/native/media-picker";

Enveloppez l’application une fois dans ThemeProvider de @krizaka/ui/native : chaque composant lit ses rôles de couleur.

Exemples

React Native n’a pas d’aperçu en direct sur le web : chaque exemple montre la capture de sa story, testée dans les deux thèmes, et le code à copier.

A story's photos

Up to four photos, from the library or the camera.

Media picker — A story's photos, tel que React Native le rendMedia picker — A story's photos, tel que React Native le rend

Props

Photos and videos picked from the library or the camera, as a grid of square tiles: an add tile (the system's picker, or a sheet to choose library or camera), a remove button on each tile, a count against max.

PropTypeDéfautDescription
labelsrequisMediaPickerLabels—The words, passed translated.
onValueChangerequis(media: PickedMedia[]) => void—Called with the new list.
valuerequisreadonly PickedMedia[]—The media picked (controlled).
accept"all" | "images" | "videos"imagesWhat can be picked. Default images.
camerabooleantrueOffer the camera beside the library. Default true.
maxnumber1The most that can be picked. Default 1.
onPermissionDenied(() => void)—Called when the camera is refused (show a PermissionPrompt).
styleStyleProp<ViewStyle>—Styles merged last.

Accessibilité

  • The add tile and each remove button are named (labels).
  • Refused camera: onPermissionDenied shows a PermissionPrompt.

Bonnes pratiques

  • Set max, and accept to what the feature takes.
  • Upload from the uri of each picked item (a Dropzone on the web).

Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page