feat: iOS修改菜单配置,由flutter注入,sdk调用

master
jizelin 2021-03-03 22:59:09 +08:00
parent 46137b77f0
commit 761e78798b
2 changed files with 51 additions and 28 deletions

View File

@ -41,42 +41,65 @@
NSLog(@"getUserInfoWithAppletInfo"); NSLog(@"getUserInfoWithAppletInfo");
__block NSDictionary *userInfo; __block NSDictionary *userInfo;
FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
[channel invokeMethod:@"extensionApi:getUserInfo" arguments:nil result:^(id _Nullable result) { [channel invokeMethod:@"extensionApi:getUserInfo" arguments:nil result:^(id _Nullable result) {
userInfo = result; CFRunLoopStop(CFRunLoopGetMain());
userInfo = result;
}]; }];
CFRunLoopRun();
return userInfo; return userInfo;
} }
- (NSArray<id<FATAppletMenuProtocol>> *)customMenusInApplet:(FATAppletInfo *)appletInfo atPath:(NSString *)path { - (NSArray<id<FATAppletMenuProtocol>> *)customMenusInApplet:(FATAppletInfo *)appletInfo atPath:(NSString *)path {
MopCustomMenuModel *favModel1 = [[MopCustomMenuModel alloc] init]; NSLog(@"customMenusInApplet");
favModel1.menuId = @"WXShareAPPFriends"; __block NSArray *list;
favModel1.menuTitle = @"微信好友"; FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
favModel1.menuIconImage = [UIImage imageNamed:@"mini_menu_chat"]; [channel invokeMethod:@"extensionApi:getCustomMenus" arguments:@{@"appId": appletInfo.appId} result:^(id _Nullable result) {
favModel1.menuType = FATAppletMenuStyleOnMiniProgram; CFRunLoopStop(CFRunLoopGetMain());
list = result;
}];
CFRunLoopRun();
MopCustomMenuModel *favModel2 = [[MopCustomMenuModel alloc] init]; NSMutableArray *models = [NSMutableArray array];
favModel2.menuId = @"ShareSinaWeibo"; for (NSDictionary<NSString *, NSString *> *data in list) {
favModel2.menuTitle = @"新浪微博"; MopCustomMenuModel *model = [[MopCustomMenuModel alloc] init];
favModel2.menuIconImage = [UIImage imageNamed:@"mini_menu_chat"]; model.menuId = data[@"menuId"];
favModel2.menuType = FATAppletMenuStyleOnMiniProgram; 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]; return models;
favModel3.menuId = @"Restart"; }
favModel3.menuTitle = @"重启";
favModel3.menuIconImage = [UIImage imageNamed:@"minipro_list_setting"]; - (void)customMenu:(id<FATAppletMenuProtocol>)customMenu inApplet:(FATAppletInfo *)appletInfo didClickAtPath:(NSString *)path {
favModel3.menuType = FATAppletMenuStyleCommon; NSDictionary *arguments = @{
@"appId": appletInfo.appId,
MopCustomMenuModel *favModel4 = [[MopCustomMenuModel alloc] init]; @"path": path,
favModel4.menuId = @"ShareQQFriends"; @"menuId": customMenu.menuId,
favModel4.menuTitle = @"QQ好友"; @"appInfo": appletInfo.description
favModel4.menuIconImage = [UIImage imageNamed:@"minipro_list_setting"]; };
favModel4.menuType = FATAppletMenuStyleOnMiniProgram; FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
[channel invokeMethod:@"extensionApi:onCustomMenuClick" arguments:arguments result:^(id _Nullable result) {
return @[favModel1, favModel2, favModel3, favModel4];
}];
} }
- (void)clickCustomItemMenuWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode code, NSDictionary *result))completion { - (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 @end

View File

@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk.
s.dependency 'Flutter' s.dependency 'Flutter'
s.ios.deployment_target = '9.0' s.ios.deployment_target = '9.0'
s.dependency 'FinApplet' , '2.21.1' s.dependency 'FinApplet' , '2.22.0-alpha20210303v01'
s.dependency 'FinAppletExt' , '2.21.1' s.dependency 'FinAppletExt' , '2.22.0-alpha20210303v01'
end end