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

Merge pull request #597 from xujim/master

修正present问题并添加测试用例
parents ec334dcd d7d0f159
......@@ -11,15 +11,33 @@ class FirstRouteWidget extends StatelessWidget {
title: Text('First Route'),
),
body: Center(
child: RaisedButton(
child: Text('Open second route'),
onPressed: () {
print("open second page!");
FlutterBoost.singleton.open("second").then((Map value) {
print(
"call me when page is finished. did recieve second route result $value");
});
},
child:
Column(
mainAxisAlignment: MainAxisAlignment.center,
children:
<Widget>[
RaisedButton(
child: Text('Open second route'),
onPressed: () {
print("open second page!");
FlutterBoost.singleton.open("second").then((Map value) {
print(
"call me when page is finished. did recieve second route result $value");
});
},
),
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 @@
}else{
[_engine runWithEntrypoint:nil];
}
_dummy = [[FLBFlutterViewContainer alloc] initWithEngine:_engine
nibName:nil
bundle:nil];
_dummy.name = kIgnoreMessageWithName;
// _dummy = [[FLBFlutterViewContainer alloc] initWithEngine:_engine
// nibName:nil
// bundle:nil];
// _dummy.name = kIgnoreMessageWithName;
}
return self;
......@@ -100,7 +100,7 @@
- (void)atacheToViewController:(FlutterViewController *)vc
{
if(_engine.viewController != vc){
[(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
// [(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
_engine.viewController = vc;
}
}
......@@ -114,8 +114,8 @@
- (void)prepareEngineIfNeeded
{
[(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
NSLog(@"[XDEBUG]---surface changed--reset-");
// [(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
// NSLog(@"[XDEBUG]---surface changed--reset-");
// [self detach];
}
......
......@@ -51,6 +51,9 @@
if(self = [super initWithEngine:FLUTTER_APP.flutterProvider.engine
nibName:_flbNibName
bundle:_flbNibBundle]){
//NOTES:在present页面时,默认是全屏,如此可以触发底层VC的页面事件。否则不会触发而导致异常
self.modalPresentationStyle = UIModalPresentationFullScreen;
[self _setup];
}
return self;
......@@ -219,6 +222,13 @@ static NSUInteger kInstanceCounter = 0;
uniqueId:self.uniqueIDString];
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
[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;
params:_params
uniqueId:self.uniqueIDString];
[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
// struct objc_super target = {
// .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