Commit 951a88a5 authored by 余玠's avatar 余玠

优化接口封装

parent 62d3504f
...@@ -21,18 +21,23 @@ ...@@ -21,18 +21,23 @@
completion:(void (^)(BOOL))completion completion:(void (^)(BOOL))completion
{ {
BOOL animated = [exts[@"animated"] boolValue]; BOOL animated = [exts[@"animated"] boolValue];
if([params[@"present"] boolValue]){
FLBFlutterViewContainer *vc = FLBFlutterViewContainer.new; FLBFlutterViewContainer *vc = FLBFlutterViewContainer.new;
[vc setName:name params:params]; [vc setName:name params:params];
[self.navigationController presentViewController:vc animated:animated completion:^{ [self.navigationController pushViewController:vc animated:animated];
if(completion) completion(YES); if(completion) completion(YES);
}]; }
}else{
- (void)present:(NSString *)name
urlParams:(NSDictionary *)params
exts:(NSDictionary *)exts
completion:(void (^)(BOOL))completion
{
BOOL animated = [exts[@"animated"] boolValue];
FLBFlutterViewContainer *vc = FLBFlutterViewContainer.new; FLBFlutterViewContainer *vc = FLBFlutterViewContainer.new;
[vc setName:name params:params]; [vc setName:name params:params];
[self.navigationController pushViewController:vc animated:animated]; [self.navigationController presentViewController:vc animated:animated completion:^{
if(completion) completion(YES); if(completion) completion(YES);
} }];
} }
- (void)close:(NSString *)uid - (void)close:(NSString *)uid
......
...@@ -51,6 +51,20 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -51,6 +51,20 @@ NS_ASSUME_NONNULL_BEGIN
exts:(NSDictionary *)exts exts:(NSDictionary *)exts
completion:(void (^)(BOOL finished))completion; completion:(void (^)(BOOL finished))completion;
/**
* 基于Native平台实现present页面打开,Dart层的页面打开能力依赖于这个函数实现;Native或者Dart侧不建议直接使用这个函数。应直接使用FlutterBoost封装的函数
*
* @param url 打开的页面资源定位符
* @param urlParams 传人页面的参数; 若有特殊逻辑,可以通过这个参数设置回调的id
* @param exts 额外参数
* @param completion 打开页面的即时回调,页面一旦打开即回调
*/
@optional
- (void)present:(NSString *)url
urlParams:(NSDictionary *)urlParams
exts:(NSDictionary *)exts
completion:(void (^)(BOOL finished))completion;
/** /**
* 基于Native平台实现页面关闭,Dart层的页面关闭能力依赖于这个函数实现;Native或者Dart侧不建议直接使用这个函数。应直接使用FlutterBoost封装的函数 * 基于Native平台实现页面关闭,Dart层的页面关闭能力依赖于这个函数实现;Native或者Dart侧不建议直接使用这个函数。应直接使用FlutterBoost封装的函数
* *
......
...@@ -186,11 +186,17 @@ ...@@ -186,11 +186,17 @@
} }
_callbackCache[cid] = resultCallback; _callbackCache[cid] = resultCallback;
if([urlParams[@"present"]respondsToSelector:@selector(boolValue)] && [urlParams[@"present"] boolValue] && [self.platform respondsToSelector:@selector(present:urlParams:exts:completion:)]){
[self.platform present:url
urlParams:urlParams
exts:exts
completion:completion];
}else{
[self.platform open:url [self.platform open:url
urlParams:urlParams urlParams:urlParams
exts:exts exts:exts
completion:completion]; completion:completion];
}
} }
- (void)didInitPageContainer:(NSString *)url - (void)didInitPageContainer:(NSString *)url
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment