Add convenience/code-share-enabling native-event decoding method to API
This commit is contained in:
parent
9749a8a30d
commit
751702ceaa
@ -7,9 +7,19 @@ async function getAlbumsWithThumbnails() {
|
||||
return albums;
|
||||
}
|
||||
|
||||
async function getImageUriForId(imageId) {
|
||||
// Return what getImagesForIds() typically returns in the 'uri' field.
|
||||
return `file://${imageId}`;
|
||||
}
|
||||
|
||||
async function getImagesForIds(imagesUris = []) {
|
||||
const images = await NativeGalleryModule.getImagesForUris(imagesUris);
|
||||
return images;
|
||||
return await NativeGalleryModule.getImagesForUris(imagesUris);
|
||||
}
|
||||
|
||||
async function getImageForTapEvent(nativeEvent) {
|
||||
const selectedImageId = nativeEvent.selected;
|
||||
const imageUri = selectedImageId && await getImageUriForId(selectedImageId);
|
||||
return {selectedImageId, imageUri};
|
||||
}
|
||||
|
||||
async function checkDevicePhotosAuthorizationStatus() {
|
||||
@ -26,5 +36,7 @@ export default {
|
||||
checkDevicePhotosAuthorizationStatus,
|
||||
requestDevicePhotosAuthorization,
|
||||
getAlbumsWithThumbnails,
|
||||
getImagesForIds
|
||||
getImageUriForId,
|
||||
getImagesForIds,
|
||||
getImageForTapEvent
|
||||
}
|
||||
|
||||
@ -9,11 +9,32 @@ async function getAlbumsWithThumbnails() {
|
||||
return albums;
|
||||
}
|
||||
|
||||
async function getImageUriForId(imageId) {
|
||||
const images = await CKGallery.getImagesForIds(imagesId);
|
||||
if (!images) {
|
||||
return;
|
||||
}
|
||||
return images.uri;
|
||||
}
|
||||
|
||||
async function getImagesForIds(imagesId = []) {
|
||||
const images = await CKGallery.getImagesForIds(imagesId);
|
||||
return images;
|
||||
}
|
||||
|
||||
async function getImageForTapEvent(nativeEvent) {
|
||||
let selectedImageId;
|
||||
let imageUri;
|
||||
if (nativeEvent.selectedId) {
|
||||
selectedImageId = nativeEvent.selectedId;
|
||||
imageUri = nativeEvent.selected;
|
||||
} else {
|
||||
selectedImageId = nativeEvent.selected;
|
||||
imageUri = await getImageUriForId(selectedImageId);
|
||||
}
|
||||
return {selectedImageId, imageUri};
|
||||
}
|
||||
|
||||
async function checkDevicePhotosAuthorizationStatus() {
|
||||
const isAuthorized = await CKGallery.checkDevicePhotosAuthorizationStatus();
|
||||
return isAuthorized;
|
||||
@ -26,7 +47,9 @@ async function requestDevicePhotosAuthorization() {
|
||||
|
||||
export default {
|
||||
getAlbumsWithThumbnails,
|
||||
getImageUriForId,
|
||||
getImagesForIds,
|
||||
getImageForTapEvent,
|
||||
checkDevicePhotosAuthorizationStatus,
|
||||
requestDevicePhotosAuthorization
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user