Commit e82fa6fc authored by Jim's avatar Jim Committed by GitHub

Merge pull request #597 from xujim/master

修正present问题并添加测试用例
parents ec334dcd d7d0f159
...@@ -11,7 +11,12 @@ class FirstRouteWidget extends StatelessWidget { ...@@ -11,7 +11,12 @@ class FirstRouteWidget extends StatelessWidget {
title: Text('First Route'), title: Text('First Route'),
), ),
body: Center( body: Center(
child: RaisedButton( child:
Column(
mainAxisAlignment: MainAxisAlignment.center,
children:
<Widget>[
RaisedButton(
child: Text('Open second route'), child: Text('Open second route'),
onPressed: () { onPressed: () {
print("open second page!"); print("open second page!");
...@@ -21,6 +26,19 @@ class FirstRouteWidget extends StatelessWidget { ...@@ -21,6 +26,19 @@ class FirstRouteWidget extends StatelessWidget {
}); });
}, },
), ),
RaisedButton(
child: Text('Present second route'),
onPressed: () {
print("Present second page!");
FlutterBoost.singleton.open("second",urlParams:{"present":true}).then((Map value) {
print(
"call me when page is finished. did recieve second route result $value");
});
},
),
],
),
), ),
); );
} }
......
...@@ -53,10 +53,10 @@ ...@@ -53,10 +53,10 @@
}else{ }else{
[_engine runWithEntrypoint:nil]; [_engine runWithEntrypoint:nil];
} }
_dummy = [[FLBFlutterViewContainer alloc] initWithEngine:_engine // _dummy = [[FLBFlutterViewContainer alloc] initWithEngine:_engine
nibName:nil // nibName:nil
bundle:nil]; // bundle:nil];
_dummy.name = kIgnoreMessageWithName; // _dummy.name = kIgnoreMessageWithName;
} }
return self; return self;
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
- (void)atacheToViewController:(FlutterViewController *)vc - (void)atacheToViewController:(FlutterViewController *)vc
{ {
if(_engine.viewController != vc){ if(_engine.viewController != vc){
[(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO]; // [(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
_engine.viewController = vc; _engine.viewController = vc;
} }
} }
...@@ -114,8 +114,8 @@ ...@@ -114,8 +114,8 @@
- (void)prepareEngineIfNeeded - (void)prepareEngineIfNeeded
{ {
[(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO]; // [(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
NSLog(@"[XDEBUG]---surface changed--reset-"); // NSLog(@"[XDEBUG]---surface changed--reset-");
// [self detach]; // [self detach];
} }
......
...@@ -51,6 +51,9 @@ ...@@ -51,6 +51,9 @@
if(self = [super initWithEngine:FLUTTER_APP.flutterProvider.engine if(self = [super initWithEngine:FLUTTER_APP.flutterProvider.engine
nibName:_flbNibName nibName:_flbNibName
bundle:_flbNibBundle]){ bundle:_flbNibBundle]){
//NOTES:在present页面时,默认是全屏,如此可以触发底层VC的页面事件。否则不会触发而导致异常
self.modalPresentationStyle = UIModalPresentationFullScreen;
[self _setup]; [self _setup];
} }
return self; return self;
...@@ -219,6 +222,13 @@ static NSUInteger kInstanceCounter = 0; ...@@ -219,6 +222,13 @@ static NSUInteger kInstanceCounter = 0;
uniqueId:self.uniqueIDString]; uniqueId:self.uniqueIDString];
[[[UIApplication sharedApplication] keyWindow] endEditing:YES]; [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
//NOTES:因为UIViewController在present view后dismiss其页面的view disappear会发生在下一个页面view appear之后,从而让当前engine持有的vc inactive,此处可驱使其重新resume
if (![self.uniqueIDString isEqualToString:[(FLBFlutterViewContainer*)FLUTTER_VC uniqueIDString]])
{
[FLUTTER_APP resume];
}
} }
...@@ -229,6 +239,14 @@ static NSUInteger kInstanceCounter = 0; ...@@ -229,6 +239,14 @@ static NSUInteger kInstanceCounter = 0;
params:_params params:_params
uniqueId:self.uniqueIDString]; uniqueId:self.uniqueIDString];
[super viewDidDisappear:animated]; [super viewDidDisappear:animated];
//NOTES:因为UIViewController在present view后dismiss其页面的view disappear会发生在下一个页面view appear之后,导致当前engine持有的VC被surfaceUpdate(NO),从而销毁底层的raster。此处是考虑到这种情形,重建surface
if (FLUTTER_VC.beingPresented || self.beingDismissed || ![self.uniqueIDString isEqualToString:[(FLBFlutterViewContainer*)FLUTTER_VC uniqueIDString]])
{
[FLUTTER_APP resume];
[(FLBFlutterViewContainer*)FLUTTER_VC surfaceUpdated:YES];
}
// instead of calling [super viewDidDisappear:animated];, call super's super // instead of calling [super viewDidDisappear:animated];, call super's super
// struct objc_super target = { // struct objc_super target = {
// .super_class = class_getSuperclass([FlutterViewController class]), // .super_class = class_getSuperclass([FlutterViewController class]),
......
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