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
1211dd23
Commit
1211dd23
authored
Nov 22, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #539 from Hixie/clean-up-modal
Clean up the term "modal" in the navigator
parents
377c74f7
c51260ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
24 deletions
+23
-24
hero_controller.dart
packages/flutter/lib/src/widgets/hero_controller.dart
+2
-2
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+21
-22
No files found.
packages/flutter/lib/src/widgets/hero_controller.dart
View file @
1211dd23
...
...
@@ -24,7 +24,7 @@ class HeroController extends NavigatorObserver {
final
List
<
OverlayEntry
>
_overlayEntries
=
new
List
<
OverlayEntry
>();
void
didPush
Modal
(
Route
route
,
Route
previousRoute
)
{
void
didPush
(
Route
route
,
Route
previousRoute
)
{
assert
(
navigator
!=
null
);
assert
(
route
!=
null
);
if
(
route
is
ModalRoute
)
{
// as opposed to StateRoute, say
...
...
@@ -37,7 +37,7 @@ class HeroController extends NavigatorObserver {
}
}
void
didPop
Modal
(
Route
route
,
Route
previousRoute
)
{
void
didPop
(
Route
route
,
Route
previousRoute
)
{
assert
(
navigator
!=
null
);
assert
(
route
!=
null
);
if
(
route
is
ModalRoute
)
{
// as opposed to StateRoute, say
...
...
packages/flutter/lib/src/widgets/navigator.dart
View file @
1211dd23
...
...
@@ -13,13 +13,13 @@ abstract class Route<T> {
/// The given route has been pushed onto the navigator after this route.
/// Return true if the route before this one should be notified also. The
/// first route to return false will be the one passed to the
/// NavigatorObserver's didPush
Modal
() as the previousRoute.
/// NavigatorObserver's didPush() as the previousRoute.
bool
willPushNext
(
Route
nextRoute
)
=>
false
;
/// The given route, which came after this one, has been popped off the
/// navigator. Return true if the route before this one should be notified
/// also. The first route to return false will be the one passed to the
/// NavigatorObserver's didPush
Modal
() as the previousRoute.
/// NavigatorObserver's didPush() as the previousRoute.
bool
didPopNext
(
Route
nextRoute
)
=>
false
;
}
...
...
@@ -34,8 +34,8 @@ typedef Route RouteFactory(NamedRouteSettings settings);
class
NavigatorObserver
{
NavigatorState
_navigator
;
NavigatorState
get
navigator
=>
_navigator
;
void
didPush
Modal
(
Route
route
,
Route
previousRoute
)
{
}
void
didPop
Modal
(
Route
route
,
Route
previousRoute
)
{
}
void
didPush
(
Route
route
,
Route
previousRoute
)
{
}
void
didPop
(
Route
route
,
Route
previousRoute
)
{
}
}
class
Navigator
extends
StatefulComponent
{
...
...
@@ -61,8 +61,7 @@ class Navigator extends StatefulComponent {
class
NavigatorState
extends
State
<
Navigator
>
{
final
GlobalKey
<
OverlayState
>
_overlayKey
=
new
GlobalKey
<
OverlayState
>();
// TODO(ianh): Rename _modal to _history or some such
final
List
<
Route
>
_modal
=
new
List
<
Route
>();
final
List
<
Route
>
_history
=
new
List
<
Route
>();
void
initState
()
{
super
.
initState
();
...
...
@@ -84,11 +83,11 @@ class NavigatorState extends State<Navigator> {
super
.
dispose
();
}
bool
get
hasPreviousRoute
=>
_
modal
.
length
>
1
;
bool
get
hasPreviousRoute
=>
_
history
.
length
>
1
;
OverlayState
get
overlay
=>
_overlayKey
.
currentState
;
OverlayEntry
get
_currentOverlay
{
for
(
Route
route
in
_
modal
.
reversed
)
{
for
(
Route
route
in
_
history
.
reversed
)
{
if
(
route
.
overlayEntries
.
isNotEmpty
)
return
route
.
overlayEntries
.
last
;
}
...
...
@@ -106,12 +105,12 @@ class NavigatorState extends State<Navigator> {
void
push
(
Route
route
,
{
Set
<
Key
>
mostValuableKeys
})
{
setState
(()
{
int
index
=
_
modal
.
length
-
1
;
while
(
index
>=
0
&&
_
modal
[
index
].
willPushNext
(
route
))
int
index
=
_
history
.
length
-
1
;
while
(
index
>=
0
&&
_
history
[
index
].
willPushNext
(
route
))
index
-=
1
;
route
.
didPush
(
overlay
,
_currentOverlay
);
config
.
observer
?.
didPush
Modal
(
route
,
index
>=
0
?
_modal
[
index
]
:
null
);
_
modal
.
add
(
route
);
config
.
observer
?.
didPush
(
route
,
index
>=
0
?
_history
[
index
]
:
null
);
_
history
.
add
(
route
);
});
}
...
...
@@ -126,13 +125,13 @@ class NavigatorState extends State<Navigator> {
/// The type of the result argument, if provided, must match the type argument
/// of the class of the given route. (In practice, this is usually "dynamic".)
void
remove
(
Route
route
,
[
dynamic
result
])
{
assert
(
_
modal
.
contains
(
route
));
assert
(
_
history
.
contains
(
route
));
assert
(
route
.
overlayEntries
.
isEmpty
);
if
(
_
modal
.
last
==
route
)
{
if
(
_
history
.
last
==
route
)
{
pop
(
result
);
}
else
{
setState
(()
{
_
modal
.
remove
(
route
);
_
history
.
remove
(
route
);
route
.
didPop
(
result
);
});
}
...
...
@@ -149,21 +148,21 @@ class NavigatorState extends State<Navigator> {
// We use setState to guarantee that we'll rebuild, since the routes can't
// do that for themselves, even if they have changed their own state (e.g.
// ModalScope.isCurrent).
assert
(
_
modal
.
length
>
1
);
Route
route
=
_
modal
.
removeLast
();
assert
(
_
history
.
length
>
1
);
Route
route
=
_
history
.
removeLast
();
route
.
didPop
(
result
);
int
index
=
_
modal
.
length
-
1
;
while
(
index
>=
0
&&
_
modal
[
index
].
didPopNext
(
route
))
int
index
=
_
history
.
length
-
1
;
while
(
index
>=
0
&&
_
history
[
index
].
didPopNext
(
route
))
index
-=
1
;
config
.
observer
?.
didPop
Modal
(
route
,
index
>=
0
?
_modal
[
index
]
:
null
);
config
.
observer
?.
didPop
(
route
,
index
>=
0
?
_history
[
index
]
:
null
);
});
}
Widget
build
(
BuildContext
context
)
{
assert
(
_
modal
.
isNotEmpty
);
assert
(
_
history
.
isNotEmpty
);
return
new
Overlay
(
key:
_overlayKey
,
initialEntries:
_
modal
.
first
.
overlayEntries
initialEntries:
_
history
.
first
.
overlayEntries
);
}
}
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