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
1
Merge Requests
1
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
14e0a099
Commit
14e0a099
authored
Sep 15, 2020
by
ColdPaleLight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add GlobalRouteSettingsManager
parent
bf030eb4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
23 deletions
+66
-23
lib/container/boost_container.dart
lib/container/boost_container.dart
+38
-2
lib/flutter_boost.dart
lib/flutter_boost.dart
+28
-21
No files found.
lib/container/boost_container.dart
View file @
14e0a099
...
...
@@ -135,7 +135,7 @@ class BoostContainerState extends NavigatorState {
@override
BoostContainer
get
widget
=>
super
.
widget
as
BoostContainer
;
final
List
<
Route
<
dynamic
>>
routerHistory
=
<
Route
<
dynamic
>>[];
List
<
Route
<
dynamic
>>
routerHistory
=
<
Route
<
dynamic
>>[];
bool
multipleRouteMode
=
false
;
...
...
@@ -163,7 +163,12 @@ class BoostContainerState extends NavigatorState {
@override
void
dispose
()
{
for
(
Route
route
in
routerHistory
)
{
GlobalRouteSettingsManager
.
instance
.
removeSettings
(
route
);
}
routerHistory
.
clear
();
super
.
dispose
();
}
...
...
@@ -173,6 +178,8 @@ class BoostContainerState extends NavigatorState {
backPressedHandler
?.
call
();
}
Route
get
topRoute
=>
routerHistory
.
isNotEmpty
?
routerHistory
.
last
:
null
;
@override
Future
<
bool
>
maybePop
<
T
extends
Object
>([
T
result
])
async
{
final
Route
<
T
>
route
=
routerHistory
.
last
;
...
...
@@ -197,12 +204,16 @@ class BoostContainerState extends NavigatorState {
@override
bool
pop
<
T
extends
Object
>([
T
result
])
{
Route
removedRoute
;
if
(
routerHistory
.
length
>
1
)
{
routerHistory
.
removeLast
();
r
emovedRoute
=
r
outerHistory
.
removeLast
();
}
if
(
canPop
())
{
super
.
pop
<
T
>(
result
);
if
(
removedRoute
!=
null
)
{
GlobalRouteSettingsManager
.
instance
.
removeSettings
(
removedRoute
);
}
if
(
Platform
.
isIOS
&&
multipleRouteMode
&&
!
canPop
())
{
FlutterBoost
.
singleton
.
channel
.
invokeMethod
<
dynamic
>(
'enablePopGesture'
,
null
);
...
...
@@ -329,3 +340,28 @@ class ContainerNavigatorObserver extends NavigatorObserver {
}
}
}
class
GlobalRouteSettingsManager
{
GlobalRouteSettingsManager
.
_
();
static
GlobalRouteSettingsManager
instance
=
GlobalRouteSettingsManager
.
_
();
final
Map
<
Route
,
BoostRouteSettings
>
_routeSettingsMap
=
<
Route
,
BoostRouteSettings
>{};
void
addSettings
(
Route
route
,
BoostRouteSettings
settings
)
{
_routeSettingsMap
[
route
]
=
settings
;
}
void
removeSettings
(
Route
route
)
{
_routeSettingsMap
.
remove
(
route
);
}
BoostRouteSettings
getSettings
(
Route
route
)
{
return
_routeSettingsMap
[
route
];
}
bool
contains
(
Route
route
)
{
return
_routeSettingsMap
[
route
]
!=
null
;
}
}
lib/flutter_boost.dart
View file @
14e0a099
...
...
@@ -51,8 +51,6 @@ typedef void PostPushRoute(String url, String uniqueId, Map params, Route route,
typedef
Route
FlutterBoostRouteBuilder
(
Widget
widget
);
class
FlutterBoost
{
static
final
FlutterBoost
_instance
=
FlutterBoost
();
final
GlobalKey
<
ContainerManagerState
>
containerManagerKey
=
...
...
@@ -155,39 +153,40 @@ class FlutterBoost {
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
,
FlutterBoostRouteBuilder
routeBuilder
})
{
final
BoostRouteSettings
routeSettings
=
ContainerCoordinator
.
singleton
.
createRouteSettings
(
url
,
urlParams:
urlParams
,
exts:
exts
);
final
BoostRouteSettings
routeSettings
=
ContainerCoordinator
.
singleton
.
createRouteSettings
(
url
,
urlParams:
urlParams
,
exts:
exts
);
final
Widget
page
=
ContainerCoordinator
.
singleton
.
createPage
(
routeSettings
.
name
,
routeSettings
.
params
,
routeSettings
.
uniqueId
);
if
(
page
==
null
)
{
if
(
page
==
null
)
{
return
open
(
url
,
urlParams:
urlParams
,
exts:
exts
);
}
final
Route
<
Map
<
dynamic
,
dynamic
>>
route
=
routeBuilder
!=
null
?
routeBuilder
(
page
)
:
defaultRoute
(
page
,
routeSettings
);
:
defaultRoute
(
page
,
routeSettings
);
FlutterBoost
.
containerManager
?.
onstageContainer
?.
multipleRouteMode
=
true
;
GlobalRouteSettingsManager
.
instance
.
addSettings
(
route
,
routeSettings
)
;
FlutterBoost
.
containerManager
?.
onstageContainer
?.
multipleRouteMode
=
true
;
return
FlutterBoost
.
containerManager
?.
onstageContainer
?.
push
(
route
);
}
Route
<
Map
<
dynamic
,
dynamic
>>
defaultRoute
(
Widget
page
,
BoostRouteSettings
settings
)
{
RouteSettings
routeSettings
=
new
RouteSettings
(
name:
settings
.
name
,
arguments:
settings
.
params
);
Route
<
Map
<
dynamic
,
dynamic
>>
defaultRoute
(
Widget
page
,
BoostRouteSettings
settings
)
{
RouteSettings
routeSettings
=
new
RouteSettings
(
name:
settings
.
name
,
arguments:
settings
.
params
);
if
(
Platform
.
isIOS
)
{
return
CupertinoPageRoute
<
Map
<
dynamic
,
dynamic
>>
(
return
CupertinoPageRoute
<
Map
<
dynamic
,
dynamic
>>(
settings:
routeSettings
,
builder:
(
BuildContext
context
)
=>
page
);
}
return
PageRouteBuilder
(
transitionDuration:
Duration
(
milliseconds:
300
),
settings:
routeSettings
,
settings:
routeSettings
,
pageBuilder:
(
context
,
animation
,
secondaryAnimation
)
=>
page
,
transitionsBuilder:
(
context
,
animation
,
secondaryAnimation
,
child
)
{
var
offsetAnimation
=
Tween
<
Offset
>(
...
...
@@ -199,7 +198,6 @@ class FlutterBoost {
child:
child
,
);
});
}
/**
...
...
@@ -211,9 +209,9 @@ class FlutterBoost {
Future
<
bool
>
close
(
String
id
,
{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
})
{
//判断当前onStage的容器是不是通过openInCurrentContainer打开过界面
if
(
FlutterBoost
.
containerManager
?.
onstageContainer
?.
multipleRouteMode
??
false
)
{
if
(
FlutterBoost
.
containerManager
?.
onstageContainer
?.
multipleRouteMode
??
false
)
{
return
Future
.
value
(
closeInCurrentContainer
(
result
));
}
...
...
@@ -247,11 +245,8 @@ class FlutterBoost {
properties
[
"exts"
]
=
exts
;
}
return
channel
.
invokeMethod
<
bool
>(
'closePage'
,
properties
);
}
Future
<
bool
>
closeCurrent
(
{
Map
<
String
,
dynamic
>
result
,
Map
<
String
,
dynamic
>
exts
})
{
BoostContainerSettings
settings
=
containerManager
?.
onstageSettings
;
...
...
@@ -290,4 +285,16 @@ class FlutterBoost {
///register callbacks for Navigators push & pop
void
addBoostNavigatorObserver
(
NavigatorObserver
observer
)
=>
ContainerNavigatorObserver
.
boostObservers
.
add
(
observer
);
BoostRouteSettings
getBoostRouteSettings
(
Route
route
)
{
return
GlobalRouteSettingsManager
.
instance
.
getSettings
(
route
);
}
BoostRouteSettings
getCurrentBoostRouteSettings
()
{
Route
route
=
FlutterBoost
?.
containerManager
?.
onstageContainer
?.
topRoute
;
if
(
route
!=
null
)
{
return
GlobalRouteSettingsManager
.
instance
.
getSettings
(
route
);
}
return
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