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
e26ead11
Commit
e26ead11
authored
Sep 08, 2020
by
justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增openInCurrentContainer 接口
parent
accf615f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
15 deletions
+56
-15
example/lib/flutter_to_flutter_sample.dart
example/lib/flutter_to_flutter_sample.dart
+1
-1
lib/container/container_coordinator.dart
lib/container/container_coordinator.dart
+5
-0
lib/flutter_boost.dart
lib/flutter_boost.dart
+50
-14
No files found.
example/lib/flutter_to_flutter_sample.dart
View file @
e26ead11
...
@@ -31,7 +31,7 @@ class F2FFirstPageState extends State<F2FFirstPage>{
...
@@ -31,7 +31,7 @@ class F2FFirstPageState extends State<F2FFirstPage>{
RaisedButton
(
RaisedButton
(
child:
Text
(
'Open second without native container'
),
child:
Text
(
'Open second without native container'
),
onPressed:
()
{
onPressed:
()
{
FlutterBoost
API
.
singleton
.
open
(
"f2f_second"
,
noNeedNativeContainer:
true
);
FlutterBoost
.
singleton
.
openInCurrentContainer
(
"f2f_second"
);
},
},
),
),
],
],
...
...
lib/container/container_coordinator.dart
View file @
e26ead11
...
@@ -73,6 +73,11 @@ class ContainerCoordinator {
...
@@ -73,6 +73,11 @@ class ContainerCoordinator {
return
routeSettings
;
return
routeSettings
;
}
}
bool
isFlutterPageUrl
(
String
url
){
return
_pageBuilders
.
containsKey
(
url
);
}
Widget
createPage
(
String
name
,
Map
params
,
String
pageId
)
{
Widget
createPage
(
String
name
,
Map
params
,
String
pageId
)
{
Widget
page
;
Widget
page
;
...
...
lib/flutter_boost.dart
View file @
e26ead11
...
@@ -39,16 +39,18 @@ export 'flutter_boost_api.dart';
...
@@ -39,16 +39,18 @@ export 'flutter_boost_api.dart';
typedef
Widget
PageBuilder
(
String
pageName
,
Map
params
,
String
uniqueId
);
typedef
Widget
PageBuilder
(
String
pageName
,
Map
params
,
String
uniqueId
);
typedef
Route
PrePushRoute
(
typedef
Route
PrePushRoute
(
String
url
,
String
uniqueId
,
Map
params
,
String
url
,
String
uniqueId
,
Map
params
,
Route
route
);
Route
route
);
typedef
void
PostPushRoute
(
typedef
void
PostPushRoute
(
String
url
,
String
uniqueId
,
Map
params
,
Route
route
,
String
url
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
result
);
Future
result
);
typedef
Route
FlutterBoostRouteBuilder
(
Widget
widget
);
class
FlutterBoost
{
class
FlutterBoost
{
static
final
FlutterBoost
_instance
=
FlutterBoost
();
static
final
FlutterBoost
_instance
=
FlutterBoost
();
final
GlobalKey
<
ContainerManagerState
>
containerManagerKey
=
final
GlobalKey
<
ContainerManagerState
>
containerManagerKey
=
GlobalKey
<
ContainerManagerState
>();
GlobalKey
<
ContainerManagerState
>();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
BoostChannel
_boostChannel
=
BoostChannel
();
final
BoostChannel
_boostChannel
=
BoostChannel
();
...
@@ -72,15 +74,14 @@ class FlutterBoost {
...
@@ -72,15 +74,14 @@ class FlutterBoost {
});
});
}
}
static
TransitionBuilder
init
(
static
TransitionBuilder
init
({
TransitionBuilder
builder
,
{
TransitionBuilder
builder
,
PrePushRoute
prePush
,
PrePushRoute
prePush
,
PostPushRoute
postPush
})
{
PostPushRoute
postPush
})
{
if
(
Platform
.
isAndroid
)
{
if
(
Platform
.
isAndroid
)
{
onPageStart
();
onPageStart
();
}
else
if
(
Platform
.
isIOS
)
{
}
else
if
(
Platform
.
isIOS
)
{
assert
(()
{
assert
(()
{
()
async
{
()
async
{
onPageStart
();
onPageStart
();
}();
}();
return
true
;
return
true
;
...
@@ -124,16 +125,51 @@ class FlutterBoost {
...
@@ -124,16 +125,51 @@ class FlutterBoost {
Future
<
Map
<
dynamic
,
dynamic
>>
open
(
String
url
,
Future
<
Map
<
dynamic
,
dynamic
>>
open
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
{
Map
<
String
,
dynamic
>
exts
})
{
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
properties
[
"url"
]
=
url
;
properties
[
"url"
]
=
url
;
properties
[
"urlParams"
]
=
urlParams
;
properties
[
"urlParams"
]
=
urlParams
;
properties
[
"exts"
]
=
exts
;
properties
[
"exts"
]
=
exts
;
//TODO 判断是不是需要跳Flutter,有没有前置拦截逻辑,如果都没有,就找到Navigator去把页面推进去
return
channel
.
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
'openPage'
,
properties
);
}
/**
*
* when flutter page->flutter page,do not open the new Activity Container
*
**/
Future
<
Map
<
dynamic
,
dynamic
>>
openInCurrentContainer
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
,
FlutterBoostRouteBuilder
routeBuilder
})
{
return
channel
.
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
'openPage'
,
properties
);
if
(!
ContainerCoordinator
.
singleton
.
isFlutterPageUrl
(
url
)){
return
open
(
url
,
urlParams:
urlParams
,
exts:
exts
);
}
String
uniqueId
=
'
${url}
_
${DateTime.now().millisecondsSinceEpoch}
'
;
final
Widget
page
=
ContainerCoordinator
.
singleton
.
createPage
(
url
,
urlParams
,
uniqueId
);
final
Route
<
Map
<
dynamic
,
dynamic
>>
route
=
routeBuilder
!=
null
?
routeBuilder
(
page
)
:
PageRouteBuilder
<
Map
<
dynamic
,
dynamic
>>(
pageBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
,)
=>
page
);
return
FlutterBoost
.
containerManager
?.
onstageContainer
?.
push
(
route
);
}
/**
* close flutter page but not close container
*/
bool
closeInCurrentContainer
<
T
extends
Object
>([
T
result
])
{
return
FlutterBoost
.
containerManager
?.
onstageContainer
?.
pop
(
result
);
}
}
Future
<
bool
>
close
(
String
id
,
Future
<
bool
>
close
(
String
id
,
...
@@ -197,7 +233,7 @@ class FlutterBoost {
...
@@ -197,7 +233,7 @@ class FlutterBoost {
///register for Container lifecycle callbacks
///register for Container lifecycle callbacks
VoidCallback
addBoostContainerLifeCycleObserver
(
VoidCallback
addBoostContainerLifeCycleObserver
(
BoostContainerLifeCycleObserver
observer
)
=>
BoostContainerLifeCycleObserver
observer
)
=>
_observersHolder
.
addObserver
<
BoostContainerLifeCycleObserver
>(
observer
);
_observersHolder
.
addObserver
<
BoostContainerLifeCycleObserver
>(
observer
);
///register callbacks for Navigators push & pop
///register callbacks for Navigators push & pop
...
...
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