Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢冠章
flutter_boost_1.22.4
Commits
b393b000
Commit
b393b000
authored
Jun 20, 2019
by
Jidong Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
accabe65
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
188 additions
and
420 deletions
+188
-420
example/ios/Podfile.lock
example/ios/Podfile.lock
+1
-2
ios/Classes/1.0/FLBFlutterApplication.m
ios/Classes/1.0/FLBFlutterApplication.m
+24
-1
ios/Classes/1.5/FLB2FlutterApplication.m
ios/Classes/1.5/FLB2FlutterApplication.m
+15
-0
ios/Classes/Boost/FLB2Platform.h
ios/Classes/Boost/FLB2Platform.h
+7
-7
ios/Classes/Boost/FLBFlutterApplicationInterface.h
ios/Classes/Boost/FLBFlutterApplicationInterface.h
+14
-0
ios/Classes/Boost/FLBResultMediator.h
ios/Classes/Boost/FLBResultMediator.h
+0
-39
ios/Classes/Boost/FLBResultMediator.m
ios/Classes/Boost/FLBResultMediator.m
+0
-98
ios/Classes/Boost/FlutterBoostPlugin.h
ios/Classes/Boost/FlutterBoostPlugin.h
+0
-14
ios/Classes/Boost/FlutterBoostPlugin.m
ios/Classes/Boost/FlutterBoostPlugin.m
+1
-33
ios/Classes/Boost/FlutterBoostPlugin_private.h
ios/Classes/Boost/FlutterBoostPlugin_private.h
+0
-3
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_closePage.mm
...NavigationService/handlers/NavigationService_closePage.mm
+9
-22
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.mm
...Service/handlers/NavigationService_onFlutterPageResult.mm
+1
-4
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.mm
.../NavigationService/handlers/NavigationService_openPage.mm
+10
-14
lib/flutter_boost.dart
lib/flutter_boost.dart
+70
-61
lib/messaging/handlers/on_native_page_result_handler.dart
lib/messaging/handlers/on_native_page_result_handler.dart
+0
-2
lib/messaging/message_proxy.dart
lib/messaging/message_proxy.dart
+10
-6
lib/messaging/page_result_mediator.dart
lib/messaging/page_result_mediator.dart
+0
-81
lib/messaging/service/navigation_service.dart
lib/messaging/service/navigation_service.dart
+17
-11
lib/router/router.dart
lib/router/router.dart
+9
-22
No files found.
example/ios/Podfile.lock
View file @
b393b000
...
...
@@ -2,7 +2,6 @@ PODS:
- Flutter (1.0.0)
- flutter_boost (0.0.1):
- Flutter
- xservice_kit
- xservice_kit (0.0.1):
- Flutter
...
...
@@ -21,7 +20,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
flutter_boost:
6a083f2f1b67f9b08724d6c4b280a099d1b40797
flutter_boost:
a018687cd20f74f410a6ab17bd33187f5f31f8fd
xservice_kit: a86c64372b3e41e7d8e9b1a0b9139866680f525c
PODFILE CHECKSUM: 2a757a7bdc03b37a2814666652fdff1cf694243f
...
...
ios/Classes/1.0/FLBFlutterApplication.m
View file @
b393b000
...
...
@@ -128,7 +128,30 @@
-
(
id
<
FLB2FlutterProvider
>
)
flutterProvider
{
return
_viewProvider
;
return
(
id
)
_viewProvider
;
}
-
(
void
)
close
:(
NSString
*
)
uid
result
:(
NSDictionary
*
)
result
exts
:(
NSDictionary
*
)
exts
completion
:(
void
(
^
)(
BOOL
))
completion
{
[
self
.
platform
closePage
:
uid
animated:
[
exts
[
@"animated"
]
boolValue
]
params:
exts
[
@"params"
]
completion:
completion
];
}
-
(
void
)
open
:(
NSString
*
)
url
urlParams
:(
NSDictionary
*
)
urlParams
exts
:(
NSDictionary
*
)
exts
reult
:(
void
(
^
)(
NSDictionary
*
))
resultCallback
completion
:(
void
(
^
)(
BOOL
))
completion
{
[
self
.
platform
openPage
:
url
params:
urlParams
animated:
[
exts
[
@"animated"
]
boolValue
]
completion:
completion
];
}
@end
ios/Classes/1.5/FLB2FlutterApplication.m
View file @
b393b000
...
...
@@ -129,4 +129,19 @@
return
self
.
flutterProvider
.
engine
.
viewController
;
}
-
(
void
)
close
:(
NSString
*
)
uid
result
:(
NSDictionary
*
)
result
exts
:(
NSDictionary
*
)
exts
completion
:(
void
(
^
)(
BOOL
))
completion
{
}
-
(
void
)
open
:(
NSString
*
)
url
urlParams
:(
NSDictionary
*
)
urlParams
exts
:(
NSDictionary
*
)
exts
reult
:(
void
(
^
)(
NSDictionary
*
))
resultCallback
completion
:(
void
(
^
)(
BOOL
))
completion
{
}
@end
ios/Classes/Boost/FLB2Platform.h
View file @
b393b000
...
...
@@ -33,14 +33,14 @@ NS_ASSUME_NONNULL_BEGIN
-
(
BOOL
)
userBoost2
;
@required
-
(
void
)
open
Page
:(
NSString
*
)
name
params
:(
NSDictionary
*
)
p
arams
animated
:(
BOOL
)
animated
-
(
void
)
open
:(
NSString
*
)
url
urlParams
:(
NSDictionary
*
)
urlP
arams
exts
:(
BOOL
)
animated
completion
:(
void
(
^
)(
BOOL
finished
))
completion
;
-
(
void
)
close
Page
:(
NSString
*
)
uid
animated
:(
BOOL
)
animated
params
:(
NSDictionary
*
)
param
s
-
(
void
)
close
:(
NSString
*
)
uid
result
:(
NSDictionary
*
)
result
exts
:(
NSDictionary
*
)
ext
s
completion
:(
void
(
^
)(
BOOL
finished
))
completion
;
@end
...
...
ios/Classes/Boost/FLBFlutterApplicationInterface.h
View file @
b393b000
...
...
@@ -55,6 +55,20 @@ NS_ASSUME_NONNULL_BEGIN
-
(
void
)
resume
;
-
(
void
)
inactive
;
-
(
BOOL
)
isRunning
;
#pragma mark - handle close/open messages
-
(
void
)
close
:(
NSString
*
)
uid
result
:(
NSDictionary
*
)
result
exts
:(
NSDictionary
*
)
exts
completion
:(
void
(
^
)(
BOOL
))
completion
;
-
(
void
)
open
:(
NSString
*
)
url
urlParams
:(
NSDictionary
*
)
urlParams
exts
:(
NSDictionary
*
)
exts
reult
:(
void
(
^
)(
NSDictionary
*
))
resultCallback
completion
:(
void
(
^
)(
BOOL
))
completion
;
@end
NS_ASSUME_NONNULL_END
...
...
ios/Classes/Boost/FLBResultMediator.h
deleted
100755 → 0
View file @
accabe65
/*
* 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>
NS_ASSUME_NONNULL_BEGIN
typedef
void
(
^
FLBPageResultHandler
)(
NSString
*
,
NSDictionary
*
);
@interface
FLBResultMediator
:
NSObject
-
(
void
)
onResultForKey
:(
NSString
*
)
resultId
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
;
-
(
void
)
setResultHandler
:(
FLBPageResultHandler
)
handler
forKey
:(
NSString
*
)
vcid
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
@end
NS_ASSUME_NONNULL_END
ios/Classes/Boost/FLBResultMediator.m
deleted
100755 → 0
View file @
accabe65
/*
* 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 "FLBResultMediator.h"
#import "Service_NavigationService.h"
@interface
FLBResultMediator
()
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
handlers
;
@end
@implementation
FLBResultMediator
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
_handlers
=
[
NSMutableDictionary
new
];
}
return
self
;
}
-
(
void
)
onResultForKey
:(
NSString
*
)
rid
resultData
:(
NSDictionary
*
)
resultData
params
:(
nonnull
NSDictionary
*
)
params
{
if
(
!
rid
)
return
;
NSString
*
key
=
rid
;
if
(
_handlers
[
key
]){
FLBPageResultHandler
handler
=
_handlers
[
key
];
handler
(
key
,
resultData
);
[
_handlers
removeObjectForKey
:
key
];
}
else
{
//Cannot find handler here. Try to forward message to flutter.
//Use forward to avoid circle.
if
(
!
params
||
!
params
[
@"forward"
]){
NSMutableDictionary
*
tmp
=
params
.
mutableCopy
;
if
(
!
tmp
){
tmp
=
NSMutableDictionary
.
new
;
}
tmp
[
@"forward"
]
=
@
(
1
);
params
=
tmp
;
[
Service_NavigationService
onNativePageResult
:
^
(
NSNumber
*
r
)
{}
uniqueId:
rid
key:
rid
resultData:
resultData
params:
params
];
}
else
{
NSMutableDictionary
*
tmp
=
params
.
mutableCopy
;
tmp
[
@"forward"
]
=
@
([
params
[
@"forward"
]
intValue
]
+
1
);
params
=
tmp
;
if
([
params
[
@"forward"
]
intValue
]
<=
2
){
[
Service_NavigationService
onNativePageResult
:
^
(
NSNumber
*
r
)
{}
uniqueId:
rid
key:
rid
resultData:
resultData
params:
params
];
}
}
}
}
-
(
void
)
setResultHandler
:(
FLBPageResultHandler
)
handler
forKey
:(
NSString
*
)
vcid
{
if
(
!
handler
||
!
vcid
)
return
;
_handlers
[
vcid
]
=
handler
;
}
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
{
if
(
!
vcid
)
return
;
[
_handlers
removeObjectForKey
:
vcid
];
}
@end
ios/Classes/Boost/FlutterBoostPlugin.h
View file @
b393b000
...
...
@@ -46,18 +46,4 @@
-
(
FLBVoidCallback
)
addEventListener
:(
FLBEventListener
)
listner
forName
:(
NSString
*
)
name
;
#pragma mark - handing vc result.
-
(
void
)
openPage
:(
NSString
*
)
name
params
:(
NSDictionary
*
)
params
animated
:(
BOOL
)
animated
completion
:(
void
(
^
)(
BOOL
finished
))
completion
resultHandler
:(
void
(
^
)(
NSString
*
resultId
,
NSDictionary
*
rData
))
resultHandler
;
-
(
void
)
onResultForKey
:(
NSString
*
)
vcId
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
;
-
(
void
)
setResultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
handler
forKey
:(
NSString
*
)
result_id
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
@end
ios/Classes/Boost/FlutterBoostPlugin.m
View file @
b393b000
...
...
@@ -23,7 +23,6 @@
*/
#import "FlutterBoostPlugin.h"
#import "FLBResultMediator.h"
#import "FlutterBoostPlugin_private.h"
#import "FLBFactory.h"
#import "FLB2Factory.h"
...
...
@@ -97,7 +96,6 @@
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
_resultMediator
=
[
FLBResultMediator
new
];
_dispatcher
=
FLBMessageDispather
.
new
;
}
...
...
@@ -109,10 +107,6 @@
return
_application
;
}
-
(
FLBResultMediator
*
)
resultMediator
{
return
_resultMediator
;
}
-
(
id
<
FLBAbstractFactory
>
)
factory
{
...
...
@@ -149,32 +143,6 @@
return
[
self
.
application
flutterViewController
];
}
-
(
void
)
openPage
:(
NSString
*
)
name
params
:(
NSDictionary
*
)
params
animated
:(
BOOL
)
animated
completion
:(
void
(
^
)(
BOOL
))
completion
resultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
resultHandler
{
static
int
kRid
=
0
;
NSString
*
resultId
=
[
NSString
stringWithFormat
:
@"result_id_%d"
,
kRid
++
];
[
_resultMediator
setResultHandler
:
^
(
NSString
*
_Nonnull
resultId
,
NSDictionary
*
_Nonnull
resultData
)
{
if
(
resultHandler
)
resultHandler
(
resultId
,
resultData
);
}
forKey
:
resultId
];
}
-
(
void
)
onResultForKey
:(
NSString
*
)
vcId
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
{
[
_resultMediator
onResultForKey
:
vcId
resultData
:
resultData
params
:
params
];
}
-
(
void
)
setResultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
handler
forKey
:(
NSString
*
)
vcid
{
[
_resultMediator
setResultHandler
:
handler
forKey
:
vcid
];
}
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
{
[
_resultMediator
removeHandlerForKey
:
vcid
];
}
#pragma mark - broadcast event to/from flutter
-
(
void
)
sendEvent
:(
NSString
*
)
eventName
...
...
@@ -187,7 +155,7 @@
-
(
FLBVoidCallback
)
addEventListener
:(
FLBEventListener
)
listner
forName
:(
NSString
*
)
name
{
[
_broadcastor
addEventListener
:
listner
return
[
_broadcastor
addEventListener
:
listner
forName:
name
];
}
...
...
ios/Classes/Boost/FlutterBoostPlugin_private.h
View file @
b393b000
...
...
@@ -24,17 +24,14 @@
#import <Flutter/Flutter.h>
#import "FLBFlutterApplicationInterface.h"
#import "FLBResultMediator.h"
#import "FLBAbstractFactory.h"
@interface
FlutterBoostPlugin
(){
id
<
FLBFlutterApplicationInterface
>
_application
;
FLBResultMediator
*
_resultMediator
;
id
<
FLBAbstractFactory
>
_factory
;
}
-
(
id
<
FLBFlutterApplicationInterface
>
)
application
;
-
(
FLBResultMediator
*
)
resultMediator
;
-
(
id
<
FLBAbstractFactory
>
)
factory
;
@property
(
nonatomic
,
strong
)
FlutterMethodChannel
*
methodChannel
;
...
...
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_closePage.mm
View file @
b393b000
...
...
@@ -31,30 +31,17 @@
@implementation
NavigationService_closePage
-
(
void
)
onCall
:(
void
(
^
)(
BOOL
))
result
uniqueId
:(
NSString
*
)
uniqueId
pageName
:(
NSString
*
)
pageName
params
:(
NSDictionary
*
)
params
animated
:(
NSNumber
*
)
animated
{
//Add your handler code here!
[
FLUTTER_APP
.
platform
closePage
:
uniqueId
animated:
animated
.
boolValue
params:
params
completion:
^
(
BOOL
finished
)
{
if
(
result
)
result
(
finished
);
}];
}
#pragma mark - Do not edit these method.
-
(
BOOL
)
call
:(
id
<
FLBMessage
>
)
msg
result
:(
void
(
^
)(
BOOL
))
result
-
(
BOOL
)
call
:(
id
<
FLBMessage
>
)
msg
result
:(
void
(
^
)(
BOOL
))
result
Block
{
NSDictionary
*
args
=
msg
.
params
;
[
self
onCall
:
result
uniqueId:
args
[
@"uniqueId"
]
pageName:
args
[
@"pageName"
]
params:
args
[
@"params"
]
animated:
args
[
@"animated"
]];
NSDictionary
*
exts
=
args
[
@"exts"
];
NSString
*
uid
=
args
[
@"uniqueId"
];
NSDictionary
*
resultData
=
args
[
@"result"
];
[
FLUTTER_APP
close
:
uid
result:
resultData
exts:
exts
completion:
resultBlock
];
return
YES
;
}
...
...
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.mm
View file @
b393b000
...
...
@@ -32,10 +32,7 @@
-
(
void
)
onCall
:(
void
(
^
)(
BOOL
))
result
uniqueId
:(
NSString
*
)
uniqueId
key
:(
NSString
*
)
key
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
{
//Add your handler code here!
[
FlutterBoostPlugin
.
sharedInstance
onResultForKey
:
key
resultData:
resultData
params:
params
];
}
#pragma mark - Do not edit these method.
...
...
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.mm
View file @
b393b000
...
...
@@ -33,27 +33,23 @@
@implementation
NavigationService_openPage
-
(
void
)
onCall
:(
void
(
^
)(
BOOL
))
result
pageName
:(
NSString
*
)
pageName
params
:(
NSDictionary
*
)
params
animated
:(
NSNumber
*
)
animated
{
[
FLUTTER_APP
.
platform
openPage
:
pageName
params:
params
animated:
animated
.
boolValue
completion:
^
(
BOOL
finished
)
{
if
(
result
)
result
(
YES
);
}];
}
#pragma mark - Do not edit these method.
-
(
BOOL
)
call
:(
id
<
FLBMessage
>
)
msg
result
:(
void
(
^
)(
BOOL
))
result
{
-
(
BOOL
)
call
:(
id
<
FLBMessage
>
)
msg
result
:(
void
(
^
)(
NSDictionary
*
))
result
{
NSDictionary
*
args
=
msg
.
params
;
[
self
onCall
:
result
pageName
:
args
[
@"pageName"
]
params
:
args
[
@"params"
]
animated
:
args
[
@"animated"
]];
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
@"
BOOL
"
;
return
@"
NSDictionary *
"
;
}
-
(
NSArray
*
)
handledMessageNames
...
...
lib/flutter_boost.dart
View file @
b393b000
...
...
@@ -55,43 +55,16 @@ typedef void PostPushRoute(
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
result
);
class
FlutterBoost
{
static
final
FlutterBoost
_instance
=
FlutterBoost
();
final
GlobalKey
<
ContainerManagerState
>
containerManagerKey
=
GlobalKey
<
ContainerManagerState
>();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
PageResultMediator
_resultMediator
=
PageResultMediator
();
final
Router
_router
=
Router
();
final
MethodChannel
_methodChannel
=
MethodChannel
(
'flutter_boost'
);
final
MessageDispatcher
_dispatcher
=
MessageDispatcher
();
Broadcastor
_broadcastor
;
FlutterBoost
()
{
_router
.
resultMediator
=
_resultMediator
;
_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
());
_methodChannel
.
setMethodCallHandler
((
MethodCall
call
){
if
(
call
.
method
==
"__event__"
){
//Handler broadcast event.
return
_broadcastor
.
handleCall
(
call
);
}
else
{
return
_dispatcher
.
dispatch
(
call
);
}
});
}
Broadcastor
_broadcastor
;
static
FlutterBoost
get
singleton
=>
_instance
;
...
...
@@ -123,6 +96,31 @@ 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
());
_methodChannel
.
setMethodCallHandler
((
MethodCall
call
){
if
(
call
.
method
==
"__event__"
){
//Handler broadcast event.
return
_broadcastor
.
handleCall
(
call
);
}
else
{
return
_dispatcher
.
dispatch
(
call
);
}
});
}
///Register a default page builder.
void
registerDefaultPageBuilder
(
PageBuilder
builder
)
{
ContainerCoordinator
.
singleton
.
registerDefaultPageBuilder
(
builder
);
...
...
@@ -133,17 +131,52 @@ class FlutterBoost {
ContainerCoordinator
.
singleton
.
registerPageBuilders
(
builders
);
}
Future
<
bool
>
openPage
(
String
name
,
Map
params
,
{
bool
animated
,
PageResultHandler
resultHandler
})
{
return
_router
.
openPage
(
name
,
params
,
animated:
animated
,
resultHandler:
resultHandler
);
Future
<
Map
<
String
,
dynamic
>>
open
(
String
url
,{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
}){
return
_router
.
open
(
url
,
urlParams:
urlParams
,
exts:
exts
);
}
Future
<
bool
>
close
(
String
id
,{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
}){
return
_router
.
close
(
id
,
result:
result
,
exts:
exts
);
}
//Listen broadcast event from native.
Function
addEventListener
(
String
name
,
EventListener
listener
){
return
_broadcastor
.
addEventListener
(
name
,
listener
);
}
//Send broadcast event to native.
void
sendEvent
(
String
name
,
Map
arguments
){
_broadcastor
.
sendEvent
(
name
,
arguments
);
}
Future
<
bool
>
openPage
(
String
name
,
Map
params
,{
bool
animated
})
{
Map
<
String
,
dynamic
>
exts
=
Map
();
if
(
animated
!=
null
){
exts
[
"animated"
]
=
animated
;
}
return
open
(
name
,
urlParams:
params
,
exts:
exts
);
}
Future
<
bool
>
closePage
(
String
name
,
String
pageI
d
,
Map
params
,
Future
<
bool
>
closePage
(
String
url
,
String
i
d
,
Map
params
,
{
bool
animated
})
{
return
_router
.
closePage
(
name
,
pageId
,
params
,
animated:
animated
);
Map
<
String
,
dynamic
>
exts
=
Map
();
if
(
animated
!=
null
){
exts
[
"animated"
]
=
animated
;
}
if
(
name
!=
null
){
exts
[
"url"
]
=
url
;
}
if
(
params
!=
null
){
exts
[
"params"
]
=
params
;
}
close
(
id
,
result:
{}
,
exts:
exts
);
}
//Close currentPage page.
Future
<
bool
>
closeCurPage
(
Map
params
)
{
return
_router
.
closeCurPage
(
params
);
...
...
@@ -170,21 +203,6 @@ class FlutterBoost {
}
bool
onPageResult
(
String
key
,
Map
resultData
,
Map
params
)
{
if
(
_resultMediator
.
isResultId
(
key
)){
_resultMediator
.
onPageResult
(
key
,
resultData
,
params
);
}
else
{
containerManager
?.
containerStateOf
(
key
)?.
performOnResult
(
resultData
);
}
return
true
;
}
VoidCallback
setPageResultHandler
(
String
key
,
PageResultHandler
handler
)
{
return
_resultMediator
.
setPageResultHandler
(
key
,
handler
);
}
///register for Container changed callbacks
VoidCallback
addContainerObserver
(
BoostContainerObserver
observer
)
=>
_observersHolder
.
addObserver
<
BoostContainerObserver
>(
observer
);
...
...
@@ -199,13 +217,4 @@ class FlutterBoost {
_observersHolder
.
addObserver
<
BoostNavigatorObserver
>(
observer
);
//Listen broadcast event from native.
Function
addEventListener
(
String
name
,
EventListener
listener
){
return
_broadcastor
.
addEventListener
(
name
,
listener
);
}
//Send broadcast event to native.
void
sendEvent
(
String
name
,
Map
arguments
){
_broadcastor
.
sendEvent
(
name
,
arguments
);
}
}
lib/messaging/handlers/on_native_page_result_handler.dart
View file @
b393b000
...
...
@@ -24,7 +24,6 @@
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:flutter_boost/messaging/base/message_handler.dart'
;
...
...
@@ -42,6 +41,5 @@ class OnNativePageResultHandler implements MessageHandler {
//==============================================Do not edit code above!
Future
<
bool
>
onCall
(
String
uniqueId
,
String
key
,
Map
resultData
,
Map
params
)
async
{
return
FlutterBoost
.
singleton
.
onPageResult
(
key
,
resultData
,
params
);
}
}
lib/messaging/message_proxy.dart
View file @
b393b000
...
...
@@ -25,19 +25,23 @@ import 'package:flutter_boost/messaging/service/navigation_service.dart';
import
'dart:async'
;
abstract
class
MessageProxy
{
Future
<
bool
>
openPage
(
String
pageName
,
Map
params
,
bool
animated
);
Future
<
bool
>
closePage
(
String
uniqueId
,
String
pageName
,
Map
params
,
bool
animated
);
Future
<
Map
<
String
,
dynamic
>>
open
(
String
url
,{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
}
);
void
close
(
String
id
,{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
}
);
}
class
MessageProxyImp
implements
MessageProxy
{
@override
Future
<
bool
>
openPage
(
String
pageName
,
Map
params
,
bool
animated
)
{
return
NavigationService
.
openPage
(
pageName
,
params
,
animated
);
Future
<
Map
<
String
,
dynamic
>>
open
(
String
url
,{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
{
return
NavigationService
.
openPage
(
url
,
urlParams
,
exts
);
}
@override
Future
<
bool
>
closePage
(
String
uniqueId
,
String
pageName
,
Map
params
,
bool
animated
)
{
return
NavigationService
.
closePage
(
uniqueId
,
pageName
,
params
,
animated
);
void
close
(
String
id
,{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
})
{
return
NavigationService
.
closePage
(
uniqueId
,
result:
result
,
exts:
exts
);
}
}
lib/messaging/page_result_mediator.dart
deleted
100755 → 0
View file @
accabe65
/*
* 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/support/logger.dart'
;
import
'package:flutter_boost/messaging/service/navigation_service.dart'
;
typedef
void
PageResultHandler
(
String
key
,
Map
<
String
,
dynamic
>
result
);
typedef
VoidCallback
=
void
Function
();
class
PageResultMediator
{
static
int
_resultId
=
0
;
String
createResultId
(){
_resultId
++;
return
"result_id_
$_resultId
"
;
}
bool
isResultId
(
String
rid
){
if
(
rid
==
null
)
return
false
;
return
rid
.
contains
(
"result_id"
);
}
Map
<
String
,
PageResultHandler
>
_handlers
=
Map
();
void
onPageResult
(
String
key
,
Map
<
String
,
dynamic
>
resultData
,
Map
params
){
if
(
key
==
null
)
return
;
Logger
.
log
(
"did receive page result
$resultData
for page key
$key
"
);
if
(
_handlers
.
containsKey
(
key
)){
_handlers
[
key
](
key
,
resultData
);
_handlers
.
remove
(
key
);
}
else
{
//Cannot find handler consider forward to native.
//Use forward to avoid circle.
if
(
params
==
null
||
!
params
.
containsKey
(
"forward"
)){
if
(
params
==
null
){
params
=
new
Map
();
}
params
[
"forward"
]
=
1
;
NavigationService
.
onFlutterPageResult
(
key
,
key
,
resultData
,
params
);
}
else
{
params
[
"forward"
]
=
params
[
"forward"
]+
1
;
if
(
params
[
"forward"
]
<=
2
){
NavigationService
.
onFlutterPageResult
(
key
,
key
,
resultData
,
params
);
}
}
}
}
VoidCallback
setPageResultHandler
(
String
key
,
PageResultHandler
handler
){
if
(
key
==
null
||
handler
==
null
)
return
(){};
_handlers
[
key
]
=
handler
;
return
(){
_handlers
.
remove
(
key
);
};
}
}
lib/messaging/service/navigation_service.dart
View file @
b393b000
...
...
@@ -61,23 +61,29 @@ class NavigationService {
return
Future
<
Map
>((){});
}
}
static
Future
<
bool
>
openPage
(
String
pageName
,
Map
params
,
bool
animated
)
{
static
Future
<
Map
<
String
,
dynamic
>>
openPage
(
String
url
,
Map
urlParams
,
Map
exts
)
{
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
properties
[
"
pageName"
]=
pageName
;
properties
[
"
p
arams"
]=
params
;
properties
[
"
animated"
]=
animated
;
return
methodChannel
.
invokeMethod
(
'openPage'
,
properties
).
then
<
bool
>((
value
){
properties
[
"
url"
]=
url
;
properties
[
"
urlP
arams"
]=
params
;
properties
[
"
exts"
]=
exts
;
return
methodChannel
.
invokeMethod
(
'openPage'
,
properties
).
then
<
Map
<
String
,
dynamic
>
>((
value
){
return
(
value
);
});
}
static
Future
<
bool
>
closePage
(
String
uniqueId
,
String
pageName
,
Map
params
,
bool
animated
)
{
static
Future
<
bool
>
closePage
(
String
uniqueId
,{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
})
{
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
properties
[
"uniqueId"
]=
uniqueId
;
properties
[
"pageName"
]=
pageName
;
properties
[
"params"
]=
params
;
properties
[
"animated"
]=
animated
;
if
(
result
!=
null
){
properties
[
"result"
]=
result
;
}
if
(
exts
!=
null
)
{
properties
[
"exts"
]
=
exts
;
}
return
methodChannel
.
invokeMethod
(
'closePage'
,
properties
).
then
<
bool
>((
value
){
return
value
;
});
}
}
\ No newline at end of file
lib/router/router.dart
View file @
b393b000
...
...
@@ -31,8 +31,6 @@ import 'package:flutter_boost/support/logger.dart';
class
Router
{
MessageProxy
_msgProxy
=
MessageProxyImp
();
PageResultMediator
resultMediator
=
null
;
void
setMessageProxy
(
MessageProxy
prx
)
{
if
(
prx
!=
null
)
{
...
...
@@ -41,27 +39,14 @@ class Router {
}
Future
<
bool
>
openPage
(
String
url
,
Map
params
,
{
bool
animated
=
true
,
PageResultHandler
resultHandler
})
{
if
(
resultHandler
!=
null
)
{
String
rid
=
resultMediator
.
createResultId
();
params
[
"result_id"
]
=
rid
;
FlutterBoost
.
singleton
.
setPageResultHandler
(
rid
,
(
String
key
,
Map
<
dynamic
,
dynamic
>
result
)
{
Logger
.
log
(
"Recieved result
$result
for from page key
$key
"
);
if
(
resultHandler
!=
null
)
{
resultHandler
(
key
,
result
);
}
});
Future
<
Map
<
String
,
dynamic
>>
open
(
String
url
,{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
}){
return
_msgProxy
.
open
(
url
,
urlParams:
urlParams
,
exts:
exts
);
}
return
_msgProxy
.
openPage
(
url
,
params
,
animated
);
Future
<
bool
>
close
(
String
id
,{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
}){
return
_msgProxy
.
close
(
id
,
result:
result
,
exts:
exts
);
}
Future
<
bool
>
closePage
(
String
name
,
String
pageId
,
Map
params
,
{
bool
animated
=
true
})
{
return
_msgProxy
.
closePage
(
pageId
,
name
,
params
,
animated
);
}
//Close currentPage page.
Future
<
bool
>
closeCurPage
(
Map
params
)
{
...
...
@@ -87,7 +72,9 @@ class Router {
animated
=
params
[
"animated"
]
as
bool
;
}
return
_msgProxy
.
closePage
(
settings
.
uniqueId
,
settings
.
name
,
settings
.
params
,
animated
);
Map
<
String
,
dynamic
>
exts
=
Map
();
exts
[
"animated"
]
=
animated
;
return
_msgProxy
.
close
(
id
,
result:
{}
,
exts:
exts
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment