From 770c922c44b3ef0c89c74c448c5bee71a881b868 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Sun, 1 Sep 2024 17:44:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20++?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/page/developer/develop_index_page.dart | 2 +- ios/Classes/PMPlugin.m | 4 ++-- ios/Classes/core/PMManager.h | 6 +++--- ios/Classes/core/PMManager.m | 16 ++++++++-------- lib/src/internal/editor.dart | 4 ++-- lib/src/internal/plugin.dart | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/example/lib/page/developer/develop_index_page.dart b/example/lib/page/developer/develop_index_page.dart index bd32ba1c..cfb7cbb1 100644 --- a/example/lib/page/developer/develop_index_page.dart +++ b/example/lib/page/developer/develop_index_page.dart @@ -262,7 +262,7 @@ class _DeveloperIndexPageState extends State { 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 { diff --git a/ios/Classes/PMPlugin.m b/ios/Classes/PMPlugin.m index b750f75f..aa622aeb 100644 --- a/ios/Classes/PMPlugin.m +++ b/ios/Classes/PMPlugin.m @@ -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) { diff --git a/ios/Classes/core/PMManager.h b/ios/Classes/core/PMManager.h index 8ab11ac9..57848125 100644 --- a/ios/Classes/core/PMManager.h +++ b/ios/Classes/core/PMManager.h @@ -53,18 +53,18 @@ typedef void (^AssetResult)(PMAssetEntity *); - (void)deleteWithIds:(NSArray *)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; diff --git a/ios/Classes/core/PMManager.m b/ios/Classes/core/PMManager.m index 28a9f2b3..ebcc1f1a 100644 --- a/ios/Classes/core/PMManager.m +++ b/ios/Classes/core/PMManager.m @@ -126,14 +126,14 @@ - (NSUInteger)getAssetCountWithType:(int)type option:(NSObject *)f - (NSArray *)getAssetsWithType:(int)type option:(NSObject *)option start:(int)start end:(int)end { PHFetchOptions *options = [option getFetchOptions:type]; PHFetchResult *result = [PHAsset fetchAssetsWithOptions:options]; - + NSUInteger endOffset = end; if (endOffset > result.count) { endOffset = result.count; } - + NSMutableArray* array = [NSMutableArray new]; - + for (NSUInteger i = start; i < endOffset; i++){ if (i >= result.count) { break; @@ -142,7 +142,7 @@ - (NSUInteger)getAssetCountWithType:(int)type option:(NSObject *)f PMAssetEntity *pmAsset = [self convertPHAssetToAssetEntity:asset needTitle:[option needTitle]]; [array addObject: pmAsset]; } - + return array; } @@ -1022,11 +1022,11 @@ - (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; @@ -1034,7 +1034,7 @@ - (void)saveLivePhoto:(NSString *)imagePath 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; diff --git a/lib/src/internal/editor.dart b/lib/src/internal/editor.dart index 39822089..087a9029 100644 --- a/lib/src/internal/editor.dart +++ b/lib/src/internal/editor.dart @@ -283,14 +283,14 @@ class DarwinEditor { Future 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, ); diff --git a/lib/src/internal/plugin.dart b/lib/src/internal/plugin.dart index eedee4af..1c1d0e58 100644 --- a/lib/src/internal/plugin.dart +++ b/lib/src/internal/plugin.dart @@ -671,7 +671,7 @@ mixin IosPlugin on BasePlugin { Future saveLivePhoto({ required File imageFile, required File videoFile, - required String? title, + required String? filename, String? desc, String? relativePath, }) async { @@ -687,13 +687,13 @@ mixin IosPlugin on BasePlugin { { '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 iosCreateAlbum(