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
d284055d
Commit
d284055d
authored
Jun 21, 2019
by
Yacumima
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
0e7d161c
3a16ccfd
Changes
77
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
77 changed files
with
2255 additions
and
1214 deletions
+2255
-1214
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterView.java
...va/com/taobao/idlefish/flutterboost/BoostFlutterView.java
+15
-2
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
...ava/com/taobao/idlefish/flutterboost/ContainerRecord.java
+4
-4
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService.java
...ish/flutterboost/NavigationService/NavigationService.java
+0
-257
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_closePage.java
...rboost/NavigationService/NavigationService_closePage.java
+0
-79
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_onFlutterPageResult.java
...igationService/NavigationService_onFlutterPageResult.java
+0
-77
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_onShownContainerChanged.java
...ionService/NavigationService_onShownContainerChanged.java
+0
-79
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_openPage.java
...erboost/NavigationService/NavigationService_openPage.java
+0
-97
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_pageOnStart.java
...oost/NavigationService/NavigationService_pageOnStart.java
+0
-97
android/src/main/java/com/taobao/idlefish/flutterboost/containers/BoostFlutterFragment.java
...dlefish/flutterboost/containers/BoostFlutterFragment.java
+1
-1
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/NavigationService.java
...o/idlefish/flutterboost/messageing/NavigationService.java
+255
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/Broadcastor.java
...ao/idlefish/flutterboost/messageing/base/Broadcastor.java
+117
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/EvenListener.java
...o/idlefish/flutterboost/messageing/base/EvenListener.java
+10
-13
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/Message.java
...taobao/idlefish/flutterboost/messageing/base/Message.java
+12
-12
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageDispatcher.java
...efish/flutterboost/messageing/base/MessageDispatcher.java
+10
-18
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageDispatcherImp.java
...sh/flutterboost/messageing/base/MessageDispatcherImp.java
+73
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageHandler.java
...idlefish/flutterboost/messageing/base/MessageHandler.java
+32
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageImp.java
...bao/idlefish/flutterboost/messageing/base/MessageImp.java
+46
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageResult.java
.../idlefish/flutterboost/messageing/base/MessageResult.java
+30
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/ClosePageHandler.java
...sh/flutterboost/messageing/handlers/ClosePageHandler.java
+60
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OnFlutterPageResultHandler.java
...boost/messageing/handlers/OnFlutterPageResultHandler.java
+59
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OnShownContainerChangedHandler.java
...t/messageing/handlers/OnShownContainerChangedHandler.java
+59
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OpenPageHandler.java
...ish/flutterboost/messageing/handlers/OpenPageHandler.java
+72
-0
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/PageOnStartHandler.java
.../flutterboost/messageing/handlers/PageOnStartHandler.java
+77
-0
example/ios/Podfile.lock
example/ios/Podfile.lock
+1
-2
example/ios/Runner.xcodeproj/project.pbxproj
example/ios/Runner.xcodeproj/project.pbxproj
+0
-4
example/ios/Runner/DemoRouter.h
example/ios/Runner/DemoRouter.h
+2
-2
example/ios/Runner/DemoRouter.m
example/ios/Runner/DemoRouter.m
+62
-4
example/ios/Runner/UIViewControllerDemo.m
example/ios/Runner/UIViewControllerDemo.m
+1
-3
example/lib/simple_page_widgets.dart
example/lib/simple_page_widgets.dart
+6
-5
ios/Classes/1.0/FLBFlutterApplication.m
ios/Classes/1.0/FLBFlutterApplication.m
+38
-1
ios/Classes/1.0/FLBFlutterViewContainer.m
ios/Classes/1.0/FLBFlutterViewContainer.m
+0
-10
ios/Classes/1.5/FLB2FlutterApplication.m
ios/Classes/1.5/FLB2FlutterApplication.m
+68
-0
ios/Classes/Boost/FLB2Platform.h
ios/Classes/Boost/FLB2Platform.h
+7
-7
ios/Classes/Boost/FLBFlutterApplicationInterface.h
ios/Classes/Boost/FLBFlutterApplicationInterface.h
+23
-0
ios/Classes/Boost/FLBTypes.h
ios/Classes/Boost/FLBTypes.h
+33
-0
ios/Classes/Boost/FlutterBoostPlugin.h
ios/Classes/Boost/FlutterBoostPlugin.h
+6
-12
ios/Classes/Boost/FlutterBoostPlugin.m
ios/Classes/Boost/FlutterBoostPlugin.m
+63
-43
ios/Classes/Boost/FlutterBoostPlugin_private.h
ios/Classes/Boost/FlutterBoostPlugin_private.h
+3
-4
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_closePage.h
.../NavigationService/handlers/NavigationService_closePage.h
+4
-3
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_closePage.mm
...NavigationService/handlers/NavigationService_closePage.mm
+20
-27
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.h
...nService/handlers/NavigationService_onFlutterPageResult.h
+3
-3
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.mm
...Service/handlers/NavigationService_onFlutterPageResult.mm
+12
-13
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onShownContainerChanged.h
...vice/handlers/NavigationService_onShownContainerChanged.h
+3
-3
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onShownContainerChanged.mm
...ice/handlers/NavigationService_onShownContainerChanged.mm
+10
-8
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.h
...d/NavigationService/handlers/NavigationService_openPage.h
+3
-3
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.mm
.../NavigationService/handlers/NavigationService_openPage.mm
+18
-20
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_pageOnStart.h
...avigationService/handlers/NavigationService_pageOnStart.h
+2
-2
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_pageOnStart.mm
...vigationService/handlers/NavigationService_pageOnStart.mm
+16
-13
ios/Classes/Messaging/Generated/NavigationService/service/Service_NavigationService.h
...ted/NavigationService/service/Service_NavigationService.h
+4
-5
ios/Classes/Messaging/Generated/NavigationService/service/Service_NavigationService.mm
...ed/NavigationService/service/Service_NavigationService.mm
+23
-26
ios/Classes/Messaging/base/FLBBroadcastor.h
ios/Classes/Messaging/base/FLBBroadcastor.h
+46
-0
ios/Classes/Messaging/base/FLBBroadcastor.m
ios/Classes/Messaging/base/FLBBroadcastor.m
+89
-0
ios/Classes/Messaging/base/FLBMessageDispather.h
ios/Classes/Messaging/base/FLBMessageDispather.h
+30
-0
ios/Classes/Messaging/base/FLBMessageDispather.m
ios/Classes/Messaging/base/FLBMessageDispather.m
+79
-0
ios/Classes/Messaging/base/FLBMessageHandlerImp.h
ios/Classes/Messaging/base/FLBMessageHandlerImp.h
+30
-0
ios/Classes/Messaging/base/FLBMessageHandlerImp.m
ios/Classes/Messaging/base/FLBMessageHandlerImp.m
+176
-0
ios/Classes/Messaging/base/FLBMessageImp.h
ios/Classes/Messaging/base/FLBMessageImp.h
+8
-11
ios/Classes/Messaging/base/FLBMessageImp.m
ios/Classes/Messaging/base/FLBMessageImp.m
+38
-0
ios/Classes/Messaging/base/FLBMessageing.h
ios/Classes/Messaging/base/FLBMessageing.h
+48
-0
ios/flutter_boost.podspec
ios/flutter_boost.podspec
+1
-2
lib/AIOService/NavigationService/service/NavigationServiceRegister.dart
.../NavigationService/service/NavigationServiceRegister.dart
+0
-48
lib/container/container_coordinator.dart
lib/container/container_coordinator.dart
+5
-4
lib/container/container_manager.dart
lib/container/container_manager.dart
+1
-1
lib/flutter_boost.dart
lib/flutter_boost.dart
+105
-38
lib/messaging/base/broadcastor.dart
lib/messaging/base/broadcastor.dart
+89
-0
lib/messaging/base/message_dispatcher.dart
lib/messaging/base/message_dispatcher.dart
+47
-0
lib/messaging/base/message_handler.dart
lib/messaging/base/message_handler.dart
+31
-0
lib/messaging/handlers/did_disappear_page_container_handler.dart
...saging/handlers/did_disappear_page_container_handler.dart
+2
-11
lib/messaging/handlers/did_init_page_container_handler.dart
lib/messaging/handlers/did_init_page_container_handler.dart
+5
-9
lib/messaging/handlers/did_show_page_container_handler.dart
lib/messaging/handlers/did_show_page_container_handler.dart
+2
-12
lib/messaging/handlers/on_native_page_result_handler.dart
lib/messaging/handlers/on_native_page_result_handler.dart
+2
-13
lib/messaging/handlers/will_dealloc_page_container_handler.dart
...ssaging/handlers/will_dealloc_page_container_handler.dart
+2
-13
lib/messaging/handlers/will_disappear_page_container_handler.dart
...aging/handlers/will_disappear_page_container_handler.dart
+2
-12
lib/messaging/handlers/will_show_page_container_handler.dart
lib/messaging/handlers/will_show_page_container_handler.dart
+2
-12
lib/messaging/message_proxy.dart
lib/messaging/message_proxy.dart
+11
-7
lib/messaging/service/navigation_service.dart
lib/messaging/service/navigation_service.dart
+32
-39
lib/router/router.dart
lib/router/router.dart
+9
-23
No files found.
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterView.java
View file @
d284055d
...
...
@@ -63,7 +63,7 @@ public class BoostFlutterView extends FrameLayout {
private
final
List
<
OnFirstFrameRenderedListener
>
mFirstFrameRenderedListeners
=
new
LinkedList
<>();
private
boolean
mNeedSnapshotWhenDetach
=
tru
e
;
private
boolean
mNeedSnapshotWhenDetach
=
fals
e
;
private
ImageView
mSnapshot
;
...
...
@@ -74,6 +74,11 @@ public class BoostFlutterView extends FrameLayout {
if
(
mRenderingProgressCover
!=
null
&&
mRenderingProgressCover
.
getParent
()
!=
null
)
{
((
ViewGroup
)
mRenderingProgressCover
.
getParent
()).
removeView
(
mRenderingProgressCover
);
}
if
(
mNeedSnapshotWhenDetach
&&
mSnapshot
.
getParent
()
!=
null
)
{
((
ViewGroup
)
mSnapshot
.
getParent
()).
removeView
(
mSnapshot
);
}
final
Object
[]
listeners
=
mFirstFrameRenderedListeners
.
toArray
();
for
(
Object
obj
:
listeners
)
{
((
OnFirstFrameRenderedListener
)
obj
).
onFirstFrameRendered
(
BoostFlutterView
.
this
);
...
...
@@ -230,7 +235,15 @@ public class BoostFlutterView extends FrameLayout {
Debuger
.
log
(
"BoostFlutterView onDetach"
);
if
(
mNeedSnapshotWhenDetach
)
{
//mFlutterView.
if
(
mSnapshot
.
getParent
()
!=
null
)
{
((
ViewGroup
)
mSnapshot
.
getParent
()).
removeView
(
mSnapshot
);
}
Debuger
.
log
(
"BoostFlutterView snapshot"
);
mSnapshot
.
setImageBitmap
(
mFlutterEngine
.
getRenderer
().
getBitmap
());
BoostFlutterView
.
this
.
addView
(
mSnapshot
);
}
mFlutterView
.
removeOnFirstFrameRenderedListener
(
mOnFirstFrameRenderedListener
);
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
View file @
d284055d
...
...
@@ -25,15 +25,14 @@ package com.taobao.idlefish.flutterboost;
import
android.content.Intent
;
import
com.taobao.idlefish.flutterboost.NavigationService.NavigationService
;
import
com.taobao.idlefish.flutterboost.messageing.NavigationService
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
import
java.util.HashMap
;
import
java.util.Map
;
import
fleamarket.taobao.com.xservicekit.handler.MessageResult
;
public
class
ContainerRecord
implements
IContainerRecord
{
private
final
FlutterViewContainerManager
mManager
;
private
final
IFlutterViewContainer
mContainer
;
...
...
@@ -143,7 +142,8 @@ public class ContainerRecord implements IContainerRecord {
map
.
put
(
"type"
,
"backPressedCallback"
);
map
.
put
(
"name"
,
mContainer
.
getContainerName
());
map
.
put
(
"uniqueId"
,
mUniqueId
);
NavigationService
.
getService
().
emitEvent
(
map
);
FlutterBoostPlugin
.
getInstance
().
sendEvent
(
"lifecycle"
,
map
);
mContainer
.
getBoostFlutterView
().
onBackPressed
();
}
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService.java
deleted
100755 → 0
View file @
0e7d161c
This diff is collapsed.
Click to expand it.
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_closePage.java
deleted
100755 → 0
View file @
0e7d161c
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.NavigationService
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
fleamarket.taobao.com.xservicekit.handler.MessageHandler
;
import
fleamarket.taobao.com.xservicekit.handler.MessageResult
;
import
fleamarket.taobao.com.xservicekit.service.ServiceGateway
;
public
class
NavigationService_closePage
implements
MessageHandler
<
Boolean
>{
private
Object
mContext
=
null
;
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
uniqueId
,
String
pageName
,
Map
params
,
Boolean
animated
){
FlutterBoostPlugin
.
singleton
().
containerManager
().
closeContainer
(
uniqueId
,
null
);
result
.
success
(
true
);
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
this
.
onCall
(
result
,(
String
)
args
.
get
(
"uniqueId"
),(
String
)
args
.
get
(
"pageName"
),(
Map
)
args
.
get
(
"params"
),(
Boolean
)
args
.
get
(
"animated"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"closePage"
);
return
h
;
}
@Override
public
Object
getContext
()
{
return
mContext
;
}
@Override
public
void
setContext
(
Object
obj
)
{
mContext
=
obj
;
}
@Override
public
String
service
()
{
return
"NavigationService"
;
}
public
static
void
register
(){
ServiceGateway
.
sharedInstance
().
registerHandler
(
new
NavigationService_closePage
());
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_onFlutterPageResult.java
deleted
100755 → 0
View file @
0e7d161c
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.NavigationService
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
fleamarket.taobao.com.xservicekit.handler.MessageHandler
;
import
fleamarket.taobao.com.xservicekit.handler.MessageResult
;
import
fleamarket.taobao.com.xservicekit.service.ServiceGateway
;
public
class
NavigationService_onFlutterPageResult
implements
MessageHandler
<
Boolean
>{
private
Object
mContext
=
null
;
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
uniqueId
,
String
key
,
Map
resultData
,
Map
params
){
// FlutterBoostPlugin.containerManager().setContainerResult(uniqueId,resultData);
// result.success(true);
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
this
.
onCall
(
result
,(
String
)
args
.
get
(
"uniqueId"
),(
String
)
args
.
get
(
"key"
),(
Map
)
args
.
get
(
"resultData"
),(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"onFlutterPageResult"
);
return
h
;
}
@Override
public
Object
getContext
()
{
return
mContext
;
}
@Override
public
void
setContext
(
Object
obj
)
{
mContext
=
obj
;
}
@Override
public
String
service
()
{
return
"NavigationService"
;
}
public
static
void
register
(){
ServiceGateway
.
sharedInstance
().
registerHandler
(
new
NavigationService_onFlutterPageResult
());
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_onShownContainerChanged.java
deleted
100755 → 0
View file @
0e7d161c
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.NavigationService
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
fleamarket.taobao.com.xservicekit.handler.MessageHandler
;
import
fleamarket.taobao.com.xservicekit.handler.MessageResult
;
import
fleamarket.taobao.com.xservicekit.service.ServiceGateway
;
public
class
NavigationService_onShownContainerChanged
implements
MessageHandler
<
Boolean
>{
private
Object
mContext
=
null
;
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
now
,
String
old
,
Map
params
){
//Add your handler code here.
FlutterBoostPlugin
.
singleton
().
containerManager
().
onShownContainerChanged
(
old
,
now
);
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
this
.
onCall
(
result
,(
String
)
args
.
get
(
"newName"
),(
String
)
args
.
get
(
"oldName"
),(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"onShownContainerChanged"
);
return
h
;
}
@Override
public
Object
getContext
()
{
return
mContext
;
}
@Override
public
void
setContext
(
Object
obj
)
{
mContext
=
obj
;
}
@Override
public
String
service
()
{
return
"NavigationService"
;
}
public
static
void
register
(){
ServiceGateway
.
sharedInstance
().
registerHandler
(
new
NavigationService_onShownContainerChanged
());
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_openPage.java
deleted
100755 → 0
View file @
0e7d161c
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.NavigationService
;
import
android.content.Context
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
fleamarket.taobao.com.xservicekit.handler.MessageHandler
;
import
fleamarket.taobao.com.xservicekit.handler.MessageResult
;
import
fleamarket.taobao.com.xservicekit.service.ServiceGateway
;
public
class
NavigationService_openPage
implements
MessageHandler
<
Boolean
>{
private
Object
mContext
=
null
;
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
Boolean
animated
){
int
requestCode
=
0
;
if
(
params
!=
null
&&
params
.
get
(
"requestCode"
)
!=
null
)
{
requestCode
=
(
int
)
params
.
get
(
"requestCode"
);
}
Context
ctx
=
FlutterBoostPlugin
.
singleton
().
currentActivity
();
if
(
ctx
==
null
)
{
ctx
=
FlutterBoostPlugin
.
singleton
().
platform
().
getApplication
();
}
FlutterBoostPlugin
.
singleton
().
platform
().
startActivity
(
ctx
,
pageName
,
params
,
requestCode
);
if
(
result
!=
null
){
result
.
success
(
true
);
}
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
this
.
onCall
(
result
,(
String
)
args
.
get
(
"pageName"
),(
Map
)
args
.
get
(
"params"
),(
Boolean
)
args
.
get
(
"animated"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"openPage"
);
return
h
;
}
@Override
public
Object
getContext
()
{
return
mContext
;
}
@Override
public
void
setContext
(
Object
obj
)
{
mContext
=
obj
;
}
@Override
public
String
service
()
{
return
"NavigationService"
;
}
public
static
void
register
(){
ServiceGateway
.
sharedInstance
().
registerHandler
(
new
NavigationService_openPage
());
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_pageOnStart.java
deleted
100755 → 0
View file @
0e7d161c
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.NavigationService
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
fleamarket.taobao.com.xservicekit.handler.MessageHandler
;
import
fleamarket.taobao.com.xservicekit.handler.MessageResult
;
import
fleamarket.taobao.com.xservicekit.service.ServiceGateway
;
public
class
NavigationService_pageOnStart
implements
MessageHandler
<
Map
>{
private
Object
mContext
=
null
;
private
boolean
onCall
(
MessageResult
<
Map
>
result
,
Map
params
){
Map
<
String
,
Object
>
pageInfo
=
new
HashMap
<>();
try
{
IContainerRecord
record
=
FlutterBoostPlugin
.
singleton
()
.
containerManager
().
getCurrentTopRecord
();
if
(
record
==
null
)
{
record
=
FlutterBoostPlugin
.
singleton
().
containerManager
().
getLastGenerateRecord
();
}
pageInfo
.
put
(
"name"
,
record
.
getContainer
().
getContainerName
());
pageInfo
.
put
(
"params"
,
record
.
getContainer
().
getContainerParams
());
pageInfo
.
put
(
"uniqueId"
,
record
.
uniqueId
());
result
.
success
(
pageInfo
);
}
catch
(
Throwable
t
){
result
.
success
(
pageInfo
);
}
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Map
>
result
)
{
this
.
onCall
(
result
,(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"pageOnStart"
);
return
h
;
}
@Override
public
Object
getContext
()
{
return
mContext
;
}
@Override
public
void
setContext
(
Object
obj
)
{
mContext
=
obj
;
}
@Override
public
String
service
()
{
return
"NavigationService"
;
}
public
static
void
register
(){
ServiceGateway
.
sharedInstance
().
registerHandler
(
new
NavigationService_pageOnStart
());
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/containers/BoostFlutterFragment.java
View file @
d284055d
...
...
@@ -69,7 +69,7 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
BoostFlutterView
.
Builder
builder
=
new
BoostFlutterView
.
Builder
(
getContextActivity
());
return
builder
.
flutterEngine
(
engine
)
.
renderMode
(
FlutterView
.
RenderMode
.
textur
e
)
.
renderMode
(
FlutterView
.
RenderMode
.
surfac
e
)
.
transparencyMode
(
FlutterView
.
TransparencyMode
.
opaque
)
.
build
();
}
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/NavigationService.java
0 → 100755
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.HashMap
;
import
java.util.Map
;
import
io.flutter.plugin.common.MethodChannel
;
public
class
NavigationService
{
public
static
MethodChannel
methodChannel
=
null
;
public
static
void
onNativePageResult
(
final
MessageResult
<
Boolean
>
result
,
String
uniqueId
,
String
key
,
Map
resultData
,
Map
params
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"uniqueId"
,
uniqueId
);
args
.
put
(
"key"
,
key
);
args
.
put
(
"resultData"
,
resultData
);
args
.
put
(
"params"
,
params
);
methodChannel
.
invokeMethod
(
"onNativePageResult"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
didShowPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"didShowPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
willShowPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"willShowPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
willDisappearPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"willDisappearPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
didDisappearPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"didDisappearPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
didInitPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"didInitPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
willDeallocPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"willDeallocPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
}
\ No newline at end of file
ios/Classes/Boost/FLBResultMediator.m
→
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/Broadcastor.java
100755 → 100644
View file @
d284055d
/*
* 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
...
...
@@ -21,78 +21,97 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
#import "FLBResultMediator.h"
#import "Service_NavigationService.h"
import
android.support.annotation.Nullable
;
@interface
FLBResultMediator
()
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
handlers
;
@end
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
@implementation
FLBResultMediator
import
io.flutter.plugin.common.MethodChannel
;
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
_handlers
=
[
NSMutableDictionary
new
];
public
class
Broadcastor
{
private
MethodChannel
channel
=
null
;
private
Map
<
String
,
List
<
EvenListener
>>
lists
=
new
HashMap
<>();
public
Broadcastor
(
MethodChannel
channel
)
{
this
.
channel
=
channel
;
}
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
;
public
void
sendEvent
(
String
name
,
Map
arguments
)
{
if
(
name
==
null
)
{
return
;
}
Map
msg
=
new
HashMap
();
msg
.
put
(
"name"
,
name
);
if
(
arguments
!=
null
){
msg
.
put
(
"arguments"
,
arguments
);
}
channel
.
invokeMethod
(
"__event__"
,
msg
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
@Nullable
Object
o
)
{
}
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
];
@Override
public
void
error
(
String
s
,
@Nullable
String
s1
,
@Nullable
Object
o
)
{
}
@Override
public
void
notImplemented
()
{
}
});
}
public
void
dispatch
(
String
name
,
Map
arguments
)
{
if
(
name
==
null
||
arguments
==
null
){
return
;
}
String
eventName
=
(
String
)
arguments
.
get
(
"name"
);
Map
eventArguments
=
(
Map
)
arguments
.
get
(
"arguments"
);
List
<
EvenListener
>
list
=
lists
.
get
(
eventName
);
if
(
list
==
null
){
return
;
}
for
(
EvenListener
l
:
list
){
l
.
onEvent
(
eventName
,
eventArguments
);
}
return
;
}
}
-
(
void
)
setResultHandler
:(
FLBPageResultHandler
)
handler
forKey
:(
NSString
*
)
vcid
{
if
(
!
handler
||
!
vcid
)
return
;
_handlers
[
vcid
]
=
handler
;
}
public
void
addEventListener
(
String
name
,
EvenListener
listener
){
if
(
listener
==
null
||
name
==
null
){
return
;
}
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
{
if
(
!
vcid
)
return
;
[
_handlers
removeObjectForKey
:
vcid
];
}
List
<
EvenListener
>
list
=
lists
.
get
(
name
);
if
(
list
==
null
){
list
=
new
LinkedList
<>();
lists
.
put
(
name
,
list
);
}
list
.
add
(
listener
);
}
public
void
removeEventListener
(
String
name
,
EvenListener
listener
){
if
(
listener
==
null
||
name
==
null
){
return
;
}
List
<
EvenListener
>
list
=
lists
.
get
(
name
);
if
(
list
!=
null
){
list
.
remove
(
listener
);
}
}
@end
}
lib/AIOService/loader/ServiceLoader.dart
→
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/EvenListener.java
100755 → 100644
View file @
d284055d
/*
* 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
...
...
@@ -21,13 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
'../NavigationService/service/NavigationServiceRegister.dart'
;
class
ServiceLoader
{
static
load
(){
NavigationServiceRegister
.
register
();
}
}
\ No newline at end of file
import
java.util.Map
;
public
interface
EvenListener
{
void
onEvent
(
String
eventName
,
Map
arguments
);
}
android/src/main/java/com/taobao/idlefish/flutterboost/
loader/ServiceLoader
.java
→
android/src/main/java/com/taobao/idlefish/flutterboost/
messageing/base/Message
.java
100755 → 100644
View file @
d284055d
/*
* 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
...
...
@@ -22,11 +22,11 @@
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.loader
;
public
class
ServiceLoader
{
public
static
void
load
(){
com
.
taobao
.
idlefish
.
flutterboost
.
NavigationService
.
NavigationServiceRegister
.
register
();
}
}
\ No newline at end of file
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.Map
;
public
interface
Message
{
String
name
();
Map
arguments
();
}
android/src/main/java/com/taobao/idlefish/flutterboost/
NavigationService/NavigationServiceRegist
er.java
→
android/src/main/java/com/taobao/idlefish/flutterboost/
messageing/base/MessageDispatch
er.java
100755 → 100644
View file @
d284055d
/*
* 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
...
...
@@ -21,18 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
package
com.taobao.idlefish.flutterboost.NavigationService
;
public
class
NavigationServiceRegister
{
public
static
void
register
(){
NavigationService
.
register
();
NavigationService_onShownContainerChanged
.
register
();
NavigationService_onFlutterPageResult
.
register
();
NavigationService_pageOnStart
.
register
();
NavigationService_openPage
.
register
();
NavigationService_closePage
.
register
();
}
}
\ No newline at end of file
public
interface
MessageDispatcher
<
T
>{
boolean
dispatch
(
Message
msg
,
MessageResult
<
T
>
result
);
void
addHandler
(
MessageHandler
<
T
>
handler
);
void
removeHandler
(
MessageHandler
<
T
>
handler
);
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageDispatcherImp.java
0 → 100644
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
MessageDispatcherImp
implements
MessageDispatcher
{
private
Map
<
String
,
MessageHandler
>
handlers
=
new
HashMap
<>();
@Override
public
boolean
dispatch
(
Message
msg
,
MessageResult
result
)
{
if
(
msg
==
null
){
return
false
;
}
MessageHandler
h
=
handlers
.
get
(
msg
.
name
());
if
(
h
!=
null
){
return
h
.
onMethodCall
(
msg
.
name
(),
msg
.
arguments
(),
result
);
}
return
false
;
}
@Override
public
void
addHandler
(
MessageHandler
handler
)
{
if
(
handler
==
null
){
return
;
}
List
<
String
>
names
=
handler
.
handleMessageNames
();
for
(
String
name
:
names
){
handlers
.
put
(
name
,
handler
);
}
}
@Override
public
void
removeHandler
(
MessageHandler
handler
)
{
if
(
handler
==
null
){
return
;
}
List
<
String
>
names
=
handler
.
handleMessageNames
();
for
(
String
name
:
names
){
if
(
handler
==
handlers
.
get
(
name
)){
handlers
.
remove
(
name
);
}
}
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageHandler.java
0 → 100644
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.List
;
import
java.util.Map
;
public
interface
MessageHandler
<
T
>
{
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
T
>
result
);
List
<
String
>
handleMessageNames
();
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageImp.java
0 → 100644
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.Map
;
public
class
MessageImp
implements
Message
{
private
String
name
;
private
Map
args
;
public
MessageImp
(
String
name
,
Map
args
){
this
.
name
=
name
;
this
.
args
=
args
;
}
@Override
public
String
name
()
{
return
name
;
}
@Override
public
Map
arguments
()
{
return
args
;
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageResult.java
0 → 100644
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
public
interface
MessageResult
<
T
>
{
void
success
(
T
var1
);
void
error
(
String
var1
,
String
var2
,
Object
var3
);
void
notImplemented
();
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/ClosePageHandler.java
0 → 100755
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.FlutterViewContainerManager
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
ClosePageHandler
implements
MessageHandler
<
Boolean
>
{
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
//TODO:接入新的close消息
String
uniqueId
=
(
String
)
args
.
get
(
"uniqueId"
);
Map
resultData
=
(
Map
)
args
.
get
(
"result"
);
Map
exts
=
(
Map
)
args
.
get
(
"exts"
);
FlutterBoostPlugin
.
containerManager
().
closeContainer
(
uniqueId
,
null
);
result
.
success
(
true
);
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"closePage"
);
return
h
;
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OnFlutterPageResultHandler.java
0 → 100755
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerManager
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
OnFlutterPageResultHandler
implements
MessageHandler
<
Boolean
>
{
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
uniqueId
,
String
key
,
Map
resultData
,
Map
params
)
{
result
.
success
(
true
);
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
this
.
onCall
(
result
,
(
String
)
args
.
get
(
"uniqueId"
),
(
String
)
args
.
get
(
"key"
),
(
Map
)
args
.
get
(
"resultData"
),
(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"onFlutterPageResult"
);
return
h
;
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OnShownContainerChangedHandler.java
0 → 100755
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
OnShownContainerChangedHandler
implements
MessageHandler
<
Boolean
>
{
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
now
,
String
old
,
Map
params
)
{
//Add your handler code here.
FlutterBoostPlugin
.
containerManager
().
onShownContainerChanged
(
old
,
now
);
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
this
.
onCall
(
result
,
(
String
)
args
.
get
(
"newName"
),
(
String
)
args
.
get
(
"oldName"
),
(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"onShownContainerChanged"
);
return
h
;
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OpenPageHandler.java
0 → 100755
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
OpenPageHandler
implements
MessageHandler
<
Map
>
{
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Map
>
result
)
{
//TODO:接入新的open方法,同时兼容老方法
Map
params
=
(
Map
)
args
.
get
(
"urlParams"
);
Map
exts
=
(
Map
)
args
.
get
(
"exts"
);
String
url
=
(
String
)
args
.
get
(
"url"
);
int
requestCode
=
0
;
if
(
params
!=
null
&&
params
.
get
(
"requestCode"
)
!=
null
)
{
requestCode
=
(
int
)
params
.
get
(
"requestCode"
);
}
FlutterBoostPlugin
.
openPage
(
null
,
url
,
params
,
0
);
//TODO: to call future.
if
(
result
!=
null
)
{
result
.
success
(
new
HashMap
());
}
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"openPage"
);
return
h
;
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/PageOnStartHandler.java
0 → 100755
View file @
d284055d
/*
* 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.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.FlutterViewContainerManager
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
PageOnStartHandler
implements
MessageHandler
<
Map
>
{
private
boolean
onCall
(
MessageResult
<
Map
>
result
,
Map
params
)
{
Map
<
String
,
Object
>
pageInfo
=
new
HashMap
<>();
try
{
IContainerRecord
record
=
FlutterBoostPlugin
.
containerManager
().
getCurrentTopRecord
();
if
(
record
==
null
)
{
record
=
FlutterBoostPlugin
.
containerManager
().
getLastGenerateRecord
();
}
pageInfo
.
put
(
"name"
,
record
.
getContainer
().
getContainerName
());
pageInfo
.
put
(
"params"
,
record
.
getContainer
().
getContainerParams
());
pageInfo
.
put
(
"uniqueId"
,
record
.
uniqueId
());
result
.
success
(
pageInfo
);
}
catch
(
Throwable
t
)
{
result
.
success
(
pageInfo
);
}
return
true
;
}
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Map
>
result
)
{
this
.
onCall
(
result
,
(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"pageOnStart"
);
return
h
;
}
}
\ No newline at end of file
example/ios/Podfile.lock
View file @
d284055d
...
...
@@ -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:
e6949ea7bf22ad0766867b631996c2a7afa1a710
xservice_kit: a86c64372b3e41e7d8e9b1a0b9139866680f525c
PODFILE CHECKSUM: 2a757a7bdc03b37a2814666652fdff1cf694243f
...
...
example/ios/Runner.xcodeproj/project.pbxproj
View file @
d284055d
...
...
@@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2
/* GeneratedPluginRegistrant.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
1498D2331E8E89220040F4C2
/* GeneratedPluginRegistrant.m */
;
};
2D5378261FAA1A9400D5DBA9
/* flutter_assets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
2D5378251FAA1A9400D5DBA9
/* flutter_assets */
;
};
3B3967161E833CAA004F5970
/* AppFrameworkInfo.plist in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3B3967151E833CAA004F5970
/* AppFrameworkInfo.plist */
;
};
3B80C3941E831B6300D905FE
/* App.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3B80C3931E831B6300D905FE
/* App.framework */
;
};
3B80C3951E831B6300D905FE
/* App.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3B80C3931E831B6300D905FE
/* App.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
...
...
@@ -45,7 +44,6 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2
/* GeneratedPluginRegistrant.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
GeneratedPluginRegistrant.h
;
sourceTree
=
"<group>"
;
};
1498D2331E8E89220040F4C2
/* GeneratedPluginRegistrant.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
GeneratedPluginRegistrant.m
;
sourceTree
=
"<group>"
;
};
2D5378251FAA1A9400D5DBA9
/* flutter_assets */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
folder
;
name
=
flutter_assets
;
path
=
Flutter/flutter_assets
;
sourceTree
=
SOURCE_ROOT
;
};
3B3967151E833CAA004F5970
/* AppFrameworkInfo.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
name
=
AppFrameworkInfo.plist
;
path
=
Flutter/AppFrameworkInfo.plist
;
sourceTree
=
"<group>"
;
};
3B80C3931E831B6300D905FE
/* App.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
App.framework
;
path
=
Flutter/App.framework
;
sourceTree
=
"<group>"
;
};
7AFA3C8E1D35360C0083082E
/* Release.xcconfig */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.xcconfig
;
name
=
Release.xcconfig
;
path
=
Flutter/Release.xcconfig
;
sourceTree
=
"<group>"
;
};
...
...
@@ -105,7 +103,6 @@
9740EEB11CF90186004384FC
/* Flutter */
=
{
isa
=
PBXGroup
;
children
=
(
2D5378251FAA1A9400D5DBA9
/* flutter_assets */
,
3B80C3931E831B6300D905FE
/* App.framework */
,
3B3967151E833CAA004F5970
/* AppFrameworkInfo.plist */
,
9740EEBA1CF902C7004384FC
/* Flutter.framework */
,
...
...
@@ -232,7 +229,6 @@
3B3967161E833CAA004F5970
/* AppFrameworkInfo.plist in Resources */
,
9740EEB41CF90195004384FC
/* Debug.xcconfig in Resources */
,
97C146FE1CF9000F007C117D
/* Assets.xcassets in Resources */
,
2D5378261FAA1A9400D5DBA9
/* flutter_assets in Resources */
,
97C146FC1CF9000F007C117D
/* Main.storyboard in Resources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
...
...
example/ios/Runner/DemoRouter.h
View file @
d284055d
...
...
@@ -8,11 +8,11 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <flutter_boost/F
LBPlatform
.h>
#import <flutter_boost/F
lutterBoost
.h>
NS_ASSUME_NONNULL_BEGIN
@interface
DemoRouter
:
NSObject
<
FLBPlatform
>
@interface
DemoRouter
:
NSObject
<
FLB
2
Platform
>
@property
(
nonatomic
,
strong
)
UINavigationController
*
navigationController
;
...
...
example/ios/Runner/DemoRouter.m
View file @
d284055d
...
...
@@ -21,11 +21,64 @@
return
instance
;
}
// Boost 2 switch
-
(
BOOL
)
userBoost2
{
return
YES
;
}
#pragma mark - Boost 2
-
(
void
)
open
:(
NSString
*
)
name
urlParams
:(
NSDictionary
*
)
params
exts
:(
NSDictionary
*
)
exts
completion
:(
void
(
^
)(
BOOL
))
completion
{
BOOL
animated
=
[
exts
[
@"animated"
]
boolValue
];
animated
=
YES
;
if
([
params
[
@"present"
]
boolValue
]){
FLB2FlutterViewContainer
*
vc
=
FLB2FlutterViewContainer
.
new
;
[
vc
setName
:
name
params
:
params
];
[
self
.
navigationController
presentViewController
:
vc
animated
:
animated
completion
:^
{
if
(
completion
)
completion
(
YES
);
}];
}
else
{
FLB2FlutterViewContainer
*
vc
=
FLB2FlutterViewContainer
.
new
;
[
vc
setName
:
name
params
:
params
];
[
self
.
navigationController
pushViewController
:
vc
animated
:
animated
];
if
(
completion
)
completion
(
YES
);
}
}
-
(
void
)
close
:(
NSString
*
)
uid
result
:(
NSDictionary
*
)
result
exts
:(
NSDictionary
*
)
exts
completion
:(
void
(
^
)(
BOOL
))
completion
{
BOOL
animated
=
[
exts
[
@"animated"
]
boolValue
];
animated
=
YES
;
FLBFlutterViewContainer
*
vc
=
(
id
)
self
.
navigationController
.
presentedViewController
;
if
([
vc
isKindOfClass
:
FLBFlutterViewContainer
.
class
]
&&
[
vc
.
uniqueIDString
isEqual
:
uid
]){
[
vc
dismissViewControllerAnimated
:
animated
completion
:
^
{}];
}
else
{
[
self
.
navigationController
popViewControllerAnimated
:
animated
];
}
}
#pragma mark - Boost 1
-
(
void
)
openPage
:(
NSString
*
)
name
params
:(
NSDictionary
*
)
params
animated
:(
BOOL
)
animated
completion
:(
void
(
^
)(
BOOL
))
completion
{
if
([
self
userBoost2
]){
NSMutableDictionary
*
exts
=
NSMutableDictionary
.
new
;
exts
[
@"url"
]
=
name
;
exts
[
@"params"
]
=
params
;
exts
[
@"animated"
]
=
@
(
animated
);
[
self
open
:
name
urlParams
:
params
exts
:
exts
completion
:
completion
];
return
;
}
if
([
params
[
@"present"
]
boolValue
]){
FLBFlutterViewContainer
*
vc
=
FLBFlutterViewContainer
.
new
;
[
vc
setName
:
name
params
:
params
];
...
...
@@ -40,14 +93,19 @@
}
}
-
(
BOOL
)
accessibilityEnable
{
return
YES
;
}
-
(
void
)
closePage
:(
NSString
*
)
uid
animated
:(
BOOL
)
animated
params
:(
NSDictionary
*
)
params
completion
:(
void
(
^
)(
BOOL
))
completion
{
if
([
self
userBoost2
]){
NSMutableDictionary
*
exts
=
NSMutableDictionary
.
new
;
exts
[
@"params"
]
=
params
;
exts
[
@"animated"
]
=
@
(
animated
);
[
self
close
:
uid
result
:@{}
exts
:
exts
completion
:
completion
];
return
;
}
FLBFlutterViewContainer
*
vc
=
(
id
)
self
.
navigationController
.
presentedViewController
;
if
([
vc
isKindOfClass
:
FLBFlutterViewContainer
.
class
]
&&
[
vc
.
uniqueIDString
isEqual
:
uid
]){
[
vc
dismissViewControllerAnimated
:
animated
completion
:
^
{}];
...
...
example/ios/Runner/UIViewControllerDemo.m
View file @
d284055d
...
...
@@ -26,9 +26,7 @@
-
(
IBAction
)
pushFlutterPage
:(
id
)
sender
{
[
DemoRouter
.
sharedRouter
openPage
:
@"first"
params
:@{}
animated
:
YES
completion
:^
(
BOOL
f
){
[
FlutterBoostPlugin
.
sharedInstance
onResultForKey
:
@"result_id_100"
resultData
:@{}
params
:
@{}];
}];
}
...
...
example/lib/simple_page_widgets.dart
View file @
d284055d
...
...
@@ -13,8 +13,10 @@ class FirstRouteWidget extends StatelessWidget {
child:
Text
(
'Open second route'
),
onPressed:
()
{
FlutterBoost
.
singleton
.
openPage
(
"second"
,
{},
animated:
true
,
resultHandler:
(
String
key
,
Map
<
dynamic
,
dynamic
>
result
){
print
(
"did recieve second route result
$key
$result
"
);
print
(
"open second page!"
);
FlutterBoost
.
singleton
.
open
(
"second"
).
then
((
Map
value
){
print
(
"did recieve second route result"
);
print
(
"did recieve second route result
$value
"
);
});
},
...
...
@@ -39,12 +41,11 @@ class SecondRouteWidget extends StatelessWidget {
BoostContainerSettings
settings
=
BoostContainer
.
of
(
context
).
settings
;
if
(
settings
.
params
.
containsKey
(
"result_id"
)){
String
rid
=
settings
.
params
[
"result_id"
];
FlutterBoost
.
singleton
.
onPageResult
(
rid
,
{
"data"
:
"works"
},{});
}
FlutterBoost
.
singleton
.
close
PageForContext
(
context
);
FlutterBoost
.
singleton
.
close
(
settings
.
uniqueId
,
result:
{
"result"
:
"data from second"
}
);
},
child:
Text
(
'Go back!'
),
child:
Text
(
'Go back
with result
!'
),
),
),
);
...
...
ios/Classes/1.0/FLBFlutterApplication.m
View file @
d284055d
...
...
@@ -128,7 +128,44 @@
-
(
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
];
}
-
(
void
)
didInitPageContainer
:(
NSString
*
)
url
params
:(
NSDictionary
*
)
urlParams
uniqueId
:(
NSString
*
)
uniqueId
{
}
-
(
void
)
willDeallocPageContainer
:(
NSString
*
)
url
params
:(
NSDictionary
*
)
params
uniqueId
:(
NSString
*
)
uniqueId
{
}
@end
ios/Classes/1.0/FLBFlutterViewContainer.m
View file @
d284055d
...
...
@@ -391,15 +391,5 @@ static NSUInteger kInstanceCounter = 0;
self
.
interactiveGestureActive
=
NO
;
}
#pragma mark - FLBViewControllerResultHandler
-
(
void
)
onRecievedResult
:(
NSDictionary
*
)
resultData
forKey
:(
NSString
*
)
key
{
[
Service_NavigationService
onNativePageResult
:
^
(
NSNumber
*
finished
)
{}
uniqueId:
self
.
uniqueIDString
key:
key
resultData:
resultData
params:
@{}];
}
@end
ios/Classes/1.5/FLB2FlutterApplication.m
View file @
d284055d
...
...
@@ -32,6 +32,10 @@
@property
(
nonatomic
,
strong
)
id
<
FLB2FlutterProvider
>
viewProvider
;
@property
(
nonatomic
,
assign
)
BOOL
isRunning
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
pageResultCallbacks
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
callbackCache
;
@end
...
...
@@ -73,6 +77,8 @@
{
if
(
self
=
[
super
init
])
{
_manager
=
[
FLBFlutterContainerManager
new
];
_pageResultCallbacks
=
NSMutableDictionary
.
new
;
_callbackCache
=
NSMutableDictionary
.
new
;
}
return
self
;
}
...
...
@@ -129,4 +135,66 @@
return
self
.
flutterProvider
.
engine
.
viewController
;
}
-
(
void
)
close
:(
NSString
*
)
uniqueId
result
:(
NSDictionary
*
)
result
exts
:(
NSDictionary
*
)
exts
completion
:(
void
(
^
)(
BOOL
))
completion
{
[
self
.
platform
close
:
uniqueId
result:
result
exts:
exts
completion:
completion
];
if
(
_pageResultCallbacks
[
uniqueId
]){
void
(
^
cb
)(
NSDictionary
*
)
=
_pageResultCallbacks
[
uniqueId
];
cb
(
result
);
[
_pageResultCallbacks
removeObjectForKey
:
uniqueId
];
}
}
-
(
void
)
open
:(
NSString
*
)
url
urlParams
:(
NSDictionary
*
)
urlParams
exts
:(
NSDictionary
*
)
exts
reult
:(
void
(
^
)(
NSDictionary
*
))
resultCallback
completion
:(
void
(
^
)(
BOOL
))
completion
{
NSString
*
cid
=
urlParams
[
@"__calback_id__"
];
if
(
!
cid
){
static
int64_t
sCallbackID
=
1
;
cid
=
@
(
sCallbackID
).
stringValue
;
sCallbackID
+=
2
;
}
_callbackCache
[
cid
]
=
resultCallback
;
[
self
.
platform
open
:
url
urlParams:
urlParams
exts:
exts
completion:
completion
];
}
-
(
void
)
didInitPageContainer
:(
NSString
*
)
url
params
:(
NSDictionary
*
)
urlParams
uniqueId
:(
NSString
*
)
uniqueId
{
NSString
*
cid
=
urlParams
[
@"__calback_id__"
];
if
(
cid
&&
_callbackCache
[
cid
]){
_pageResultCallbacks
[
uniqueId
]
=
_callbackCache
[
cid
];
[
_callbackCache
removeObjectForKey
:
cid
];
}
}
-
(
void
)
willDeallocPageContainer
:(
NSString
*
)
url
params
:(
NSDictionary
*
)
params
uniqueId
:(
NSString
*
)
uniqueId
{
if
(
_pageResultCallbacks
[
uniqueId
]){
void
(
^
cb
)(
NSDictionary
*
)
=
_pageResultCallbacks
[
uniqueId
];
cb
(@{});
[
_pageResultCallbacks
removeObjectForKey
:
uniqueId
];
}
}
@end
ios/Classes/Boost/FLB2Platform.h
View file @
d284055d
...
...
@@ -33,15 +33,15 @@ 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
:(
NSDictionary
*
)
exts
completion
:(
void
(
^
)(
BOOL
finished
))
completion
;
-
(
void
)
close
Page
:(
NSString
*
)
uid
animated
:(
BOOL
)
animated
params
:(
NSDictionary
*
)
param
s
completion
:(
void
(
^
)(
BOOL
finished
))
completion
;
-
(
void
)
close
:(
NSString
*
)
uid
result
:(
NSDictionary
*
)
result
exts
:(
NSDictionary
*
)
ext
s
completion
:(
void
(
^
)(
BOOL
finished
))
completion
;
@end
NS_ASSUME_NONNULL_END
ios/Classes/Boost/FLBFlutterApplicationInterface.h
View file @
d284055d
...
...
@@ -55,6 +55,29 @@ NS_ASSUME_NONNULL_BEGIN
-
(
void
)
resume
;
-
(
void
)
inactive
;
-
(
BOOL
)
isRunning
;
#pragma mark - handle 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
;
-
(
void
)
didInitPageContainer
:(
NSString
*
)
url
params
:(
NSDictionary
*
)
urlParams
uniqueId
:(
NSString
*
)
uniqueId
;
-
(
void
)
willDeallocPageContainer
:(
NSString
*
)
url
params
:(
NSDictionary
*
)
params
uniqueId
:(
NSString
*
)
uniqueId
;
@end
NS_ASSUME_NONNULL_END
...
...
ios/Classes/Boost/FLBTypes.h
0 → 100644
View file @
d284055d
/*
* 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.
*/
#ifndef FLBTypes_h
#define FLBTypes_h
typedef
void
(
^
FLBEventListener
)
(
NSString
*
name
,
NSDictionary
*
arguments
);
typedef
void
(
^
FLBVoidCallback
)(
void
);
#endif
/* FLBTypes_h */
ios/Classes/Boost/FlutterBoostPlugin.h
View file @
d284055d
...
...
@@ -24,6 +24,7 @@
#import <Flutter/Flutter.h>
#import "FLB2Platform.h"
#import "FLBTypes.h"
@interface
FlutterBoostPlugin
:
NSObject
<
FlutterPlugin
>
...
...
@@ -38,18 +39,11 @@
-
(
BOOL
)
isRunning
;
-
(
FlutterViewController
*
)
currentViewController
;
#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
;
#pragma mark - broadcast event to/from flutter
-
(
void
)
sendEvent
:(
NSString
*
)
eventName
arguments
:(
NSDictionary
*
)
arguments
;
-
(
void
)
onResultForKey
:(
NSString
*
)
vcId
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
;
-
(
FLBVoidCallback
)
addEventListener
:(
FLBEventListener
)
listner
forName
:(
NSString
*
)
name
;
-
(
void
)
setResultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
handler
forKey
:(
NSString
*
)
result_id
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
@end
ios/Classes/Boost/FlutterBoostPlugin.m
View file @
d284055d
...
...
@@ -23,13 +23,65 @@
*/
#import "FlutterBoostPlugin.h"
#import "FLBResultMediator.h"
#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"
@interface
FlutterBoostPlugin
()
@property
(
nonatomic
,
strong
)
FLBMessageDispather
*
dispatcher
;
@end
@implementation
FlutterBoostPlugin
+
(
void
)
registerWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>*
)
registrar
{
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
methodChannelWithName:
@"flutter_boost"
binaryMessenger:
[
registrar
messenger
]];
FlutterBoostPlugin
*
instance
=
[
self
.
class
sharedInstance
];
[
instance
registerHandlers
];
instance
.
methodChannel
=
channel
;
instance
.
broadcastor
=
[[
FLBBroadcastor
alloc
]
initWithMethodChannel
:
channel
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
}
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
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
);
}
}
}
-
(
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
{
static
id
_instance
=
nil
;
...
...
@@ -44,7 +96,7 @@
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
_
resultMediator
=
[
FLBResultMediator
new
]
;
_
dispatcher
=
FLBMessageDispather
.
new
;
}
return
self
;
...
...
@@ -55,33 +107,12 @@
return
_application
;
}
-
(
FLBResultMediator
*
)
resultMediator
{
return
_resultMediator
;
}
-
(
id
<
FLBAbstractFactory
>
)
factory
{
return
_factory
;
}
+
(
void
)
registerWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>*
)
registrar
{
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
methodChannelWithName:
@"flutter_boost"
binaryMessenger:
[
registrar
messenger
]];
FlutterBoostPlugin
*
instance
=
[
self
.
class
sharedInstance
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
}
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
if
([
@"getPlatformVersion"
isEqualToString
:
call
.
method
])
{
result
([
@"iOS "
stringByAppendingString
:[[
UIDevice
currentDevice
]
systemVersion
]]);
}
else
{
result
(
FlutterMethodNotImplemented
);
}
}
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLB2Platform
>
)
platform
onStart
:(
void
(
^
)(
id
<
FlutterBinaryMessenger
,
FlutterTextureRegistry
,
...
...
@@ -112,31 +143,20 @@
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
#pragma mark - broadcast event to/from flutter
-
(
void
)
sendEvent
:(
NSString
*
)
eventName
arguments
:(
NSDictionary
*
)
arguments
{
[
_resultMediator
setResultHandler
:
handler
forKey
:
vcid
];
[
_broadcastor
sendEvent
:
eventName
arguments:
arguments
];
}
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
-
(
FLBVoidCallback
)
addEventListener
:(
FLBEventListener
)
listner
forName
:(
NSString
*
)
name
{
[
_resultMediator
removeHandlerForKey
:
vcid
];
return
[
_broadcastor
addEventListener
:
listner
forName:
name
];
}
@end
ios/Classes/Boost/FlutterBoostPlugin_private.h
View file @
d284055d
...
...
@@ -24,22 +24,21 @@
#import <Flutter/Flutter.h>
#import "FLBFlutterApplicationInterface.h"
#import "FLBResultMediator.h"
#import "FLBAbstractFactory.h"
#import "FLBBroadcastor.h"
@interface
FlutterBoostPlugin
(){
id
<
FLBFlutterApplicationInterface
>
_application
;
FLBResultMediator
*
_resultMediator
;
id
<
FLBAbstractFactory
>
_factory
;
}
-
(
id
<
FLBFlutterApplicationInterface
>
)
application
;
-
(
FLBResultMediator
*
)
resultMediator
;
-
(
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
;
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_closePage.h
View file @
d284055d
...
...
@@ -23,6 +23,7 @@
*/
// Generated by AIOCodeGen do not edit!
#import "FlutterServiceCallHandler.h"
@interface
NavigationService_closePage
:
FlutterServiceCallHandler
@end
\ No newline at end of file
#import "FLBMessageHandlerImp.h"
@interface
NavigationService_closePage
:
FLBMessageHandlerImp
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_closePage.mm
View file @
d284055d
...
...
@@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
//Generated by AIOCodeGen.
#import "ServiceGateway.h"
#import "NavigationService_closePage.h"
...
...
@@ -31,36 +30,30 @@
#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application
@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.
-
(
void
)
__flutter_p_handler_closePage
:(
NSDictionary
*
)
args
result
:(
void
(
^
)(
BOOL
))
result
{
[
self
onCall
:
result
uniqueId
:
args
[
@"uniqueId"
]
pageName
:
args
[
@"pageName"
]
params
:
args
[
@"params"
]
animated
:
args
[
@"animated"
]];
}
+
(
void
)
load
{
[[
ServiceGateway
sharedInstance
]
registerHandler
:[
NavigationService_closePage
new
]];
-
(
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"
;
}
-
(
NSString
*
)
service
{
return
@"NavigationService"
;
}
-
(
NSArray
*
)
handledMessageNames
{
return
@[
@"closePage"
];
}
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.h
View file @
d284055d
...
...
@@ -23,6 +23,6 @@
*/
// Generated by AIOCodeGen do not edit!
#import "FlutterServiceCallHandler.h"
@interface
NavigationService_onFlutterPageResult
:
FlutterServiceCallHandler
@end
\ No newline at end of file
#import "FLBMessageHandlerImp.h"
@interface
NavigationService_onFlutterPageResult
:
FLBMessageHandlerImp
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.mm
View file @
d284055d
...
...
@@ -32,26 +32,25 @@
-
(
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.
-
(
void
)
__flutter_p_handler_onFlutterPageResult
:(
NSDictionary
*
)
args
result
:(
void
(
^
)(
BOOL
))
result
{
-
(
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
;
}
+
(
void
)
load
{
[[
ServiceGateway
sharedInstance
]
registerHandler
:[
NavigationService_onFlutterPageResult
new
]];
}
-
(
NSArray
*
)
handledMessageNames
{
return
@[
@"onFlutterPageResult"
];
}
-
(
NSString
*
)
returnType
{
return
@"BOOL"
;
}
-
(
NSString
*
)
service
{
return
@"NavigationService"
;
}
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onShownContainerChanged.h
View file @
d284055d
...
...
@@ -23,6 +23,6 @@
*/
// Generated by AIOCodeGen do not edit!
#import "FlutterServiceCallHandler.h"
@interface
NavigationService_onShownContainerChanged
:
FlutterServiceCallHandler
@end
\ No newline at end of file
#import "FLBMessageHandlerImp.h"
@interface
NavigationService_onShownContainerChanged
:
FLBMessageHandlerImp
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onShownContainerChanged.mm
View file @
d284055d
...
...
@@ -38,19 +38,21 @@
}
#pragma mark - Do not edit these method.
-
(
void
)
__flutter_p_handler_onShownContainerChanged
:(
NSDictionary
*
)
args
result
:(
void
(
^
)(
BOOL
))
result
{
-
(
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
;
}
+
(
void
)
load
{
[[
ServiceGateway
sharedInstance
]
registerHandler
:[
NavigationService_onShownContainerChanged
new
]];
}
-
(
NSString
*
)
returnType
{
return
@"BOOL"
;
}
-
(
NSString
*
)
service
{
return
@"NavigationService"
;
}
-
(
NSArray
*
)
handledMessageNames
{
return
@[
@"onShownContainerChanged"
];
}
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.h
View file @
d284055d
...
...
@@ -23,6 +23,6 @@
*/
// Generated by AIOCodeGen do not edit!
#import "FlutterServiceCallHandler.h"
@interface
NavigationService_openPage
:
FlutterServiceCallHandler
@end
\ No newline at end of file
#import "FLBMessageHandlerImp.h"
@interface
NavigationService_openPage
:
FLBMessageHandlerImp
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.mm
View file @
d284055d
...
...
@@ -32,31 +32,29 @@
#define FLUTTER_APP [FlutterBoostPlugin sharedInstance].application
@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.
-
(
void
)
__flutter_p_handler_openPage
:(
NSDictionary
*
)
args
result
:(
void
(
^
)(
BOOL
))
result
{
[
self
onCall
:
result
pageName
:
args
[
@"pageName"
]
params
:
args
[
@"params"
]
animated
:
args
[
@"animated"
]];
}
+
(
void
)
load
{
[[
ServiceGateway
sharedInstance
]
registerHandler
:[
NavigationService_openPage
new
]];
-
(
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
@"BOOL"
;
}
-
(
NSString
*
)
service
{
return
@"NavigationService"
;
return
@"NSDictionary *"
;
}
-
(
NSArray
*
)
handledMessageNames
{
return
@[
@"openPage"
];
}
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_pageOnStart.h
View file @
d284055d
...
...
@@ -23,6 +23,6 @@
*/
// Generated by AIOCodeGen do not edit!
#import "F
lutterServiceCallHandler
.h"
@interface
NavigationService_pageOnStart
:
F
lutterServiceCallHandler
#import "F
LBMessageHandlerImp
.h"
@interface
NavigationService_pageOnStart
:
F
LBMessageHandlerImp
@end
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_pageOnStart.mm
View file @
d284055d
...
...
@@ -24,8 +24,8 @@
//Generated by AIOCodeGen.
#import "ServiceGateway.h"
#import "NavigationService_pageOnStart.h"
#import "ServiceGateway.h"
#import "NavigationService_pageOnStart.h"
#import "FlutterBoostPlugin_private.h"
@implementation
NavigationService_pageOnStart
...
...
@@ -40,19 +40,22 @@
}
#pragma mark - Do not edit these method.
-
(
void
)
__flutter_p_handler_pageOnStart
:(
NSDictionary
*
)
args
result
:(
void
(
^
)(
NSDictionary
*
))
result
{
[
self
onCall
:
result
params
:
args
[
@"params"
]];
}
+
(
void
)
load
{
[[
ServiceGateway
sharedInstance
]
registerHandler
:[
NavigationService_pageOnStart
new
]];
}
-
(
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 *"
;
}
-
(
NSString
*
)
service
{
return
@"NavigationService"
;
}
-
(
NSArray
*
)
handledMessageNames
{
return
@[
@"pageOnStart"
];
}
@end
ios/Classes/Messaging/Generated/NavigationService/service/Service_NavigationService.h
View file @
d284055d
...
...
@@ -22,11 +22,10 @@
* THE SOFTWARE.
*/
//Generated by AIOCodeGen do not edit!
#import "FlutterServiceTemplate.h"
#import <Foundation/Foundation.h>
@interface
Service_NavigationService
:
NSObject
+
(
FlutterServiceTemplate
*
)
service
;
+
(
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
;
+
(
void
)
willShowPageContainer
:(
void
(
^
)(
NSNumber
*
))
result
pageName
:(
NSString
*
)
pageName
params
:(
NSDictionary
*
)
params
uniqueId
:(
NSString
*
)
uniqueId
;
...
...
@@ -34,4 +33,4 @@
+
(
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
;
@end
\ No newline at end of file
@end
ios/Classes/Messaging/Generated/NavigationService/service/Service_NavigationService.mm
View file @
d284055d
...
...
@@ -22,29 +22,18 @@
* THE SOFTWARE.
*/
//Generated by AIOCodeGen. Do not edit!
#import "Service_NavigationService.h"
#import "ServiceGateway.h"
#import "FlutterServiceTemplate.h"
#import "Service_NavigationService.h"
#import <Flutter/Flutter.h>
#import "FlutterBoostPlugin_private.h"
@implementation
Service_NavigationService
+
(
Flutter
ServiceTemplate
*
)
service
+
(
Flutter
MethodChannel
*
)
methodChannel
{
static
id
_instance
=
nil
;
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
_instance
=
[[
FlutterServiceTemplate
alloc
]
initWithName
:
@"NavigationService"
];
});
return
_instance
;
}
+
(
void
)
load
{
[[
ServiceGateway
sharedInstance
]
addService
:[
self
service
]];
return
FlutterBoostPlugin
.
sharedInstance
.
methodChannel
;
}
+
(
void
)
onNativePageResult
:(
void
(
^
)(
NSNumber
*
))
result
uniqueId
:(
NSString
*
)
uniqueId
key
:(
NSString
*
)
key
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
{
NSMutableDictionary
*
tmp
=
[
NSMutableDictionary
dictionary
];
...
...
@@ -52,7 +41,7 @@
if
(
key
)
tmp
[
@"key"
]
=
key
;
if
(
resultData
)
tmp
[
@"resultData"
]
=
resultData
;
if
(
params
)
tmp
[
@"params"
]
=
params
;
[
self
.
service
invoke
:
@"onNativePageResult"
arg
s
:
tmp
result
:^
(
id
tTesult
)
{
[
self
.
methodChannel
invokeMethod
:
@"onNativePageResult"
argument
s
:
tmp
result
:^
(
id
tTesult
)
{
if
(
result
)
{
result
(
tTesult
);
}
...
...
@@ -65,7 +54,7 @@
if
(
pageName
)
tmp
[
@"pageName"
]
=
pageName
;
if
(
params
)
tmp
[
@"params"
]
=
params
;
if
(
uniqueId
)
tmp
[
@"uniqueId"
]
=
uniqueId
;
[
self
.
service
invoke
:
@"didShowPageContainer"
arg
s
:
tmp
result
:^
(
id
tTesult
)
{
[
self
.
methodChannel
invokeMethod
:
@"didShowPageContainer"
argument
s
:
tmp
result
:^
(
id
tTesult
)
{
if
(
result
)
{
result
(
tTesult
);
}
...
...
@@ -78,7 +67,7 @@
if
(
pageName
)
tmp
[
@"pageName"
]
=
pageName
;
if
(
params
)
tmp
[
@"params"
]
=
params
;
if
(
uniqueId
)
tmp
[
@"uniqueId"
]
=
uniqueId
;
[
self
.
service
invoke
:
@"willShowPageContainer"
arg
s
:
tmp
result
:^
(
id
tTesult
)
{
[
self
.
methodChannel
invokeMethod
:
@"willShowPageContainer"
argument
s
:
tmp
result
:^
(
id
tTesult
)
{
if
(
result
)
{
result
(
tTesult
);
}
...
...
@@ -91,7 +80,7 @@
if
(
pageName
)
tmp
[
@"pageName"
]
=
pageName
;
if
(
params
)
tmp
[
@"params"
]
=
params
;
if
(
uniqueId
)
tmp
[
@"uniqueId"
]
=
uniqueId
;
[
self
.
service
invoke
:
@"willDisappearPageContainer"
arg
s
:
tmp
result
:^
(
id
tTesult
)
{
[
self
.
methodChannel
invokeMethod
:
@"willDisappearPageContainer"
argument
s
:
tmp
result
:^
(
id
tTesult
)
{
if
(
result
)
{
result
(
tTesult
);
}
...
...
@@ -104,7 +93,7 @@
if
(
pageName
)
tmp
[
@"pageName"
]
=
pageName
;
if
(
params
)
tmp
[
@"params"
]
=
params
;
if
(
uniqueId
)
tmp
[
@"uniqueId"
]
=
uniqueId
;
[
self
.
service
invoke
:
@"didDisappearPageContainer"
arg
s
:
tmp
result
:^
(
id
tTesult
)
{
[
self
.
methodChannel
invokeMethod
:
@"didDisappearPageContainer"
argument
s
:
tmp
result
:^
(
id
tTesult
)
{
if
(
result
)
{
result
(
tTesult
);
}
...
...
@@ -117,11 +106,15 @@
if
(
pageName
)
tmp
[
@"pageName"
]
=
pageName
;
if
(
params
)
tmp
[
@"params"
]
=
params
;
if
(
uniqueId
)
tmp
[
@"uniqueId"
]
=
uniqueId
;
[
self
.
service
invoke
:
@"didInitPageContainer"
arg
s
:
tmp
result
:^
(
id
tTesult
)
{
[
self
.
methodChannel
invokeMethod
:
@"didInitPageContainer"
argument
s
:
tmp
result
:^
(
id
tTesult
)
{
if
(
result
)
{
result
(
tTesult
);
}
}];
[
FlutterBoostPlugin
.
sharedInstance
.
application
didInitPageContainer
:
pageName
params:
params
uniqueId:
uniqueId
];
}
+
(
void
)
willDeallocPageContainer
:(
void
(
^
)(
NSNumber
*
))
result
pageName
:(
NSString
*
)
pageName
params
:(
NSDictionary
*
)
params
uniqueId
:(
NSString
*
)
uniqueId
...
...
@@ -130,12 +123,16 @@
if
(
pageName
)
tmp
[
@"pageName"
]
=
pageName
;
if
(
params
)
tmp
[
@"params"
]
=
params
;
if
(
uniqueId
)
tmp
[
@"uniqueId"
]
=
uniqueId
;
[
self
.
service
invoke
:
@"willDeallocPageContainer"
arg
s
:
tmp
result
:^
(
id
tTesult
)
{
[
self
.
methodChannel
invokeMethod
:
@"willDeallocPageContainer"
argument
s
:
tmp
result
:^
(
id
tTesult
)
{
if
(
result
)
{
result
(
tTesult
);
}
}];
[
FlutterBoostPlugin
.
sharedInstance
.
application
willDeallocPageContainer
:
pageName
params:
params
uniqueId:
uniqueId
];
}
@end
\ No newline at end of file
@end
ios/Classes/Messaging/base/FLBBroadcastor.h
0 → 100644
View file @
d284055d
/*
* 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
lib/messaging/page_result_mediator.dart
→
ios/Classes/Messaging/base/FLBBroadcastor.m
100755 → 100644
View file @
d284055d
/*
* 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
...
...
@@ -21,61 +21,69 @@
* 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/AIOService/NavigationService/service/NavigationService.dart'
;
typedef
void
PageResultHandler
(
String
key
,
Map
<
String
,
dynamic
>
result
);
typedef
VoidCallback
=
void
Function
();
class
PageResultMediator
{
#import "FLBBroadcastor.h"
static
int
_resultId
=
0
;
@interface
FLBBroadcastor
()
@property
(
nonatomic
,
strong
)
FlutterMethodChannel
*
channel
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
lists
;
String
createResultId
(){
_resultId
++;
return
"result_id_
$_resultId
"
;
}
@end
bool
isResultId
(
String
rid
){
if
(
rid
==
null
)
return
false
;
return
rid
.
contains
(
"result_id"
);
}
@implementation
FLBBroadcastor
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
"
);
-
(
instancetype
)
initWithMethodChannel
:(
FlutterMethodChannel
*
)
channel
{
if
(
self
=
[
super
init
])
{
_channel
=
channel
;
_lists
=
NSMutableDictionary
.
new
;
}
return
self
;
}
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
);
}
}
-
(
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
;
}
}
VoidCallback
setPageResultHandler
(
String
key
,
PageResultHandler
handler
){
if
(
key
==
null
||
handler
==
null
)
return
(){};
_handlers
[
key
]
=
handler
;
return
(){
_handlers
.
remove
(
key
);
[
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
ios/Classes/Messaging/base/FLBMessageDispather.h
0 → 100755
View file @
d284055d
/*
* 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
ios/Classes/Messaging/base/FLBMessageDispather.m
0 → 100755
View file @
d284055d
/*
* 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
ios/Classes/Messaging/base/FLBMessageHandlerImp.h
0 → 100755
View file @
d284055d
/*
* 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
ios/Classes/Messaging/base/FLBMessageHandlerImp.m
0 → 100755
View file @
d284055d
/*
* 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
ios/Classes/
Boost/FLBResultMediator
.h
→
ios/Classes/
Messaging/base/FLBMessageImp
.h
100755 → 100644
View file @
d284055d
/*
* 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
...
...
@@ -21,18 +21,15 @@
* 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
typedef
void
(
^
FLBPageResultHandler
)(
NSString
*
,
NSDictionary
*
);
@interface
FLBResultMediator
:
NSObject
@interface
FLBMessageImp
:
NSObject
<
FLBMessage
>
-
(
void
)
onResultForKey
:(
NSString
*
)
resultId
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
;
-
(
void
)
setResultHandler
:(
FLBPageResultHandler
)
handler
forKey
:(
NSString
*
)
vcid
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
@property
(
nonatomic
,
copy
)
NSString
*
name
;
@property
(
nonatomic
,
strong
)
NSDictionary
*
params
;
@end
...
...
ios/Classes/Messaging/base/FLBMessageImp.m
0 → 100644
View file @
d284055d
/*
* 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
ios/Classes/Messaging/base/FLBMessageing.h
0 → 100755
View file @
d284055d
/*
* 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
ios/flutter_boost.podspec
View file @
d284055d
...
...
@@ -21,12 +21,11 @@ A new Flutter plugin make flutter better to use!
'Classes/Boost/FLB2Platform.h'
,
'Classes/Boost/FLBFlutterContainer.h'
,
'Classes/Boost/FLBFlutterAppDelegate.h'
,
'Classes/Boost/FLBTypes.h'
,
'Classes/1.0/FLBFlutterViewContainer.h'
,
'Classes/1.5/FLB2FlutterViewContainer.h'
s
.
dependency
'Flutter'
s
.
dependency
'xservice_kit'
s
.
libraries
=
'c++'
s
.
ios
.
deployment_target
=
'8.0'
...
...
lib/AIOService/NavigationService/service/NavigationServiceRegister.dart
deleted
100755 → 0
View file @
0e7d161c
/*
* 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
'NavigationService.dart'
;
import
'../handlers/NavigationService_onNativePageResult.dart'
;
import
'../handlers/NavigationService_didShowPageContainer.dart'
;
import
'../handlers/NavigationService_willShowPageContainer.dart'
;
import
'../handlers/NavigationService_willDisappearPageContainer.dart'
;
import
'../handlers/NavigationService_didDisappearPageContainer.dart'
;
import
'../handlers/NavigationService_didInitPageContainer.dart'
;
import
'../handlers/NavigationService_willDeallocPageContainer.dart'
;
class
NavigationServiceRegister
{
static
register
(){
NavigationService
.
regsiter
();
NavigationService_onNativePageResult
.
regsiter
();
NavigationService_didShowPageContainer
.
regsiter
();
NavigationService_willShowPageContainer
.
regsiter
();
NavigationService_willDisappearPageContainer
.
regsiter
();
NavigationService_didDisappearPageContainer
.
regsiter
();
NavigationService_didInitPageContainer
.
regsiter
();
NavigationService_willDeallocPageContainer
.
regsiter
();
}
}
\ No newline at end of file
lib/container/container_coordinator.dart
View file @
d284055d
...
...
@@ -24,7 +24,6 @@
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_boost/AIOService/NavigationService/service/NavigationService.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'
;
...
...
@@ -37,7 +36,9 @@ class ContainerCoordinator implements NativePageContainerEventHandler {
PageBuilder
_defaultPageBuilder
;
ContainerCoordinator
()
{
NavigationService
.
listenEvent
(
onChannelEvent
);
FlutterBoost
.
singleton
.
addEventListener
(
"lifecycle"
,
(
String
name
,
Map
arguments
){
onChannelEvent
(
arguments
);
});
}
BoostContainerSettings
_createContainerSettings
(
...
...
@@ -88,7 +89,7 @@ class ContainerCoordinator implements NativePageContainerEventHandler {
void
onChannelEvent
(
dynamic
event
)
{
if
(
event
is
Map
)
{
Map
map
=
event
as
Map
;
Map
map
=
event
;
final
String
type
=
map
[
'type'
];
switch
(
type
)
{
...
...
@@ -177,7 +178,7 @@ class ContainerCoordinator implements NativePageContainerEventHandler {
FlutterBoost
.
containerManager
?.
remove
(
pageId
);
Logger
.
log
(
'native containner dealloc,
\n
manager dump:
\n
${FlutterBoost.containerManager?.dump()}
'
);
'native containner dealloc,
\n
manager dump:
\n
${FlutterBoost.containerManager?.dump()}
'
);
return
true
;
}
...
...
lib/container/container_manager.dart
View file @
d284055d
...
...
@@ -23,7 +23,7 @@
*/
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter_boost/
AIOService/NavigationService/service/NavigationS
ervice.dart'
;
import
'package:flutter_boost/
messaging/service/navigation_s
ervice.dart'
;
import
'package:flutter_boost/container/boost_container.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
...
...
lib/flutter_boost.dart
View file @
d284055d
...
...
@@ -24,19 +24,26 @@
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_boost/AIOService/NavigationService/service/NavigationService.dart'
;
import
'package:flutter_boost/messaging/service/navigation_service.dart'
;
import
'package:flutter_boost/container/boost_container.dart'
;
import
'package:flutter_boost/container/container_manager.dart'
;
import
'package:flutter_boost/messaging/page_result_mediator.dart'
;
import
'package:flutter_boost/router/router.dart'
;
import
'AIOService/loader/ServiceLoader.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'
;
export
'container/container_manager.dart'
;
import
'package:flutter/services.dart'
;
typedef
Widget
PageBuilder
(
String
pageName
,
Map
params
,
String
uniqueId
);
...
...
@@ -47,18 +54,18 @@ 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
();
FlutterBoost
()
{
_router
.
resultMediator
=
_resultMediator
;
ServiceLoader
.
load
();
}
int
_callbackID
=
0
;
Broadcastor
_broadcastor
;
static
FlutterBoost
get
singleton
=>
_instance
;
...
...
@@ -67,8 +74,8 @@ class FlutterBoost {
static
TransitionBuilder
init
(
{
TransitionBuilder
builder
,
PrePushRoute
prePush
,
PostPushRoute
postPush
})
{
PrePushRoute
prePush
,
PostPushRoute
postPush
})
{
return
(
BuildContext
context
,
Widget
child
)
{
assert
(
child
is
Navigator
,
'child must be Navigator, what is wrong?'
);
...
...
@@ -90,32 +97,105 @@ 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
);
}
///Register page builder for a key.
void
registerPageBuilder
(
String
pageName
,
PageBuilder
builder
)
{
ContainerCoordinator
.
singleton
.
registerPageBuilder
(
pageName
,
builder
);
}
///Register a map builders
void
registerPageBuilders
(
Map
<
String
,
PageBuilder
>
builders
)
{
ContainerCoordinator
.
singleton
.
registerPageBuilders
(
builders
);
}
Future
<
bool
>
openPage
(
String
url
,
Map
params
,
{
bool
animated
,
PageResultHandler
resultHandler
})
{
return
_router
.
openPage
(
url
,
params
,
animated:
animated
,
resultHandler:
resultHandler
);
Future
<
Map
<
dynamic
,
dynamic
>>
open
(
String
url
,{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
}){
if
(
urlParams
==
null
)
{
urlParams
=
Map
();
}
if
(
exts
==
null
){
exts
=
Map
();
}
urlParams
[
"__calback_id__"
]
=
_callbackID
;
_callbackID
+=
2
;
return
_router
.
open
(
url
,
urlParams:
urlParams
,
exts:
exts
);
}
Future
<
bool
>
close
(
String
id
,{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
}){
if
(
result
==
null
)
{
result
=
Map
();
}
if
(
exts
==
null
){
exts
=
Map
();
}
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
<
Map
<
String
,
dynamic
>>
openPage
(
String
name
,
Map
params
,{
bool
animated
})
{
Map
<
String
,
dynamic
>
exts
=
Map
();
if
(
animated
!=
null
){
exts
[
"animated"
]
=
animated
;
}
else
{
exts
[
"animated"
]
=
true
;
}
return
open
(
name
,
urlParams:
params
,
exts:
exts
);
}
Future
<
bool
>
closePage
(
String
url
,
String
pageI
d
,
Map
params
,
Future
<
bool
>
closePage
(
String
url
,
String
i
d
,
Map
params
,
{
bool
animated
})
{
return
_router
.
closePage
(
url
,
pageId
,
params
,
animated:
animated
);
Map
<
String
,
dynamic
>
exts
=
Map
();
if
(
animated
!=
null
){
exts
[
"animated"
]
=
animated
;
}
else
{
exts
[
"animated"
]
=
true
;
}
if
(
url
!=
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
);
...
...
@@ -142,21 +222,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
);
...
...
@@ -169,4 +234,6 @@ class FlutterBoost {
///register callbacks for Navigators push & pop
VoidCallback
addBoostNavigatorObserver
(
BoostNavigatorObserver
observer
)
=>
_observersHolder
.
addObserver
<
BoostNavigatorObserver
>(
observer
);
}
lib/messaging/base/broadcastor.dart
0 → 100644
View file @
d284055d
/*
* 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
lib/messaging/base/message_dispatcher.dart
0 → 100644
View file @
d284055d
/*
* 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
;
}
}
lib/messaging/base/message_handler.dart
0 → 100644
View file @
d284055d
/*
* 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
lib/
AIOService/NavigationService/handlers/NavigationService_didDisappearPageContain
er.dart
→
lib/
messaging/handlers/did_disappear_page_container_handl
er.dart
View file @
d284055d
...
...
@@ -25,24 +25,15 @@ import 'dart:async';
import
'package:flutter/services.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'package:xservice_kit/ServiceCallHandler.dart'
;
import
'package:xservice_kit/ServiceGateway.dart'
;
import
'package:flutter_boost/messaging/base/message_handler.dart'
;
class
NavigationService_didDisappearPageContainer
extends
ServiceCallHandler
{
static
void
regsiter
()
{
ServiceGateway
.
sharedInstance
()
.
registerHandler
(
new
NavigationService_didDisappearPageContainer
());
}
class
DidDisappearPageContainerHandler
implements
MessageHandler
{
@override
String
name
()
{
return
"didDisappearPageContainer"
;
}
@override
String
service
()
{
return
"NavigationService"
;
}
@override
Future
<
bool
>
onMethodCall
(
MethodCall
call
)
{
...
...
lib/
AIOService/NavigationService/handlers/NavigationService_didInitPageContain
er.dart
→
lib/
messaging/handlers/did_init_page_container_handl
er.dart
View file @
d284055d
...
...
@@ -24,14 +24,14 @@
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:xservice_kit/ServiceCallHandler.dart'
;
import
'package:xservice_kit/ServiceGateway.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
class
NavigationService_didInitPageContainer
extends
ServiceCallHandler
{
import
'package:flutter_boost/messaging/base/message_handler.dart'
;
class
DidInitPageContainerHandler
implements
MessageHandler
{
static
void
regsiter
()
{
ServiceGateway
.
sharedInstance
()
.
registerHandler
(
new
NavigationService_didInitPageContainer
());
//
ServiceGateway.sharedInstance()
//
.registerHandler(new NavigationService_didInitPageContainer());
}
@override
...
...
@@ -39,10 +39,6 @@ class NavigationService_didInitPageContainer extends ServiceCallHandler {
return
"didInitPageContainer"
;
}
@override
String
service
()
{
return
"NavigationService"
;
}
@override
Future
<
bool
>
onMethodCall
(
MethodCall
call
)
{
...
...
lib/
AIOService/NavigationService/handlers/NavigationService_didShowPageContain
er.dart
→
lib/
messaging/handlers/did_show_page_container_handl
er.dart
View file @
d284055d
...
...
@@ -25,25 +25,15 @@ import 'dart:async';
import
'package:flutter/services.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'package:xservice_kit/ServiceCallHandler.dart'
;
import
'package:xservice_kit/ServiceGateway.dart'
;
import
'package:flutter_boost/messaging/base/message_handler.dart'
;
class
NavigationService_didShowPageContainer
extends
ServiceCallHandler
{
static
void
regsiter
()
{
ServiceGateway
.
sharedInstance
()
.
registerHandler
(
new
NavigationService_didShowPageContainer
());
}
class
DidShowPageContainerHandler
implements
MessageHandler
{
@override
String
name
()
{
return
"didShowPageContainer"
;
}
@override
String
service
()
{
return
"NavigationService"
;
}
@override
Future
<
bool
>
onMethodCall
(
MethodCall
call
)
{
return
onCall
(
call
.
arguments
[
"pageName"
],
call
.
arguments
[
"params"
],
...
...
lib/
AIOService/NavigationService/handlers/NavigationService_onNativePageResult
.dart
→
lib/
messaging/handlers/on_native_page_result_handler
.dart
View file @
d284055d
...
...
@@ -24,26 +24,16 @@
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:xservice_kit/ServiceCallHandler.dart'
;
import
'package:xservice_kit/ServiceGateway.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
class
NavigationService_onNativePageResult
extends
ServiceCallHandler
{
import
'package:flutter_boost/messaging/base/message_handler.dart'
;
static
void
regsiter
()
{
ServiceGateway
.
sharedInstance
().
registerHandler
(
new
NavigationService_onNativePageResult
());
}
class
OnNativePageResultHandler
implements
MessageHandler
{
@override
String
name
()
{
return
"onNativePageResult"
;
}
@override
String
service
()
{
return
"NavigationService"
;
}
@override
Future
<
bool
>
onMethodCall
(
MethodCall
call
)
{
return
onCall
(
call
.
arguments
[
"uniqueId"
],
call
.
arguments
[
"key"
],
call
.
arguments
[
"resultData"
],
call
.
arguments
[
"params"
]);
...
...
@@ -51,6 +41,5 @@ class NavigationService_onNativePageResult extends ServiceCallHandler {
//==============================================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/
AIOService/NavigationService/handlers/NavigationService_willDeallocPageContain
er.dart
→
lib/
messaging/handlers/will_dealloc_page_container_handl
er.dart
View file @
d284055d
...
...
@@ -25,25 +25,14 @@ import 'dart:async';
import
'package:flutter/services.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'package:xservice_kit/ServiceCallHandler.dart'
;
import
'package:xservice_kit/ServiceGateway.dart'
;
class
NavigationService_willDeallocPageContainer
extends
ServiceCallHandler
{
static
void
regsiter
()
{
ServiceGateway
.
sharedInstance
()
.
registerHandler
(
new
NavigationService_willDeallocPageContainer
());
}
import
'package:flutter_boost/messaging/base/message_handler.dart'
;
class
WillDeallocPageContainerHandler
implements
MessageHandler
{
@override
String
name
()
{
return
"willDeallocPageContainer"
;
}
@override
String
service
()
{
return
"NavigationService"
;
}
@override
Future
<
bool
>
onMethodCall
(
MethodCall
call
)
{
return
onCall
(
call
.
arguments
[
"pageName"
],
call
.
arguments
[
"params"
],
...
...
lib/
AIOService/NavigationService/handlers/NavigationService_willDisappearPageContain
er.dart
→
lib/
messaging/handlers/will_disappear_page_container_handl
er.dart
View file @
d284055d
...
...
@@ -25,25 +25,15 @@ import 'dart:async';
import
'package:flutter/services.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'package:xservice_kit/ServiceCallHandler.dart'
;
import
'package:xservice_kit/ServiceGateway.dart'
;
import
'package:flutter_boost/messaging/base/message_handler.dart'
;
class
NavigationService_willDisappearPageContainer
extends
ServiceCallHandler
{
static
void
regsiter
()
{
ServiceGateway
.
sharedInstance
()
.
registerHandler
(
new
NavigationService_willDisappearPageContainer
());
}
class
WillDisappearPageContainerHandler
implements
MessageHandler
{
@override
String
name
()
{
return
"willDisappearPageContainer"
;
}
@override
String
service
()
{
return
"NavigationService"
;
}
@override
Future
<
bool
>
onMethodCall
(
MethodCall
call
)
{
return
onCall
(
call
.
arguments
[
"pageName"
],
call
.
arguments
[
"params"
],
...
...
lib/
AIOService/NavigationService/handlers/NavigationService_willShowPageContain
er.dart
→
lib/
messaging/handlers/will_show_page_container_handl
er.dart
View file @
d284055d
...
...
@@ -25,25 +25,15 @@ import 'dart:async';
import
'package:flutter/services.dart'
;
import
'package:flutter_boost/container/container_coordinator.dart'
;
import
'package:xservice_kit/ServiceCallHandler.dart'
;
import
'package:xservice_kit/ServiceGateway.dart'
;
import
'package:flutter_boost/messaging/base/message_handler.dart'
;
class
NavigationService_willShowPageContainer
extends
ServiceCallHandler
{
static
void
regsiter
()
{
ServiceGateway
.
sharedInstance
()
.
registerHandler
(
new
NavigationService_willShowPageContainer
());
}
class
WillShowPageContainerHandler
implements
MessageHandler
{
@override
String
name
()
{
return
"willShowPageContainer"
;
}
@override
String
service
()
{
return
"NavigationService"
;
}
@override
Future
<
bool
>
onMethodCall
(
MethodCall
call
)
{
return
onCall
(
call
.
arguments
[
"pageName"
],
call
.
arguments
[
"params"
],
...
...
lib/messaging/message_proxy.dart
View file @
d284055d
...
...
@@ -21,23 +21,27 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import
'package:flutter_boost/
AIOService/NavigationService/service/NavigationS
ervice.dart'
;
import
'package:flutter_boost/
messaging/service/navigation_s
ervice.dart'
;
import
'dart:async'
;
abstract
class
MessageProxy
{
Future
<
bool
>
openPage
(
String
pageName
,
Map
params
,
bool
animated
);
Future
<
bool
>
close
Page
(
String
uniqueId
,
String
pageName
,
Map
params
,
bool
animated
);
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
<
bool
>
openPage
(
String
pageName
,
Map
params
,
bool
animated
)
{
return
NavigationService
.
openPage
(
pageName
,
params
,
animated
);
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
Page
(
String
uniqueId
,
String
pageName
,
Map
params
,
bool
animated
)
{
return
NavigationService
.
closePage
(
uniqueId
,
pageName
,
params
,
animated
);
Future
<
bool
>
close
(
String
id
,{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
})
{
return
NavigationService
.
closePage
(
id
,
result:
result
,
exts:
exts
);
}
}
lib/
AIOService/NavigationService/service/NavigationS
ervice.dart
→
lib/
messaging/service/navigation_s
ervice.dart
View file @
d284055d
...
...
@@ -22,34 +22,21 @@
* THE SOFTWARE.
*/
import
'dart:async'
;
import
'package:xservice_kit/foundation_ext/foundation_ext.dart'
;
import
'package:xservice_kit/ServiceTemplate.dart'
;
import
'package:xservice_kit/ServiceGateway.dart'
;
class
NavigationService
{
static
final
ServiceTemplate
_service
=
new
ServiceTemplate
(
"NavigationService"
);
static
void
regsiter
()
{
ServiceGateway
.
sharedInstance
().
registerService
(
_service
);
}
//List event from event channel.
static
int
listenEvent
(
void
onData
(
dynamic
event
))
{
return
_service
.
listenEvent
(
onData
);
}
//Cancel event for subscription with ID.
static
void
cancelEventForSubscription
(
int
subID
)
{
_service
.
cancelEventForSubscription
(
subID
);
}
import
'dart:async'
;
import
'package:flutter/services.dart'
;
class
NavigationService
{
static
MethodChannel
methodChannel
;
static
Future
<
bool
>
onShownContainerChanged
(
String
newName
,
String
oldName
,
Map
params
)
{
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
properties
[
"newName"
]=
newName
;
properties
[
"oldName"
]=
oldName
;
properties
[
"params"
]=
params
;
return
_service
.
methodChannel
()
.
invokeMethod
(
'onShownContainerChanged'
,
properties
).
then
<
bool
>((
value
){
return
BOOL
(
value
);
return
methodChannel
.
invokeMethod
(
'onShownContainerChanged'
,
properties
).
then
<
bool
>((
value
){
return
(
value
);
});
}
static
Future
<
bool
>
onFlutterPageResult
(
String
uniqueId
,
String
key
,
Map
resultData
,
Map
params
)
{
...
...
@@ -58,39 +45,45 @@
properties
[
"key"
]=
key
;
properties
[
"resultData"
]=
resultData
;
properties
[
"params"
]=
params
;
return
_service
.
methodChannel
()
.
invokeMethod
(
'onFlutterPageResult'
,
properties
).
then
<
bool
>((
value
){
return
BOOL
(
value
);
return
methodChannel
.
invokeMethod
(
'onFlutterPageResult'
,
properties
).
then
<
bool
>((
value
){
return
(
value
);
});
}
static
Future
<
Map
>
pageOnStart
(
Map
params
)
async
{
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
properties
[
"params"
]=
params
;
try
{
return
await
_service
.
methodChannel
()
.
invokeMethod
(
'pageOnStart'
,
properties
).
then
<
Map
>((
value
){
return
await
methodChannel
.
invokeMethod
(
'pageOnStart'
,
properties
).
then
<
Map
>((
value
){
return
value
as
Map
;
});
}
catch
(
e
)
{
print
(
'Page on start exception'
);
return
Future
<
Map
>
.
value
(
{});
return
Future
<
Map
>
(()
{});
}
}
static
Future
<
bool
>
openPage
(
String
pageName
,
Map
params
,
bool
animated
)
{
static
Future
<
Map
<
dynamic
,
dynamic
>>
openPage
(
String
url
,
Map
urlParams
,
Map
exts
)
{
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
properties
[
"
pageName"
]=
pageName
;
properties
[
"
params"
]=
p
arams
;
properties
[
"
animated"
]=
animated
;
return
_service
.
methodChannel
().
invokeMethod
(
'openPage'
,
properties
).
then
<
bool
>((
value
){
return
BOOL
(
value
);
properties
[
"
url"
]=
url
;
properties
[
"
urlParams"
]=
urlP
arams
;
properties
[
"
exts"
]=
exts
;
return
methodChannel
.
invokeMethod
(
'openPage'
,
properties
).
then
<
Map
<
dynamic
,
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
;
return
_service
.
methodChannel
().
invokeMethod
(
'closePage'
,
properties
).
then
<
bool
>((
value
){
return
BOOL
(
value
);
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 @
d284055d
...
...
@@ -26,13 +26,10 @@ 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/messaging/page_result_mediator.dart'
;
import
'package:flutter_boost/support/logger.dart'
;
class
Router
{
MessageProxy
_msgProxy
=
MessageProxyImp
();
PageResultMediator
resultMediator
=
null
;
void
setMessageProxy
(
MessageProxy
prx
)
{
if
(
prx
!=
null
)
{
...
...
@@ -41,28 +38,15 @@ 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
);
}
});
}
return
_msgProxy
.
openPage
(
url
,
params
,
animated
);
Future
<
Map
<
dynamic
,
dynamic
>>
open
(
String
url
,{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
}){
return
_msgProxy
.
open
(
url
,
urlParams:
urlParams
,
exts:
exts
);
}
Future
<
bool
>
closePage
(
String
name
,
String
pageId
,
Map
params
,
{
bool
animated
=
true
})
{
return
_msgProxy
.
closePage
(
pageId
,
name
,
params
,
animated
);
Future
<
bool
>
close
(
String
id
,{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
}){
return
_msgProxy
.
close
(
id
,
result:
result
,
exts:
exts
);
}
//Close currentPage page.
Future
<
bool
>
closeCurPage
(
Map
params
)
{
BoostContainerSettings
settings
;
...
...
@@ -87,7 +71,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
(
settings
.
uniqueId
,
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