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
3eaefd81
Commit
3eaefd81
authored
Oct 07, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1518 from abarth/performance_route
Separate Route and PerformanceRoute
parents
9f8b53f4
30d16e24
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
57 deletions
+67
-57
performance.dart
packages/flutter/lib/src/animation/performance.dart
+10
-8
dialog.dart
packages/flutter/lib/src/widgets/dialog.dart
+1
-1
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+0
-1
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+54
-45
popup_menu.dart
packages/flutter/lib/src/widgets/popup_menu.dart
+1
-1
snack_bar.dart
packages/flutter/lib/src/widgets/snack_bar.dart
+1
-1
No files found.
packages/flutter/lib/src/animation/performance.dart
View file @
3eaefd81
...
...
@@ -41,6 +41,15 @@ abstract class PerformanceView {
void
addStatusListener
(
PerformanceStatusListener
listener
);
/// Stops calling the listener every time the status of the performance changes
void
removeStatusListener
(
PerformanceStatusListener
listener
);
/// The current status of this animation
PerformanceStatus
get
status
;
/// Whether this animation is stopped at the beginning
bool
get
isDismissed
=>
status
==
PerformanceStatus
.
dismissed
;
/// Whether this animation is stopped at the end
bool
get
isCompleted
=>
status
==
PerformanceStatus
.
completed
;
}
/// A timeline that can be reversed and used to update [Animatable]s.
...
...
@@ -51,7 +60,7 @@ abstract class PerformanceView {
/// may also take direct control of the timeline by manipulating [progress], or
/// [fling] the timeline causing a physics-based simulation to take over the
/// progression.
class
Performance
implement
s
PerformanceView
{
class
Performance
extend
s
PerformanceView
{
Performance
({
this
.
duration
,
double
progress
})
{
_timeline
=
new
SimulationStepper
(
_tick
);
if
(
progress
!=
null
)
...
...
@@ -94,16 +103,9 @@ class Performance implements PerformanceView {
return
timing
!=
null
?
timing
.
transform
(
progress
,
_curveDirection
)
:
progress
;
}
/// Whether this animation is stopped at the beginning
bool
get
isDismissed
=>
status
==
PerformanceStatus
.
dismissed
;
/// Whether this animation is stopped at the end
bool
get
isCompleted
=>
status
==
PerformanceStatus
.
completed
;
/// Whether this animation is currently animating in either the forward or reverse direction
bool
get
isAnimating
=>
_timeline
.
isAnimating
;
/// The current status of this animation
PerformanceStatus
get
status
{
if
(!
isAnimating
&&
progress
==
1.0
)
return
PerformanceStatus
.
completed
;
...
...
packages/flutter/lib/src/widgets/dialog.dart
View file @
3eaefd81
...
...
@@ -131,7 +131,7 @@ class Dialog extends StatelessComponent {
}
}
class
_DialogRoute
extends
Route
{
class
_DialogRoute
extends
Performance
Route
{
_DialogRoute
({
this
.
completer
,
this
.
builder
});
final
Completer
completer
;
...
...
packages/flutter/lib/src/widgets/drag_target.dart
View file @
3eaefd81
...
...
@@ -256,7 +256,6 @@ class DragRoute extends Route {
bool
get
ephemeral
=>
true
;
bool
get
modal
=>
false
;
bool
get
opaque
=>
false
;
Duration
get
transitionDuration
=>
const
Duration
();
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
)
{
return
new
Positioned
(
...
...
packages/flutter/lib/src/widgets/navigator.dart
View file @
3eaefd81
...
...
@@ -71,13 +71,6 @@ class NavigatorState extends State<Navigator> {
push
(
new
PageRoute
(
builder
));
}
void
_insertRoute
(
Route
route
)
{
_history
.
insert
(
_currentPosition
,
route
);
route
.
_onDismissed
=
_handleRouteDismissed
;
route
.
_onRemoveRoute
=
_handleRemoveRoute
;
route
.
didPush
();
}
void
push
(
Route
route
)
{
assert
(!
_debugCurrentlyHaveRoute
(
route
));
setState
(()
{
...
...
@@ -119,13 +112,18 @@ class NavigatorState extends State<Navigator> {
return
index
>=
0
&&
index
<=
_currentPosition
;
}
void
_
handleRouteDismissed
(
Route
route
)
{
void
_
didDismissRoute
(
Route
route
)
{
assert
(
_history
.
contains
(
route
));
if
(
_history
.
lastIndexOf
(
route
)
<=
_currentPosition
)
popRoute
(
route
);
}
void
_handleRemoveRoute
(
Route
route
)
{
void
_insertRoute
(
Route
route
)
{
_history
.
insert
(
_currentPosition
,
route
);
route
.
didPush
(
this
);
}
void
_removeRoute
(
Route
route
)
{
assert
(
_history
.
contains
(
route
));
setState
(()
{
_history
.
remove
(
route
);
...
...
@@ -165,33 +163,7 @@ class NavigatorState extends State<Navigator> {
}
abstract
class
Route
{
Route
()
{
_performance
=
createPerformance
();
}
PerformanceView
get
performance
=>
_performance
?.
view
;
Performance
_performance
;
_RouteCallback
_onDismissed
;
_RouteCallback
_onRemoveRoute
;
Performance
createPerformance
()
{
Duration
duration
=
transitionDuration
;
if
(
duration
>
Duration
.
ZERO
)
{
return
new
Performance
(
duration:
duration
)
..
addStatusListener
((
PerformanceStatus
status
)
{
if
(
status
==
PerformanceStatus
.
dismissed
)
{
if
(
_onDismissed
!=
null
)
_onDismissed
(
this
);
if
(
_onRemoveRoute
!=
null
)
_onRemoveRoute
(
this
);
}
});
}
return
null
;
}
/// If hasContent is true, then the route represents some on-screen state.
///
/// If hasContent is false, then no performance will be created, and the values of
...
...
@@ -242,32 +214,69 @@ abstract class Route {
/// cover the entire application surface or are in any way semi-transparent.
bool
get
opaque
=>
false
;
/// If this is set to a non-zero [Duration], then an [Performance]
/// object, available via the performance field, will be created when the
/// route is first built, using the duration described here.
Duration
get
transitionDuration
=>
Duration
.
ZERO
;
PerformanceView
get
performance
=>
null
;
bool
get
isActuallyOpaque
=>
(
performance
==
null
||
performance
.
isCompleted
)
&&
opaque
;
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
);
NavigatorState
_navigator
;
void
didPush
(
NavigatorState
navigator
)
{
assert
(
_navigator
==
null
);
_navigator
=
navigator
;
assert
(
_navigator
!=
null
);
performance
?.
addStatusListener
(
_handlePerformanceStatusChanged
);
}
void
didPop
([
dynamic
result
])
{
assert
(
_navigator
!=
null
);
if
(
performance
==
null
)
_navigator
.
_removeRoute
(
this
);
}
void
_handlePerformanceStatusChanged
(
PerformanceStatus
status
)
{
if
(
status
==
PerformanceStatus
.
dismissed
)
{
_navigator
.
_didDismissRoute
(
this
);
_navigator
.
_removeRoute
(
this
);
_navigator
=
null
;
}
}
String
toString
()
=>
'
$runtimeType
()'
;
}
abstract
class
PerformanceRoute
extends
Route
{
PerformanceView
get
performance
=>
_performance
?.
view
;
Performance
_performance
;
Performance
createPerformance
()
{
Duration
duration
=
transitionDuration
;
assert
(
duration
>=
Duration
.
ZERO
);
return
new
Performance
(
duration:
duration
);
}
Duration
get
transitionDuration
;
bool
get
isActuallyOpaque
=>
(
performance
==
null
||
_performance
.
isCompleted
)
&&
opaque
;
Widget
build
(
NavigatorState
navigator
,
PerformanceView
nextRoutePerformance
);
void
didPush
()
{
void
didPush
(
NavigatorState
navigator
)
{
_performance
=
createPerformance
();
super
.
didPush
(
navigator
);
_performance
?.
forward
();
}
void
didPop
([
dynamic
result
])
{
_performance
?.
reverse
();
if
(
performance
==
null
&&
_onRemoveRoute
!=
null
)
_onRemoveRoute
(
this
);
super
.
didPop
(
result
);
}
String
toString
()
=>
'
$runtimeType
()'
;
}
const
Duration
_kTransitionDuration
=
const
Duration
(
milliseconds:
150
);
const
Point
_kTransitionStartPoint
=
const
Point
(
0.0
,
75.0
);
class
PageRoute
extends
Route
{
class
PageRoute
extends
Performance
Route
{
PageRoute
(
this
.
builder
);
final
RouteBuilder
builder
;
...
...
packages/flutter/lib/src/widgets/popup_menu.dart
View file @
3eaefd81
...
...
@@ -117,7 +117,7 @@ class MenuPosition {
final
double
left
;
}
class
_MenuRoute
extends
Route
{
class
_MenuRoute
extends
Performance
Route
{
_MenuRoute
({
this
.
completer
,
this
.
position
,
this
.
builder
,
this
.
level
});
final
Completer
completer
;
...
...
packages/flutter/lib/src/widgets/snack_bar.dart
View file @
3eaefd81
...
...
@@ -97,7 +97,7 @@ class SnackBar extends StatelessComponent {
}
}
class
_SnackBarRoute
extends
Route
{
class
_SnackBarRoute
extends
Performance
Route
{
_SnackBarRoute
({
this
.
content
,
this
.
actions
});
final
Widget
content
;
...
...
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