Skip to content

Commit

Permalink
🎨 ++
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Sep 1, 2024
1 parent f4f78e3 commit 770c922
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion example/lib/page/developer/develop_index_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class _DeveloperIndexPageState extends State<DeveloperIndexPage> {
final assets = await PhotoManager.editor.darwin.saveLivePhoto(
imageFile: imgFile,
videoFile: videoFile,
title: 'preview_0',
filename: 'preview_0',
);
print('save live photo result : ${assets?.id}');
} finally {
Expand Down
4 changes: 2 additions & 2 deletions ios/Classes/PMPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ - (void)handleMethodResultHandler:(ResultHandler *)handler manager:(PMManager *)
} else if ([call.method isEqualToString:@"saveLivePhoto"]) {
NSString *videoPath = call.arguments[@"videoPath"];
NSString *imagePath = call.arguments[@"imagePath"];
NSString *title = call.arguments[@"title"];
NSString *filename = call.arguments[@"filename"];
NSString *desc = call.arguments[@"desc"];
[manager saveLivePhoto:imagePath
videoPath:videoPath
title:title
filename:filename
desc:desc
block:^(PMAssetEntity *asset) {
if (!asset) {
Expand Down
6 changes: 3 additions & 3 deletions ios/Classes/core/PMManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ typedef void (^AssetResult)(PMAssetEntity *);
- (void)deleteWithIds:(NSArray<NSString *> *)ids changedBlock:(ChangeIds)block;

- (void)saveImage:(NSData *)data
title:(NSString *)title
filename:(NSString *)filename
desc:(NSString *)desc
block:(AssetResult)block;

- (void)saveVideo:(NSString *)path
title:(NSString *)title
filename:(NSString *)filename
desc:(NSString *)desc
block:(AssetResult)block;

- (void)saveLivePhoto:(NSString *)imagePath
videoPath:(NSString *)videoPath
title:(NSString *)title
filename:(NSString *)filename
desc:(NSString *)desc
block:(AssetResult)block;

Expand Down
16 changes: 8 additions & 8 deletions ios/Classes/core/PMManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ - (NSUInteger)getAssetCountWithType:(int)type option:(NSObject<PMBaseFilter> *)f
- (NSArray<PMAssetEntity *> *)getAssetsWithType:(int)type option:(NSObject<PMBaseFilter> *)option start:(int)start end:(int)end {
PHFetchOptions *options = [option getFetchOptions:type];
PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithOptions:options];

NSUInteger endOffset = end;
if (endOffset > result.count) {
endOffset = result.count;
}

NSMutableArray<PMAssetEntity*>* array = [NSMutableArray new];

for (NSUInteger i = start; i < endOffset; i++){
if (i >= result.count) {
break;
Expand All @@ -142,7 +142,7 @@ - (NSUInteger)getAssetCountWithType:(int)type option:(NSObject<PMBaseFilter> *)f
PMAssetEntity *pmAsset = [self convertPHAssetToAssetEntity:asset needTitle:[option needTitle]];
[array addObject: pmAsset];
}

return array;
}

Expand Down Expand Up @@ -1022,19 +1022,19 @@ - (void)saveVideo:(NSString *)path

- (void)saveLivePhoto:(NSString *)imagePath
videoPath:(NSString *)videoPath
title:(NSString *)title
filename:(NSString *)filename
desc:(NSString *)desc
block:(AssetResult)block {
[PMLogUtils.sharedInstance info:[NSString stringWithFormat:@"save LivePhoto with imagePath: %@, videoPath: %@, title: %@, desc %@",
imagePath, videoPath, title, desc]];
[PMLogUtils.sharedInstance info:[NSString stringWithFormat:@"save LivePhoto with imagePath: %@, videoPath: %@, filename: %@, desc %@",
imagePath, videoPath, filename, desc]];
NSURL *videoURL = [NSURL fileURLWithPath:videoPath];
NSURL *imageURL = [NSURL fileURLWithPath:imagePath];
__block NSString *assetId = nil;
[[PHPhotoLibrary sharedPhotoLibrary]
performChanges:^{
PHAssetCreationRequest *request = [PHAssetCreationRequest creationRequestForAsset];
PHAssetResourceCreationOptions *options = [PHAssetResourceCreationOptions new];
[options setOriginalFilename:title];
[options setOriginalFilename:filename];
[request addResourceWithType:PHAssetResourceTypePhoto fileURL:imageURL options:options];
[request addResourceWithType:PHAssetResourceTypePairedVideo fileURL:videoURL options:options];
assetId = request.placeholderForCreatedAsset.localIdentifier;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/internal/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,14 @@ class DarwinEditor {
Future<AssetEntity?> saveLivePhoto({
required File imageFile,
required File videoFile,
required String title,
required String filename,
String? desc,
String? relativePath,
}) {
return plugin.saveLivePhoto(
imageFile: imageFile,
videoFile: videoFile,
title: title,
filename: filename,
desc: desc,
relativePath: relativePath,
);
Expand Down
8 changes: 4 additions & 4 deletions lib/src/internal/plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ mixin IosPlugin on BasePlugin {
Future<AssetEntity?> saveLivePhoto({
required File imageFile,
required File videoFile,
required String? title,
required String? filename,
String? desc,
String? relativePath,
}) async {
Expand All @@ -687,13 +687,13 @@ mixin IosPlugin on BasePlugin {
<String, dynamic>{
'imagePath': imageFile.absolute.path,
'videoPath': videoFile.absolute.path,
'title': title,
'desc': desc ?? '',
'filename': filename,
'desc': desc,
'relativePath': relativePath,
...onlyAddPermission,
},
);
return ConvertUtils.convertMapToAsset(result.cast(), title: title);
return ConvertUtils.convertMapToAsset(result.cast(), title: filename);
}

Future<AssetPathEntity?> iosCreateAlbum(
Expand Down

0 comments on commit 770c922

Please sign in to comment.