From 761e78798b1b3fd65dde527c22d4fa0caa65bbf5 Mon Sep 17 00:00:00 2001 From: jizelin Date: Wed, 3 Mar 2021 22:59:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20iOS=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E7=94=B1flutter=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=EF=BC=8Csdk=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOPAppletDelegate.m | 75 +++++++++++++++++++---------- ios/mop.podspec | 4 +- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/ios/Classes/Api/MOPAppletDelegate.m b/ios/Classes/Api/MOPAppletDelegate.m index ec39fe1..c3ff701 100644 --- a/ios/Classes/Api/MOPAppletDelegate.m +++ b/ios/Classes/Api/MOPAppletDelegate.m @@ -41,42 +41,65 @@ NSLog(@"getUserInfoWithAppletInfo"); __block NSDictionary *userInfo; FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; - [channel invokeMethod:@"extensionApi:getUserInfo" arguments:nil result:^(id _Nullable result) { - userInfo = result; + [channel invokeMethod:@"extensionApi:getUserInfo" arguments:nil result:^(id _Nullable result) { + CFRunLoopStop(CFRunLoopGetMain()); + userInfo = result; }]; + CFRunLoopRun(); return userInfo; } - (NSArray> *)customMenusInApplet:(FATAppletInfo *)appletInfo atPath:(NSString *)path { - MopCustomMenuModel *favModel1 = [[MopCustomMenuModel alloc] init]; - favModel1.menuId = @"WXShareAPPFriends"; - favModel1.menuTitle = @"微信好友"; - favModel1.menuIconImage = [UIImage imageNamed:@"mini_menu_chat"]; - favModel1.menuType = FATAppletMenuStyleOnMiniProgram; + NSLog(@"customMenusInApplet"); + __block NSArray *list; + FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; + [channel invokeMethod:@"extensionApi:getCustomMenus" arguments:@{@"appId": appletInfo.appId} result:^(id _Nullable result) { + CFRunLoopStop(CFRunLoopGetMain()); + list = result; + }]; + CFRunLoopRun(); - MopCustomMenuModel *favModel2 = [[MopCustomMenuModel alloc] init]; - favModel2.menuId = @"ShareSinaWeibo"; - favModel2.menuTitle = @"新浪微博"; - favModel2.menuIconImage = [UIImage imageNamed:@"mini_menu_chat"]; - favModel2.menuType = FATAppletMenuStyleOnMiniProgram; + NSMutableArray *models = [NSMutableArray array]; + for (NSDictionary *data in list) { + MopCustomMenuModel *model = [[MopCustomMenuModel alloc] init]; + model.menuId = data[@"menuId"]; + model.menuTitle = data[@"title"]; + model.menuIconImage = [UIImage imageNamed:data[@"image"]]; + NSString *typeString = data[@"type"]; + if (typeString) { + FATAppletMenuStyle style = [typeString isEqualToString:@"onMiniProgram"] ? FATAppletMenuStyleOnMiniProgram : FATAppletMenuStyleCommon; + model.menuType = style; + } + [models addObject:model]; + } - MopCustomMenuModel *favModel3 = [[MopCustomMenuModel alloc] init]; - favModel3.menuId = @"Restart"; - favModel3.menuTitle = @"重启"; - favModel3.menuIconImage = [UIImage imageNamed:@"minipro_list_setting"]; - favModel3.menuType = FATAppletMenuStyleCommon; - - MopCustomMenuModel *favModel4 = [[MopCustomMenuModel alloc] init]; - favModel4.menuId = @"ShareQQFriends"; - favModel4.menuTitle = @"QQ好友"; - favModel4.menuIconImage = [UIImage imageNamed:@"minipro_list_setting"]; - favModel4.menuType = FATAppletMenuStyleOnMiniProgram; - - return @[favModel1, favModel2, favModel3, favModel4]; + return models; +} + +- (void)customMenu:(id)customMenu inApplet:(FATAppletInfo *)appletInfo didClickAtPath:(NSString *)path { + NSDictionary *arguments = @{ + @"appId": appletInfo.appId, + @"path": path, + @"menuId": customMenu.menuId, + @"appInfo": appletInfo.description + }; + FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; + [channel invokeMethod:@"extensionApi:onCustomMenuClick" arguments:arguments result:^(id _Nullable result) { + + }]; } - (void)clickCustomItemMenuWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode code, NSDictionary *result))completion { - NSLog(@"%@", contentInfo); + NSDictionary *arguments = @{ + @"appId": contentInfo[@"appId"], + @"path": contentInfo[@"path"], + @"menuId": contentInfo[@"menuId"], + @"appInfo": [NSString stringWithFormat:@"{'title': '%@', 'description': '%@', 'imageUrl': '%@'}", contentInfo[@"title"], contentInfo[@"description"], contentInfo[@"imageUrl"]] + }; + FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; + [channel invokeMethod:@"extensionApi:onCustomMenuClick" arguments:arguments result:^(id _Nullable result) { + + }]; } @end diff --git a/ios/mop.podspec b/ios/mop.podspec index 4625c99..613a334 100644 --- a/ios/mop.podspec +++ b/ios/mop.podspec @@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk. s.dependency 'Flutter' s.ios.deployment_target = '9.0' - s.dependency 'FinApplet' , '2.21.1' - s.dependency 'FinAppletExt' , '2.21.1' + s.dependency 'FinApplet' , '2.22.0-alpha20210303v01' + s.dependency 'FinAppletExt' , '2.22.0-alpha20210303v01' end