Skip to content

Commit

Permalink
[iOS] 路由采用统一参数配置,push部分配置完成
Browse files Browse the repository at this point in the history
  • Loading branch information
luckysmg authored and ColdPaleLight committed May 12, 2021
1 parent 14a3be5 commit c085258
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 41 deletions.
2 changes: 1 addition & 1 deletion example/ios/Runner/MyFlutterBoostDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ - (void) pushNativeRoute:(NSString *) pageName arguments:(NSDictionary *) argume
}
}

- (void)pushFlutterRoute:(FlutterBoostPushOptions *)options {
- (void)pushFlutterRoute:(FlutterBoostRouteOptions *)options {

FlutterEngine* engine = [[FlutterBoost instance] engine];
engine.viewController = nil;
Expand Down
42 changes: 12 additions & 30 deletions example/ios/Runner/UIViewControllerDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,25 @@ - (void)viewDidLoad {

- (IBAction)pushFlutterPage:(id)sender {


[[FlutterBoost instance] open:@"flutterPage" arguments:@{@"animated":@(YES)} completion:^(BOOL completion) {
FlutterBoostRouteOptions* options = [[FlutterBoostRouteOptions alloc]init];
options.pageName = @"flutterPage";
options.arguments = @{@"animated":@(YES)};
options.completion = ^(BOOL completion) {

} ];


// [FlutterBoostPlugin open:@"first" urlParams:@{kPageCallBackId:@"MycallbackId#1"} exts:@{@"animated":@(YES)} onPageFinished:^(NSDictionary *result) {
// NSLog(@"call me when page finished, and your result is:%@", result);
// } completion:^(BOOL f) {
// NSLog(@"page is opened");
// }];

};

[[FlutterBoost instance]open:options];
}

- (IBAction)present:(id)sender {

[[FlutterBoost instance] open:@"secondStateful" arguments:@{@"present":@(YES)} completion:^(BOOL completion) {


}];

// [FlutterBoostPlugin open:@"second" urlParams:@{@"present":@(YES),kPageCallBackId:@"MycallbackId#2"} exts:@{@"animated":@(YES)} onPageFinished:^(NSDictionary *result) {
// NSLog(@"call me when page finished, and your result is:%@", result);
// } completion:^(BOOL f) {
// NSLog(@"page is presented");
// }];
}
FlutterBoostRouteOptions* options = [[FlutterBoostRouteOptions alloc]init];
options.pageName = @"secondStateful";
options.arguments = @{@"present":@(YES)};
options.completion = ^(BOOL completion) {

/*
#pragma mark - Navigation
};

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
[[FlutterBoost instance]open:options];
}
*/

@end
5 changes: 3 additions & 2 deletions ios/Classes/FlutterBoost.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
/// @param uniqueId 关闭的页面唯一ID符
- (void)close:(NSString *)uniqueId;

/// ( 已废弃,之后有新参数可能不支持此方法 !!! )
/// 打开新页面(默认以push方式),混合栈推荐使用的用于操作页面的接口
/// 通过arguments可以设置为以present方式打开页面:arguments:@{@"present":@(YES)}
/// @param pageName 打开的页面资源定位符
Expand All @@ -75,9 +76,9 @@
- (void)open:(NSString *)pageName arguments:(NSDictionary *)arguments completion:(void(^)(BOOL)) completion;


/// 利用启动参数配置开启新页面
/// (推荐使用)利用启动参数配置开启新页面
/// @param options 配置参数
- (void)open:(FlutterBoostPushOptions* )options;
- (void)open:(FlutterBoostRouteOptions* )options;


/// 将原生页面的数据回传到flutter侧的页面的的方法
Expand Down
4 changes: 2 additions & 2 deletions ios/Classes/FlutterBoost.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ - (FlutterViewController *) currentViewController{
#pragma mark - open/close Page
- (void)open:(NSString *)pageName arguments:(NSDictionary *)arguments completion:(void(^)(BOOL)) completion {

FlutterBoostPushOptions* options = [[FlutterBoostPushOptions alloc]init];
FlutterBoostRouteOptions* options = [[FlutterBoostRouteOptions alloc]init];
options.pageName = pageName;
options.arguments = arguments;
options.completion = completion;

[self.plugin.delegate pushFlutterRoute:options];
}

- (void)open:(FlutterBoostPushOptions* )options{
- (void)open:(FlutterBoostRouteOptions* )options{
[self.plugin.delegate pushFlutterRoute:options];
}

Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/FlutterBoostDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- (FlutterEngine*) engine;
@required
- (void) pushNativeRoute:(NSString *) pageName arguments:(NSDictionary *) arguments;
- (void) pushFlutterRoute:(FlutterBoostPushOptions*)options;
- (void) pushFlutterRoute:(FlutterBoostRouteOptions*)options;
- (void) popRoute:(NSString *)uniqueId;
@end

2 changes: 1 addition & 1 deletion ios/Classes/FlutterBoostPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ -(void)pushNativeRoute:(FBCommonParams*)input error:(FlutterError *_Nullable *_N
}

-(void)pushFlutterRoute:(FBCommonParams*)input error:(FlutterError *_Nullable *_Nonnull)error {
FlutterBoostPushOptions* options = [[FlutterBoostPushOptions alloc]init];
FlutterBoostRouteOptions* options = [[FlutterBoostRouteOptions alloc]init];
options.pageName = input.pageName;
options.uniqueId = input.uniqueId;
options.arguments = input.arguments;
Expand Down
6 changes: 3 additions & 3 deletions ios/Classes/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@
@end


///新页面打开参数配置
@interface FlutterBoostPushOptions : NSObject
///路由参数配置
@interface FlutterBoostRouteOptions : NSObject

///页面在路由表中的名字
@property(nonatomic, strong) NSString* pageName;

///参数
@property(nonatomic, strong) NSDictionary* arguments;

///参数回传的回调,仅在原生->flutter页面的时候有用
///参数回传的回调闭包,仅在原生->flutter页面的时候有用
@property(nonatomic, strong) void(^onPageFinished)(NSDictionary*);

///open方法完成后的回调,仅在原生->flutter页面的时候有用
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/Options.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ + (FlutterBoostSetupOptions*)createDefault{
@end


@implementation FlutterBoostPushOptions
@implementation FlutterBoostRouteOptions

@end

Expand Down

0 comments on commit c085258

Please sign in to comment.