Commit f01f0fe8 authored by 余玠's avatar 余玠

适配v1.12.13. 同时解决多次surfaceUpdated问题,通过这个解法,每次显示只需要调用一次。但该解法编译后动画时候会abort,不知道是否有关系——之前也出现过,但非必现

parent 7b8aa3cf
......@@ -32,6 +32,37 @@
#define FLUTTER_VIEW FLUTTER_APP.flutterViewController.view
#define FLUTTER_VC FLUTTER_APP.flutterViewController
@interface FlutterViewController (bridgeToviewDidDisappear)
- (void)flushOngoingTouches;
- (void)bridge_viewDidDisappear:(BOOL)animated;
- (void)bridge_viewWillAppear:(BOOL)animated;
@end
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincomplete-implementation"
@implementation FlutterViewController (bridgeToviewDidDisappear)
- (void)bridge_viewDidDisappear:(BOOL)animated{
// TRACE_EVENT0("flutter", "viewDidDisappear");
[self flushOngoingTouches];
[super viewDidDisappear:animated];
}
- (void)bridge_viewWillAppear:(BOOL)animated{
// TRACE_EVENT0("flutter", "viewWillAppear");
// if (_engineNeedsLaunch) {
// [_engine.get() launchEngine:nil libraryURI:nil];
// [_engine.get() setViewController:self];
// _engineNeedsLaunch = NO;
// }
[FLUTTER_APP inactive];
[super viewWillAppear:animated];
}
@end
#pragma pop
@interface FLB2FlutterViewContainer ()
@property (nonatomic,strong,readwrite) NSDictionary *params;
@property (nonatomic,assign) long long identifier;
......@@ -52,6 +83,13 @@
return self;
}
- (instancetype)initWithProject:(FlutterDartProject*)projectOrNil
nibName:(NSString*)nibNameOrNil
bundle:(NSBundle*)nibBundleOrNil {
NSAssert(NO, @"unsupported init method!");
return nil;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
if (self = [super initWithCoder: aDecoder]) {
NSAssert(NO, @"unsupported init method!");
......@@ -159,7 +197,9 @@ static NSUInteger kInstanceCounter = 0;
{
//For new page we should attach flutter view in view will appear
//for better performance.
[self attatchFlutterEngine];
[BoostMessageChannel willShowPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
......@@ -171,7 +211,8 @@ static NSUInteger kInstanceCounter = 0;
[FlutterBoostPlugin2 sharedInstance].fParams = _params;
}
[super viewWillAppear:animated];
[super bridge_viewWillAppear:animated];
[self.view setNeedsLayout];//TODO:通过param来设定
}
- (void)viewDidAppear:(BOOL)animated
......@@ -185,8 +226,9 @@ static NSUInteger kInstanceCounter = 0;
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
//NOTES:务必在show之后再update,否则有闪烁
//NOTES:务必在show之后再update,否则有闪烁; 或导致侧滑返回时上一个页面会和top页面内容一样
[self surfaceUpdated:YES];
[super viewDidAppear:animated];
}
......@@ -198,12 +240,6 @@ 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:[(FLB2FlutterViewContainer*)FLUTTER_VC uniqueIDString]])
{
[FLUTTER_APP resume];
}
}
......@@ -213,15 +249,8 @@ static NSUInteger kInstanceCounter = 0;
pageName:_name
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:[(FLB2FlutterViewContainer*)FLUTTER_VC uniqueIDString]])
{
[FLUTTER_APP resume];
[(FLB2FlutterViewContainer*)FLUTTER_VC surfaceUpdated:YES];
}
[super bridge_viewDidDisappear:animated];
}
- (void)installSplashScreenViewIfNecessary {
......
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