mirror of
https://github.com/status-im/react-native-camera-roll.git
synced 2026-08-30 21:01:10 +00:00
feat(iOS): Include subtype in get albums. (#526)
This commit is contained in:
@@ -206,6 +206,7 @@ Returns a Promise with a list of albums
|
|||||||
Array of `Album` object
|
Array of `Album` object
|
||||||
* title: {string}
|
* title: {string}
|
||||||
* count: {number}
|
* count: {number}
|
||||||
|
* subtype: {string | undefined} : See AlbumSubType type for possible values. iOS only.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+26
-1
@@ -262,9 +262,11 @@ RCT_EXPORT_METHOD(getAlbums:(NSDictionary *)params
|
|||||||
// Enumerate assets within the collection
|
// Enumerate assets within the collection
|
||||||
PHFetchResult<PHAsset *> *const assetsFetchResult = [PHAsset fetchAssetsInAssetCollection:obj options:assetFetchOptions];
|
PHFetchResult<PHAsset *> *const assetsFetchResult = [PHAsset fetchAssetsInAssetCollection:obj options:assetFetchOptions];
|
||||||
if (assetsFetchResult.count > 0) {
|
if (assetsFetchResult.count > 0) {
|
||||||
|
NSString *subtypeString = subTypeLabelForCollection(obj);
|
||||||
[result addObject:@{
|
[result addObject:@{
|
||||||
@"title": [obj localizedTitle],
|
@"title": [obj localizedTitle],
|
||||||
@"count": @(assetsFetchResult.count)
|
@"count": @(assetsFetchResult.count),
|
||||||
|
@"subtype": subtypeString
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
@@ -685,6 +687,29 @@ RCT_EXPORT_METHOD(getPhotoByInternalID:(NSString *)internalId
|
|||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSString *subTypeLabelForCollection(PHAssetCollection *assetCollection) {
|
||||||
|
PHAssetCollectionSubtype subtype = assetCollection.assetCollectionSubtype;
|
||||||
|
|
||||||
|
switch (subtype) {
|
||||||
|
case PHAssetCollectionSubtypeAlbumRegular:
|
||||||
|
return @"AlbumRegular";
|
||||||
|
case PHAssetCollectionSubtypeAlbumSyncedEvent:
|
||||||
|
return @"AlbumSyncedEvent";
|
||||||
|
case PHAssetCollectionSubtypeAlbumSyncedFaces:
|
||||||
|
return @"AlbumSyncedFaces";
|
||||||
|
case PHAssetCollectionSubtypeAlbumSyncedAlbum:
|
||||||
|
return @"AlbumSyncedAlbum";
|
||||||
|
case PHAssetCollectionSubtypeAlbumImported:
|
||||||
|
return @"AlbumImported";
|
||||||
|
case PHAssetCollectionSubtypeAlbumMyPhotoStream:
|
||||||
|
return @"AlbumMyPhotoStream";
|
||||||
|
case PHAssetCollectionSubtypeAlbumCloudShared:
|
||||||
|
return @"AlbumCloudShared";
|
||||||
|
default:
|
||||||
|
return @"Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSArray<NSString *> *) mediaSubTypeLabelsForAsset:(PHAsset *)asset {
|
- (NSArray<NSString *> *) mediaSubTypeLabelsForAsset:(PHAsset *)asset {
|
||||||
PHAssetMediaSubtype subtype = asset.mediaSubtypes;
|
PHAssetMediaSubtype subtype = asset.mediaSubtypes;
|
||||||
NSMutableArray<NSString*> *mediaSubTypeLabels = [NSMutableArray array];
|
NSMutableArray<NSString*> *mediaSubTypeLabels = [NSMutableArray array];
|
||||||
|
|||||||
@@ -158,9 +158,20 @@ export type GetAlbumsParams = {
|
|||||||
assetType?: AssetType;
|
assetType?: AssetType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type AlbumSubType =
|
||||||
|
| 'AlbumRegular'
|
||||||
|
| 'AlbumSyncedEvent'
|
||||||
|
| 'AlbumSyncedFaces'
|
||||||
|
| 'AlbumSyncedAlbum'
|
||||||
|
| 'AlbumImported'
|
||||||
|
| 'AlbumMyPhotoStream'
|
||||||
|
| 'AlbumCloudShared'
|
||||||
|
| 'Unknown';
|
||||||
|
|
||||||
export type Album = {
|
export type Album = {
|
||||||
title: string;
|
title: string;
|
||||||
count: number;
|
count: number;
|
||||||
|
subtype?: AlbumSubType;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,9 +3,20 @@
|
|||||||
// and we want to stay compatible with those
|
// and we want to stay compatible with those
|
||||||
import {TurboModuleRegistry, TurboModule} from 'react-native';
|
import {TurboModuleRegistry, TurboModule} from 'react-native';
|
||||||
|
|
||||||
|
export type AlbumSubType =
|
||||||
|
| 'AlbumRegular'
|
||||||
|
| 'AlbumSyncedEvent'
|
||||||
|
| 'AlbumSyncedFaces'
|
||||||
|
| 'AlbumSyncedAlbum'
|
||||||
|
| 'AlbumImported'
|
||||||
|
| 'AlbumMyPhotoStream'
|
||||||
|
| 'AlbumCloudShared'
|
||||||
|
| 'Unknown';
|
||||||
|
|
||||||
type Album = {
|
type Album = {
|
||||||
title: string;
|
title: string;
|
||||||
count: number;
|
count: number;
|
||||||
|
subtype?: AlbumSubType;
|
||||||
};
|
};
|
||||||
|
|
||||||
type SubTypes =
|
type SubTypes =
|
||||||
|
|||||||
Reference in New Issue
Block a user