Commit 6b5e8028 authored by XinLei's avatar XinLei Committed by GitHub

Merge pull request #8 from alibaba/master

[sync] 2020/1/19
parents a558f1e3 138e79f2
## 0.1.66
Fixed bugs
## 0.1.64 ## 0.1.64
Fixed bugs Fixed bugs
......
...@@ -22,12 +22,12 @@ You need to add Flutter to your project before moving on.The version of the flut ...@@ -22,12 +22,12 @@ You need to add Flutter to your project before moving on.The version of the flut
1. 0.1.50 is based on the flutter v1.5.4-hotfixes branch, android if other flutter versions or branches will compile incorrectly 1. 0.1.50 is based on the flutter v1.5.4-hotfixes branch, android if other flutter versions or branches will compile incorrectly
2. 0.1.51--0.1.54 is a bugfix for 0.1.50 2. 0.1.51--0.1.59 is a bugfix for 0.1.50
3. 0.1.60 is based on the flutter v1.9.1-hotfixes branch. Android does not support andriodx if other flutter branches will compile incorrectly 3. 0.1.60 is based on the flutter v1.9.1-hotfixes branch. Android does not support andriodx if other flutter branches will compile incorrectly
4. 0.1.61--0.1.64 is a bugfix for 0.1.60 4. 0.1.61--0.1.69 is a bugfix for 0.1.60
5. Statement of support for androidx 5. Statement of support for androidx
......
...@@ -35,11 +35,11 @@ android { ...@@ -35,11 +35,11 @@ android {
} }
dependencies { dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0' compileOnly 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0' compileOnly 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0' compileOnly 'com.android.support:support-v4:28.0.0'
implementation 'android.arch.lifecycle:common-java8:1.1.1' implementation 'android.arch.lifecycle:common-java8:1.1.1'
implementation 'com.alibaba:fastjson:1.2.41' compileOnly 'com.alibaba:fastjson:1.2.41'
} }
......
...@@ -73,7 +73,7 @@ public class BoostFlutterActivity extends Activity ...@@ -73,7 +73,7 @@ public class BoostFlutterActivity extends Activity
private Map params = new HashMap(); private Map params = new HashMap();
protected NewEngineIntentBuilder(@NonNull Class<? extends BoostFlutterActivity> activityClass) { public NewEngineIntentBuilder(@NonNull Class<? extends BoostFlutterActivity> activityClass) {
this.activityClass = activityClass; this.activityClass = activityClass;
} }
......
...@@ -59,5 +59,8 @@ dependencies { ...@@ -59,5 +59,8 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.alibaba:fastjson:1.2.41'
} }
...@@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
withEngine:(FlutterEngine* _Nullable)engine withEngine:(FlutterEngine* _Nullable)engine
withPluginRegisterred:(BOOL)registerPlugin
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
- (FlutterViewController *)flutterViewController; - (FlutterViewController *)flutterViewController;
......
...@@ -38,7 +38,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -38,7 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSInteger)pageCount; + (NSInteger)pageCount;
/** /**
* 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中 * 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中。本函数默认需要flutter boost来注册所有插件。
* *
* @param platform 平台层实现FLBPlatform的对象 * @param platform 平台层实现FLBPlatform的对象
* @param callback 启动之后回调 * @param callback 启动之后回调
...@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
/** /**
* 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中 * 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中。本函数默认需要flutter boost来注册所有插件。
* *
* @param platform 平台层实现FLBPlatform的对象 * @param platform 平台层实现FLBPlatform的对象
* @param engine 外部实例化engine后传入 * @param engine 外部实例化engine后传入
...@@ -56,6 +56,17 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -56,6 +56,17 @@ NS_ASSUME_NONNULL_BEGIN
engine:(FlutterEngine* _Nullable)engine engine:(FlutterEngine* _Nullable)engine
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
/**
* 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中。本函数可以控制是否需要flutter boost来注册所有插件
*
* @param platform 平台层实现FLBPlatform的对象
* @param engine 外部实例化engine后传入
* @param callback 启动之后回调
*/
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
engine:(FlutterEngine* _Nullable)engine
pluginRegisterred:(BOOL)registerPlugin
onStart:(void (^)(FlutterEngine *engine))callback;
#pragma mark - Some properties. #pragma mark - Some properties.
- (BOOL)isRunning; - (BOOL)isRunning;
......
...@@ -119,13 +119,26 @@ ...@@ -119,13 +119,26 @@
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
{ {
[self startFlutterWithPlatform:platform engine:nil onStart:callback]; [self startFlutterWithPlatform:platform
engine:nil
pluginRegisterred:YES
onStart:callback];
} }
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
engine:(FlutterEngine* _Nullable)engine engine:(FlutterEngine* _Nullable)engine
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
{ {
[self startFlutterWithPlatform:platform
engine:engine
pluginRegisterred:YES
onStart:callback];
}
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
engine:(FlutterEngine *)engine
pluginRegisterred:(BOOL)registerPlugin
onStart:(void (^)(FlutterEngine * _Nonnull))callback{
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
__weak __typeof__(self) weakSelf = self; __weak __typeof__(self) weakSelf = self;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
...@@ -134,6 +147,7 @@ ...@@ -134,6 +147,7 @@
self.application = [factory createApplication:platform]; self.application = [factory createApplication:platform];
[self.application startFlutterWithPlatform:platform [self.application startFlutterWithPlatform:platform
withEngine:engine withEngine:engine
withPluginRegisterred:registerPlugin
onStart:callback]; onStart:callback];
}); });
} }
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
withEngine:(FlutterEngine* _Nullable)engine withEngine:(FlutterEngine* _Nullable)engine
withPluginRegisterred:(BOOL)registerPlugin
onStart:(void (^)(FlutterEngine *engine))callback onStart:(void (^)(FlutterEngine *engine))callback
{ {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
...@@ -58,6 +59,16 @@ ...@@ -58,6 +59,16 @@
self.platform = platform; self.platform = platform;
self.viewProvider = [[FLBFlutterEngine alloc] initWithPlatform:platform engine:engine]; self.viewProvider = [[FLBFlutterEngine alloc] initWithPlatform:platform engine:engine];
self.isRunning = YES; self.isRunning = YES;
if(registerPlugin){
Class clazz = NSClassFromString(@"GeneratedPluginRegistrant");
FlutterEngine *myengine = [self.viewProvider engine];
if (clazz && myengine) {
if ([clazz respondsToSelector:NSSelectorFromString(@"registerWithRegistry:")]) {
[clazz performSelector:NSSelectorFromString(@"registerWithRegistry:")
withObject:myengine];
}
}
}
if(callback) callback(self.viewProvider.engine); if(callback) callback(self.viewProvider.engine);
}); });
} }
......
...@@ -57,14 +57,6 @@ ...@@ -57,14 +57,6 @@
nibName:nil nibName:nil
bundle:nil]; bundle:nil];
_dummy.name = kIgnoreMessageWithName; _dummy.name = kIgnoreMessageWithName;
Class clazz = NSClassFromString(@"GeneratedPluginRegistrant");
if (clazz) {
if ([clazz respondsToSelector:NSSelectorFromString(@"registerWithRegistry:")]) {
[clazz performSelector:NSSelectorFromString(@"registerWithRegistry:")
withObject:_engine];
}
}
} }
return self; return self;
......
...@@ -44,7 +44,6 @@ typedef void PostPushRoute( ...@@ -44,7 +44,6 @@ typedef void PostPushRoute(
String url, String uniqueId, Map params, Route route, Future result); String url, String uniqueId, Map params, Route route, Future result);
class FlutterBoost { class FlutterBoost {
static final FlutterBoost _instance = FlutterBoost(); static final FlutterBoost _instance = FlutterBoost();
final GlobalKey<ContainerManagerState> containerManagerKey = final GlobalKey<ContainerManagerState> containerManagerKey =
GlobalKey<ContainerManagerState>(); GlobalKey<ContainerManagerState>();
...@@ -56,31 +55,38 @@ class FlutterBoost { ...@@ -56,31 +55,38 @@ class FlutterBoost {
static ContainerManagerState get containerManager => static ContainerManagerState get containerManager =>
_instance.containerManagerKey.currentState; _instance.containerManagerKey.currentState;
static void onPageStart() {
WidgetsBinding.instance.addPostFrameCallback((_) {
singleton.channel.invokeMethod<Map>('pageOnStart').then((Map pageInfo) {
if (pageInfo == null || pageInfo.isEmpty) return;
if (pageInfo.containsKey("name") &&
pageInfo.containsKey("params") &&
pageInfo.containsKey("uniqueId")) {
ContainerCoordinator.singleton.nativeContainerDidShow(
pageInfo["name"], pageInfo["params"], pageInfo["uniqueId"]);
}
});
});
}
static TransitionBuilder init( static TransitionBuilder init(
{TransitionBuilder builder, {TransitionBuilder builder,
PrePushRoute prePush, PrePushRoute prePush,
PostPushRoute postPush}) { PostPushRoute postPush}) {
if (Platform.isAndroid) {
if(Platform.isAndroid){ onPageStart();
WidgetsBinding.instance.addPostFrameCallback((_){
singleton.channel.invokeMethod<Map>('pageOnStart').then((Map pageInfo){
if (pageInfo == null || pageInfo.isEmpty) return;
if (pageInfo.containsKey("name") &&
pageInfo.containsKey("params") &&
pageInfo.containsKey("uniqueId")) {
ContainerCoordinator.singleton.nativeContainerDidShow(
pageInfo["name"], pageInfo["params"], pageInfo["uniqueId"]);
}
});
});
} }
assert(() {
() async {
if (Platform.isIOS) {
onPageStart();
}
}();
return true;
}());
return (BuildContext context, Widget child) { return (BuildContext context, Widget child) {
assert(child is Navigator, 'child must be Navigator, what is wrong?'); assert(child is Navigator, 'child must be Navigator, what is wrong?');
...@@ -102,7 +108,7 @@ class FlutterBoost { ...@@ -102,7 +108,7 @@ class FlutterBoost {
BoostChannel get channel => _boostChannel; BoostChannel get channel => _boostChannel;
FlutterBoost(){ FlutterBoost() {
ContainerCoordinator(_boostChannel); ContainerCoordinator(_boostChannel);
} }
...@@ -116,30 +122,29 @@ class FlutterBoost { ...@@ -116,30 +122,29 @@ class FlutterBoost {
ContainerCoordinator.singleton.registerPageBuilders(builders); ContainerCoordinator.singleton.registerPageBuilders(builders);
} }
Future<Map<dynamic,dynamic>> open(String url,{Map<dynamic,dynamic> urlParams,Map<dynamic,dynamic> exts}){ Future<Map<dynamic, dynamic>> open(String url,
{Map<dynamic, dynamic> urlParams, Map<dynamic, dynamic> exts}) {
Map<dynamic, dynamic> properties = new Map<dynamic, dynamic>(); Map<dynamic, dynamic> properties = new Map<dynamic, dynamic>();
properties["url"] = url; properties["url"] = url;
properties["urlParams"] = urlParams; properties["urlParams"] = urlParams;
properties["exts"] = exts; properties["exts"] = exts;
return channel.invokeMethod<Map<dynamic,dynamic>>( return channel.invokeMethod<Map<dynamic, dynamic>>('openPage', properties);
'openPage', properties);
} }
Future<bool> close(String id,{Map<dynamic,dynamic> result,Map<dynamic,dynamic> exts}){ Future<bool> close(String id,
{Map<dynamic, dynamic> result, Map<dynamic, dynamic> exts}) {
assert(id != null); assert(id != null);
BoostContainerSettings settings = containerManager?.onstageSettings; BoostContainerSettings settings = containerManager?.onstageSettings;
Map<dynamic, dynamic> properties = new Map<dynamic, dynamic>(); Map<dynamic, dynamic> properties = new Map<dynamic, dynamic>();
if(exts == null){ if (exts == null) {
exts = Map<dynamic,dynamic>(); exts = Map<dynamic, dynamic>();
} }
exts["params"] = settings.params; exts["params"] = settings.params;
if(!exts.containsKey("animated")){ if (!exts.containsKey("animated")) {
exts["animated"] = true; exts["animated"] = true;
} }
...@@ -155,28 +160,30 @@ class FlutterBoost { ...@@ -155,28 +160,30 @@ class FlutterBoost {
return channel.invokeMethod<bool>('closePage', properties); return channel.invokeMethod<bool>('closePage', properties);
} }
Future<bool> closeCurrent({Map<String,dynamic> result,Map<String,dynamic> exts}) { Future<bool> closeCurrent(
{Map<String, dynamic> result, Map<String, dynamic> exts}) {
BoostContainerSettings settings = containerManager?.onstageSettings; BoostContainerSettings settings = containerManager?.onstageSettings;
if(exts == null){ if (exts == null) {
exts = Map<String,dynamic>(); exts = Map<String, dynamic>();
} }
exts["params"] = settings.params; exts["params"] = settings.params;
if(!exts.containsKey("animated")){ if (!exts.containsKey("animated")) {
exts["animated"] = true; exts["animated"] = true;
} }
return close(settings.uniqueId,result: result,exts: exts); return close(settings.uniqueId, result: result, exts: exts);
} }
Future<bool> closeByContext(BuildContext context,{Map<String,dynamic> result,Map<String,dynamic> exts}) { Future<bool> closeByContext(BuildContext context,
{Map<String, dynamic> result, Map<String, dynamic> exts}) {
BoostContainerSettings settings = containerManager?.onstageSettings; BoostContainerSettings settings = containerManager?.onstageSettings;
if(exts == null){ if (exts == null) {
exts = Map<String,dynamic>(); exts = Map<String, dynamic>();
} }
exts["params"] = settings.params; exts["params"] = settings.params;
if(!exts.containsKey("animated")){ if (!exts.containsKey("animated")) {
exts["animated"] = true; exts["animated"] = true;
} }
return close(settings.uniqueId,result: result,exts: exts); return close(settings.uniqueId, result: result, exts: exts);
} }
///register for Container changed callbacks ///register for Container changed callbacks
...@@ -191,6 +198,4 @@ class FlutterBoost { ...@@ -191,6 +198,4 @@ class FlutterBoost {
///register callbacks for Navigators push & pop ///register callbacks for Navigators push & pop
VoidCallback addBoostNavigatorObserver(BoostNavigatorObserver observer) => VoidCallback addBoostNavigatorObserver(BoostNavigatorObserver observer) =>
_observersHolder.addObserver<BoostNavigatorObserver>(observer); _observersHolder.addObserver<BoostNavigatorObserver>(observer);
} }
name: flutter_boost name: flutter_boost
description: 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. description: 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.
version: 0.1.64 version: 0.1.66
author: Alibaba Xianyu author: Alibaba Xianyu
homepage: https://github.com/alibaba/flutter_boost homepage: https://github.com/alibaba/flutter_boost
......
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