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
bf030eb4
Commit
bf030eb4
authored
Sep 11, 2020
by
justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加willPush 方法
parent
c5849a24
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
4 deletions
+35
-4
example/lib/main.dart
example/lib/main.dart
+16
-1
lib/container/boost_container.dart
lib/container/boost_container.dart
+12
-0
lib/flutter_boost.dart
lib/flutter_boost.dart
+7
-3
No files found.
example/lib/main.dart
View file @
bf030eb4
...
@@ -37,6 +37,12 @@ class _MyAppState extends State<MyApp> {
...
@@ -37,6 +37,12 @@ class _MyAppState extends State<MyApp> {
'f2f_second'
:
(
pageName
,
params
,
_
)
=>
F2FSecondPage
(),
'f2f_second'
:
(
pageName
,
params
,
_
)
=>
F2FSecondPage
(),
});
});
FlutterBoost
.
singleton
.
addBoostNavigatorObserver
(
TestBoostNavigatorObserver
());
FlutterBoost
.
singleton
.
addBoostNavigatorObserver
(
TestBoostNavigatorObserver
());
FlutterBoost
.
singleton
.
addContainerObserver
((
ContainerOperation
operation
,
BoostContainerSettings
settings
){
operation
;
settings
;
});
FlutterBoostAPI
.
singleton
.
routeSettingsBuilder
=
(
String
url
,
FlutterBoostAPI
.
singleton
.
routeSettingsBuilder
=
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
=>
BoostRouteSettings
(
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
=>
BoostRouteSettings
(
uniqueId:
'
${url}
_
${DateTime.now().millisecondsSinceEpoch}
'
,
uniqueId:
'
${url}
_
${DateTime.now().millisecondsSinceEpoch}
'
,
...
@@ -59,9 +65,13 @@ class _MyAppState extends State<MyApp> {
...
@@ -59,9 +65,13 @@ class _MyAppState extends State<MyApp> {
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
_
)
{
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
_
)
{
}
}
}
}
class
TestBoostNavigatorObserver
extends
NavigatorObserver
{
class
TestBoostNavigatorObserver
extends
ContainerNavigatorObserver
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
route
.
settings
.
name
!=
"/"
;
//1. 底下
//新页面已经push完成
print
(
"flutterboost#didPush"
);
print
(
"flutterboost#didPush"
);
}
}
...
@@ -76,5 +86,10 @@ class TestBoostNavigatorObserver extends NavigatorObserver{
...
@@ -76,5 +86,10 @@ class TestBoostNavigatorObserver extends NavigatorObserver{
void
didReplace
({
Route
<
dynamic
>
newRoute
,
Route
<
dynamic
>
oldRoute
})
{
void
didReplace
({
Route
<
dynamic
>
newRoute
,
Route
<
dynamic
>
oldRoute
})
{
print
(
"flutterboost#didReplace"
);
print
(
"flutterboost#didReplace"
);
}
}
void
willPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
print
(
"flutterboost#willPush"
);
}
}
}
lib/container/boost_container.dart
View file @
bf030eb4
...
@@ -227,6 +227,10 @@ class BoostContainerState extends NavigatorState {
...
@@ -227,6 +227,10 @@ class BoostContainerState extends NavigatorState {
.
prePushRoute
(
name
,
uniqueId
,
params
,
route
);
.
prePushRoute
(
name
,
uniqueId
,
params
,
route
);
}
}
if
(
multipleRouteMode
)
{
ContainerNavigatorObserver
.
bindContainerManager
().
willPush
(
route
,
routerHistory
.
last
);
}
Future
<
T
>
future
=
super
.
push
<
T
>(
newRoute
??
route
);
Future
<
T
>
future
=
super
.
push
<
T
>(
newRoute
??
route
);
routerHistory
.
add
(
route
);
routerHistory
.
add
(
route
);
...
@@ -289,6 +293,14 @@ class ContainerNavigatorObserver extends NavigatorObserver {
...
@@ -289,6 +293,14 @@ class ContainerNavigatorObserver extends NavigatorObserver {
boostObservers
.
remove
(
observer
);
boostObservers
.
remove
(
observer
);
}
}
void
willPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
for
(
NavigatorObserver
observer
in
boostObservers
)
{
if
(
observer
is
ContainerNavigatorObserver
){
ContainerNavigatorObserver
containerNavigatorObserver
=
observer
as
ContainerNavigatorObserver
;
containerNavigatorObserver
.
willPush
(
route
,
previousRoute
);
}
}
}
@override
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
for
(
NavigatorObserver
observer
in
boostObservers
)
{
for
(
NavigatorObserver
observer
in
boostObservers
)
{
...
...
lib/flutter_boost.dart
View file @
bf030eb4
...
@@ -77,7 +77,8 @@ class FlutterBoost {
...
@@ -77,7 +77,8 @@ class FlutterBoost {
pageInfo
[
"name"
],
pageInfo
[
"params"
],
pageInfo
[
"uniqueId"
]);
pageInfo
[
"name"
],
pageInfo
[
"params"
],
pageInfo
[
"uniqueId"
]);
}
}
});
});
});
}
);
}
}
static
TransitionBuilder
init
({
TransitionBuilder
builder
,
static
TransitionBuilder
init
({
TransitionBuilder
builder
,
...
@@ -167,7 +168,7 @@ class FlutterBoost {
...
@@ -167,7 +168,7 @@ class FlutterBoost {
final
Route
<
Map
<
dynamic
,
dynamic
>>
route
=
routeBuilder
!=
null
final
Route
<
Map
<
dynamic
,
dynamic
>>
route
=
routeBuilder
!=
null
?
routeBuilder
(
page
)
?
routeBuilder
(
page
)
:
defaultRoute
(
page
);
:
defaultRoute
(
page
,
routeSettings
);
FlutterBoost
.
containerManager
?.
onstageContainer
?.
multipleRouteMode
=
true
;
FlutterBoost
.
containerManager
?.
onstageContainer
?.
multipleRouteMode
=
true
;
...
@@ -176,14 +177,17 @@ class FlutterBoost {
...
@@ -176,14 +177,17 @@ class FlutterBoost {
}
}
Route
<
Map
<
dynamic
,
dynamic
>>
defaultRoute
(
Widget
page
)
{
Route
<
Map
<
dynamic
,
dynamic
>>
defaultRoute
(
Widget
page
,
BoostRouteSettings
settings
)
{
RouteSettings
routeSettings
=
new
RouteSettings
(
name:
settings
.
name
,
arguments:
settings
.
params
);
if
(
Platform
.
isIOS
)
{
if
(
Platform
.
isIOS
)
{
return
CupertinoPageRoute
<
Map
<
dynamic
,
dynamic
>>
(
return
CupertinoPageRoute
<
Map
<
dynamic
,
dynamic
>>
(
settings:
routeSettings
,
builder:
(
BuildContext
context
)
=>
page
builder:
(
BuildContext
context
)
=>
page
);
);
}
}
return
PageRouteBuilder
(
return
PageRouteBuilder
(
transitionDuration:
Duration
(
milliseconds:
300
),
transitionDuration:
Duration
(
milliseconds:
300
),
settings:
routeSettings
,
pageBuilder:
(
context
,
animation
,
secondaryAnimation
)
=>
page
,
pageBuilder:
(
context
,
animation
,
secondaryAnimation
)
=>
page
,
transitionsBuilder:
(
context
,
animation
,
secondaryAnimation
,
child
)
{
transitionsBuilder:
(
context
,
animation
,
secondaryAnimation
,
child
)
{
var
offsetAnimation
=
Tween
<
Offset
>(
var
offsetAnimation
=
Tween
<
Offset
>(
...
...
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