Commit 5d05f740 authored by Jidong Chen's avatar Jidong Chen

1, dart entry name

2, close params
parent 50e7acc7
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
self.platform = platform; self.platform = platform;
self.viewProvider = FLB2FlutterEngine.new; self.viewProvider = [[FLB2FlutterEngine alloc] initWithPlatform:platform];
self.isRunning = YES; self.isRunning = YES;
if(callback) callback(self.viewProvider.engine); if(callback) callback(self.viewProvider.engine);
}); });
......
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "FLB2FlutterProvider.h" #import "FLB2FlutterProvider.h"
#import "FLB2Platform.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface FLB2FlutterEngine : NSObject<FLB2FlutterProvider> @interface FLB2FlutterEngine : NSObject<FLB2FlutterProvider>
- (instancetype)initWithPlatform:(id<FLB2Platform>)platform;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -34,14 +34,20 @@ ...@@ -34,14 +34,20 @@
@implementation FLB2FlutterEngine @implementation FLB2FlutterEngine
- (instancetype)init - (instancetype)initWithPlatform:(id<FLB2Platform>)platform
{ {
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
if (self = [super init]) { if (self = [super init]) {
_engine = [[FlutterEngine alloc] initWithName:@"io.flutter" project:nil]; _engine = [[FlutterEngine alloc] initWithName:@"io.flutter" project:nil];
if(platform &&
[platform respondsToSelector: @selector(entryForDart)] &&
platform.entryForDart){
[_engine runWithEntrypoint:platform.entryForDart];
}else{
[_engine runWithEntrypoint:nil]; [_engine runWithEntrypoint:nil];
}
_dummy = [[FLB2FlutterViewContainer alloc] initWithEngine:_engine _dummy = [[FLB2FlutterViewContainer alloc] initWithEngine:_engine
nibName:nil nibName:nil
bundle:nil]; bundle:nil];
...@@ -58,6 +64,11 @@ ...@@ -58,6 +64,11 @@
#pragma clang diagnostic pop #pragma clang diagnostic pop
} }
- (instancetype)init
{
return [self initWithPlatform:nil];
}
- (void)pause - (void)pause
{ {
[[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.pause"]; [[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.pause"];
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@protocol FLB2Platform <NSObject> @protocol FLB2Platform <NSObject>
@optional
- (NSString *)entryForDart;
@required @required
- (void)open:(NSString *)url - (void)open:(NSString *)url
urlParams:(NSDictionary *)urlParams urlParams:(NSDictionary *)urlParams
......
...@@ -123,11 +123,25 @@ class FlutterBoost { ...@@ -123,11 +123,25 @@ class FlutterBoost {
assert(id != null); assert(id != null);
BoostContainerSettings settings = containerManager?.onstageSettings;
Map<String, dynamic> properties = new Map<String, dynamic>(); Map<String, dynamic> properties = new Map<String, dynamic>();
if(exts == null){
exts = Map<dynamic,dynamic>();
}
exts["params"] = settings.params;
if(!exts.containsKey("animated")){
exts["animated"] = true;
}
properties["uniqueId"] = id; properties["uniqueId"] = id;
if (result != null) { if (result != null) {
properties["result"] = result; properties["result"] = result;
} }
if (exts != null) { if (exts != null) {
properties["exts"] = exts; properties["exts"] = exts;
} }
...@@ -135,13 +149,27 @@ class FlutterBoost { ...@@ -135,13 +149,27 @@ class FlutterBoost {
} }
Future<bool> closeCurrent({Map<dynamic,dynamic> result,Map<dynamic,dynamic> exts}) { Future<bool> closeCurrent({Map<dynamic,dynamic> result,Map<dynamic,dynamic> exts}) {
String id = containerManager?.onstageSettings?.uniqueId; BoostContainerSettings settings = containerManager?.onstageSettings;
return close(id,result: result,exts: exts); if(exts == null){
exts = Map<dynamic,dynamic>();
}
exts["params"] = settings.params;
if(!exts.containsKey("animated")){
exts["animated"] = true;
}
return close(settings.uniqueId,result: result,exts: exts);
} }
Future<bool> closeByContext(BuildContext context,{Map<dynamic,dynamic> result,Map<dynamic,dynamic> exts}) { Future<bool> closeByContext(BuildContext context,{Map<dynamic,dynamic> result,Map<dynamic,dynamic> exts}) {
String id = BoostContainer.of(context)?.settings?.uniqueId; BoostContainerSettings settings = containerManager?.onstageSettings;
return close(id,result: result,exts: exts); if(exts == null){
exts = Map<dynamic,dynamic>();
}
exts["params"] = settings.params;
if(!exts.containsKey("animated")){
exts["animated"] = true;
}
return close(settings.uniqueId,result: result,exts: exts);
} }
///register for Container changed callbacks ///register for Container changed callbacks
......
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