@hortemo/expo-photos
v11.0.0
Published
Expo module exposing advanced iOS Photos APIs.
Maintainers
Readme
@hortemo/expo-photos
Lightweight Expo (React Native) wrapper for Apple's Photos framework.
Installation
npm install @hortemo/expo-photosAPI Reference
Functions
fetchAssets(options: FetchAssetsOptions): Promise<PHAsset[]>requestImage(options: RequestImageOptions): Promise<void>requestVideo(options: RequestVideoOptions): Promise<void>pickAssets(options: PickAssetsOptions): Promise<PHAsset[]>authorizationStatus(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>requestAuthorization(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>presentLimitedLibraryPicker(): Promise<void>
Components
PHImageView
A native image component that displays photos from the Photos library using PHImageManager.
import {
PHImageView,
PHImageContentMode,
PHImageRequestOptionsResizeMode,
PHImageRequestOptionsDeliveryMode,
UIViewContentMode,
} from "@hortemo/expo-photos";
<PHImageView
localIdentifier={asset.localIdentifier}
contentMode={UIViewContentMode.scaleAspectFill}
requestOptions={{
contentMode: PHImageContentMode.aspectFit,
resizeMode: PHImageRequestOptionsResizeMode.fast,
deliveryMode: PHImageRequestOptionsDeliveryMode.highQualityFormat,
targetSize: { width: 300, height: 300 },
isNetworkAccessAllowed: true,
}}
onLoad={(event) => console.log(event.nativeEvent)}
onError={(event) => console.log(event.nativeEvent.message)}
style={{ width: 300, height: 300 }}
/>PHVideoView
A video player component that streams videos from the library.
import { PHVideoView, PHVideoRequestOptionsDeliveryMode } from "@hortemo/expo-photos";
<PHVideoView
localIdentifier={asset.localIdentifier}
requestOptions={{
isNetworkAccessAllowed: true,
deliveryMode: PHVideoRequestOptionsDeliveryMode.automatic,
}}
onLoad={(event) => console.log(event.nativeEvent)}
onError={(event) => console.log(event.nativeEvent.message)}
style={{ width: 300, height: 200 }}
/>