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
73accf5a
Commit
73accf5a
authored
May 22, 2019
by
Jidong Chen
Committed by
GitHub
May 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #161 from alibaba/result_mediator
Result mediator
parents
7aed07fe
6433ecc8
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
213 additions
and
84 deletions
+213
-84
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
.../com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
+16
-37
android/src/main/java/com/taobao/idlefish/flutterboost/PageResultMediator.java
.../com/taobao/idlefish/flutterboost/PageResultMediator.java
+51
-1
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MainActivity.java
...com/taobao/idlefish/flutterboostexample/MainActivity.java
+4
-0
example/ios/Runner.xcodeproj/project.xcworkspace/xcuserdata/jidong.xcuserdatad/WorkspaceSettings.xcsettings
...cuserdata/jidong.xcuserdatad/WorkspaceSettings.xcsettings
+8
-0
example/ios/Runner/DemoRouter.m
example/ios/Runner/DemoRouter.m
+4
-1
example/ios/Runner/UIViewControllerDemo.m
example/ios/Runner/UIViewControllerDemo.m
+6
-2
example/lib/main.dart
example/lib/main.dart
+1
-0
example/lib/simple_page_widgets.dart
example/lib/simple_page_widgets.dart
+12
-1
ios/Classes/Boost/FLBResultMediator.h
ios/Classes/Boost/FLBResultMediator.h
+1
-1
ios/Classes/Boost/FLBResultMediator.m
ios/Classes/Boost/FLBResultMediator.m
+34
-3
ios/Classes/Boost/FlutterBoostPlugin.h
ios/Classes/Boost/FlutterBoostPlugin.h
+12
-2
ios/Classes/Boost/FlutterBoostPlugin.m
ios/Classes/Boost/FlutterBoostPlugin.m
+14
-2
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.mm
...Service/handlers/NavigationService_onFlutterPageResult.mm
+2
-1
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.mm
.../NavigationService/handlers/NavigationService_openPage.mm
+0
-25
lib/AIOService/NavigationService/handlers/NavigationService_onNativePageResult.dart
...ervice/handlers/NavigationService_onNativePageResult.dart
+1
-1
lib/flutter_boost.dart
lib/flutter_boost.dart
+11
-4
lib/messaging/page_result_mediator.dart
lib/messaging/page_result_mediator.dart
+30
-1
lib/router/router.dart
lib/router/router.dart
+6
-2
No files found.
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
View file @
73accf5a
...
...
@@ -56,6 +56,7 @@ import io.flutter.view.FlutterView;
public
class
FlutterBoostPlugin
implements
MethodChannel
.
MethodCallHandler
,
Application
.
ActivityLifecycleCallbacks
{
private
static
FlutterBoostPlugin
sInstance
=
null
;
private
static
int
kRid
=
0
;
public
static
synchronized
void
init
(
IPlatform
platform
)
{
if
(
sInstance
==
null
)
{
...
...
@@ -148,54 +149,32 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
ctx
=
sInstance
.
mPlatform
.
getApplication
();
}
//Handling page result.
if
(
sInstance
.
needResult
(
params
))
{
sInstance
.
mMediator
.
setHandler
(
url
,
new
PageResultHandler
()
{
@Override
public
void
onResult
(
String
key
,
Map
resultData
)
{
NavigationService
.
onNativePageResult
(
new
MessageResult
<
Boolean
>()
{
@Override
public
void
success
(
Boolean
var1
)
{
//Doing nothing now.
sInstance
.
mPlatform
.
startActivity
(
ctx
,
concatUrl
(
url
,
params
),
requestCode
);
}
@Override
public
void
error
(
String
var1
,
String
var2
,
Object
var3
)
{
//Doing nothing now.
}
public
static
void
openPage
(
Context
context
,
String
url
,
final
Map
params
,
int
requestCode
,
PageResultHandler
handler
)
{
@Override
public
void
notImplemented
()
{
//Doing nothing now.
}
},
"no use"
,
key
,
resultData
,
params
);
}
});
if
(
handler
!=
null
){
String
rid
=
createResultId
();
sInstance
.
mMediator
.
setHandler
(
rid
,
handler
);
params
.
put
(
"result_id"
,
rid
);
}
sInstance
.
mPlatform
.
startActivity
(
ctx
,
concatUrl
(
url
,
params
),
requestCode
);
openPage
(
context
,
url
,
params
,
requestCode
);
}
private
Boolean
needResult
(
Map
params
)
{
if
(
params
==
null
)
return
false
;
final
String
key
=
"needResult"
;
if
(
params
.
containsKey
(
key
))
{
if
(
params
.
get
(
key
)
instanceof
Boolean
)
{
return
(
Boolean
)
params
.
get
(
key
);
}
}
return
false
;
private
static
String
createResultId
(){
kRid
+=
2
;
return
"result_id_"
+
kRid
;
}
public
static
void
onPageResult
(
String
key
,
Map
resultData
)
{
public
static
void
onPageResult
(
String
key
,
Map
resultData
,
Map
params
)
{
if
(
sInstance
==
null
)
{
throw
new
RuntimeException
(
"FlutterBoostPlugin not init yet!"
);
}
sInstance
.
mMediator
.
onPageResult
(
key
,
resultData
);
sInstance
.
mMediator
.
onPageResult
(
key
,
resultData
,
params
);
}
public
static
void
setHandler
(
String
key
,
PageResultHandler
handler
)
{
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/PageResultMediator.java
View file @
73accf5a
...
...
@@ -23,19 +23,69 @@
*/
package
com.taobao.idlefish.flutterboost
;
import
com.taobao.idlefish.flutterboost.NavigationService.NavigationService
;
import
java.util.HashMap
;
import
java.util.Map
;
import
fleamarket.taobao.com.xservicekit.handler.MessageResult
;
class
PageResultMediator
{
private
Map
<
String
,
PageResultHandler
>
_handlers
=
new
HashMap
<>();
void
onPageResult
(
String
key
,
Map
resultData
){
void
onPageResult
(
String
key
,
Map
resultData
,
Map
params
){
if
(
key
==
null
)
return
;
if
(
_handlers
.
containsKey
(
key
)){
_handlers
.
get
(
key
).
onResult
(
key
,
resultData
);
_handlers
.
remove
(
key
);
}
else
{
if
(
params
==
null
||
!
params
.
containsKey
(
"forward"
)){
if
(
params
==
null
){
params
=
new
HashMap
();
}
params
.
put
(
"forward"
,
1
);
NavigationService
.
onNativePageResult
(
new
MessageResult
<
Boolean
>()
{
@Override
public
void
success
(
Boolean
var1
)
{
}
@Override
public
void
error
(
String
var1
,
String
var2
,
Object
var3
)
{
}
@Override
public
void
notImplemented
()
{
}
},
key
,
key
,
resultData
,
params
);
}
else
{
int
forward
=
(
Integer
)
params
.
get
(
"forward"
);
params
.
put
(
"forward"
,++
forward
);
if
(
forward
<=
2
){
NavigationService
.
onNativePageResult
(
new
MessageResult
<
Boolean
>()
{
@Override
public
void
success
(
Boolean
var1
)
{
}
@Override
public
void
error
(
String
var1
,
String
var2
,
Object
var3
)
{
}
@Override
public
void
notImplemented
()
{
}
},
key
,
key
,
resultData
,
params
);
}
}
}
}
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MainActivity.java
View file @
73accf5a
...
...
@@ -6,7 +6,10 @@ import android.support.v7.app.AppCompatActivity;
import
android.view.View
;
import
android.widget.TextView
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
java.lang.ref.WeakReference
;
import
java.util.HashMap
;
public
class
MainActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
...
...
@@ -46,6 +49,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
NATIVE_PAGE_URL
);
}
else
if
(
v
==
mOpenFlutter
)
{
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
FLUTTER_PAGE_URL
);
FlutterBoostPlugin
.
onPageResult
(
"result_id_100"
,
new
HashMap
(),
new
HashMap
());
}
else
if
(
v
==
mOpenFlutterFragment
)
{
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
FLUTTER_FRAGMENT_PAGE_URL
);
}
...
...
example/ios/Runner.xcodeproj/project.xcworkspace/xcuserdata/jidong.xcuserdatad/WorkspaceSettings.xcsettings
0 → 100644
View file @
73accf5a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
BuildLocationStyle
</key>
<string>
UseTargetSettings
</string>
</dict>
</plist>
example/ios/Runner/DemoRouter.m
View file @
73accf5a
...
...
@@ -29,11 +29,14 @@
if
([
params
[
@"present"
]
boolValue
]){
FLBFlutterViewContainer
*
vc
=
FLBFlutterViewContainer
.
new
;
[
vc
setName
:
name
params
:
params
];
[
self
.
navigationController
presentViewController
:
vc
animated
:
animated
completion
:^
{}];
[
self
.
navigationController
presentViewController
:
vc
animated
:
animated
completion
:^
{
if
(
completion
)
completion
(
YES
);
}];
}
else
{
FLBFlutterViewContainer
*
vc
=
FLBFlutterViewContainer
.
new
;
[
vc
setName
:
name
params
:
params
];
[
self
.
navigationController
pushViewController
:
vc
animated
:
animated
];
if
(
completion
)
completion
(
YES
);
}
}
...
...
example/ios/Runner/UIViewControllerDemo.m
View file @
73accf5a
...
...
@@ -9,7 +9,7 @@
#import "UIViewControllerDemo.h"
#import <Flutter/Flutter.h>
#import "DemoRouter.h"
#import <flutter_boost/FlutterBoostPlugin.h>
@interface
UIViewControllerDemo
()
...
...
@@ -25,7 +25,11 @@
-
(
IBAction
)
pushFlutterPage
:(
id
)
sender
{
[
DemoRouter
.
sharedRouter
openPage
:
@"first"
params
:@{}
animated
:
YES
completion
:^
(
BOOL
f
){}];
[
DemoRouter
.
sharedRouter
openPage
:
@"first"
params
:@{}
animated
:
YES
completion
:^
(
BOOL
f
){
[
FlutterBoostPlugin
.
sharedInstance
onResultForKey
:
@"result_id_100"
resultData
:@{}
params
:
@{}];
}];
}
-
(
IBAction
)
present
:(
id
)
sender
{
...
...
example/lib/main.dart
View file @
73accf5a
...
...
@@ -31,6 +31,7 @@ class _MyAppState extends State<MyApp> {
});
FlutterBoost
.
handleOnStartPage
();
}
@override
...
...
example/lib/simple_page_widgets.dart
View file @
73accf5a
...
...
@@ -12,7 +12,11 @@ class FirstRouteWidget extends StatelessWidget {
child:
RaisedButton
(
child:
Text
(
'Open second route'
),
onPressed:
()
{
FlutterBoost
.
singleton
.
openPage
(
"second"
,
{},
animated:
true
);
FlutterBoost
.
singleton
.
openPage
(
"second"
,
{},
animated:
true
,
resultHandler:
(
String
key
,
Map
<
dynamic
,
dynamic
>
result
){
print
(
"did recieve second route result
$key
$result
"
);
});
},
),
),
...
...
@@ -31,6 +35,13 @@ class SecondRouteWidget extends StatelessWidget {
child:
RaisedButton
(
onPressed:
()
{
// Navigate back to first route when tapped.
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
.
closePageForContext
(
context
);
},
child:
Text
(
'Go back!'
),
...
...
ios/Classes/Boost/FLBResultMediator.h
View file @
73accf5a
...
...
@@ -30,7 +30,7 @@ typedef void (^FLBPageResultHandler)(NSString *, NSDictionary *);
@interface
FLBResultMediator
:
NSObject
-
(
void
)
onResultForKey
:(
NSString
*
)
vcId
resultData
:(
NSDictionary
*
)
resultData
;
-
(
void
)
onResultForKey
:(
NSString
*
)
resultId
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
;
-
(
void
)
setResultHandler
:(
FLBPageResultHandler
)
handler
forKey
:(
NSString
*
)
vcid
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
...
...
ios/Classes/Boost/FLBResultMediator.m
View file @
73accf5a
...
...
@@ -23,6 +23,7 @@
*/
#import "FLBResultMediator.h"
#import "Service_NavigationService.h"
@interface
FLBResultMediator
()
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
handlers
;
...
...
@@ -38,16 +39,46 @@
return
self
;
}
-
(
void
)
onResultForKey
:(
NSString
*
)
vcI
d
-
(
void
)
onResultForKey
:(
NSString
*
)
ri
d
resultData
:(
NSDictionary
*
)
resultData
params
:(
nonnull
NSDictionary
*
)
params
{
if
(
!
vcI
d
)
return
;
if
(
!
ri
d
)
return
;
NSString
*
key
=
vcI
d
;
NSString
*
key
=
ri
d
;
if
(
_handlers
[
key
]){
FLBPageResultHandler
handler
=
_handlers
[
key
];
handler
(
key
,
resultData
);
[
_handlers
removeObjectForKey
:
key
];
}
else
{
//Cannot find handler here. Try to forward message to flutter.
//Use forward to avoid circle.
if
(
!
params
||
!
params
[
@"forward"
]){
NSMutableDictionary
*
tmp
=
params
.
mutableCopy
;
if
(
!
tmp
){
tmp
=
NSMutableDictionary
.
new
;
}
tmp
[
@"forward"
]
=
@
(
1
);
params
=
tmp
;
[
Service_NavigationService
onNativePageResult
:
^
(
NSNumber
*
r
)
{}
uniqueId:
rid
key:
rid
resultData:
resultData
params:
params
];
}
else
{
NSMutableDictionary
*
tmp
=
params
.
mutableCopy
;
tmp
[
@"forward"
]
=
@
([
params
[
@"forward"
]
intValue
]
+
1
);
params
=
tmp
;
if
([
params
[
@"forward"
]
intValue
]
<=
2
){
[
Service_NavigationService
onNativePageResult
:
^
(
NSNumber
*
r
)
{}
uniqueId:
rid
key:
rid
resultData:
resultData
params:
params
];
}
}
}
}
...
...
ios/Classes/Boost/FlutterBoostPlugin.h
View file @
73accf5a
...
...
@@ -42,7 +42,17 @@ typedef FLBFlutterViewContainer * (^FLBPageBuilder)(NSString *name,NSDictionary
-
(
FlutterViewController
*
)
currentViewController
;
#pragma mark - handing vc result.
-
(
void
)
onResultForKey
:(
NSString
*
)
vcId
resultData
:(
NSDictionary
*
)
resultData
;
-
(
void
)
setResultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
handler
forKey
:(
NSString
*
)
vcid
;
-
(
void
)
openPage
:(
NSString
*
)
name
params
:(
NSDictionary
*
)
params
animated
:(
BOOL
)
animated
completion
:(
void
(
^
)(
BOOL
finished
))
completion
resultHandler
:(
void
(
^
)(
NSString
*
resultId
,
NSDictionary
*
rData
))
resultHandler
;
-
(
void
)
onResultForKey
:(
NSString
*
)
vcId
resultData
:(
NSDictionary
*
)
resultData
params
:(
NSDictionary
*
)
params
;
-
(
void
)
setResultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
handler
forKey
:(
NSString
*
)
result_id
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
@end
ios/Classes/Boost/FlutterBoostPlugin.m
View file @
73accf5a
...
...
@@ -86,9 +86,21 @@
return
[[
FLBFlutterApplication
sharedApplication
]
flutterViewController
];
}
-
(
void
)
onResultForKey
:(
NSString
*
)
vcId
resultData
:(
NSDictionary
*
)
resultData
-
(
void
)
openPage
:(
NSString
*
)
name
params
:(
NSDictionary
*
)
params
animated
:(
BOOL
)
animated
completion
:(
void
(
^
)(
BOOL
))
completion
resultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
resultHandler
{
[
_resultMediator
onResultForKey
:
vcId
resultData
:
resultData
];
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
...
...
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.mm
View file @
73accf5a
...
...
@@ -34,7 +34,8 @@
{
//Add your handler code here!
[
FlutterBoostPlugin
.
sharedInstance
onResultForKey
:
key
resultData:
resultData
];
resultData:
resultData
params:
params
];
}
#pragma mark - Do not edit these method.
...
...
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.mm
View file @
73accf5a
...
...
@@ -34,21 +34,6 @@
-
(
void
)
onCall
:(
void
(
^
)(
BOOL
))
result
pageName
:(
NSString
*
)
pageName
params
:(
NSDictionary
*
)
params
animated
:(
NSNumber
*
)
animated
{
NSString
*
url
=
pageName
;
if
(
pageName
==
nil
){
pageName
=
params
[
@"url"
];
}
if
([
self
needResult
:
params
]){
[
FlutterBoostPlugin
.
sharedInstance
setResultHandler
:
^
(
NSString
*
key
,
NSDictionary
*
resultData
)
{
[
Service_NavigationService
onNativePageResult
:
^
(
NSNumber
*
)
{}
uniqueId:
@"no use"
key:
url
resultData:
resultData
params:
@{}];
}
forKey
:
url
];
}
[[
FLBFlutterApplication
sharedApplication
].
platform
openPage
:
pageName
params:
params
animated:
animated
.
boolValue
...
...
@@ -57,16 +42,6 @@
}];
}
-
(
BOOL
)
needResult
:(
NSDictionary
*
)
params
{
NSString
*
const
key
=
@"needResult"
;
NSNumber
*
val
=
params
[
key
];
if
(
val
&&
[
val
isKindOfClass
:
NSNumber
.
class
])
{
return
val
.
boolValue
;
}
return
NO
;
}
#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"
]];
...
...
lib/AIOService/NavigationService/handlers/NavigationService_onNativePageResult.dart
View file @
73accf5a
...
...
@@ -51,6 +51,6 @@ 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
);
return
FlutterBoost
.
singleton
.
onPageResult
(
key
,
resultData
,
params
);
}
}
lib/flutter_boost.dart
View file @
73accf5a
...
...
@@ -51,11 +51,12 @@ class FlutterBoost {
final
GlobalKey
<
ContainerManagerState
>
containerManagerKey
=
GlobalKey
<
ContainerManagerState
>();
final
Router
_router
=
Router
();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
PageResultMediator
_resultMediator
=
PageResultMediator
();
final
Router
_router
=
Router
();
FlutterBoost
()
{
_router
.
resultMediator
=
_resultMediator
;
ServiceLoader
.
load
();
}
...
...
@@ -140,10 +141,16 @@ class FlutterBoost {
}
}
bool
onPageResult
(
String
key
,
Map
<
String
,
dynamic
>
resultData
)
{
bool
onPageResult
(
String
key
,
Map
resultData
,
Map
params
)
{
if
(
_resultMediator
.
isResultId
(
key
)){
_resultMediator
.
onPageResult
(
key
,
resultData
,
params
);
}
else
{
containerManager
?.
containerStateOf
(
key
)?.
performOnResult
(
resultData
);
_resultMediator
.
onPageResult
(
key
,
resultData
);
}
return
true
;
}
VoidCallback
setPageResultHandler
(
String
key
,
PageResultHandler
handler
)
{
...
...
lib/messaging/page_result_mediator.dart
View file @
73accf5a
...
...
@@ -22,14 +22,27 @@
* THE SOFTWARE.
*/
import
'package:flutter_boost/support/logger.dart'
;
import
'package:flutter_boost/AIOService/NavigationService/service/NavigationService.dart'
;
typedef
void
PageResultHandler
(
String
key
,
Map
<
dynamic
,
dynamic
>
result
);
typedef
VoidCallback
=
void
Function
();
class
PageResultMediator
{
static
int
_resultId
=
0
;
String
createResultId
(){
_resultId
++;
return
"result_id_
$_resultId
"
;
}
bool
isResultId
(
String
rid
){
if
(
rid
==
null
)
return
false
;
return
rid
.
contains
(
"result_id"
);
}
Map
<
String
,
PageResultHandler
>
_handlers
=
Map
();
void
onPageResult
(
String
key
,
Map
<
dynamic
,
dynamic
>
resultData
){
void
onPageResult
(
String
key
,
Map
<
dynamic
,
dynamic
>
resultData
,
Map
params
){
if
(
key
==
null
)
return
;
...
...
@@ -38,6 +51,22 @@ class PageResultMediator{
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
);
}
}
}
}
...
...
lib/router/router.dart
View file @
73accf5a
...
...
@@ -31,6 +31,8 @@ import 'package:flutter_boost/support/logger.dart';
class
Router
{
MessageProxy
_msgProxy
=
MessageProxyImp
();
PageResultMediator
resultMediator
=
null
;
void
setMessageProxy
(
MessageProxy
prx
)
{
if
(
prx
!=
null
)
{
...
...
@@ -38,11 +40,13 @@ class Router {
}
}
Future
<
bool
>
openPage
(
String
url
,
Map
params
,
{
bool
animated
=
true
,
PageResultHandler
resultHandler
})
{
if
(
resultHandler
!=
null
)
{
params
[
"needResult"
]
=
true
;
FlutterBoost
.
singleton
.
setPageResultHandler
(
url
,
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
)
{
...
...
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