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
e80756d6
Commit
e80756d6
authored
Dec 07, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #748 from abarth/inital_performance
The intial route shouldn't run its entrance animation
parents
0f4ef5a7
ba936c0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
23 deletions
+28
-23
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+13
-6
pages.dart
packages/flutter/lib/src/widgets/pages.dart
+9
-0
page_forward_transitions_test.dart
packages/unit/test/widget/page_forward_transitions_test.dart
+6
-17
No files found.
packages/flutter/lib/src/widgets/navigator.dart
View file @
e80756d6
...
@@ -68,9 +68,15 @@ abstract class Route<T> {
...
@@ -68,9 +68,15 @@ abstract class Route<T> {
}
}
class
NamedRouteSettings
{
class
NamedRouteSettings
{
const
NamedRouteSettings
({
this
.
name
,
this
.
mostValuableKeys
});
const
NamedRouteSettings
({
this
.
name
,
this
.
mostValuableKeys
,
this
.
isInitialRoute
:
false
});
final
String
name
;
final
String
name
;
final
Set
<
Key
>
mostValuableKeys
;
final
Set
<
Key
>
mostValuableKeys
;
final
bool
isInitialRoute
;
String
toString
()
{
String
toString
()
{
String
result
=
'"
$name
"'
;
String
result
=
'"
$name
"'
;
...
@@ -161,7 +167,8 @@ class NavigatorState extends State<Navigator> {
...
@@ -161,7 +167,8 @@ class NavigatorState extends State<Navigator> {
assert
(
config
.
observer
==
null
||
config
.
observer
.
navigator
==
null
);
assert
(
config
.
observer
==
null
||
config
.
observer
.
navigator
==
null
);
config
.
observer
?.
_navigator
=
this
;
config
.
observer
?.
_navigator
=
this
;
_push
(
config
.
onGenerateRoute
(
new
NamedRouteSettings
(
_push
(
config
.
onGenerateRoute
(
new
NamedRouteSettings
(
name:
config
.
initialRoute
??
Navigator
.
defaultRouteName
name:
config
.
initialRoute
??
Navigator
.
defaultRouteName
,
isInitialRoute:
true
)));
)));
}
}
...
@@ -265,7 +272,7 @@ class NavigatorState extends State<Navigator> {
...
@@ -265,7 +272,7 @@ class NavigatorState extends State<Navigator> {
assert
(
_history
.
indexOf
(
anchorRoute
)
>
0
);
assert
(
_history
.
indexOf
(
anchorRoute
)
>
0
);
_replace
(
oldRoute:
_history
[
_history
.
indexOf
(
anchorRoute
)-
1
],
newRoute:
newRoute
);
_replace
(
oldRoute:
_history
[
_history
.
indexOf
(
anchorRoute
)-
1
],
newRoute:
newRoute
);
}
}
void
_removeRouteBefore
(
Route
anchorRoute
)
{
void
_removeRouteBefore
(
Route
anchorRoute
)
{
assert
(!
_debugLocked
);
assert
(!
_debugLocked
);
assert
(()
{
_debugLocked
=
true
;
return
true
;
});
assert
(()
{
_debugLocked
=
true
;
return
true
;
});
...
@@ -356,7 +363,7 @@ class NavigatorTransaction {
...
@@ -356,7 +363,7 @@ class NavigatorTransaction {
}
}
NavigatorState
_navigator
;
NavigatorState
_navigator
;
bool
_debugOpen
=
true
;
bool
_debugOpen
=
true
;
/// Invokes the Navigator's onGenerateRoute callback to create a route with
/// Invokes the Navigator's onGenerateRoute callback to create a route with
/// the given name, then calls [push()] with that route.
/// the given name, then calls [push()] with that route.
void
pushNamed
(
String
name
,
{
Set
<
Key
>
mostValuableKeys
})
{
void
pushNamed
(
String
name
,
{
Set
<
Key
>
mostValuableKeys
})
{
...
@@ -425,7 +432,7 @@ class NavigatorTransaction {
...
@@ -425,7 +432,7 @@ class NavigatorTransaction {
assert
(
_debugOpen
);
assert
(
_debugOpen
);
return
_navigator
.
_pop
(
result
);
return
_navigator
.
_pop
(
result
);
}
}
/// Calls pop() repeatedly until the given route is the current route.
/// Calls pop() repeatedly until the given route is the current route.
/// If it is already the current route, nothing happens.
/// If it is already the current route, nothing happens.
void
popUntil
(
Route
targetRoute
)
{
void
popUntil
(
Route
targetRoute
)
{
...
@@ -437,4 +444,4 @@ class NavigatorTransaction {
...
@@ -437,4 +444,4 @@ class NavigatorTransaction {
assert
(
_debugOpen
);
assert
(
_debugOpen
);
_debugOpen
=
false
;
_debugOpen
=
false
;
}
}
}
}
\ No newline at end of file
packages/flutter/lib/src/widgets/pages.dart
View file @
e80756d6
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/animation.dart'
;
import
'navigator.dart'
;
import
'navigator.dart'
;
import
'overlay.dart'
;
import
'overlay.dart'
;
import
'routes.dart'
;
import
'routes.dart'
;
...
@@ -19,6 +21,13 @@ abstract class PageRoute<T> extends ModalRoute<T> {
...
@@ -19,6 +21,13 @@ abstract class PageRoute<T> extends ModalRoute<T> {
bool
canTransitionTo
(
TransitionRoute
nextRoute
)
=>
nextRoute
is
PageRoute
;
bool
canTransitionTo
(
TransitionRoute
nextRoute
)
=>
nextRoute
is
PageRoute
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
nextRoute
is
PageRoute
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
nextRoute
is
PageRoute
;
Performance
createPerformanceController
()
{
Performance
performance
=
super
.
createPerformanceController
();
if
(
settings
.
isInitialRoute
)
performance
.
progress
=
1.0
;
return
performance
;
}
// Subclasses can override this method to customize way heroes are inserted
// Subclasses can override this method to customize way heroes are inserted
void
insertHeroOverlayEntry
(
OverlayEntry
entry
,
Object
tag
,
OverlayState
overlay
)
{
void
insertHeroOverlayEntry
(
OverlayEntry
entry
,
Object
tag
,
OverlayState
overlay
)
{
overlay
.
insert
(
entry
);
overlay
.
insert
(
entry
);
...
...
packages/unit/test/widget/page_forward_transitions_test.dart
View file @
e80756d6
...
@@ -28,7 +28,7 @@ class TestTransition extends TransitionComponent {
...
@@ -28,7 +28,7 @@ class TestTransition extends TransitionComponent {
}
}
class
TestRoute
<
T
>
extends
PageRoute
<
T
>
{
class
TestRoute
<
T
>
extends
PageRoute
<
T
>
{
TestRoute
(
this
.
child
);
TestRoute
(
{
this
.
child
,
NamedRouteSettings
settings
})
:
super
(
settings:
settings
);
final
Widget
child
;
final
Widget
child
;
Duration
get
transitionDuration
=>
kMaterialPageRouteTransitionDuration
;
Duration
get
transitionDuration
=>
kMaterialPageRouteTransitionDuration
;
Color
get
barrierColor
=>
null
;
Color
get
barrierColor
=>
null
;
...
@@ -71,7 +71,8 @@ void main() {
...
@@ -71,7 +71,8 @@ void main() {
switch
(
settings
.
name
)
{
switch
(
settings
.
name
)
{
case
'/'
:
case
'/'
:
return
new
TestRoute
(
return
new
TestRoute
(
new
Builder
(
settings:
settings
,
child:
new
Builder
(
key:
insideKey
,
key:
insideKey
,
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
PageRoute
route
=
ModalRoute
.
of
(
context
);
PageRoute
route
=
ModalRoute
.
of
(
context
);
...
@@ -90,30 +91,18 @@ void main() {
...
@@ -90,30 +91,18 @@ void main() {
}
}
)
)
);
);
case
'/2'
:
return
new
TestRoute
(
new
Text
(
'E'
));
case
'/2'
:
return
new
TestRoute
(
settings:
settings
,
child:
new
Text
(
'E'
));
case
'/3'
:
return
new
TestRoute
(
new
Text
(
'F'
));
case
'/3'
:
return
new
TestRoute
(
settings:
settings
,
child:
new
Text
(
'F'
));
case
'/4'
:
return
new
TestRoute
(
new
Text
(
'G'
));
case
'/4'
:
return
new
TestRoute
(
settings:
settings
,
child:
new
Text
(
'G'
));
}
}
}
}
)
)
);
);
// TODO(ianh): Remove the first part of this test once the first page doesn't animate in
NavigatorState
navigator
=
insideKey
.
currentContext
.
ancestorStateOfType
(
NavigatorState
);
NavigatorState
navigator
=
insideKey
.
currentContext
.
ancestorStateOfType
(
NavigatorState
);
expect
(
state
(),
equals
(
'AC'
));
// transition ->1 is at 0.0
tester
.
pump
(
kFourTenthsOfTheTransitionDuration
);
expect
(
state
(),
equals
(
'AC'
));
// transition ->1 is at 0.4
tester
.
pump
(
kFourTenthsOfTheTransitionDuration
);
expect
(
state
(),
equals
(
'BC'
));
// transition ->1 is at 0.8
tester
.
pump
(
kFourTenthsOfTheTransitionDuration
);
expect
(
state
(),
equals
(
'BC'
));
// transition ->1 is at 1.0
expect
(
state
(),
equals
(
'BC'
));
// transition ->1 is at 1.0
navigator
.
openTransaction
((
NavigatorTransaction
transaction
)
=>
transaction
.
pushNamed
(
'/2'
));
navigator
.
openTransaction
((
NavigatorTransaction
transaction
)
=>
transaction
.
pushNamed
(
'/2'
));
expect
(
state
(),
equals
(
'BC'
));
// transition 1->2 is not yet built
expect
(
state
(),
equals
(
'BC'
));
// transition 1->2 is not yet built
tester
.
pump
();
tester
.
pump
();
...
...
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