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
cd19702c
Commit
cd19702c
authored
Dec 03, 2015
by
Hixie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be more discerning with forward transitions
So you don't fade out when going to a popup menu, for example.
parent
93b1f100
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
28 deletions
+43
-28
page.dart
packages/flutter/lib/src/material/page.dart
+2
-3
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+6
-1
page_forward_transitions_test.dart
packages/unit/test/widget/page_forward_transitions_test.dart
+35
-24
No files found.
packages/flutter/lib/src/material/page.dart
View file @
cd19702c
...
@@ -5,8 +5,6 @@
...
@@ -5,8 +5,6 @@
import
'package:flutter/animation.dart'
;
import
'package:flutter/animation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
class
_MaterialPageTransition
extends
TransitionWithChild
{
class
_MaterialPageTransition
extends
TransitionWithChild
{
_MaterialPageTransition
({
_MaterialPageTransition
({
Key
key
,
Key
key
,
...
@@ -52,7 +50,8 @@ class MaterialPageRoute<T> extends PageRoute<T> {
...
@@ -52,7 +50,8 @@ class MaterialPageRoute<T> extends PageRoute<T> {
final
WidgetBuilder
builder
;
final
WidgetBuilder
builder
;
Duration
get
transitionDuration
=>
kMaterialPageRouteTransitionDuration
;
Duration
get
transitionDuration
=>
kMaterialPageRouteTransitionDuration
;
Color
get
barrierColor
=>
Colors
.
black54
;
Color
get
barrierColor
=>
null
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
false
;
Widget
buildPage
(
BuildContext
context
)
{
Widget
buildPage
(
BuildContext
context
)
{
Widget
result
=
builder
(
context
);
Widget
result
=
builder
(
context
);
...
...
packages/flutter/lib/src/widgets/routes.dart
View file @
cd19702c
...
@@ -150,7 +150,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
...
@@ -150,7 +150,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
final
ProxyPerformance
forwardPerformance
=
new
ProxyPerformance
();
final
ProxyPerformance
forwardPerformance
=
new
ProxyPerformance
();
void
didPushNext
(
Route
nextRoute
)
{
void
didPushNext
(
Route
nextRoute
)
{
if
(
nextRoute
is
TransitionRoute
)
{
if
(
nextRoute
is
TransitionRoute
&&
canTransitionTo
(
nextRoute
)
&&
nextRoute
.
canTransitionFrom
(
this
)
)
{
PerformanceView
current
=
forwardPerformance
.
masterPerformance
;
PerformanceView
current
=
forwardPerformance
.
masterPerformance
;
if
(
current
!=
null
)
{
if
(
current
!=
null
)
{
if
(
current
is
TrainHoppingPerformance
)
{
if
(
current
is
TrainHoppingPerformance
)
{
...
@@ -177,6 +177,9 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
...
@@ -177,6 +177,9 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
super
.
didPushNext
(
nextRoute
);
super
.
didPushNext
(
nextRoute
);
}
}
bool
canTransitionTo
(
TransitionRoute
nextRoute
)
=>
true
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
true
;
Widget
wrapTransition
(
BuildContext
context
,
Widget
child
)
{
Widget
wrapTransition
(
BuildContext
context
,
Widget
child
)
{
return
buildForwardTransition
(
return
buildForwardTransition
(
context
,
context
,
...
@@ -434,4 +437,6 @@ abstract class PageRoute<T> extends ModalRoute<T> {
...
@@ -434,4 +437,6 @@ abstract class PageRoute<T> extends ModalRoute<T> {
})
:
super
(
completer:
completer
,
settings:
settings
);
})
:
super
(
completer:
completer
,
settings:
settings
);
bool
get
opaque
=>
true
;
bool
get
opaque
=>
true
;
bool
get
barrierDismissable
=>
false
;
bool
get
barrierDismissable
=>
false
;
bool
canTransitionTo
(
TransitionRoute
nextRoute
)
=>
nextRoute
is
PageRoute
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
nextRoute
is
PageRoute
;
}
}
packages/unit/test/widget/page_forward_transitions_test.dart
View file @
cd19702c
...
@@ -27,6 +27,14 @@ class TestTransition extends TransitionComponent {
...
@@ -27,6 +27,14 @@ class TestTransition extends TransitionComponent {
}
}
}
}
class
TestRoute
<
T
>
extends
PageRoute
<
T
>
{
TestRoute
(
this
.
child
);
final
Widget
child
;
Duration
get
transitionDuration
=>
kMaterialPageRouteTransitionDuration
;
Color
get
barrierColor
=>
null
;
Widget
buildPage
(
BuildContext
context
)
=>
child
;
}
void
main
(
)
{
void
main
(
)
{
final
Duration
kTwoTenthsOfTheTransitionDuration
=
kMaterialPageRouteTransitionDuration
*
0.2
;
final
Duration
kTwoTenthsOfTheTransitionDuration
=
kMaterialPageRouteTransitionDuration
*
0.2
;
final
Duration
kFourTenthsOfTheTransitionDuration
=
kMaterialPageRouteTransitionDuration
*
0.4
;
final
Duration
kFourTenthsOfTheTransitionDuration
=
kMaterialPageRouteTransitionDuration
*
0.4
;
...
@@ -57,30 +65,33 @@ void main() {
...
@@ -57,30 +65,33 @@ void main() {
tester
.
pumpWidget
(
tester
.
pumpWidget
(
new
MaterialApp
(
new
MaterialApp
(
routes:
<
String
,
RouteBuilder
>{
onGenerateRoute:
(
NamedRouteSettings
settings
)
{
'/'
:
(
RouteArguments
args
)
{
switch
(
settings
.
name
)
{
return
new
Builder
(
case
'/'
:
key:
insideKey
,
return
new
TestRoute
(
builder:
(
BuildContext
context
)
{
new
Builder
(
PageRoute
route
=
ModalRoute
.
of
(
context
);
key:
insideKey
,
return
new
Column
([
builder:
(
BuildContext
context
)
{
new
TestTransition
(
PageRoute
route
=
ModalRoute
.
of
(
context
);
childFirstHalf:
new
Text
(
'A'
),
return
new
Column
([
childSecondHalf:
new
Text
(
'B'
),
new
TestTransition
(
performance:
route
.
performance
childFirstHalf:
new
Text
(
'A'
),
),
childSecondHalf:
new
Text
(
'B'
),
new
TestTransition
(
performance:
route
.
performance
childFirstHalf:
new
Text
(
'C'
),
),
childSecondHalf:
new
Text
(
'D'
),
new
TestTransition
(
performance:
route
.
forwardPerformance
childFirstHalf:
new
Text
(
'C'
),
),
childSecondHalf:
new
Text
(
'D'
),
]);
performance:
route
.
forwardPerformance
}
),
);
]);
},
}
'/2'
:
(
RouteArguments
args
)
=>
new
Text
(
'E'
),
)
'/3'
:
(
RouteArguments
args
)
=>
new
Text
(
'F'
),
);
'/4'
:
(
RouteArguments
args
)
=>
new
Text
(
'G'
),
case
'/2'
:
return
new
TestRoute
(
new
Text
(
'E'
));
case
'/3'
:
return
new
TestRoute
(
new
Text
(
'F'
));
case
'/4'
:
return
new
TestRoute
(
new
Text
(
'G'
));
}
}
}
)
)
);
);
...
...
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