Commit f44b7392 authored by 余玠's avatar 余玠

update documents

parent adcb0e5b
...@@ -86,16 +86,16 @@ Use FLBFlutterAppDelegate as the superclass of your AppDelegate ...@@ -86,16 +86,16 @@ Use FLBFlutterAppDelegate as the superclass of your AppDelegate
Implement FLBPlatform protocol methods for your App. Implement FLBPlatform protocol methods for your App.
```objc ```objc
@interface DemoRouter : NSObject<FLBPlatform> @interface PlatformRouterImp : NSObject<FLBPlatform>
@property (nonatomic,strong) UINavigationController *navigationController; @property (nonatomic,strong) UINavigationController *navigationController;
+ (DemoRouter *)sharedRouter; + (PlatformRouterImp *)sharedRouter;
@end @end
@implementation DemoRouter @implementation PlatformRouterImp
- (void)openPage:(NSString *)name - (void)openPage:(NSString *)name
params:(NSDictionary *)params params:(NSDictionary *)params
...@@ -129,11 +129,12 @@ Implement FLBPlatform protocol methods for your App. ...@@ -129,11 +129,12 @@ Implement FLBPlatform protocol methods for your App.
Initialize FlutterBoost with FLBPlatform at the beginning of your App. Initialize FlutterBoost with FLBPlatform at the beginning of your App, such as AppDelegate.
```objc ```objc
PlatformRouterImp *router = [PlatformRouterImp new];
[FlutterBoostPlugin.sharedInstance startFlutterWithPlatform:router [FlutterBoostPlugin.sharedInstance startFlutterWithPlatform:router
onStart:^(id engine) { onStart:^(FlutterEngine *engine) {
}]; }];
``` ```
...@@ -202,6 +203,23 @@ iOS ...@@ -202,6 +203,23 @@ iOS
[vc setName:name params:params]; [vc setName:name params:params];
[self.navigationController presentViewController:vc animated:animated completion:^{}]; [self.navigationController presentViewController:vc animated:animated completion:^{}];
``` ```
However, in this way, you cannot get the page data result after the page finished. We suggest you implement the platform page router like the way mentioned above. And finally open/close the VC as following:
```objc
//push the page
[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");
}];
//prsent the page
[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");
}];
//close the page
[FlutterBoostPlugin close:yourUniqueId result:yourdata exts:exts completion:nil];
```
Android Android
......
...@@ -82,16 +82,16 @@ class _MyAppState extends State<MyApp> { ...@@ -82,16 +82,16 @@ class _MyAppState extends State<MyApp> {
为您的应用程序实现FLBPlatform协议方法。 为您的应用程序实现FLBPlatform协议方法。
```objectivec ```objectivec
@interface DemoRouter : NSObject<FLBPlatform> @interface PlatformRouterImp : NSObject<FLBPlatform>
@property (nonatomic,strong) UINavigationController *navigationController; @property (nonatomic,strong) UINavigationController *navigationController;
+ (DemoRouter *)sharedRouter; + (PlatformRouterImp *)sharedRouter;
@end @end
@implementation DemoRouter @implementation PlatformRouterImp
- (void)openPage:(NSString *)name - (void)openPage:(NSString *)name
params:(NSDictionary *)params params:(NSDictionary *)params
...@@ -127,9 +127,10 @@ class _MyAppState extends State<MyApp> { ...@@ -127,9 +127,10 @@ class _MyAppState extends State<MyApp> {
在应用程序开头使用FLBPlatform初始化FlutterBoost。 在应用程序开头使用FLBPlatform初始化FlutterBoost。
```的ObjectiveC ```objc
PlatformRouterImp *router = [PlatformRouterImp new];
[FlutterBoostPlugin.sharedInstance startFlutterWithPlatformrouter [FlutterBoostPlugin.sharedInstance startFlutterWithPlatformrouter
onStart:^(id engine){ onStart^FlutterEngine *engine{
}]; }];
``` ```
...@@ -193,6 +194,24 @@ public class MyApplication extends FlutterApplication { ...@@ -193,6 +194,24 @@ public class MyApplication extends FlutterApplication {
[self.navigationController presentViewController:vc animated:animated completion:^{}]; [self.navigationController presentViewController:vc animated:animated completion:^{}];
``` ```
但是,这种方式无法获取页面返回的数据,建议你按上面的example实现类似于PlatformRouterImp这样的路由器,然后通过以下方式来打开/关闭页面
```objc
//push the page
[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");
}];
//prsent the page
[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");
}];
//close the page
[FlutterBoostPlugin close:yourUniqueId result:yourdata exts:exts completion:nil];
```
Android Android
```java ```java
......
...@@ -14,8 +14,7 @@ class FirstRouteWidget extends StatelessWidget { ...@@ -14,8 +14,7 @@ class FirstRouteWidget extends StatelessWidget {
onPressed: () { onPressed: () {
print("open second page!"); print("open second page!");
FlutterBoost.singleton.open("second").then((Map value) { FlutterBoost.singleton.open("second").then((Map value) {
print("did recieve second route result"); print("call me when page is finished. did recieve second route result $value");
print("did recieve second route result $value");
}); });
}, },
), ),
......
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