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
6997cfe8
Commit
6997cfe8
authored
Apr 26, 2019
by
Jidong Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,iOS page result Handling
2,Dart page result Handling
parent
39645d29
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
199 additions
and
49 deletions
+199
-49
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
.../com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
+2
-2
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 @
6997cfe8
...
@@ -187,13 +187,13 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
...
@@ -187,13 +187,13 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
return
false
;
return
false
;
}
}
public
static
void
onPageResult
(
String
key
,
Map
resultData
){
public
static
void
onPageResult
(
String
key
,
Map
resultData
,
Map
params
){
if
(
sInstance
==
null
)
{
if
(
sInstance
==
null
)
{
throw
new
RuntimeException
(
"FlutterBoostPlugin not init yet!"
);
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
){
public
static
void
setHandler
(
String
key
,
PageResultHandler
handler
){
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/PageResultMediator.java
View file @
6997cfe8
...
@@ -23,19 +23,69 @@
...
@@ -23,19 +23,69 @@
*/
*/
package
com.taobao.idlefish.flutterboost
;
package
com.taobao.idlefish.flutterboost
;
import
com.taobao.idlefish.flutterboost.NavigationService.NavigationService
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
fleamarket.taobao.com.xservicekit.handler.MessageResult
;
class
PageResultMediator
{
class
PageResultMediator
{
private
Map
<
String
,
PageResultHandler
>
_handlers
=
new
HashMap
<>();
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
(
key
==
null
)
return
;
if
(
_handlers
.
containsKey
(
key
)){
if
(
_handlers
.
containsKey
(
key
)){
_handlers
.
get
(
key
).
onResult
(
key
,
resultData
);
_handlers
.
get
(
key
).
onResult
(
key
,
resultData
);
_handlers
.
remove
(
key
);
_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 @
6997cfe8
...
@@ -6,7 +6,10 @@ import android.support.v7.app.AppCompatActivity;
...
@@ -6,7 +6,10 @@ import android.support.v7.app.AppCompatActivity;
import
android.view.View
;
import
android.view.View
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
java.lang.ref.WeakReference
;
import
java.lang.ref.WeakReference
;
import
java.util.HashMap
;
public
class
MainActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
public
class
MainActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
...
@@ -46,6 +49,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
...
@@ -46,6 +49,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
NATIVE_PAGE_URL
);
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
NATIVE_PAGE_URL
);
}
else
if
(
v
==
mOpenFlutter
)
{
}
else
if
(
v
==
mOpenFlutter
)
{
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
FLUTTER_PAGE_URL
);
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
FLUTTER_PAGE_URL
);
FlutterBoostPlugin
.
onPageResult
(
"result_id_100"
,
new
HashMap
(),
new
HashMap
());
}
else
if
(
v
==
mOpenFlutterFragment
)
{
}
else
if
(
v
==
mOpenFlutterFragment
)
{
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
FLUTTER_FRAGMENT_PAGE_URL
);
PageRouter
.
openPageByUrl
(
this
,
PageRouter
.
FLUTTER_FRAGMENT_PAGE_URL
);
}
}
...
...
example/ios/Runner.xcodeproj/project.xcworkspace/xcuserdata/jidong.xcuserdatad/WorkspaceSettings.xcsettings
0 → 100644
View file @
6997cfe8
<?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 @
6997cfe8
...
@@ -29,11 +29,14 @@
...
@@ -29,11 +29,14 @@
if
([
params
[
@"present"
]
boolValue
]){
if
([
params
[
@"present"
]
boolValue
]){
FLBFlutterViewContainer
*
vc
=
FLBFlutterViewContainer
.
new
;
FLBFlutterViewContainer
*
vc
=
FLBFlutterViewContainer
.
new
;
[
vc
setName
:
name
params
:
params
];
[
vc
setName
:
name
params
:
params
];
[
self
.
navigationController
presentViewController
:
vc
animated
:
animated
completion
:^
{}];
[
self
.
navigationController
presentViewController
:
vc
animated
:
animated
completion
:^
{
if
(
completion
)
completion
(
YES
);
}];
}
else
{
}
else
{
FLBFlutterViewContainer
*
vc
=
FLBFlutterViewContainer
.
new
;
FLBFlutterViewContainer
*
vc
=
FLBFlutterViewContainer
.
new
;
[
vc
setName
:
name
params
:
params
];
[
vc
setName
:
name
params
:
params
];
[
self
.
navigationController
pushViewController
:
vc
animated
:
animated
];
[
self
.
navigationController
pushViewController
:
vc
animated
:
animated
];
if
(
completion
)
completion
(
YES
);
}
}
}
}
...
...
example/ios/Runner/UIViewControllerDemo.m
View file @
6997cfe8
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#import "UIViewControllerDemo.h"
#import "UIViewControllerDemo.h"
#import <Flutter/Flutter.h>
#import <Flutter/Flutter.h>
#import "DemoRouter.h"
#import "DemoRouter.h"
#import <flutter_boost/FlutterBoostPlugin.h>
@interface
UIViewControllerDemo
()
@interface
UIViewControllerDemo
()
...
@@ -25,7 +25,11 @@
...
@@ -25,7 +25,11 @@
-
(
IBAction
)
pushFlutterPage
:(
id
)
sender
{
-
(
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
{
-
(
IBAction
)
present
:(
id
)
sender
{
...
...
example/lib/main.dart
View file @
6997cfe8
...
@@ -31,6 +31,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -31,6 +31,7 @@ class _MyAppState extends State<MyApp> {
});
});
FlutterBoost
.
handleOnStartPage
();
FlutterBoost
.
handleOnStartPage
();
}
}
@override
@override
...
...
example/lib/simple_page_widgets.dart
View file @
6997cfe8
...
@@ -12,7 +12,11 @@ class FirstRouteWidget extends StatelessWidget {
...
@@ -12,7 +12,11 @@ class FirstRouteWidget extends StatelessWidget {
child:
RaisedButton
(
child:
RaisedButton
(
child:
Text
(
'Open second route'
),
child:
Text
(
'Open second route'
),
onPressed:
()
{
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 {
...
@@ -31,6 +35,13 @@ class SecondRouteWidget extends StatelessWidget {
child:
RaisedButton
(
child:
RaisedButton
(
onPressed:
()
{
onPressed:
()
{
// Navigate back to first route when tapped.
// 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
);
FlutterBoost
.
singleton
.
closePageForContext
(
context
);
},
},
child:
Text
(
'Go back!'
),
child:
Text
(
'Go back!'
),
...
...
ios/Classes/Boost/FLBResultMediator.h
View file @
6997cfe8
...
@@ -30,7 +30,7 @@ typedef void (^FLBPageResultHandler)(NSString *, NSDictionary *);
...
@@ -30,7 +30,7 @@ typedef void (^FLBPageResultHandler)(NSString *, NSDictionary *);
@interface
FLBResultMediator
:
NSObject
@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
)
setResultHandler
:(
FLBPageResultHandler
)
handler
forKey
:(
NSString
*
)
vcid
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
...
...
ios/Classes/Boost/FLBResultMediator.m
View file @
6997cfe8
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
*/
*/
#import "FLBResultMediator.h"
#import "FLBResultMediator.h"
#import "Service_NavigationService.h"
@interface
FLBResultMediator
()
@interface
FLBResultMediator
()
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
handlers
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
handlers
;
...
@@ -38,16 +39,46 @@
...
@@ -38,16 +39,46 @@
return
self
;
return
self
;
}
}
-
(
void
)
onResultForKey
:(
NSString
*
)
vcI
d
-
(
void
)
onResultForKey
:(
NSString
*
)
ri
d
resultData
:(
NSDictionary
*
)
resultData
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
]){
if
(
_handlers
[
key
]){
FLBPageResultHandler
handler
=
_handlers
[
key
];
FLBPageResultHandler
handler
=
_handlers
[
key
];
handler
(
key
,
resultData
);
handler
(
key
,
resultData
);
[
_handlers
removeObjectForKey
:
key
];
[
_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 @
6997cfe8
...
@@ -42,7 +42,17 @@ typedef FLBFlutterViewContainer * (^FLBPageBuilder)(NSString *name,NSDictionary
...
@@ -42,7 +42,17 @@ typedef FLBFlutterViewContainer * (^FLBPageBuilder)(NSString *name,NSDictionary
-
(
FlutterViewController
*
)
currentViewController
;
-
(
FlutterViewController
*
)
currentViewController
;
#pragma mark - handing vc result.
#pragma mark - handing vc result.
-
(
void
)
onResultForKey
:(
NSString
*
)
vcId
resultData
:(
NSDictionary
*
)
resultData
;
-
(
void
)
openPage
:(
NSString
*
)
name
-
(
void
)
setResultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
handler
forKey
:(
NSString
*
)
vcid
;
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
;
-
(
void
)
removeHandlerForKey
:(
NSString
*
)
vcid
;
@end
@end
ios/Classes/Boost/FlutterBoostPlugin.m
View file @
6997cfe8
...
@@ -86,9 +86,21 @@
...
@@ -86,9 +86,21 @@
return
[[
FLBFlutterApplication
sharedApplication
]
flutterViewController
];
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
-
(
void
)
setResultHandler
:(
void
(
^
)(
NSString
*
,
NSDictionary
*
))
handler
forKey
:(
NSString
*
)
vcid
...
...
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_onFlutterPageResult.mm
View file @
6997cfe8
...
@@ -34,7 +34,8 @@
...
@@ -34,7 +34,8 @@
{
{
//Add your handler code here!
//Add your handler code here!
[
FlutterBoostPlugin
.
sharedInstance
onResultForKey
:
key
[
FlutterBoostPlugin
.
sharedInstance
onResultForKey
:
key
resultData:
resultData
];
resultData:
resultData
params:
params
];
}
}
#pragma mark - Do not edit these method.
#pragma mark - Do not edit these method.
...
...
ios/Classes/Messaging/Generated/NavigationService/handlers/NavigationService_openPage.mm
View file @
6997cfe8
...
@@ -34,21 +34,6 @@
...
@@ -34,21 +34,6 @@
-
(
void
)
onCall
:(
void
(
^
)(
BOOL
))
result
pageName
:(
NSString
*
)
pageName
params
:(
NSDictionary
*
)
params
animated
:(
NSNumber
*
)
animated
-
(
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
[[
FLBFlutterApplication
sharedApplication
].
platform
openPage
:
pageName
params:
params
params:
params
animated:
animated
.
boolValue
animated:
animated
.
boolValue
...
@@ -57,16 +42,6 @@
...
@@ -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.
#pragma mark - Do not edit these method.
-
(
void
)
__flutter_p_handler_openPage
:(
NSDictionary
*
)
args
result
:(
void
(
^
)(
BOOL
))
result
{
-
(
void
)
__flutter_p_handler_openPage
:(
NSDictionary
*
)
args
result
:(
void
(
^
)(
BOOL
))
result
{
[
self
onCall
:
result
pageName
:
args
[
@"pageName"
]
params
:
args
[
@"params"
]
animated
:
args
[
@"animated"
]];
[
self
onCall
:
result
pageName
:
args
[
@"pageName"
]
params
:
args
[
@"params"
]
animated
:
args
[
@"animated"
]];
...
...
lib/AIOService/NavigationService/handlers/NavigationService_onNativePageResult.dart
View file @
6997cfe8
...
@@ -51,6 +51,6 @@ class NavigationService_onNativePageResult extends ServiceCallHandler {
...
@@ -51,6 +51,6 @@ class NavigationService_onNativePageResult extends ServiceCallHandler {
//==============================================Do not edit code above!
//==============================================Do not edit code above!
Future
<
bool
>
onCall
(
String
uniqueId
,
String
key
,
Map
resultData
,
Map
params
)
async
{
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 @
6997cfe8
...
@@ -51,11 +51,12 @@ class FlutterBoost {
...
@@ -51,11 +51,12 @@ class FlutterBoost {
final
GlobalKey
<
ContainerManagerState
>
containerManagerKey
=
final
GlobalKey
<
ContainerManagerState
>
containerManagerKey
=
GlobalKey
<
ContainerManagerState
>();
GlobalKey
<
ContainerManagerState
>();
final
Router
_router
=
Router
();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
PageResultMediator
_resultMediator
=
PageResultMediator
();
final
PageResultMediator
_resultMediator
=
PageResultMediator
();
final
Router
_router
=
Router
();
FlutterBoost
()
{
FlutterBoost
()
{
_router
.
resultMediator
=
_resultMediator
;
ServiceLoader
.
load
();
ServiceLoader
.
load
();
}
}
...
@@ -140,10 +141,16 @@ class FlutterBoost {
...
@@ -140,10 +141,16 @@ class FlutterBoost {
}
}
}
}
bool
onPageResult
(
String
key
,
Map
<
String
,
dynamic
>
resultData
)
{
containerManager
?.
containerStateOf
(
key
)?.
performOnResult
(
resultData
);
bool
onPageResult
(
String
key
,
Map
resultData
,
Map
params
)
{
_resultMediator
.
onPageResult
(
key
,
resultData
);
if
(
_resultMediator
.
isResultId
(
key
)){
_resultMediator
.
onPageResult
(
key
,
resultData
,
params
);
}
else
{
containerManager
?.
containerStateOf
(
key
)?.
performOnResult
(
resultData
);
}
return
true
;
return
true
;
}
}
VoidCallback
setPageResultHandler
(
String
key
,
PageResultHandler
handler
)
{
VoidCallback
setPageResultHandler
(
String
key
,
PageResultHandler
handler
)
{
...
...
lib/messaging/page_result_mediator.dart
View file @
6997cfe8
...
@@ -22,14 +22,27 @@
...
@@ -22,14 +22,27 @@
* THE SOFTWARE.
* THE SOFTWARE.
*/
*/
import
'package:flutter_boost/support/logger.dart'
;
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
void
PageResultHandler
(
String
key
,
Map
<
dynamic
,
dynamic
>
result
);
typedef
VoidCallback
=
void
Function
();
typedef
VoidCallback
=
void
Function
();
class
PageResultMediator
{
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
();
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
;
if
(
key
==
null
)
return
;
...
@@ -38,6 +51,22 @@ class PageResultMediator{
...
@@ -38,6 +51,22 @@ class PageResultMediator{
if
(
_handlers
.
containsKey
(
key
)){
if
(
_handlers
.
containsKey
(
key
)){
_handlers
[
key
](
key
,
resultData
);
_handlers
[
key
](
key
,
resultData
);
_handlers
.
remove
(
key
);
_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 @
6997cfe8
...
@@ -31,6 +31,8 @@ import 'package:flutter_boost/support/logger.dart';
...
@@ -31,6 +31,8 @@ import 'package:flutter_boost/support/logger.dart';
class
Router
{
class
Router
{
MessageProxy
_msgProxy
=
MessageProxyImp
();
MessageProxy
_msgProxy
=
MessageProxyImp
();
PageResultMediator
resultMediator
=
null
;
void
setMessageProxy
(
MessageProxy
prx
)
{
void
setMessageProxy
(
MessageProxy
prx
)
{
if
(
prx
!=
null
)
{
if
(
prx
!=
null
)
{
...
@@ -38,11 +40,13 @@ class Router {
...
@@ -38,11 +40,13 @@ class Router {
}
}
}
}
Future
<
bool
>
openPage
(
String
url
,
Map
params
,
Future
<
bool
>
openPage
(
String
url
,
Map
params
,
{
bool
animated
=
true
,
PageResultHandler
resultHandler
})
{
{
bool
animated
=
true
,
PageResultHandler
resultHandler
})
{
if
(
resultHandler
!=
null
)
{
if
(
resultHandler
!=
null
)
{
params
[
"needResult"
]
=
true
;
String
rid
=
resultMediator
.
createResultId
();
FlutterBoost
.
singleton
.
setPageResultHandler
(
url
,
params
[
"result_id"
]
=
rid
;
FlutterBoost
.
singleton
.
setPageResultHandler
(
rid
,
(
String
key
,
Map
<
dynamic
,
dynamic
>
result
)
{
(
String
key
,
Map
<
dynamic
,
dynamic
>
result
)
{
Logger
.
log
(
"Recieved result
$result
for from page key
$key
"
);
Logger
.
log
(
"Recieved result
$result
for from page key
$key
"
);
if
(
resultHandler
!=
null
)
{
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