Commit 1b152753 authored by 余玠's avatar 余玠

重构函数命名及添加注释

parent 25a4bc3d
...@@ -53,14 +53,14 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -53,14 +53,14 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - handle messages #pragma mark - handle messages
- (void)close:(NSString *)uid - (void)close:(NSString *)uid
result:(NSDictionary *)result result:(NSDictionary *)resultData
exts:(NSDictionary *)exts exts:(NSDictionary *)exts
completion:(void (^)(BOOL))completion; completion:(void (^)(BOOL))completion;
- (void)open:(NSString *)url - (void)open:(NSString *)uri
urlParams:(NSDictionary *)urlParams urlParams:(NSDictionary *)urlParams
exts:(NSDictionary *)exts exts:(NSDictionary *)exts
reult:(void (^)(NSDictionary *))resultCallback onPageFinished:(void (^)(NSDictionary *))resultCallback
completion:(void (^)(BOOL))completion; completion:(void (^)(BOOL))completion;
......
...@@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
* 基于Native平台实现页面打开,Dart层的页面打开能力依赖于这个函数实现;Native或者Dart侧不建议直接使用这个函数。应直接使用FlutterBoost封装的函数 * 基于Native平台实现页面打开,Dart层的页面打开能力依赖于这个函数实现;Native或者Dart侧不建议直接使用这个函数。应直接使用FlutterBoost封装的函数
* *
* @param url 打开的页面资源定位符 * @param url 打开的页面资源定位符
* @param urlParams 传人页面的参数, 注意 * @param urlParams 传人页面的参数; 若有特殊逻辑,可以通过这个参数设置回调的id
* @param exts 额外参数 * @param exts 额外参数
* @param completion 打开页面的即时回调,页面一旦打开即回调 * @param completion 打开页面的即时回调,页面一旦打开即回调
*/ */
...@@ -52,9 +52,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -52,9 +52,9 @@ NS_ASSUME_NONNULL_BEGIN
completion:(void (^)(BOOL finished))completion; completion:(void (^)(BOOL finished))completion;
/** /**
* 基于Native平台实现页面打开,Dart层的页面关闭能力依赖于这个函数实现;Native或者Dart侧不建议直接使用这个函数。应直接使用FlutterBoost封装的函数 * 基于Native平台实现页面关闭,Dart层的页面关闭能力依赖于这个函数实现;Native或者Dart侧不建议直接使用这个函数。应直接使用FlutterBoost封装的函数
* *
* @param uid 打开的页面唯一ID符 * @param uid 关闭的页面唯一ID符
* @param result 页面要返回的结果(给上一个页面),会作为页面返回函数的回调参数 * @param result 页面要返回的结果(给上一个页面),会作为页面返回函数的回调参数
* @param exts 额外参数 * @param exts 额外参数
* @param completion 关闭页面的即时回调,页面一旦关闭即回调 * @param completion 关闭页面的即时回调,页面一旦关闭即回调
......
...@@ -30,6 +30,12 @@ ...@@ -30,6 +30,12 @@
#pragma mark - Initializer #pragma mark - Initializer
+ (instancetype)sharedInstance; + (instancetype)sharedInstance;
/**
* 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中
*
* @param platform 平台层实现FLBPlatform的对象
* @param callback 启动之后回调
*/
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
...@@ -46,14 +52,32 @@ ...@@ -46,14 +52,32 @@
forName:(NSString *)name; forName:(NSString *)name;
#pragma mark - open/close Page #pragma mark - open/close Page
/**
* 关闭页面,混合栈推荐使用的用于操作页面的接口
*
* @param uniqueId 关闭的页面唯一ID符
* @param resultData 页面要返回的结果(给上一个页面),会作为页面返回函数的回调参数
* @param exts 额外参数
* @param completion 关闭页面的即时回调,页面一旦关闭即回调
*/
+ (void)close:(NSString *)uniqueId + (void)close:(NSString *)uniqueId
result:(NSDictionary *)result result:(NSDictionary *)resultData
exts:(NSDictionary *)exts exts:(NSDictionary *)exts
completion:(void (^)(BOOL))completion; completion:(void (^)(BOOL))completion;
/**
* 打开新页面,混合栈推荐使用的用于操作页面的接口
*
* @param url 打开的页面资源定位符
* @param urlParams 传人页面的参数; 若有特殊逻辑,可以通过这个参数设置回调的id
* @param exts 额外参数
* @param resultCallback 当页面结束返回时执行的回调,通过这个回调可以取得页面的返回数据,如close函数传入的resultData
* @param completion 打开页面的即时回调,页面一旦打开即回调
*/
+ (void)open:(NSString *)url + (void)open:(NSString *)url
urlParams:(NSDictionary *)urlParams urlParams:(NSDictionary *)urlParams
exts:(NSDictionary *)exts exts:(NSDictionary *)exts
reult:(void (^)(NSDictionary *))resultCallback onPageFinished:(void (^)(NSDictionary *))resultCallback
completion:(void (^)(BOOL))completion; completion:(void (^)(BOOL))completion;
@end @end
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
[[FlutterBoostPlugin sharedInstance].application open:url [[FlutterBoostPlugin sharedInstance].application open:url
urlParams:urlParams urlParams:urlParams
exts:exts exts:exts
reult:result onPageFinished:result
completion:^(BOOL r) {}]; completion:^(BOOL r) {}];
}else if([@"pageOnStart" isEqualToString:call.method]){ }else if([@"pageOnStart" isEqualToString:call.method]){
NSMutableDictionary *pageInfo = [NSMutableDictionary new]; NSMutableDictionary *pageInfo = [NSMutableDictionary new];
...@@ -163,13 +163,13 @@ ...@@ -163,13 +163,13 @@
} }
#pragma mark - open/close Page #pragma mark - open/close Page
+ (void)open:(NSString *)url urlParams:(NSDictionary *)urlParams exts:(NSDictionary *)exts reult:(void (^)(NSDictionary *))resultCallback completion:(void (^)(BOOL))completion{ + (void)open:(NSString *)url urlParams:(NSDictionary *)urlParams exts:(NSDictionary *)exts onPageFinished:(void (^)(NSDictionary *))resultCallback completion:(void (^)(BOOL))completion{
id<FLBFlutterApplicationInterface> app = [[FlutterBoostPlugin sharedInstance] application]; id<FLBFlutterApplicationInterface> app = [[FlutterBoostPlugin sharedInstance] application];
[app open:url urlParams:urlParams exts:exts reult:resultCallback completion:completion]; [app open:url urlParams:urlParams exts:exts onPageFinished:resultCallback completion:completion];
} }
+ (void)close:(NSString *)uniqueId result:(NSDictionary *)result exts:(NSDictionary *)exts completion:(void (^)(BOOL))completion{ + (void)close:(NSString *)uniqueId result:(NSDictionary *)resultData exts:(NSDictionary *)exts completion:(void (^)(BOOL))completion{
id<FLBFlutterApplicationInterface> app = [[FlutterBoostPlugin sharedInstance] application]; id<FLBFlutterApplicationInterface> app = [[FlutterBoostPlugin sharedInstance] application];
[app close:uniqueId result:result exts:exts completion:completion]; [app close:uniqueId result:resultData exts:exts completion:completion];
} }
@end @end
...@@ -152,18 +152,18 @@ ...@@ -152,18 +152,18 @@
} }
- (void)close:(NSString *)uniqueId - (void)close:(NSString *)uniqueId
result:(NSDictionary *)result result:(NSDictionary *)resultData
exts:(NSDictionary *)exts exts:(NSDictionary *)exts
completion:(void (^)(BOOL))completion completion:(void (^)(BOOL))completion
{ {
[self.platform close:uniqueId [self.platform close:uniqueId
result:result result:resultData
exts:exts exts:exts
completion:completion]; completion:completion];
if(_pageResultCallbacks[uniqueId]){ if(_pageResultCallbacks[uniqueId]){
void (^cb)(NSDictionary *) = _pageResultCallbacks[uniqueId]; void (^cb)(NSDictionary *) = _pageResultCallbacks[uniqueId];
cb(result); cb(resultData);
[_pageResultCallbacks removeObjectForKey:uniqueId]; [_pageResultCallbacks removeObjectForKey:uniqueId];
} }
} }
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
- (void)open:(NSString *)url - (void)open:(NSString *)url
urlParams:(NSDictionary *)urlParams urlParams:(NSDictionary *)urlParams
exts:(NSDictionary *)exts exts:(NSDictionary *)exts
reult:(void (^)(NSDictionary *))resultCallback onPageFinished:(void (^)(NSDictionary *))resultCallback
completion:(void (^)(BOOL))completion completion:(void (^)(BOOL))completion
{ {
NSString *cid = urlParams[kPageCallBackId]; NSString *cid = urlParams[kPageCallBackId];
......
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