Commit c16f3c12 authored by Jidong Chen's avatar Jidong Chen

code opt.

parent 786e5617
......@@ -23,7 +23,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
......
......@@ -22,7 +22,7 @@
}
// Boost 2 switch
- (BOOL)userBoost2
- (BOOL)useBoost2
{
return YES;
}
......@@ -70,7 +70,7 @@
animated:(BOOL)animated
completion:(void (^)(BOOL))completion
{
if([self userBoost2]){
if([self useBoost2]){
NSMutableDictionary *exts = NSMutableDictionary.new;
exts[@"url"] = name;
exts[@"params"] = params;
......@@ -98,7 +98,7 @@
- (void)closePage:(NSString *)uid animated:(BOOL)animated params:(NSDictionary *)params completion:(void (^)(BOOL))completion
{
if([self userBoost2]){
if([self useBoost2]){
NSMutableDictionary *exts = NSMutableDictionary.new;
exts[@"params"] = params;
exts[@"animated"] = @(animated);
......
......@@ -27,7 +27,7 @@
#import "FLBStackCache.h"
#import "FLBStackCacheObjectImg.h"
#import "FLBMemoryInspector.h"
#import "Service_NavigationService.h"
#import "BoostMessageChannel.h"
#import "FlutterBoostConfig.h"
#import "FlutterBoostPlugin_private.h"
......@@ -51,7 +51,7 @@
if(!_name && name){
_name = name;
_params = params;
[Service_NavigationService didInitPageContainer:^(NSNumber *r) {}
[BoostMessageChannel didInitPageContainer:^(NSNumber *r) {}
pageName:name
params:params
uniqueId:[self uniqueIDString]];
......@@ -140,7 +140,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)notifyWillDealloc
{
[Service_NavigationService willDeallocPageContainer:^(NSNumber *r) {}
[BoostMessageChannel willDeallocPageContainer:^(NSNumber *r) {}
pageName:_name params:_params
uniqueId:[self uniqueIDString]];
......@@ -310,7 +310,7 @@ static NSUInteger kInstanceCounter = 0;
[self showSnapShotVew];
[Service_NavigationService willShowPageContainer:^(NSNumber *result) {}
[BoostMessageChannel willShowPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
......@@ -331,7 +331,7 @@ static NSUInteger kInstanceCounter = 0;
//Ensure flutter view is attached.
[self attatchFlutterView];
[Service_NavigationService didShowPageContainer:^(NSNumber *result) {}
[BoostMessageChannel didShowPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
......@@ -369,7 +369,7 @@ static NSUInteger kInstanceCounter = 0;
[self.view bringSubviewToFront:self.screenShotView];
}
[Service_NavigationService willDisappearPageContainer:^(NSNumber *result) {}
[BoostMessageChannel willDisappearPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
......@@ -379,7 +379,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidDisappear:(BOOL)animated
{
[Service_NavigationService didDisappearPageContainer:^(NSNumber *result) {}
[BoostMessageChannel didDisappearPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
......
......@@ -24,7 +24,7 @@
#import "FLB2FlutterViewContainer.h"
#import "FLB2FlutterApplication.h"
#import "Service_NavigationService.h"
#import "BoostMessageChannel.h"
#import "FLBFlutterContainerManager.h"
#import "FlutterBoostPlugin_private.h"
......@@ -64,7 +64,7 @@
if(!_name && name){
_name = name;
_params = params;
[Service_NavigationService didInitPageContainer:^(NSNumber *r) {}
[BoostMessageChannel didInitPageContainer:^(NSNumber *r) {}
pageName:name
params:params
uniqueId:[self uniqueIDString]];
......@@ -115,7 +115,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)notifyWillDealloc
{
[Service_NavigationService willDeallocPageContainer:^(NSNumber *r) {}
[BoostMessageChannel willDeallocPageContainer:^(NSNumber *r) {}
pageName:_name params:_params
uniqueId:[self uniqueIDString]];
......@@ -169,7 +169,7 @@ static NSUInteger kInstanceCounter = 0;
//For new page we should attach flutter view in view will appear
//for better performance.
[Service_NavigationService willShowPageContainer:^(NSNumber *result) {}
[BoostMessageChannel willShowPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
......@@ -190,7 +190,7 @@ static NSUInteger kInstanceCounter = 0;
//Ensure flutter view is attached.
[self attatchFlutterEngine];
[self surfaceUpdated:YES];
[Service_NavigationService didShowPageContainer:^(NSNumber *result) {}
[BoostMessageChannel didShowPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
......@@ -200,7 +200,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewWillDisappear:(BOOL)animated
{
[Service_NavigationService willDisappearPageContainer:^(NSNumber *result) {}
[BoostMessageChannel willDisappearPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
......@@ -211,7 +211,7 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidDisappear:(BOOL)animated
{
[self detatchFlutterEngine];
[Service_NavigationService didDisappearPageContainer:^(NSNumber *result) {}
[BoostMessageChannel didDisappearPageContainer:^(NSNumber *result) {}
pageName:_name
params:_params
uniqueId:self.uniqueIDString];
......
......@@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol FLB2Platform <FLBPlatform>
@optional
- (BOOL)userBoost2;
- (BOOL)useBoost2;
@required
- (void)open:(NSString *)url
......
......@@ -26,29 +26,20 @@
#import "FlutterBoostPlugin_private.h"
#import "FLBFactory.h"
#import "FLB2Factory.h"
#import "FLBMessageDispather.h"
#import "FLBMessageImp.h"
#import "NavigationService_closePage.h"
#import "NavigationService_openPage.h"
#import "NavigationService_pageOnStart.h"
#import "NavigationService_onShownContainerChanged.h"
#import "NavigationService_onFlutterPageResult.h"
#import "BoostMessageChannel.h"
#import "FlutterBoostPlugin_private.h"
@interface FlutterBoostPlugin()
@property (nonatomic,strong) FLBMessageDispather *dispatcher;
@end
@implementation FlutterBoostPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel* channel = [FlutterMethodChannel
methodChannelWithName:@"flutter_boost"
methodChannelWithName:@"flutter_boost_method"
binaryMessenger:[registrar messenger]];
FlutterBoostPlugin* instance = [self.class sharedInstance];
[instance registerHandlers];
instance.methodChannel = channel;
instance.broadcastor = [[FLBBroadcastor alloc] initWithMethodChannel:channel];
[registrar addMethodCallDelegate:instance channel:channel];
}
......@@ -56,31 +47,48 @@
if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
} else if([@"__event__" isEqual: call.method]){
[_broadcastor handleMethodCall:call result:result];
}else{
FLBMessageImp *msg = FLBMessageImp.new;
msg.name = call.method;
msg.params = call.arguments;
if(![self.dispatcher dispatch:msg result:result]){
result(FlutterMethodNotImplemented);
[BoostMessageChannel handleMethodCall:call result:result];
}else if([@"closePage" isEqualToString:call.method]){
NSDictionary *args = call.arguments;
NSDictionary *exts = args[@"exts"];
NSString *uid = args[@"uniqueId"];
NSDictionary *resultData = args[@"result"];
[[FlutterBoostPlugin sharedInstance].application close:uid
result:resultData
exts:exts
completion:^(BOOL r){
result(@(r));
}];
}else if([@"onFlutterPageResult" isEqualToString:call.method]){
//Do nothing
}else if([@"onShownContainerChanged" isEqualToString:call.method]){
NSString *newName = call.arguments[@"newName"];
if(newName){
[NSNotificationCenter.defaultCenter postNotificationName:@"flutter_boost_container_showed"
object:newName];
}
}else if([@"openPage" isEqualToString:call.method]){
NSDictionary *args = call.arguments;
NSString *url = args[@"url"];
NSDictionary *urlParams = args[@"urlParams"];
NSDictionary *exts = args[@"exts"];
[[FlutterBoostPlugin sharedInstance].application open:url
urlParams:urlParams
exts:exts
reult:result
completion:^(BOOL r) {}];
}else if([@"pageOnStart" isEqualToString:call.method]){
NSMutableDictionary *pageInfo = [NSMutableDictionary new];
pageInfo[@"name"] =[FlutterBoostPlugin sharedInstance].fPagename;
pageInfo[@"params"] = [FlutterBoostPlugin sharedInstance].fParams;
pageInfo[@"uniqueId"] = [FlutterBoostPlugin sharedInstance].fPageId;
if(result) result(pageInfo);
}else{
result(FlutterMethodNotImplemented);
}
}
- (void)registerHandlers
{
NSArray *handlers = @[
NavigationService_openPage.class,
NavigationService_closePage.class,
NavigationService_pageOnStart.class,
NavigationService_onShownContainerChanged.class,
NavigationService_onFlutterPageResult.class
];
for(Class cls in handlers){
[self.dispatcher registerHandler:cls.new];
}
}
+ (instancetype)sharedInstance
{
......@@ -93,14 +101,6 @@
return _instance;
}
- (instancetype)init
{
if (self = [super init]) {
_dispatcher = FLBMessageDispather.new;
}
return self;
}
- (id<FLBFlutterApplicationInterface>)application
{
......@@ -121,7 +121,7 @@
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if([platform respondsToSelector:@selector(userBoost2)] && platform.userBoost2){
if([platform respondsToSelector:@selector(useBoost2)] && platform.useBoost2){
_factory = FLB2Factory.new;
}else{
_factory = FLBFactory.new;
......@@ -148,15 +148,15 @@
- (void)sendEvent:(NSString *)eventName
arguments:(NSDictionary *)arguments
{
[_broadcastor sendEvent:eventName
arguments:arguments];
[BoostMessageChannel sendEvent:eventName
arguments:arguments];
}
- (FLBVoidCallback)addEventListener:(FLBEventListener)listner
forName:(NSString *)name
{
return [_broadcastor addEventListener:listner
forName:name];
return [BoostMessageChannel addEventListener:listner
forName:name];
}
@end
......@@ -25,7 +25,6 @@
#import "FLBFlutterApplicationInterface.h"
#import "FLBAbstractFactory.h"
#import "FLBBroadcastor.h"
@interface FlutterBoostPlugin(){
id<FLBFlutterApplicationInterface> _application;
......@@ -36,7 +35,6 @@
- (id<FLBAbstractFactory>)factory;
@property (nonatomic,strong) FlutterMethodChannel *methodChannel;
@property (nonatomic,strong) FLBBroadcastor *broadcastor;
@property (nonatomic,copy) NSString *fPageId;
@property (nonatomic,copy) NSString *fPagename;
@property (nonatomic,strong) NSDictionary *fParams;
......
......@@ -23,8 +23,10 @@
*/
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
#import "FLBTypes.h"
@interface Service_NavigationService : NSObject
@interface BoostMessageChannel : NSObject
+ (void)onNativePageResult:(void (^)(NSNumber *))result uniqueId:(NSString *)uniqueId key:(NSString *)key resultData:(NSDictionary *)resultData params:(NSDictionary *)params;
+ (void)didShowPageContainer:(void (^)(NSNumber *))result pageName:(NSString *)pageName params:(NSDictionary *)params uniqueId:(NSString *)uniqueId;
......@@ -33,4 +35,15 @@
+ (void)didDisappearPageContainer:(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)sendEvent:(NSString *)eventName
arguments:(NSDictionary *)arguments;
+ (FLBVoidCallback)addEventListener:(FLBEventListener)listner
forName:(NSString *)name;
+ (void)handleMethodCall:(FlutterMethodCall *)call
result:(FlutterResult)result;
@end
......@@ -23,17 +23,72 @@
*/
#import "Service_NavigationService.h"
#import <Flutter/Flutter.h>
#import "BoostMessageChannel.h"
#import "FlutterBoostPlugin_private.h"
@implementation Service_NavigationService
@implementation BoostMessageChannel
+ (NSMutableDictionary *)lists{
static NSMutableDictionary *_list = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_list = [NSMutableDictionary new];
});
return _list;
}
+ (FlutterMethodChannel *)methodChannel
{
return FlutterBoostPlugin.sharedInstance.methodChannel;
}
+ (void)sendEvent:(NSString *)eventName
arguments:(NSDictionary *)arguments
{
if(!eventName) return;
NSMutableDictionary *msg = [NSMutableDictionary new];
msg[@"name"] = eventName;
msg[@"arguments"] = arguments;
[self.methodChannel invokeMethod:@"__event__"
arguments:msg
result:^(id r){}];
}
+ (FLBVoidCallback)addEventListener:(FLBEventListener)listner
forName:(NSString *)name
{
if(!name || !listner) return ^{};
NSMutableArray *list = [self lists][name];
if(!list){
list = [NSMutableArray new];
[self lists][name] = list;
}
[list addObject:listner];
return ^{
[list removeObject:listner];
};
}
+ (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
{
if([call.method isEqual:@"__event__"]){
NSString *name = call.arguments[@"name"];
NSDictionary *arguments = call.arguments[@"arguments"];
if(name){
NSMutableArray *list = [self lists][name];
if(list){
for(FLBEventListener l in list){
l(name,arguments);
}
}
}
}
}
+ (void)onNativePageResult:(void (^)(NSNumber *))result uniqueId:(NSString *)uniqueId key:(NSString *)key resultData:(NSDictionary *)resultData params:(NSDictionary *)params
{
NSMutableDictionary *tmp = [NSMutableDictionary dictionary];
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// Generated by AIOCodeGen do not edit!
#import "FLBMessageHandlerImp.h"
@interface NavigationService_closePage : FLBMessageHandlerImp
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "ServiceGateway.h"
#import "NavigationService_closePage.h"
#import "FlutterBoostPlugin_private.h"
#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application
@implementation NavigationService_closePage
#pragma mark - Do not edit these method.
- (BOOL)call:(id<FLBMessage>)msg result:(void (^)(BOOL))resultBlock
{
NSDictionary *args = msg.params;
NSDictionary *exts = args[@"exts"];
NSString *uid = args[@"uniqueId"];
NSDictionary *resultData = args[@"result"];
[FLUTTER_APP close:uid
result:resultData
exts:exts
completion:resultBlock];
return YES;
}
- (NSString *)returnType
{
return @"BOOL";
}
- (NSArray *)handledMessageNames
{
return @[@"closePage"];
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// Generated by AIOCodeGen do not edit!
#import "FLBMessageHandlerImp.h"
@interface NavigationService_onFlutterPageResult : FLBMessageHandlerImp
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//Generated by AIOCodeGen.
#import "ServiceGateway.h"
#import "NavigationService_onFlutterPageResult.h"
#import "FlutterBoost.h"
@implementation NavigationService_onFlutterPageResult
- (void)onCall:(void (^)(BOOL))result uniqueId:(NSString *)uniqueId key:(NSString *)key resultData:(NSDictionary *)resultData params:(NSDictionary *)params
{
}
#pragma mark - Do not edit these method.
- (BOOL)call:(id<FLBMessage>)msg result:(void (^)(BOOL))result
{
NSDictionary *args = msg.params;
[self onCall:result uniqueId:args[@"uniqueId"] key:args[@"key"] resultData:args[@"resultData"] params:args[@"params"]];
return YES;
}
- (NSArray *)handledMessageNames
{
return @[@"onFlutterPageResult"];
}
- (NSString *)returnType
{
return @"BOOL";
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// Generated by AIOCodeGen do not edit!
#import "FLBMessageHandlerImp.h"
@interface NavigationService_onShownContainerChanged : FLBMessageHandlerImp
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//Generated by AIOCodeGen.
#import "ServiceGateway.h"
#import "NavigationService_onShownContainerChanged.h"
@implementation NavigationService_onShownContainerChanged
- (void)onCall:(void (^)(BOOL))result newName:(NSString *)newName oldName:(NSString *)oldName params:(NSDictionary *)params
{
if(newName){
[NSNotificationCenter.defaultCenter postNotificationName:@"flutter_boost_container_showed"
object:newName];
}
}
#pragma mark - Do not edit these method.
- (BOOL)call:(id<FLBMessage>)msg result:(void (^)(BOOL))result
{
NSDictionary *args = msg.params;
[self onCall:result newName:args[@"newName"] oldName:args[@"oldName"] params:args[@"params"]];
return YES;
}
- (NSString *)returnType
{
return @"BOOL";
}
- (NSArray *)handledMessageNames
{
return @[@"onShownContainerChanged"];
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// Generated by AIOCodeGen do not edit!
#import "FLBMessageHandlerImp.h"
@interface NavigationService_openPage : FLBMessageHandlerImp
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//Generated by AIOCodeGen.
#import "ServiceGateway.h"
#import "NavigationService_openPage.h"
#import "Service_NavigationService.h"
#import "FlutterBoostPlugin_private.h"
#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application
@implementation NavigationService_openPage
#pragma mark - Do not edit these method.
- (BOOL)call:(id<FLBMessage>)msg result:(void (^)(NSDictionary *))result{
NSDictionary *args = msg.params;
NSString *url = args[@"url"];
NSDictionary *urlParams = args[@"urlParams"];
NSDictionary *exts = args[@"exts"];
[FLUTTER_APP open:url
urlParams:urlParams
exts:exts
reult:result
completion:^(BOOL) {}];
return YES;
}
- (NSString *)returnType
{
return @"NSDictionary *";
}
- (NSArray *)handledMessageNames
{
return @[@"openPage"];
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// Generated by AIOCodeGen do not edit!
#import "FLBMessageHandlerImp.h"
@interface NavigationService_pageOnStart : FLBMessageHandlerImp
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//Generated by AIOCodeGen.
#import "ServiceGateway.h"
#import "NavigationService_pageOnStart.h"
#import "FlutterBoostPlugin_private.h"
@implementation NavigationService_pageOnStart
- (void)onCall:(void (^)(NSDictionary *))result params:(NSDictionary *)params
{
NSMutableDictionary *pageInfo = [NSMutableDictionary new];
pageInfo[@"name"] =[FlutterBoostPlugin sharedInstance].fPagename;
pageInfo[@"params"] = [FlutterBoostPlugin sharedInstance].fParams;
pageInfo[@"uniqueId"] = [FlutterBoostPlugin sharedInstance].fPageId;
if(result) result(pageInfo);
}
#pragma mark - Do not edit these method.
- (BOOL)call:(id<FLBMessage>)msg result:(void (^)(NSDictionary *))result
{
NSDictionary *args = msg.params;
[self onCall:result params:args[@"params"]];
return YES;
}
- (NSString *)returnType
{
return @"NSDictionary *";
}
- (NSArray *)handledMessageNames
{
return @[@"pageOnStart"];
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
#import "FLBTypes.h"
NS_ASSUME_NONNULL_BEGIN
@interface FLBBroadcastor : NSObject
- (instancetype)initWithMethodChannel:(FlutterMethodChannel *)channel;
- (void)sendEvent:(NSString *)eventName
arguments:(NSDictionary *)arguments;
- (FLBVoidCallback)addEventListener:(FLBEventListener)listner
forName:(NSString *)name;
- (void)handleMethodCall:(FlutterMethodCall *)call
result:(FlutterResult)result;
@end
NS_ASSUME_NONNULL_END
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBBroadcastor.h"
@interface FLBBroadcastor()
@property (nonatomic,strong) FlutterMethodChannel *channel;
@property (nonatomic,strong) NSMutableDictionary *lists;
@end
@implementation FLBBroadcastor
- (instancetype)initWithMethodChannel:(FlutterMethodChannel *)channel
{
if (self = [super init]) {
_channel = channel;
_lists = NSMutableDictionary.new;
}
return self;
}
- (void)sendEvent:(NSString *)eventName
arguments:(NSDictionary *)arguments
{
if(!eventName) return;
NSMutableDictionary *msg = NSMutableDictionary.new;
msg[@"name"] = eventName;
msg[@"arguments"] = arguments;
[_channel invokeMethod:@"__event__"
arguments:msg
result:^(id r){}];
}
- (FLBVoidCallback)addEventListener:(FLBEventListener)listner
forName:(NSString *)name
{
if(!name || !listner) return ^{};
NSMutableArray *list = _lists[name];
if(!list){
list = NSMutableArray.new;
_lists[name] = list;
}
[list addObject:listner];
return ^{
[list removeObject:listner];
};
}
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
{
if([call.method isEqual:@"__event__"]){
NSString *name = call.arguments[@"name"];
NSDictionary *arguments = call.arguments[@"arguments"];
if(name){
NSMutableArray *list = _lists[name];
if(list){
for(FLBEventListener l in list){
l(name,arguments);
}
}
}
}
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import "FLBMessageing.h"
@interface FLBMessageDispather : NSObject<FLBMessageDispatcher>
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBMessageDispather.h"
@interface FLBMessageDispather()
@property (nonatomic,strong) NSMutableDictionary *handlerMap;
@end
@implementation FLBMessageDispather
- (instancetype)init
{
if (self = [super init]) {
_handlerMap = NSMutableDictionary.new;
}
return self;
}
- (BOOL)dispatch:(id<FLBMessage>)msg result:(void (^)(id date))result
{
if (msg) {
id<FLBMessageHandler> handler = _handlerMap[msg.name];
[handler handle:msg result:result];
return handler != nil;
}else{
return NO;
}
}
- (void)registerHandler:(id<FLBMessageHandler>)handler
{
if(!handler) return;
NSArray *methods = handler.handledMessageNames;
for(NSString *name in methods){
if(_handlerMap[name]){
NSAssert(NO, @"Conflicted method call name results in undefined error!");
}else{
_handlerMap[name] = handler;
}
}
}
- (void)removeHandler:(id<FLBMessageHandler>)handler
{
NSArray *methods = handler.handledMessageNames;
[_handlerMap removeObjectsForKeys:methods];
}
- (void)removeAll
{
[_handlerMap removeAllObjects];
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import "FLBMessageing.h"
@interface FLBMessageHandlerImp : NSObject<FLBMessageHandler>
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBMessageHandlerImp.h"
#import "FLBMessageImp.h"
typedef void (^SendResult)(NSObject *result);
@interface FLBMessageHandlerImp()
@property (nonatomic,strong) NSMutableDictionary *callHandlers;
@property (nonatomic,strong) NSMutableArray *methodNames;
@end
@implementation FLBMessageHandlerImp
- (instancetype)init{
if (self = [super init]) {
_callHandlers = [NSMutableDictionary new];
_methodNames = NSMutableArray.new;
[self bindCallMethod];
}
return self;
}
#pragma mark - method handling logic.
//Farward this msg to old entry.
- (BOOL)handle:(id<FLBMessage>)msg result:(void (^)(id data))result
{
return [self handleMethodCall:msg.name args:msg.params result:result];
}
- (NSArray *)handledMessageNames
{
return _methodNames;
}
- (bool)handleMethodCall:(NSString*)call
args:(NSDictionary *)args
result:(void (^)(id data))result
{
void (^handler)(NSDictionary *,SendResult) = [self findHandler:call];
if (handler) {
handler(args,result);
return YES;
}
return NO;
}
- (id)findHandler:(NSString *)call
{
return _callHandlers[call];
}
- (void)bindCallMethod
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
SEL method = @selector(call:result:);
for(NSString *name in self.handledMessageNames){
if (_callHandlers[name]) {
continue;
}
__weak typeof(self) weakSelf = self;
_callHandlers[name] = ^(NSDictionary *args,SendResult result){
id resultBlock = [weakSelf getHandlerBlockForType:weakSelf.returnType result:result];
if (resultBlock && result) {
FLBMessageImp *msg = FLBMessageImp.new;
msg.name = name;
msg.params = args;
[weakSelf performSelector:method withObject:msg withObject:resultBlock];
}else{
#if DEBUG
[NSException raise:@"invalid call" format:@"missing handler and result!"];
#endif
}
};
}
#pragma clang diagnostic pop
}
- (id)getHandlerBlockForType:(NSString *)type result:(SendResult)result
{
if ([type isEqual:@"int64_t"]) {
return ^(int64_t value){
result(@(value));
};
}
if ([type isEqual:@"double"]) {
return ^(double value){
result(@(value));
};
}
if ([type isEqual:@"BOOL"]) {
return ^(BOOL value){
result(@(value));
};
}
if ([type hasPrefix:@"NSString"]) {
return ^(NSString *value){
if ([value isKindOfClass:NSNumber.class]) {
#if DEBUG
[NSException raise:@"invalid type" format:@"require NSString!"];
#endif
value = ((NSNumber *)value).stringValue;
}
result(value);
};
}
if ([type hasPrefix:@"NSArray"]) {
return ^(NSArray *value){
result(value);
};
}
if ([type hasPrefix:@"NSDictionary"]) {
return ^(NSDictionary *value){
result(value);
};
}
if ([type isEqual:@"id"]) {
return result;
}
/*
@"int":@"int64_t",
@"double":@"double",
@"bool":@"BOOL",
@"String":@"NSString *",
*/
return nil;
}
- (NSString *)returnType
{
return @"id";
}
- (NSString *)service
{
return @"root";
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import "FLBMessageing.h"
NS_ASSUME_NONNULL_BEGIN
@interface FLBMessageImp : NSObject<FLBMessage>
@property (nonatomic,copy) NSString *name;
@property (nonatomic,strong) NSDictionary *params;
@end
NS_ASSUME_NONNULL_END
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBMessageImp.h"
@implementation FLBMessageImp
- (NSString *)name
{
return _name;
}
- (NSDictionary *)params
{
return _params;
}
@end
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
@protocol FLBMessage <NSObject>
@required
- (NSString *)name;
- (NSDictionary *)params;
@end
@protocol FLBMessageHandler <NSObject>
@required
- (BOOL)handle:(id<FLBMessage>)msg result:(void (^)(id result))result;
- (NSArray *)handledMessageNames;
- (NSString *)service;
@end
@protocol FLBMessageDispatcher <NSObject>
@required
- (BOOL)dispatch:(id<FLBMessage>)msg result:(void (^)(id result))result;
- (void)registerHandler:(id<FLBMessageHandler>) handler;
- (void)removeHandler:(id<FLBMessageHandler>) handler;
- (void)removeAll;
@end
......@@ -26,10 +26,10 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_boost/container/boost_container.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter_boost/messaging/native_page_container_event_handler.dart';
import 'package:flutter_boost/messaging/native_container_event_handler.dart';
import 'package:flutter_boost/support/logger.dart';
class ContainerCoordinator implements NativePageContainerEventHandler {
class ContainerCoordinator implements NativeContainerEventHandler {
static final ContainerCoordinator singleton = ContainerCoordinator();
final Map<String, PageBuilder> _pageBuilders = <String, PageBuilder>{};
......
......@@ -23,7 +23,7 @@
*/
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_boost/messaging/service/navigation_service.dart';
import 'package:flutter_boost/messaging/boost_message_channel.dart';
import 'package:flutter_boost/container/boost_container.dart';
import 'package:flutter_boost/container/container_coordinator.dart';
import 'package:flutter_boost/flutter_boost.dart';
......@@ -135,7 +135,7 @@ class ContainerManagerState extends State<BoostContainerManager> {
void _onShownContainerChanged(String old, String now) {
Logger.log('onShownContainerChanged old:$old now:$now');
NavigationService.onShownContainerChanged(now, old, <dynamic, dynamic>{});
BoostMessageChannel.onShownContainerChanged(now, old, <dynamic, dynamic>{});
}
void _refreshOverlayEntries() {
......
......@@ -24,21 +24,12 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_boost/messaging/service/navigation_service.dart';
import 'package:flutter_boost/messaging/boost_message_channel.dart';
import 'package:flutter_boost/container/boost_container.dart';
import 'package:flutter_boost/container/container_manager.dart';
import 'package:flutter_boost/router/router.dart';
import 'container/container_coordinator.dart';
import 'messaging/base/message_dispatcher.dart';
import 'messaging/handlers/did_disappear_page_container_handler.dart';
import 'messaging/handlers/did_show_page_container_handler.dart';
import 'messaging/handlers/did_init_page_container_handler.dart';
import 'messaging/handlers/on_native_page_result_handler.dart';
import 'messaging/handlers/will_dealloc_page_container_handler.dart';
import 'messaging/handlers/will_show_page_container_handler.dart';
import 'messaging/handlers/will_disappear_page_container_handler.dart';
import 'messaging/base/broadcastor.dart';
import 'observers_holders.dart';
export 'container/boost_container.dart';
......@@ -61,13 +52,9 @@ class FlutterBoost {
final ObserversHolder _observersHolder = ObserversHolder();
final Router _router = Router();
final MethodChannel _methodChannel = MethodChannel('flutter_boost_method');
final EventChannel _eventChannel = EventChannel('flutter_boost_event');
final MessageDispatcher _dispatcher = MessageDispatcher();
int _callbackID = 0;
Broadcastor _broadcastor;
static FlutterBoost get singleton => _instance;
static ContainerManagerState get containerManager =>
......@@ -99,26 +86,49 @@ class FlutterBoost {
ObserversHolder get observersHolder => _observersHolder;
FlutterBoost() {
_broadcastor = Broadcastor(_methodChannel);
//Config message handlers
NavigationService.methodChannel = _methodChannel;
_dispatcher.registerHandler(DidDisappearPageContainerHandler());
_dispatcher.registerHandler(DidInitPageContainerHandler());
_dispatcher.registerHandler(DidShowPageContainerHandler());
_dispatcher.registerHandler(OnNativePageResultHandler());
_dispatcher.registerHandler(WillDeallocPageContainerHandler());
_dispatcher.registerHandler(WillShowPageContainerHandler());
_dispatcher.registerHandler(WillDisappearPageContainerHandler());
BoostMessageChannel.methodChannel = _methodChannel;
_methodChannel.setMethodCallHandler((MethodCall call){
if(call.method == "__event__"){
//Handler broadcast event.
return _broadcastor.handleCall(call);
}else{
return _dispatcher.dispatch(call);
return BoostMessageChannel.handleEventCall(call);
}else if(call.method == "didDisappearPageContainer"){
String pageName = call.arguments["pageName"];
Map params = call.arguments["params"];
String uniqueId = call.arguments["uniqueId"];
ContainerCoordinator.singleton
.nativeContainerDidDisappear(pageName, params, uniqueId);
}else if(call.method == "nativeContainerDidInit"){
String pageName = call.arguments["pageName"];
Map params = call.arguments["params"];
String uniqueId = call.arguments["uniqueId"];
ContainerCoordinator.singleton
.nativeContainerDidInit(pageName, params, uniqueId);
}else if(call.method == "didShowPageContainer"){
String pageName = call.arguments["pageName"];
Map params = call.arguments["params"];
String uniqueId = call.arguments["uniqueId"];
ContainerCoordinator.singleton
.nativeContainerDidShow(pageName, params, uniqueId);
}else if(call.method == "willDeallocPageContainer"){
String pageName = call.arguments["pageName"];
Map params = call.arguments["params"];
String uniqueId = call.arguments["uniqueId"];
ContainerCoordinator.singleton
.nativeContainerWillDealloc(pageName, params, uniqueId);
}else if(call.method == "willDisappearPageContainer"){
String pageName = call.arguments["pageName"];
Map params = call.arguments["params"];
String uniqueId = call.arguments["uniqueId"];
ContainerCoordinator.singleton
.nativeContainerWillDisappear(pageName, params, uniqueId);
}else if(call.method == "willShowPageContainer"){
String pageName = call.arguments["pageName"];
Map params = call.arguments["params"];
String uniqueId = call.arguments["uniqueId"];
ContainerCoordinator.singleton
.nativeContainerWillShow(pageName, params, uniqueId);
}
return Future<dynamic>((){});
});
}
......@@ -157,12 +167,12 @@ class FlutterBoost {
//Listen broadcast event from native.
Function addEventListener(String name , EventListener listener){
return _broadcastor.addEventListener(name, listener);
return BoostMessageChannel.addEventListener(name, listener);
}
//Send broadcast event to native.
void sendEvent(String name , Map arguments){
_broadcastor.sendEvent(name, arguments);
BoostMessageChannel.sendEvent(name, arguments);
}
Future<Map<String,dynamic>> openPage(String name, Map params,{bool animated}) {
......@@ -193,7 +203,7 @@ class FlutterBoost {
exts["params"] = params;
}
close(id, result: {} , exts: exts);
return close(id, result: {} , exts: exts);
}
......@@ -211,7 +221,7 @@ class FlutterBoost {
///query current top page and show it
static void handleOnStartPage() async {
final Map<dynamic, dynamic> pageInfo =
await NavigationService.pageOnStart(<dynamic, dynamic>{});
await BoostMessageChannel.pageOnStart(<dynamic, dynamic>{});
if (pageInfo == null || pageInfo.isEmpty) return;
if (pageInfo.containsKey("name") &&
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'package:flutter/services.dart';
typedef Future<dynamic> EventListener(String name , Map arguments);
class Broadcastor{
MethodChannel _channel;
Map<String,List<EventListener>> _lists = Map();
Broadcastor(MethodChannel channel){
_channel = channel;
}
void sendEvent(String name , Map arguments){
if(name == null) {
return;
}
if(arguments == null){
arguments = Map();
}
Map msg = Map();
msg["name"] = name;
msg["arguments"] = arguments;
_channel.invokeMethod("__event__",msg);
}
Function addEventListener(String name , EventListener listener){
if(name == null || listener == null){
return (){};
}
List<EventListener> list = _lists[name];
if(list == null){
list = List();
_lists[name] = list;
}
list.add(listener);
return (){
list.remove(listener);
};
}
Future<dynamic> handleCall(MethodCall call){
if(call.method != "__event__"){
return Future<dynamic>((){});
}
String name = call.arguments["name"];
Map arg = call.arguments["arguments"];
List<EventListener> list = _lists[name];
if(list != null){
for(EventListener l in list){
l(name,arg);
}
}
return Future<dynamic>((){});
}
}
\ No newline at end of file
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
import 'message_handler.dart';
class MessageDispatcher{
Map<String,MessageHandler> _handlers = Map();
Future<dynamic> dispatch(MethodCall call){
if(_handlers.containsKey(call.method)){
return _handlers[call.method].onMethodCall(call);
}{
return null;
}
}
void registerHandler(MessageHandler handler){
_handlers[handler.name()] = handler;
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
abstract class MessageHandler{
String name();
Future<dynamic> onMethodCall(MethodCall call);
}
\ No newline at end of file
......@@ -25,11 +25,67 @@
import 'dart:async';
import 'package:flutter/services.dart';
typedef Future<dynamic> EventListener(String name , Map arguments);
class NavigationService {
class BoostMessageChannel {
static MethodChannel methodChannel;
static Map<String,List<EventListener>> _lists = Map();
static void sendEvent(String name , Map arguments){
if(name == null) {
return;
}
if(arguments == null){
arguments = Map();
}
Map msg = Map();
msg["name"] = name;
msg["arguments"] = arguments;
methodChannel.invokeMethod("__event__",msg);
}
static Function addEventListener(String name , EventListener listener){
if(name == null || listener == null){
return (){};
}
List<EventListener> list = _lists[name];
if(list == null){
list = List();
_lists[name] = list;
}
list.add(listener);
return (){
list.remove(listener);
};
}
static Future<dynamic> handleEventCall(MethodCall call){
if(call.method != "__event__"){
return Future<dynamic>((){});
}
String name = call.arguments["name"];
Map arg = call.arguments["arguments"];
List<EventListener> list = _lists[name];
if(list != null){
for(EventListener l in list){
l(name,arg);
}
}
return Future<dynamic>((){});
}
static Future<bool> onShownContainerChanged(String newName,String oldName,Map params) {
Map<String,dynamic> properties = new Map<String,dynamic>();
properties["newName"]=newName;
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_boost/container/container_coordinator.dart';
import 'package:flutter_boost/messaging/base/message_handler.dart';
class DidDisappearPageContainerHandler implements MessageHandler {
@override
String name() {
return "didDisappearPageContainer";
}
@override
Future<bool> onMethodCall(MethodCall call) {
return onCall(call.arguments["pageName"], call.arguments["params"],
call.arguments["uniqueId"]);
}
//==============================================Do not edit code above!
Future<bool> onCall(String pageName, Map params, String uniqueId) async {
return ContainerCoordinator.singleton
.nativeContainerDidDisappear(pageName, params, uniqueId);
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_boost/container/container_coordinator.dart';
import 'package:flutter_boost/messaging/base/message_handler.dart';
class DidInitPageContainerHandler implements MessageHandler {
static void regsiter() {
// ServiceGateway.sharedInstance()
// .registerHandler(new NavigationService_didInitPageContainer());
}
@override
String name() {
return "didInitPageContainer";
}
@override
Future<bool> onMethodCall(MethodCall call) {
return onCall(call.arguments["pageName"], call.arguments["params"],
call.arguments["uniqueId"]);
}
//==============================================Do not edit code above!
Future<bool> onCall(String pageName, Map params, String uniqueId) async {
return ContainerCoordinator.singleton
.nativeContainerDidInit(pageName, params, uniqueId);
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_boost/container/container_coordinator.dart';
import 'package:flutter_boost/messaging/base/message_handler.dart';
class DidShowPageContainerHandler implements MessageHandler {
@override
String name() {
return "didShowPageContainer";
}
@override
Future<bool> onMethodCall(MethodCall call) {
return onCall(call.arguments["pageName"], call.arguments["params"],
call.arguments["uniqueId"]);
}
//==============================================Do not edit code above!
Future<bool> onCall(String pageName, Map params, String uniqueId) async {
return ContainerCoordinator.singleton
.nativeContainerDidShow(pageName, params, uniqueId);
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_boost/messaging/base/message_handler.dart';
class OnNativePageResultHandler implements MessageHandler {
@override
String name() {
return "onNativePageResult";
}
@override
Future<bool> onMethodCall(MethodCall call) {
return onCall(call.arguments["uniqueId"],call.arguments["key"],call.arguments["resultData"],call.arguments["params"]);
}
//==============================================Do not edit code above!
Future<bool> onCall(String uniqueId,String key,Map resultData,Map params) async{
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_boost/container/container_coordinator.dart';
import 'package:flutter_boost/messaging/base/message_handler.dart';
class WillDeallocPageContainerHandler implements MessageHandler {
@override
String name() {
return "willDeallocPageContainer";
}
@override
Future<bool> onMethodCall(MethodCall call) {
return onCall(call.arguments["pageName"], call.arguments["params"],
call.arguments["uniqueId"]);
}
//==============================================Do not edit code above!
Future<bool> onCall(String pageName, Map params, String uniqueId) async {
return ContainerCoordinator.singleton
.nativeContainerWillDealloc(pageName, params, uniqueId);
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_boost/container/container_coordinator.dart';
import 'package:flutter_boost/messaging/base/message_handler.dart';
class WillDisappearPageContainerHandler implements MessageHandler {
@override
String name() {
return "willDisappearPageContainer";
}
@override
Future<bool> onMethodCall(MethodCall call) {
return onCall(call.arguments["pageName"], call.arguments["params"],
call.arguments["uniqueId"]);
}
//==============================================Do not edit code above!
Future<bool> onCall(String pageName, Map params, String uniqueId) async {
return ContainerCoordinator.singleton
.nativeContainerWillDisappear(pageName, params, uniqueId);
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_boost/container/container_coordinator.dart';
import 'package:flutter_boost/messaging/base/message_handler.dart';
class WillShowPageContainerHandler implements MessageHandler {
@override
String name() {
return "willShowPageContainer";
}
@override
Future<bool> onMethodCall(MethodCall call) {
return onCall(call.arguments["pageName"], call.arguments["params"],
call.arguments["uniqueId"]);
}
//==============================================Do not edit code above!
Future<bool> onCall(String pageName, Map params, String uniqueId) async {
return ContainerCoordinator.singleton
.nativeContainerWillShow(pageName, params, uniqueId);
}
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'package:flutter_boost/messaging/service/navigation_service.dart';
import 'dart:async';
abstract class MessageProxy{
Future<Map<dynamic,dynamic>> open(String url,{Map<String,dynamic> urlParams,Map<String,dynamic> exts});
Future<bool> close(String id,{Map<String,dynamic> result,Map<String,dynamic> exts});
}
class MessageProxyImp implements MessageProxy{
@override
Future<Map<dynamic,dynamic>> open(String url,{Map<String,dynamic> urlParams,Map<String,dynamic> exts}){
return NavigationService.openPage(url, urlParams, exts);
}
@override
Future<bool> close(String id,{Map<String,dynamic> result,Map<String,dynamic> exts}){
return NavigationService.closePage(id,result: result,exts: exts);
}
}
......@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
abstract class NativePageContainerEventHandler{
abstract class NativeContainerEventHandler{
bool nativeContainerWillShow(String name , Map params, String pageId);
bool nativeContainerDidShow(String name , Map params, String pageId);
bool nativeContainerWillDisappear(String name , Map params, String pageId);
......
......@@ -25,25 +25,17 @@ import 'dart:async';
import 'package:flutter_boost/container/boost_container.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:flutter_boost/messaging/message_proxy.dart';
import 'package:flutter_boost/support/logger.dart';
import 'package:flutter_boost/messaging/boost_message_channel.dart';
class Router {
MessageProxy _msgProxy = MessageProxyImp();
void setMessageProxy(MessageProxy prx) {
if (prx != null) {
_msgProxy = prx;
}
}
Future<Map<dynamic,dynamic>> open(String url,{Map<String,dynamic> urlParams,Map<String,dynamic> exts}){
return _msgProxy.open(url,urlParams: urlParams,exts: exts);
return BoostMessageChannel.openPage(url,urlParams, exts);
}
Future<bool> close(String id,{Map<String,dynamic> result,Map<String,dynamic> exts}){
return _msgProxy.close(id,result:result,exts: exts);
return BoostMessageChannel.closePage(id,result:result,exts: exts);
}
......@@ -74,6 +66,6 @@ class Router {
Map<String,dynamic> exts = Map();
exts["animated"] = animated;
return _msgProxy.close(settings.uniqueId,result: {} ,exts: exts);
return BoostMessageChannel.closePage(settings.uniqueId,result: {} ,exts: exts);
}
}
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