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
a54c2905
Commit
a54c2905
authored
Jul 30, 2015
by
Matt Perry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify Navigator's Transition code a bit.
parent
c9284dff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
37 deletions
+14
-37
navigator.dart
packages/flutter/lib/widgets/navigator.dart
+14
-37
No files found.
packages/flutter/lib/widgets/navigator.dart
View file @
a54c2905
...
@@ -7,6 +7,7 @@ import 'dart:async';
...
@@ -7,6 +7,7 @@ import 'dart:async';
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animated_value.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/animation_performance.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/animation/curves.dart'
;
import
'package:sky/animation/forces.dart'
;
import
'package:sky/widgets/animated_component.dart'
;
import
'package:sky/widgets/animated_component.dart'
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/focus.dart'
;
import
'package:sky/widgets/focus.dart'
;
...
@@ -65,7 +66,6 @@ class RouteState extends RouteBase {
...
@@ -65,7 +66,6 @@ class RouteState extends RouteBase {
// and support multiple transition types
// and support multiple transition types
const
Duration
_kTransitionDuration
=
const
Duration
(
milliseconds:
150
);
const
Duration
_kTransitionDuration
=
const
Duration
(
milliseconds:
150
);
const
Point
_kTransitionStartPoint
=
const
Point
(
0.0
,
75.0
);
const
Point
_kTransitionStartPoint
=
const
Point
(
0.0
,
75.0
);
enum
TransitionDirection
{
forward
,
reverse
}
class
Transition
extends
AnimatedComponent
{
class
Transition
extends
AnimatedComponent
{
Transition
({
Transition
({
Key
key
,
Key
key
,
...
@@ -76,7 +76,7 @@ class Transition extends AnimatedComponent {
...
@@ -76,7 +76,7 @@ class Transition extends AnimatedComponent {
this
.
interactive
this
.
interactive
}):
super
(
key:
key
);
}):
super
(
key:
key
);
Widget
content
;
Widget
content
;
Transition
Direction
direction
;
Direction
direction
;
bool
interactive
;
bool
interactive
;
Function
onDismissed
;
Function
onDismissed
;
Function
onCompleted
;
Function
onCompleted
;
...
@@ -91,61 +91,38 @@ class Transition extends AnimatedComponent {
...
@@ -91,61 +91,38 @@ class Transition extends AnimatedComponent {
end:
Point
.
origin
,
end:
Point
.
origin
,
curve:
easeOut
curve:
easeOut
);
);
_opacity
=
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
)
_opacity
=
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
,
curve:
easeOut
);
..
curve
=
easeOut
;
_performance
=
new
AnimationPerformance
(
duration:
_kTransitionDuration
)
_performance
=
new
AnimationPerformance
()
..
variable
=
new
AnimatedList
([
_position
,
_opacity
]);
..
duration
=
_kTransitionDuration
if
(
direction
==
Direction
.
reverse
)
..
variable
=
new
AnimatedList
([
_position
,
_opacity
])
..
addListener
(
_checkDismissed
)
..
addListener
(
_checkCompleted
);
if
(
direction
==
TransitionDirection
.
reverse
)
_performance
.
progress
=
1.0
;
_performance
.
progress
=
1.0
;
_performance
.
addStatusListener
(
_checkStatusChanged
);
watch
(
_performance
);
watch
(
_performance
);
_start
();
_start
();
}
}
void
_start
()
{
void
_start
()
{
_dismissed
=
false
;
_performance
.
play
(
direction
);
switch
(
direction
)
{
case
TransitionDirection
.
forward
:
_performance
.
play
();
break
;
case
TransitionDirection
.
reverse
:
_performance
.
reverse
();
break
;
}
}
}
void
syncFields
(
Transition
source
)
{
void
syncFields
(
Transition
source
)
{
content
=
source
.
content
;
content
=
source
.
content
;
interactive
=
source
.
interactive
;
onDismissed
=
source
.
onDismissed
;
if
(
direction
!=
source
.
direction
)
{
if
(
direction
!=
source
.
direction
)
{
direction
=
source
.
direction
;
direction
=
source
.
direction
;
_start
();
_start
();
}
}
interactive
=
source
.
interactive
;
onDismissed
=
source
.
onDismissed
;
super
.
syncFields
(
source
);
super
.
syncFields
(
source
);
}
}
bool
_dismissed
=
false
;
void
_checkStatusChanged
(
AnimationStatus
status
)
{
void
_checkDismissed
()
{
if
(
_performance
.
isDismissed
)
{
if
(!
_dismissed
&&
direction
==
TransitionDirection
.
reverse
&&
_performance
.
isDismissed
)
{
if
(
onDismissed
!=
null
)
if
(
onDismissed
!=
null
)
onDismissed
();
onDismissed
();
_dismissed
=
true
;
}
else
if
(
_performance
.
isCompleted
)
{
}
}
bool
_completed
=
false
;
void
_checkCompleted
()
{
if
(!
_completed
&&
direction
==
TransitionDirection
.
forward
&&
_performance
.
isCompleted
)
{
if
(
onCompleted
!=
null
)
if
(
onCompleted
!=
null
)
onCompleted
();
onCompleted
();
_completed
=
true
;
}
}
}
}
...
@@ -266,7 +243,7 @@ class Navigator extends StatefulComponent {
...
@@ -266,7 +243,7 @@ class Navigator extends StatefulComponent {
Transition
transition
=
new
Transition
(
Transition
transition
=
new
Transition
(
key:
new
Key
.
fromObjectIdentity
(
historyEntry
),
key:
new
Key
.
fromObjectIdentity
(
historyEntry
),
content:
content
,
content:
content
,
direction:
(
i
<=
state
.
historyIndex
)
?
TransitionDirection
.
forward
:
Transition
Direction
.
reverse
,
direction:
(
i
<=
state
.
historyIndex
)
?
Direction
.
forward
:
Direction
.
reverse
,
interactive:
(
i
==
state
.
historyIndex
),
interactive:
(
i
==
state
.
historyIndex
),
onDismissed:
()
{
onDismissed:
()
{
setState
(()
{
setState
(()
{
...
...
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