Commit a7776b25 authored by XinLei's avatar XinLei Committed by GitHub

Merge pull request #3 from alibaba/master

sync 2019/10/29
parents dd88fee1 aa8d47d6
...@@ -5,9 +5,35 @@ ...@@ -5,9 +5,35 @@
<a href="https://mp.weixin.qq.com/s?__biz=MzU4MDUxOTI5NA==&mid=2247484367&idx=1&sn=fcbc485f068dae5de9f68d52607ea08f&chksm=fd54d7deca235ec86249a9e3714ec18be8b2d6dc580cae19e4e5113533a6c5b44dfa5813c4c3&scene=0&subscene=131&clicktime=1551942425&ascene=7&devicetype=android-28&version=2700033b&nettype=ctnet&abtest_cookie=BAABAAoACwASABMABAAklx4AVpkeAMSZHgDWmR4AAAA%3D&lang=zh_CN&pass_ticket=1qvHqOsbLBHv3wwAcw577EHhNjg6EKXqTfnOiFbbbaw%3D&wx_header=1">中文介绍</a> <a href="https://mp.weixin.qq.com/s?__biz=MzU4MDUxOTI5NA==&mid=2247484367&idx=1&sn=fcbc485f068dae5de9f68d52607ea08f&chksm=fd54d7deca235ec86249a9e3714ec18be8b2d6dc580cae19e4e5113533a6c5b44dfa5813c4c3&scene=0&subscene=131&clicktime=1551942425&ascene=7&devicetype=android-28&version=2700033b&nettype=ctnet&abtest_cookie=BAABAAoACwASABMABAAklx4AVpkeAMSZHgDWmR4AAAA%3D&lang=zh_CN&pass_ticket=1qvHqOsbLBHv3wwAcw577EHhNjg6EKXqTfnOiFbbbaw%3D&wx_header=1">中文介绍</a>
</p> </p>
# Latest News
Currently, version 1.9 of flutter is supported.
flutter branch:v1.9.1-hotfixes
FlutterBoost branch:feature/flutter_1.9_upgrade
FlutterBoost for androidx branch:feature/flutter_1.9_androidx_upgrade
```java
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: 'feature/flutter_1.9_upgrade'
```
dingding group:
<img width="200" src="https://img.alicdn.com/tfs/TB1JSzVeYY1gK0jSZTEXXXDQVXa-892-1213.jpg">
# Release Note # Release Note
Please checkout the release note for the latest 0.1.50 to see changes [0.1.50 release note](https://github.com/alibaba/flutter_boost/releases) Please checkout the release note for the latest 0.1.54 to see changes [0.1.54 release note](https://github.com/alibaba/flutter_boost/releases)
# FlutterBoost # FlutterBoost
A next-generation Flutter-Native hybrid solution. FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts.The philosophy of FlutterBoost is to use Flutter as easy as using a WebView. Managing Native pages and Flutter pages at the same time is non-trivial in an existing App. FlutterBoost takes care of page resolution for you. The only thing you need to care about is the name of the page(usually could be an URL).  A next-generation Flutter-Native hybrid solution. FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts.The philosophy of FlutterBoost is to use Flutter as easy as using a WebView. Managing Native pages and Flutter pages at the same time is non-trivial in an existing App. FlutterBoost takes care of page resolution for you. The only thing you need to care about is the name of the page(usually could be an URL). 
...@@ -290,12 +316,6 @@ Please see the example for details. ...@@ -290,12 +316,6 @@ Please see the example for details.
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
# Problem feedback group( dingding group)
<img width="200" src="https://img.alicdn.com/tfs/TB1JSzVeYY1gK0jSZTEXXXDQVXa-892-1213.jpg">
## 关于我们 ## 关于我们
阿里巴巴-闲鱼技术是国内最早也是最大规模线上运行Flutter的团队。 阿里巴巴-闲鱼技术是国内最早也是最大规模线上运行Flutter的团队。
......
...@@ -2,6 +2,27 @@ ...@@ -2,6 +2,27 @@
<img src="flutter_boost.png"> <img src="flutter_boost.png">
</p> </p>
# 项目最新动态
目前已经支持flutter 1.9版本。
对应的flutter 版本是:v1.9.1-hotfixes
flutter boost分支是:feature/flutter_1.9_upgrade
flutter boost androidx 分支是:feature/flutter_1.9_androidx_upgrade
代码引入方式:
```java
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: 'feature/flutter_1.9_upgrade'
```
# Release Note # Release Note
......
<?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"
...@@ -56,8 +56,11 @@ ...@@ -56,8 +56,11 @@
if(!_existedID[vc.uniqueIDString]){ if(!_existedID[vc.uniqueIDString]){
[_idStk addObject:vc.uniqueIDString]; [_idStk addObject:vc.uniqueIDString];
} }
_existedID[vc.uniqueIDString] = vc.uniqueIDString; _existedID[vc.uniqueIDString] = vc.name;
} }
#if DEBUG
[self dump:@"ADD"];
#endif
} }
- (void)remove:(id<FLBFlutterContainer>)vc - (void)remove:(id<FLBFlutterContainer>)vc
...@@ -66,6 +69,9 @@ ...@@ -66,6 +69,9 @@
[_existedID removeObjectForKey:vc.uniqueIDString]; [_existedID removeObjectForKey:vc.uniqueIDString];
[_idStk removeObject:vc.uniqueIDString]; [_idStk removeObject:vc.uniqueIDString];
} }
#if DEBUG
[self dump:@"REMOVE"];
#endif
} }
- (NSString *)peak - (NSString *)peak
...@@ -73,4 +79,13 @@ ...@@ -73,4 +79,13 @@
return _idStk.lastObject; return _idStk.lastObject;
} }
#if DEBUG
- (void)dump:(NSString*)flag{
NSMutableString *log = [[NSMutableString alloc]initWithFormat:@"[DEBUG]--%@--PageStack uid/name", flag];
for(NSString *uid in _idStk){
[log appendFormat:@"-->%@/%@",uid, _existedID[uid]];
}
NSLog(@"%@\n", log);
}
#endif
@end @end
...@@ -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;
......
...@@ -111,26 +111,16 @@ ...@@ -111,26 +111,16 @@
return _instance; return _instance;
} }
- (id<FLBFlutterApplicationInterface>)application
{
return _application;
}
- (id<FLBAbstractFactory>)factory
{
return _factory;
}
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
{ {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
__weak __typeof__(self) weakSelf = self;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
self->_factory = FLBFactory.new; __strong __typeof__(weakSelf) self = weakSelf;
self->_application = [self->_factory createApplication:platform]; self.factory = FLBFactory.new;
[self->_application startFlutterWithPlatform:platform self.application = [self->_factory createApplication:platform];
[self.application startFlutterWithPlatform:platform
onStart:callback]; onStart:callback];
}); });
} }
......
...@@ -26,14 +26,11 @@ ...@@ -26,14 +26,11 @@
#import "FLBFlutterApplicationInterface.h" #import "FLBFlutterApplicationInterface.h"
#import "FLBAbstractFactory.h" #import "FLBAbstractFactory.h"
#import "FlutterBoostPlugin.h" #import "FlutterBoostPlugin.h"
@interface FlutterBoostPlugin(){ @interface FlutterBoostPlugin()
id<FLBFlutterApplicationInterface> _application; @property (nonatomic,strong) id<FLBFlutterApplicationInterface> application;
id<FLBAbstractFactory> _factory; @property (nonatomic,strong) id<FLBAbstractFactory> factory;
}
@property (nonatomic,strong) FlutterMethodChannel *methodChannel; @property (nonatomic,strong) FlutterMethodChannel *methodChannel;
@property (nonatomic,copy) NSString *fPageId; @property (nonatomic,copy) NSString *fPageId;
@property (nonatomic,copy) NSString *fPagename; @property (nonatomic,copy) NSString *fPagename;
@property (nonatomic,strong) NSDictionary *fParams; @property (nonatomic,strong) NSDictionary *fParams;
- (id<FLBFlutterApplicationInterface>)application;
- (id<FLBAbstractFactory>)factory;
@end @end
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- (id<FLBFlutterApplicationInterface>)createApplication:(id<FLBPlatform>)platform - (id<FLBFlutterApplicationInterface>)createApplication:(id<FLBPlatform>)platform
{ {
return [FLBFlutterApplication sharedApplication]; return [FLBFlutterApplication new];
} }
- (id<FLBFlutterContainer>)createFlutterContainer - (id<FLBFlutterContainer>)createFlutterContainer
......
...@@ -30,6 +30,5 @@ ...@@ -30,6 +30,5 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface FLBFlutterApplication : NSObject<FLBFlutterApplicationInterface> @interface FLBFlutterApplication : NSObject<FLBFlutterApplicationInterface>
+ (FLBFlutterApplication *)sharedApplication;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -39,16 +39,6 @@ ...@@ -39,16 +39,6 @@
@implementation FLBFlutterApplication @implementation FLBFlutterApplication
@synthesize platform; @synthesize platform;
+ (FLBFlutterApplication *)sharedApplication
{
static FLBFlutterApplication *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [self new];
});
return instance;
}
- (BOOL)isRunning - (BOOL)isRunning
{ {
return _isRunning; return _isRunning;
......
...@@ -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];
} }
...@@ -148,7 +149,7 @@ static NSUInteger kInstanceCounter = 0; ...@@ -148,7 +149,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)setEnableForRunnersBatch:(BOOL)enable{ - (void)setEnableForRunnersBatch:(BOOL)enable{
//dummy function //dummy function
NSLog(@"[DEBUG]- I did nothing, I am innocent"); // NSLog(@"[DEBUG]- I did nothing, I am innocent");
} }
#pragma mark - Life circle methods #pragma mark - Life circle methods
...@@ -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.
...@@ -184,8 +175,15 @@ static NSUInteger kInstanceCounter = 0; ...@@ -184,8 +175,15 @@ static NSUInteger kInstanceCounter = 0;
[FlutterBoostPlugin sharedInstance].fPageId = self.uniqueIDString; [FlutterBoostPlugin sharedInstance].fPageId = self.uniqueIDString;
[FlutterBoostPlugin sharedInstance].fParams = _params; [FlutterBoostPlugin sharedInstance].fParams = _params;
} }
[super viewWillAppear:animated]; [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 +192,15 @@ static NSUInteger kInstanceCounter = 0; ...@@ -194,13 +192,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 +217,18 @@ static NSUInteger kInstanceCounter = 0; ...@@ -217,14 +217,18 @@ 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]; [super viewDidDisappear:animated];
[FLUTTER_APP resume]; //// instead of calling [super viewDidDisappear: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(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