ReScript bindings for
@react-native-community/cameraroll.
Exposed as ReactNativeCameraRoll module.
@rescript-react-native/cameraroll X.y.* means it's compatible with
@react-native-community/cameraroll X.y.*
Installation
When
@react-native-community/cameraroll
is properly installed & configured by following their installation instructions,
you can install the bindings:
npm install @rescript-react-native/cameraroll # or yarn add @rescript-react-native/cameraroll
@rescript-react-native/cameraroll should be added to bs-dependencies in your
bsconfig.json:
{
//...
"bs-dependencies": [
"@rescript/react",
"rescript-react-native",
// ...
+ "@rescript-react-native/cameraroll"
],
//...
}Methods
save
Allows saving photos and videos to the Camera Roll or Photo Gallery, similar to
saveToCameraRoll.
The function will return the URI for the saved file as a string wrapped in a Promise.
save: string => Js.Promise.t(string)
saveWithOptions
Allows saving photos and videos to the Camera Roll or Photo Gallery, similar to
saveToCameraRoll, however, a particular album may be
specified in a saveOptions object.
The function will return the URI for the saved file as a string wrapped in a Promise.
saveWithOptions: (string, saveOptions) => Js.Promise.t(string)
saveToCameraRoll
Allows saving photos and videos to the Camera Roll or Photo Gallery. File to be
saved is specified as a tag (of type string) which can be
- on Android, a local image or video URI, such as "file:///sdcard/img.png"
- on iOS, a local video URI or any image URI (local, remote asset-library, or base64 data URIs)
Media type (photo or video) will be automatically inferred; any file will be
inferred to be a photo, unless the file extension is mov or mp4, then it
will be inferred to be a video.
The function will return the URI for the saved file as a string wrapped in a Promise.
saveToCameraRoll: string => Js.Promise.t(string)
saveToCameraRollWithType
Allows saving photos and videos to the Camera Roll, where the tag will be
specified as above, overriding the automatically determined type by specifying
one of the polymorphic variants `photo or `video.
The function will return the URI for the saved file as a string wrapped in a Promise.
saveToCameraRollWithType: (string, [ | #photo | #video]) => Js.Promise.t(string)
deletePhotos
To request deletion of photos (as array(string)) from the Camera Roll. Returns
bool wrapped in a Promise. The Promise will be rejected if deletion does not
succeed; on Android that would imply a system error whereas on iOS the user
may have cancelled the request to delete.
On Android, the uri must be a local image or video URI, such as "file:///sdcard/img.png".
On iOS, the uri can be any image URI (including local, remote asset-library and base64 data URIs) or a local video file URI. The user will be presented with a dialog box that showing the asset(s) and asked for confirmation. This cannot be bypassed as per Apple Developer guidelines.
deletePhotos: array(string) => Js.Promise.t(bool)
getAlbums
Returns a list of albums wrapped in a Promise.
getAlbums: unit => Js.Promise.t(array(album))
getAlbumsWithParams
Returns a list of albums of type specified in a getAlbumsParams object,
wrapped in a Promise.
getAlbums: getAlbumsParams => Js.Promise.t(array(album))
getPhotos
Allows searching for photos or videos matching given parameters.
Takes as argument getPhotosParams and returns a photoIdentifiersPage object
wrapped in a Promise. edges key of the photoIdentifiersPage object would be
of type array(photoIdentifier), where each photoIdentifier object would
contain details of each photo or video matching parameters provided in the
getPhotosParam object.
getPhotos: getPhotosParams => Js.Promise.t(photoIdentifiersPage)
Types
album
type album = { title: string, count: int };
getAlbumsParams;
can be constructed with the constructor of the same name
getAlbumsParams: ( ~assetType: [ | #All | #Photos | #Videos ] ) => getAlbumsParams
getPhotosParams
can be constructed with the constructor of the same name
firsttakes an integer which specifies the number of files for which details will be returned. Files will match in reverse order (i.e. most recent first)aftertakes a string which should be obtained fromphotoIdentifiersPagereturned in a previousgetPhotoscall, under theend_cursorkey contained in turn under thepage_infokey.
getPhotosParams: ( ~first: int, ~after: string=?, ~groupTypes: [ | #Album | #All | #Event | #Faces | #Library | #PhotoStream | #SavedPhotos ] =?, ~groupName: string=?, ~assetType: [ | #All | #Videos | #Photos]=?, ~mimeTypes: array(string)=?, ~fromTime: float=?, ~toTime: float=?, ~include_: array(string)=?, unit ) => getPhotosParams
image
type image = { filename: Js.Nullable.t(string), uri: string, height: Js.Nullable.t(float), width: Js.Nullable.t(float), fileSize: Js.Nullable.t(float), playableDuration: Js.Nullable.t(float), }
location
type location = { latitude: Js.Nullable.t(float), longitude: Js.Nullable.t(float), altitude: Js.Nullable.t(float), heading: Js.Nullable.t(float), speed: Js.Nullable.t(float), };
node
type node = { \"type": string, \"group_name": string, image, timestamp: float, location: Js.Nullable.t(location), }
pageInfo
type pageInfo = { \"has_next_page": bool, \"start_cursor": Js.Nullable.t(string), \"end_curson": Js.Nullable.t(string), };
photoIdentifiersPage
type photoIdentifiersPage = { edges: array(photoIdentifier), \"page_info", }
photoIdentifier
type photoIdentifier = {node}
saveOptions
can be constructed with the constructor of the same name
saveOptions: ( ~_type: [ | #auto | #photo | #video ], ~album: string ) => saveOptions