1.增加相机和相册的弹框选择

master
wangzhaoyao 2022-08-25 21:40:52 +08:00
parent 0a5217e652
commit 17af0c0e8d
1 changed files with 31 additions and 5 deletions

View File

@ -8,6 +8,7 @@
#import "MOPAppletDelegate.h" #import "MOPAppletDelegate.h"
#import "MopPlugin.h" #import "MopPlugin.h"
#import "MopCustomMenuModel.h" #import "MopCustomMenuModel.h"
#import <mop/MOPTools.h>
@interface NSString (FATEncode) @interface NSString (FATEncode)
- (NSString *)fat_encodeString; - (NSString *)fat_encodeString;
@ -144,15 +145,40 @@ static NSString *scheme = @"fatae55433be2f62915";//App对应的scheme
} }
- (void)chooseAvatarWithAppletInfo:(FATAppletInfo *)appletInfo bindChooseAvatar:(void (^)(NSDictionary *result))bindChooseAvatar { - (void)chooseAvatarWithAppletInfo:(FATAppletInfo *)appletInfo bindChooseAvatar:(void (^)(NSDictionary *result))bindChooseAvatar {
NSDictionary *params = @{@"name":@"chooseAvatar"};
FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
[channel invokeMethod:@"extensionApi:chooseAvatar" arguments:params result:^(id _Nullable result) { message:nil
!bindChooseAvatar?: bindChooseAvatar(result); preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *chooseAlbumAction = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
NSDictionary *params = @{@"name":@"chooseAvatarAlbum"};
FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
[channel invokeMethod:@"extensionApi:chooseAvatarAlbum" arguments:params result:^(id _Nullable result) {
!bindChooseAvatar?: bindChooseAvatar(result);
}];
}]; }];
UIAlertAction *photoAction = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
NSDictionary *params = @{@"name":@"chooseAvatarPhoto"};
FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
[channel invokeMethod:@"extensionApi:chooseAvatarPhoto" arguments:params result:^(id _Nullable result) {
!bindChooseAvatar?: bindChooseAvatar(result);
}];
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action){
bindChooseAvatar(@{});
}];
[alertController addAction:chooseAlbumAction];
[alertController addAction:photoAction];
[alertController addAction:cancelAction];
UIViewController *topVC = [MOPTools topViewController];
[topVC presentViewController:alertController animated:YES completion:nil];
} }
@end @end
@implementation NSString (FATEncode) @implementation NSString (FATEncode)