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
519b190c
Commit
519b190c
authored
Dec 04, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #745 from Hixie/yak2-better-transitions-api
Refactor forward transition building
parents
42eafce0
a83eadcc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
48 deletions
+83
-48
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+1
-1
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+4
-2
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+3
-1
page.dart
packages/flutter/lib/src/material/page.dart
+2
-2
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+3
-1
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+67
-40
page_forward_transitions_test.dart
packages/unit/test/widget/page_forward_transitions_test.dart
+3
-1
No files found.
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
519b190c
...
...
@@ -158,7 +158,7 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
return
BottomSheet
.
createPerformance
();
}
Widget
buildPage
(
BuildContext
context
)
{
Widget
buildPage
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardPerformance
)
{
return
new
_ModalBottomSheet
(
route:
this
);
}
}
...
...
packages/flutter/lib/src/material/dialog.dart
View file @
519b190c
...
...
@@ -127,9 +127,11 @@ class _DialogRoute<T> extends PopupRoute<T> {
bool
get
barrierDismissable
=>
true
;
Color
get
barrierColor
=>
Colors
.
black54
;
Widget
buildPage
(
BuildContext
context
)
=>
child
;
Widget
buildPage
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardPerformance
)
{
return
child
;
}
Widget
buildTransition
(
BuildContext
context
,
PerformanceView
p
erformance
,
Widget
child
)
{
Widget
buildTransition
s
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardP
erformance
,
Widget
child
)
{
return
new
FadeTransition
(
performance:
performance
,
opacity:
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
,
curve:
Curves
.
easeOut
),
...
...
packages/flutter/lib/src/material/dropdown.dart
View file @
519b190c
...
...
@@ -168,7 +168,9 @@ class _DropDownRoute<T> extends PopupRoute<T> {
bool
get
barrierDismissable
=>
true
;
Color
get
barrierColor
=>
null
;
Widget
buildPage
(
BuildContext
context
)
=>
new
_DropDownMenu
(
route:
this
);
Widget
buildPage
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardPerformance
)
{
return
new
_DropDownMenu
(
route:
this
);
}
}
class
DropDownMenuItem
<
T
>
extends
StatelessComponent
{
...
...
packages/flutter/lib/src/material/page.dart
View file @
519b190c
...
...
@@ -53,7 +53,7 @@ class MaterialPageRoute<T> extends PageRoute<T> {
Color
get
barrierColor
=>
null
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
false
;
Widget
buildPage
(
BuildContext
context
)
{
Widget
buildPage
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardPerformance
)
{
Widget
result
=
builder
(
context
);
assert
(()
{
if
(
result
==
null
)
...
...
@@ -64,7 +64,7 @@ class MaterialPageRoute<T> extends PageRoute<T> {
return
result
;
}
Widget
buildTransition
(
BuildContext
context
,
PerformanceView
p
erformance
,
Widget
child
)
{
Widget
buildTransition
s
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardP
erformance
,
Widget
child
)
{
return
new
_MaterialPageTransition
(
performance:
performance
,
child:
child
...
...
packages/flutter/lib/src/material/popup_menu.dart
View file @
519b190c
...
...
@@ -109,7 +109,9 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
bool
get
barrierDismissable
=>
true
;
Color
get
barrierColor
=>
null
;
Widget
buildPage
(
BuildContext
context
)
=>
new
_PopupMenu
(
route:
this
);
Widget
buildPage
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardPerformance
)
{
return
new
_PopupMenu
(
route:
this
);
}
}
Future
showMenu
(
{
BuildContext
context
,
ModalPosition
position
,
List
<
PopupMenuItem
>
items
,
int
elevation:
8
})
{
...
...
packages/flutter/lib/src/widgets/routes.dart
View file @
519b190c
...
...
@@ -13,7 +13,6 @@ import 'modal_barrier.dart';
import
'navigator.dart'
;
import
'overlay.dart'
;
import
'page_storage.dart'
;
import
'status_transitions.dart'
;
const
_kTransparent
=
const
Color
(
0x00000000
);
...
...
@@ -147,11 +146,12 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
}
final
ProxyPerformance
forwardPerformance
=
new
ProxyPerformance
();
PerformanceView
get
forwardPerformance
=>
_forwardPerformance
;
final
ProxyPerformance
_forwardPerformance
=
new
ProxyPerformance
();
void
didPushNext
(
Route
nextRoute
)
{
if
(
nextRoute
is
TransitionRoute
&&
canTransitionTo
(
nextRoute
)
&&
nextRoute
.
canTransitionFrom
(
this
))
{
PerformanceView
current
=
forwardPerformance
.
masterPerformance
;
PerformanceView
current
=
_
forwardPerformance
.
masterPerformance
;
if
(
current
!=
null
)
{
if
(
current
is
TrainHoppingPerformance
)
{
TrainHoppingPerformance
newPerformance
;
...
...
@@ -159,19 +159,19 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
current
.
currentTrain
,
nextRoute
.
performance
,
onSwitchedTrain:
()
{
assert
(
forwardPerformance
.
masterPerformance
==
newPerformance
);
assert
(
_
forwardPerformance
.
masterPerformance
==
newPerformance
);
assert
(
newPerformance
.
currentTrain
==
nextRoute
.
performance
);
forwardPerformance
.
masterPerformance
=
newPerformance
.
currentTrain
;
_
forwardPerformance
.
masterPerformance
=
newPerformance
.
currentTrain
;
newPerformance
.
dispose
();
}
);
forwardPerformance
.
masterPerformance
=
newPerformance
;
_
forwardPerformance
.
masterPerformance
=
newPerformance
;
current
.
dispose
();
}
else
{
forwardPerformance
.
masterPerformance
=
new
TrainHoppingPerformance
(
current
,
nextRoute
.
performance
);
_
forwardPerformance
.
masterPerformance
=
new
TrainHoppingPerformance
(
current
,
nextRoute
.
performance
);
}
}
else
{
forwardPerformance
.
masterPerformance
=
nextRoute
.
performance
;
_
forwardPerformance
.
masterPerformance
=
nextRoute
.
performance
;
}
}
super
.
didPushNext
(
nextRoute
);
...
...
@@ -180,21 +180,6 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
bool
canTransitionTo
(
TransitionRoute
nextRoute
)
=>
true
;
bool
canTransitionFrom
(
TransitionRoute
nextRoute
)
=>
true
;
Widget
wrapTransition
(
BuildContext
context
,
Widget
child
)
{
return
buildForwardTransition
(
context
,
forwardPerformance
,
buildTransition
(
context
,
performance
,
child
)
);
}
Widget
buildTransition
(
BuildContext
context
,
PerformanceView
performance
,
Widget
child
)
=>
child
;
Widget
buildForwardTransition
(
BuildContext
context
,
PerformanceView
performance
,
Widget
child
)
=>
child
;
String
get
debugLabel
=>
'
$runtimeType
'
;
String
toString
()
=>
'
$runtimeType
(performance:
$_performance
)'
;
}
...
...
@@ -270,44 +255,85 @@ class _ModalScopeStatus extends InheritedWidget {
}
}
class
_ModalScope
extends
Stat
usTransition
Component
{
class
_ModalScope
extends
Stat
eful
Component
{
_ModalScope
({
Key
key
,
this
.
subtreeKey
,
this
.
storageBucket
,
PerformanceView
performance
,
this
.
performance
,
this
.
forwardPerformance
,
this
.
current
,
this
.
route
})
:
super
(
key:
key
,
performance:
performance
);
})
:
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
();
}
class
_ModalScopeState
extends
State
<
_ModalScope
>
{
void
initState
()
{
super
.
initState
();
config
.
performance
?.
addStatusListener
(
_performanceStatusChanged
);
config
.
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
);
}
}
void
dispose
()
{
config
.
performance
?.
removeStatusListener
(
_performanceStatusChanged
);
config
.
forwardPerformance
?.
removeStatusListener
(
_performanceStatusChanged
);
super
.
dispose
();
}
void
_performanceStatusChanged
(
PerformanceStatus
status
)
{
setState
(()
{
// The performances' states are our build state, and they changed already.
});
}
Widget
build
(
BuildContext
context
)
{
Widget
contents
=
new
PageStorage
(
key:
subtreeKey
,
bucket:
storageBucket
,
key:
config
.
subtreeKey
,
bucket:
config
.
storageBucket
,
child:
new
_ModalScopeStatus
(
current:
current
,
route:
route
,
child:
route
.
buildPage
(
context
)
current:
c
onfig
.
c
urrent
,
route:
config
.
route
,
child:
config
.
route
.
buildPage
(
context
,
config
.
performance
,
config
.
forwardPerformance
)
)
);
if
(
route
.
offstage
)
{
if
(
config
.
route
.
offstage
)
{
contents
=
new
OffStage
(
child:
contents
);
}
else
{
contents
=
new
Focus
(
key:
new
GlobalObjectKey
(
route
),
key:
new
GlobalObjectKey
(
config
.
route
),
child:
new
IgnorePointer
(
ignoring:
performance
.
status
==
PerformanceStatus
.
reverse
,
child:
route
.
wrapTransition
(
context
,
contents
)
ignoring:
config
.
performance
?.
status
==
PerformanceStatus
.
reverse
,
child:
config
.
route
.
buildTransitions
(
context
,
config
.
performance
,
config
.
forwardPerformance
,
contents
)
)
);
}
contents
=
new
RepaintBoundary
(
child:
contents
);
ModalPosition
position
=
route
.
position
;
ModalPosition
position
=
config
.
route
.
position
;
if
(
position
==
null
)
return
contents
;
return
new
Positioned
(
...
...
@@ -347,8 +373,8 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
// The API for subclasses to override - used by _ModalScope
ModalPosition
get
position
=>
null
;
Widget
buildPage
(
BuildContext
context
);
Widget
buildTransition
(
BuildContext
context
,
PerformanceView
p
erformance
,
Widget
child
)
{
Widget
buildPage
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardPerformance
);
Widget
buildTransition
s
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardP
erformance
,
Widget
child
)
{
return
child
;
}
...
...
@@ -385,7 +411,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
// Internals
final
GlobalKey
<
StatusTransitionState
>
_scopeKey
=
new
GlobalKey
<
StatusTransition
State
>();
final
GlobalKey
<
_ModalScopeState
>
_scopeKey
=
new
GlobalKey
<
_ModalScope
State
>();
final
GlobalKey
_subtreeKey
=
new
GlobalKey
();
final
PageStorageBucket
_storageBucket
=
new
PageStorageBucket
();
...
...
@@ -408,9 +434,10 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
subtreeKey:
_subtreeKey
,
storageBucket:
_storageBucket
,
performance:
performance
,
forwardPerformance:
forwardPerformance
,
current:
isCurrent
,
route:
this
// calls buildTransition
()/buildForwardTransition
() and buildPage(), defined above
// calls buildTransition
s
() and buildPage(), defined above
);
}
...
...
packages/unit/test/widget/page_forward_transitions_test.dart
View file @
519b190c
...
...
@@ -30,7 +30,9 @@ class TestRoute<T> extends PageRoute<T> {
final
Widget
child
;
Duration
get
transitionDuration
=>
kMaterialPageRouteTransitionDuration
;
Color
get
barrierColor
=>
null
;
Widget
buildPage
(
BuildContext
context
)
=>
child
;
Widget
buildPage
(
BuildContext
context
,
PerformanceView
performance
,
PerformanceView
forwardPerformance
)
{
return
child
;
}
}
void
main
(
)
{
...
...
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