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
6f7ceff0
Commit
6f7ceff0
authored
Feb 27, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2235 from abarth/animation_status
Elide fewer AnimationStatus callbacks
parents
c56be8ef
25ab5555
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
6 deletions
+74
-6
animation_controller.dart
packages/flutter/lib/src/animation/animation_controller.dart
+8
-5
overlay.dart
packages/flutter/lib/src/widgets/overlay.dart
+1
-1
animation_controller_test.dart
...ges/flutter/test/animation/animation_controller_test.dart
+65
-0
No files found.
packages/flutter/lib/src/animation/animation_controller.dart
View file @
6f7ceff0
...
...
@@ -146,6 +146,7 @@ class AnimationController extends Animation<double>
stop
();
if
(
simulationDuration
==
Duration
.
ZERO
)
{
assert
(
value
==
target
);
_checkStatusChanged
();
return
new
Future
.
value
();
}
assert
(
simulationDuration
>
Duration
.
ZERO
);
...
...
@@ -180,7 +181,9 @@ class AnimationController extends Animation<double>
assert
(!
isAnimating
);
_simulation
=
simulation
;
_value
=
simulation
.
x
(
0.0
).
clamp
(
lowerBound
,
upperBound
);
return
_ticker
.
start
();
Future
result
=
_ticker
.
start
();
_checkStatusChanged
();
return
result
;
}
/// Stops running this animation.
...
...
@@ -194,13 +197,13 @@ class AnimationController extends Animation<double>
stop
();
}
AnimationStatus
_lastStatus
=
AnimationStatus
.
dismissed
;
AnimationStatus
_last
Reported
Status
=
AnimationStatus
.
dismissed
;
void
_checkStatusChanged
()
{
AnimationStatus
newStatus
=
status
;
AnimationStatus
oldStatus
=
_lastStatus
;
_lastStatus
=
newStatus
;
if
(
oldStatus
!=
newStatus
)
if
(
_lastReportedStatus
!=
newStatus
)
{
_lastReportedStatus
=
newStatus
;
notifyStatusListeners
(
newStatus
);
}
}
void
_tick
(
Duration
elapsed
)
{
...
...
packages/flutter/lib/src/widgets/overlay.dart
View file @
6f7ceff0
...
...
@@ -22,9 +22,9 @@ class OverlayEntry {
bool
get
opaque
=>
_opaque
;
bool
_opaque
;
void
set
opaque
(
bool
value
)
{
assert
(
_overlay
!=
null
);
if
(
_opaque
==
value
)
return
;
assert
(
_overlay
!=
null
);
_overlay
.
setState
(()
{
_opaque
=
value
;
});
...
...
packages/flutter/test/animation/animation_controller_test.dart
View file @
6f7ceff0
...
...
@@ -36,5 +36,70 @@ void main() {
Scheduler
.
instance
.
handleBeginFrame
(
const
Duration
(
seconds:
2
));
expect
(
didComplete
,
isTrue
);
expect
(
didDismiss
,
isTrue
);
controller
.
stop
();
});
test
(
"Receives status callbacks for forward and reverse"
,
()
{
WidgetFlutterBinding
.
ensureInitialized
();
AnimationController
controller
=
new
AnimationController
(
duration:
const
Duration
(
milliseconds:
100
)
);
List
<
double
>
valueLog
=
<
double
>[];
List
<
AnimationStatus
>
log
=
<
AnimationStatus
>[];
controller
..
addStatusListener
((
AnimationStatus
status
)
{
log
.
add
(
status
);
})
..
addListener
(()
{
valueLog
.
add
(
controller
.
value
);
});
expect
(
log
,
equals
([]));
expect
(
valueLog
,
equals
([]));
controller
.
forward
();
expect
(
log
,
equals
([
AnimationStatus
.
forward
]));
expect
(
valueLog
,
equals
([]));
controller
.
reverse
();
expect
(
log
,
equals
([
AnimationStatus
.
forward
,
AnimationStatus
.
dismissed
]));
expect
(
valueLog
,
equals
([]));
controller
.
reverse
();
expect
(
log
,
equals
([
AnimationStatus
.
forward
,
AnimationStatus
.
dismissed
]));
expect
(
valueLog
,
equals
([]));
log
.
clear
();
controller
.
forward
();
expect
(
log
,
equals
([
AnimationStatus
.
forward
]));
expect
(
valueLog
,
equals
([]));
controller
.
forward
();
expect
(
log
,
equals
([
AnimationStatus
.
forward
]));
expect
(
valueLog
,
equals
([]));
controller
.
reverse
();
log
.
clear
();
Scheduler
.
instance
.
handleBeginFrame
(
const
Duration
(
seconds:
10
));
expect
(
log
,
equals
([]));
expect
(
valueLog
,
equals
([]));
Scheduler
.
instance
.
handleBeginFrame
(
const
Duration
(
seconds:
20
));
expect
(
log
,
equals
([]));
expect
(
valueLog
,
equals
([]));
Scheduler
.
instance
.
handleBeginFrame
(
const
Duration
(
seconds:
30
));
expect
(
log
,
equals
([]));
expect
(
valueLog
,
equals
([]));
Scheduler
.
instance
.
handleBeginFrame
(
const
Duration
(
seconds:
40
));
expect
(
log
,
equals
([]));
expect
(
valueLog
,
equals
([]));
controller
.
stop
();
});
}
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