feat: iOS修改菜单配置,由flutter注入,sdk调用
parent
46137b77f0
commit
761e78798b
|
@ -42,41 +42,64 @@
|
||||||
__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) {
|
||||||
|
CFRunLoopStop(CFRunLoopGetMain());
|
||||||
userInfo = result;
|
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"];
|
|
||||||
favModel3.menuType = FATAppletMenuStyleCommon;
|
|
||||||
|
|
||||||
MopCustomMenuModel *favModel4 = [[MopCustomMenuModel alloc] init];
|
- (void)customMenu:(id<FATAppletMenuProtocol>)customMenu inApplet:(FATAppletInfo *)appletInfo didClickAtPath:(NSString *)path {
|
||||||
favModel4.menuId = @"ShareQQFriends";
|
NSDictionary *arguments = @{
|
||||||
favModel4.menuTitle = @"QQ好友";
|
@"appId": appletInfo.appId,
|
||||||
favModel4.menuIconImage = [UIImage imageNamed:@"minipro_list_setting"];
|
@"path": path,
|
||||||
favModel4.menuType = FATAppletMenuStyleOnMiniProgram;
|
@"menuId": customMenu.menuId,
|
||||||
|
@"appInfo": appletInfo.description
|
||||||
|
};
|
||||||
|
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue