Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e857bc6f
Commit
e857bc6f
authored
Dec 08, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #806 from abarth/use_route_state
_ModalScope has local copies of route state
parents
2a69a981
f202e7ab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
39 deletions
+17
-39
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+17
-39
No files found.
packages/flutter/lib/src/widgets/routes.dart
View file @
e857bc6f
...
...
@@ -258,45 +258,35 @@ abstract class LocalHistoryRoute<T> extends Route<T> {
class
_ModalScopeStatus
extends
InheritedWidget
{
_ModalScopeStatus
({
Key
key
,
this
.
c
urrent
,
this
.
isC
urrent
,
this
.
route
,
Widget
child
})
:
super
(
key:
key
,
child:
child
)
{
assert
(
c
urrent
!=
null
);
assert
(
isC
urrent
!=
null
);
assert
(
route
!=
null
);
assert
(
child
!=
null
);
}
final
bool
c
urrent
;
final
bool
isC
urrent
;
final
Route
route
;
bool
updateShouldNotify
(
_ModalScopeStatus
old
)
{
return
current
!=
old
.
c
urrent
||
return
isCurrent
!=
old
.
isC
urrent
||
route
!=
old
.
route
;
}
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
description
.
add
(
'
${
c
urrent ? "active" : "inactive"}
'
);
description
.
add
(
'
${
isC
urrent ? "active" : "inactive"}
'
);
}
}
class
_ModalScope
extends
StatefulComponent
{
_ModalScope
({
Key
key
,
this
.
subtreeKey
,
this
.
storageBucket
,
this
.
performance
,
this
.
forwardPerformance
,
this
.
current
,
this
.
route
})
:
super
(
key:
key
);
final
GlobalKey
subtreeKey
;
final
PageStorageBucket
storageBucket
;
final
PerformanceView
performance
;
final
PerformanceView
forwardPerformance
;
final
bool
current
;
final
ModalRoute
route
;
_ModalScopeState
createState
()
=>
new
_ModalScopeState
();
...
...
@@ -305,24 +295,17 @@ class _ModalScope extends StatefulComponent {
class
_ModalScopeState
extends
State
<
_ModalScope
>
{
void
initState
()
{
super
.
initState
();
config
.
performance
?.
addStatusListener
(
_performanceStatusChanged
);
config
.
forwardPerformance
?.
addStatusListener
(
_performanceStatusChanged
);
config
.
route
.
performance
?.
addStatusListener
(
_performanceStatusChanged
);
config
.
route
.
forwardPerformance
?.
addStatusListener
(
_performanceStatusChanged
);
}
void
didUpdateConfig
(
_ModalScope
oldConfig
)
{
if
(
config
.
performance
!=
oldConfig
.
performance
)
{
oldConfig
.
performance
?.
removeStatusListener
(
_performanceStatusChanged
);
config
.
performance
?.
addStatusListener
(
_performanceStatusChanged
);
}
if
(
config
.
forwardPerformance
!=
oldConfig
.
forwardPerformance
)
{
oldConfig
.
forwardPerformance
?.
removeStatusListener
(
_performanceStatusChanged
);
config
.
forwardPerformance
?.
addStatusListener
(
_performanceStatusChanged
);
}
assert
(
config
.
route
==
oldConfig
.
route
);
}
void
dispose
()
{
config
.
performance
?.
removeStatusListener
(
_performanceStatusChanged
);
config
.
forwardPerformance
?.
removeStatusListener
(
_performanceStatusChanged
);
config
.
route
.
performance
?.
removeStatusListener
(
_performanceStatusChanged
);
config
.
route
.
forwardPerformance
?.
removeStatusListener
(
_performanceStatusChanged
);
super
.
dispose
();
}
...
...
@@ -334,12 +317,12 @@ class _ModalScopeState extends State<_ModalScope> {
Widget
build
(
BuildContext
context
)
{
Widget
contents
=
new
PageStorage
(
key:
config
.
subtreeKey
,
bucket:
config
.
storageBucket
,
key:
config
.
route
.
_
subtreeKey
,
bucket:
config
.
route
.
_
storageBucket
,
child:
new
_ModalScopeStatus
(
current:
config
.
current
,
route:
config
.
route
,
child:
config
.
route
.
buildPage
(
context
,
config
.
performance
,
config
.
forwardPerformance
)
isCurrent:
config
.
route
.
isCurrent
,
child:
config
.
route
.
buildPage
(
context
,
config
.
route
.
performance
,
config
.
route
.
forwardPerformance
)
)
);
if
(
config
.
route
.
offstage
)
{
...
...
@@ -348,11 +331,11 @@ class _ModalScopeState extends State<_ModalScope> {
contents
=
new
Focus
(
key:
new
GlobalObjectKey
(
config
.
route
),
child:
new
IgnorePointer
(
ignoring:
config
.
performance
?.
status
==
PerformanceStatus
.
reverse
,
ignoring:
config
.
route
.
performance
?.
status
==
PerformanceStatus
.
reverse
,
child:
config
.
route
.
buildTransitions
(
context
,
config
.
performance
,
config
.
forwardPerformance
,
config
.
route
.
performance
,
config
.
route
.
forwardPerformance
,
contents
)
)
...
...
@@ -457,11 +440,6 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
Widget
_buildModalScope
(
BuildContext
context
)
{
return
new
_ModalScope
(
key:
_scopeKey
,
subtreeKey:
_subtreeKey
,
storageBucket:
_storageBucket
,
performance:
performance
,
forwardPerformance:
forwardPerformance
,
current:
isCurrent
,
route:
this
// calls buildTransitions() and buildPage(), defined above
);
...
...
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