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

1, dart entry name

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