Commit dd87a8bf authored by 余玠's avatar 余玠

Merge branch 'master' into feature/flutter_1.9_upgrade

parents 368ae69d 87a43534
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait"> <device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/> <adaptation id="fullscreen"/>
</device> </device>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<scenes> <scenes/>
<!--Flutter View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document> </document>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
</dict>
</plist>
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
...@@ -45,9 +45,22 @@ ...@@ -45,9 +45,22 @@
- (FlutterViewController *)currentViewController; - (FlutterViewController *)currentViewController;
#pragma mark - broadcast event to/from flutter #pragma mark - broadcast event to/from flutter
/**
* Native层往Dart层发送事件,事件名称通过eventName指定
*
* @param eventName 事件名称
* @param arguments 参数
*/
- (void)sendEvent:(NSString *)eventName - (void)sendEvent:(NSString *)eventName
arguments:(NSDictionary *)arguments; arguments:(NSDictionary *)arguments;
/**
* 添加监听Dart层调用Native层的事件
*
* @param name 事件名称
* @param listner 事件监听器
*/
- (FLBVoidCallback)addEventListener:(FLBEventListener)listner - (FLBVoidCallback)addEventListener:(FLBEventListener)listner
forName:(NSString *)name; forName:(NSString *)name;
......
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
- (void)resume - (void)resume
{ {
[[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"]; [[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"];
[(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:YES];
} }
- (void)inactive - (void)inactive
...@@ -110,6 +109,7 @@ ...@@ -110,6 +109,7 @@
- (void)atacheToViewController:(FlutterViewController *)vc - (void)atacheToViewController:(FlutterViewController *)vc
{ {
if(_engine.viewController != vc){ if(_engine.viewController != vc){
[(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
_engine.viewController = vc; _engine.viewController = vc;
} }
} }
...@@ -123,11 +123,9 @@ ...@@ -123,11 +123,9 @@
- (void)prepareEngineIfNeeded - (void)prepareEngineIfNeeded
{ {
// if ([_dummy respondsToSelector:@selector(setEnableForRunnersBatch:)]) { [(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
// [_dummy setEnableForRunnersBatch:YES]; NSLog(@"[XDEBUG]---surface changed--reset-");
// } // [self detach];
[self detach];
[_dummy surfaceUpdated:YES];
} }
@end @end
......
...@@ -38,7 +38,12 @@ ...@@ -38,7 +38,12 @@
+ (void)didInitPageContainer:(void (^)(NSNumber *))result pageName:(NSString *)pageName params:(NSDictionary *)params uniqueId:(NSString *)uniqueId; + (void)didInitPageContainer:(void (^)(NSNumber *))result pageName:(NSString *)pageName params:(NSDictionary *)params uniqueId:(NSString *)uniqueId;
+ (void)willDeallocPageContainer:(void (^)(NSNumber *))result pageName:(NSString *)pageName params:(NSDictionary *)params uniqueId:(NSString *)uniqueId; + (void)willDeallocPageContainer:(void (^)(NSNumber *))result pageName:(NSString *)pageName params:(NSDictionary *)params uniqueId:(NSString *)uniqueId;
/**
* Native层往Dart层发送事件,事件名称通过eventName指定
*
* @param eventName 事件名称
* @param arguments 参数
*/
+ (void)sendEvent:(NSString *)eventName + (void)sendEvent:(NSString *)eventName
arguments:(NSDictionary *)arguments; arguments:(NSDictionary *)arguments;
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#import "BoostMessageChannel.h" #import "BoostMessageChannel.h"
#import "FLBFlutterContainerManager.h" #import "FLBFlutterContainerManager.h"
#import "FlutterBoostPlugin_private.h" #import "FlutterBoostPlugin_private.h"
#import <objc/message.h>
#import <objc/runtime.h>
#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application #define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application
#define FLUTTER_VIEW FLUTTER_APP.flutterViewController.view #define FLUTTER_VIEW FLUTTER_APP.flutterViewController.view
...@@ -137,7 +139,6 @@ static NSUInteger kInstanceCounter = 0; ...@@ -137,7 +139,6 @@ static NSUInteger kInstanceCounter = 0;
- (void)attatchFlutterEngine - (void)attatchFlutterEngine
{ {
[FLUTTER_APP.flutterProvider prepareEngineIfNeeded];
[FLUTTER_APP.flutterProvider atacheToViewController:self]; [FLUTTER_APP.flutterProvider atacheToViewController:self];
} }
...@@ -161,16 +162,6 @@ static NSUInteger kInstanceCounter = 0; ...@@ -161,16 +162,6 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
if([FLUTTER_APP contains:self]){
[self surfaceUpdated:NO];
[self detatchFlutterEngine];
}else{
[self attatchFlutterEngine];
[self surfaceUpdated:YES];
}
[FLUTTER_APP resume];
//For new page we should attach flutter view in view will appear //For new page we should attach flutter view in view will appear
//for better performance. //for better performance.
...@@ -185,7 +176,13 @@ static NSUInteger kInstanceCounter = 0; ...@@ -185,7 +176,13 @@ static NSUInteger kInstanceCounter = 0;
[FlutterBoostPlugin sharedInstance].fParams = _params; [FlutterBoostPlugin sharedInstance].fParams = _params;
} }
[super viewWillAppear:animated]; //instead of calling [super viewWillAppear:animated];, call super's super
struct objc_super target = {
.super_class = class_getSuperclass([FlutterViewController class]),
.receiver = self,
};
NSMethodSignature * (*callSuper)(struct objc_super *, SEL, BOOL animated) = (__typeof__(callSuper))objc_msgSendSuper;
callSuper(&target, @selector(viewWillAppear:), animated);
} }
- (void)viewDidAppear:(BOOL)animated - (void)viewDidAppear:(BOOL)animated
...@@ -194,13 +191,15 @@ static NSUInteger kInstanceCounter = 0; ...@@ -194,13 +191,15 @@ static NSUInteger kInstanceCounter = 0;
//Ensure flutter view is attached. //Ensure flutter view is attached.
[self attatchFlutterEngine]; [self attatchFlutterEngine];
[FLUTTER_APP resume];
[BoostMessageChannel didShowPageContainer:^(NSNumber *result) {} [BoostMessageChannel didShowPageContainer:^(NSNumber *result) {}
pageName:_name pageName:_name
params:_params params:_params
uniqueId:self.uniqueIDString]; uniqueId:self.uniqueIDString];
//NOTES:务必在show之后再update,否则有闪烁
[self surfaceUpdated:YES];
[super viewDidAppear:animated]; [super viewDidAppear:animated];
} }
...@@ -217,14 +216,17 @@ static NSUInteger kInstanceCounter = 0; ...@@ -217,14 +216,17 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidDisappear:(BOOL)animated - (void)viewDidDisappear:(BOOL)animated
{ {
[FLUTTER_APP resume];
[BoostMessageChannel didDisappearPageContainer:^(NSNumber *result) {} [BoostMessageChannel didDisappearPageContainer:^(NSNumber *result) {}
pageName:_name pageName:_name
params:_params params:_params
uniqueId:self.uniqueIDString]; uniqueId:self.uniqueIDString];
[super viewDidDisappear:animated]; // instead of calling [super viewDidDisappear:animated];, call super's super
[FLUTTER_APP resume]; struct objc_super target = {
.super_class = class_getSuperclass([FlutterViewController class]),
.receiver = self,
};
NSMethodSignature * (*callSuper)(struct objc_super *, SEL, BOOL animated) = (__typeof__(callSuper))objc_msgSendSuper;
callSuper(&target, @selector(viewDidDisappear:), animated);
} }
- (void)installSplashScreenViewIfNecessary { - (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