-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit swaps the fork of @react-native-camera-roll/camera-roll with a patch and upgrades this library to the latest version. needed for : #18138 Verify if camera album related features still work. - iOS status: ready
- Loading branch information
1 parent
d12c05a
commit c197cee
Showing
6 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- /tmp/tmp-status-mobile-3907e6b2e/tmp.re8kHerusA/CameraRoll.ts 2024-04-16 15:17:12.942432000 +0200 | ||
+++ ./node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll.ts 2024-04-16 15:17:42.455250986 +0200 | ||
@@ -239,6 +239,19 @@ | ||
} | ||
|
||
/** | ||
+ * Returns total iOS image count | ||
+ */ | ||
+ static getPhotosCountiOS(): Promise<number> { | ||
+ return RNCCameraRoll.getPhotosCountiOS(''); | ||
+ } | ||
+ /** | ||
+ * Returns favorites and their count iOS | ||
+ */ | ||
+ static getFavoritesiOS(): Promise<Album> { | ||
+ return RNCCameraRoll.getFavoritesiOS(''); | ||
+ } | ||
+ | ||
+ /** | ||
* Saves the photo or video to the camera roll or photo library, and returns the URI of the newly created asset. | ||
* | ||
* @deprecated `save(...)` is deprecated - use `saveAsset(...)` instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- /tmp/tmp-status-mobile-3907e6b2e/tmp.juxTO1BeCM/NativeCameraRollModule.ts 2024-04-16 15:21:28.379979000 +0200 | ||
+++ ./node_modules/@react-native-camera-roll/camera-roll/src/NativeCameraRollModule.ts 2024-04-16 15:21:40.490391291 +0200 | ||
@@ -81,6 +81,8 @@ | ||
getPhotos(params: Object): Promise<PhotoIdentifiersPage>; | ||
getAlbums(params: Object): Promise<Album[]>; | ||
deletePhotos(photoUris: Array<string>): Promise<void>; | ||
+ getPhotosCountiOS(arg: string): Promise<number>; | ||
+ getFavoritesiOS(arg: string): Promise<Album>; | ||
getPhotoByInternalID( | ||
internalID: string, | ||
options: Object, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- /tmp/tmp-status-mobile-3907e6b2e/tmp.O0mkyjqnsy/RNCCameraRoll.mm 2024-04-16 15:26:23.070258000 +0200 | ||
+++ ./node_modules/@react-native-camera-roll/camera-roll/ios/RNCCameraRoll.mm 2024-04-16 15:26:32.664996066 +0200 | ||
@@ -955,6 +955,53 @@ | ||
return [albumTitles copy]; | ||
} | ||
|
||
+RCT_EXPORT_METHOD(getPhotosCountiOS:(NSString *)blank | ||
+ resolve:(RCTPromiseResolveBlock)resolve | ||
+ reject:(RCTPromiseRejectBlock)reject) | ||
+{ | ||
+ __block NSInteger intTotalCount=0; | ||
+ PHFetchOptions *allPhotosOptions = [PHFetchOptions new]; | ||
+ allPhotosOptions.predicate = [NSPredicate predicateWithFormat:@"mediaType == %d ",PHAssetMediaTypeImage]; | ||
+ PHFetchResult *allPhotosResult = [PHAsset fetchAssetsWithOptions:allPhotosOptions]; | ||
+ intTotalCount+=allPhotosResult.count; | ||
+ | ||
+ resolve(@(intTotalCount)); | ||
+} | ||
+ | ||
+RCT_EXPORT_METHOD(getFavoritesiOS:(NSString *)blank | ||
+ resolve:(RCTPromiseResolveBlock)resolve | ||
+ reject:(RCTPromiseRejectBlock)reject) | ||
+{ | ||
+ __block NSInteger intTotalCount=0; | ||
+ PHFetchOptions *fetchOptions = [PHFetchOptions new]; | ||
+ NSString *format = @"(favorite == true)"; | ||
+ fetchOptions.predicate = [NSPredicate predicateWithFormat:format]; | ||
+ PHFetchResult<PHAsset *> *const assetsFetchResult = [PHAsset fetchAssetsWithOptions:fetchOptions]; | ||
+ PHAsset *imageAsset = [assetsFetchResult firstObject]; | ||
+ NSMutableArray * result = [NSMutableArray new]; | ||
+ | ||
+ for (PHAsset* asset in assetsFetchResult) { | ||
+ NSArray *resources = [PHAssetResource assetResourcesForAsset:asset ]; | ||
+ if ([resources count] < 1) continue; | ||
+ NSString *orgFilename = ((PHAssetResource*)resources[0]).originalFilename; | ||
+ NSString *uit = ((PHAssetResource*)resources[0]).uniformTypeIdentifier; | ||
+ NSString *mimeType = (NSString *)CFBridgingRelease(UTTypeCopyPreferredTagWithClass((__bridge CFStringRef _Nonnull)(uit), kUTTagClassMIMEType)); | ||
+ CFStringRef extension = UTTypeCopyPreferredTagWithClass((__bridge CFStringRef _Nonnull)(uit), kUTTagClassFilenameExtension); | ||
+ [result addObject:@{ | ||
+ @"width": @([asset pixelWidth]), | ||
+ @"height": @([asset pixelHeight]), | ||
+ @"filename": orgFilename ?: @"", | ||
+ @"mimeType": mimeType ?: @"", | ||
+ @"id": [asset localIdentifier], | ||
+ @"creationDate": [asset creationDate], | ||
+ @"uri": [NSString stringWithFormat:@"ph://%@", [asset localIdentifier]], | ||
+ @"duration": @([asset duration]) | ||
+ }]; | ||
+ } | ||
+ [result addObject:@{@"count": @(assetsFetchResult.count)}]; | ||
+ resolve(result); | ||
+} | ||
+ | ||
static void checkPhotoLibraryConfig() | ||
{ | ||
#if RCT_DEV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters