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
7f95d9b5
Commit
7f95d9b5
authored
Jan 19, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1303 from abarth/tween2
Introduce Tween and the new animation API
parents
548dbf08
bc20871c
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
462 additions
and
25 deletions
+462
-25
progress_indicator.dart
examples/widgets/progress_indicator.dart
+22
-24
animation.dart
packages/flutter/lib/animation.dart
+1
-0
tween.dart
packages/flutter/lib/src/animation/tween.dart
+376
-0
transitions.dart
packages/flutter/lib/src/widgets/transitions.dart
+63
-1
No files found.
examples/widgets/progress_indicator.dart
View file @
7f95d9b5
...
...
@@ -12,39 +12,38 @@ class ProgressIndicatorApp extends StatefulComponent {
class
_ProgressIndicatorAppState
extends
State
<
ProgressIndicatorApp
>
{
void
initState
()
{
super
.
initState
();
valueAnimation
=
new
ValuePerformance
<
double
>()
..
duration
=
const
Duration
(
milliseconds:
1500
)
..
variable
=
new
AnimatedValue
<
double
>(
0.0
,
end:
1.0
,
curve:
new
Interval
(
0.0
,
0.9
,
curve:
Curves
.
ease
)
,
reverseCurve:
Curves
.
ease
);
valueAnimation
.
addStatusListener
((
PerformanceStatus
status
)
{
controller
=
new
AnimationController
(
duration:
const
Duration
(
milliseconds:
1500
)
)..
play
(
AnimationDirection
.
forward
);
animation
=
new
ACurve
(
parent:
controller
,
curve:
new
Interval
(
0.0
,
0.9
,
curve:
Curves
.
ease
),
reverseCurve:
Curves
.
ease
).
.
addStatusListener
((
PerformanceStatus
status
)
{
if
(
status
==
PerformanceStatus
.
dismissed
||
status
==
PerformanceStatus
.
completed
)
reverseValueAnimationDirection
();
});
valueAnimation
.
play
(
valueAnimationDirection
);
}
ValuePerformance
<
double
>
valueA
nimation
;
Animation
Direction
valueAnimationDirection
=
AnimationDirection
.
forward
;
Animation
a
nimation
;
Animation
Controller
controller
;
void
handleTap
()
{
setState
(()
{
// valueAnimation.isAnimating is part of our build state
if
(
valueAnimation
.
isAnimating
)
valueAnimation
.
stop
();
if
(
controller
.
isAnimating
)
controller
.
stop
();
else
valueAnimation
.
resume
();
controller
.
resume
();
});
}
void
reverseValueAnimationDirection
()
{
valueAnimationDirection
=
(
valueAnimationD
irection
==
AnimationDirection
.
forward
)
AnimationDirection
direction
=
(
controller
.
d
irection
==
AnimationDirection
.
forward
)
?
AnimationDirection
.
reverse
:
AnimationDirection
.
forward
;
valueAnimation
.
play
(
valueAnimationD
irection
);
controller
.
play
(
d
irection
);
}
Widget
buildIndicators
(
BuildContext
context
)
{
...
...
@@ -55,19 +54,19 @@ class _ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
),
new
LinearProgressIndicator
(),
new
LinearProgressIndicator
(),
new
LinearProgressIndicator
(
value:
valueAnimation
.
value
),
new
LinearProgressIndicator
(
value:
animation
.
progress
),
new
CircularProgressIndicator
(),
new
SizedBox
(
width:
20.0
,
height:
20.0
,
child:
new
CircularProgressIndicator
(
value:
valueAnimation
.
value
)
child:
new
CircularProgressIndicator
(
value:
animation
.
progress
)
),
new
SizedBox
(
width:
50.0
,
height:
30.0
,
child:
new
CircularProgressIndicator
(
value:
valueAnimation
.
value
)
child:
new
CircularProgressIndicator
(
value:
animation
.
progress
)
),
new
Text
(
"
${(
valueAnimation.value * 100.0).toStringAsFixed(1)}
%"
+
(
valueAnimation
.
isAnimating
?
''
:
' (paused)'
))
new
Text
(
"
${(
animation.progress * 100.0).toStringAsFixed(1)}
%"
+
(
controller
.
isAnimating
?
''
:
' (paused)'
))
];
return
new
Column
(
children:
indicators
...
...
@@ -82,9 +81,8 @@ class _ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
onTap:
handleTap
,
child:
new
Container
(
padding:
const
EdgeDims
.
symmetric
(
vertical:
12.0
,
horizontal:
8.0
),
child:
new
BuilderTransition
(
variables:
<
AnimatedValue
<
double
>>[
valueAnimation
.
variable
],
performance:
valueAnimation
.
view
,
child:
new
AnimationWatchingBuilder
(
watchable:
animation
,
builder:
buildIndicators
)
)
...
...
packages/flutter/lib/animation.dart
View file @
7f95d9b5
...
...
@@ -16,3 +16,4 @@ export 'src/animation/performance.dart';
export
'src/animation/scroll_behavior.dart'
;
export
'src/animation/simulation_stepper.dart'
;
export
'src/animation/ticker.dart'
;
export
'src/animation/tween.dart'
;
packages/flutter/lib/src/animation/tween.dart
0 → 100644
View file @
7f95d9b5
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/widgets/transitions.dart
View file @
7f95d9b5
...
...
@@ -63,6 +63,55 @@ class _TransitionState extends State<TransitionComponent> {
}
}
abstract
class
AnimationWatchingComponent
extends
StatefulComponent
{
AnimationWatchingComponent
({
Key
key
,
this
.
watchable
})
:
super
(
key:
key
)
{
assert
(
watchable
!=
null
);
}
final
Watchable
watchable
;
Widget
build
(
BuildContext
context
);
_AnimationWatchingComponentState
createState
()
=>
new
_AnimationWatchingComponentState
();
void
debugFillDescription
(
List
<
String
>
description
)
{
super
.
debugFillDescription
(
description
);
description
.
add
(
'watchable:
$watchable
'
);
}
}
class
_AnimationWatchingComponentState
extends
State
<
AnimationWatchingComponent
>
{
void
initState
()
{
super
.
initState
();
config
.
watchable
.
addListener
(
_handleTick
);
}
void
didUpdateConfig
(
AnimationWatchingComponent
oldConfig
)
{
if
(
config
.
watchable
!=
oldConfig
.
watchable
)
{
oldConfig
.
watchable
.
removeListener
(
_handleTick
);
config
.
watchable
.
addListener
(
_handleTick
);
}
}
void
dispose
()
{
config
.
watchable
.
removeListener
(
_handleTick
);
super
.
dispose
();
}
void
_handleTick
()
{
setState
(()
{
// The watchable's state is our build state, and it changed already.
});
}
Widget
build
(
BuildContext
context
)
{
return
config
.
build
(
context
);
}
}
abstract
class
TransitionWithChild
extends
TransitionComponent
{
TransitionWithChild
({
Key
key
,
...
...
@@ -284,7 +333,6 @@ class PositionedTransition extends TransitionWithChild {
}
}
class
BuilderTransition
extends
TransitionComponent
{
BuilderTransition
({
Key
key
,
...
...
@@ -303,3 +351,17 @@ class BuilderTransition extends TransitionComponent {
return
builder
(
context
);
}
}
class
AnimationWatchingBuilder
extends
AnimationWatchingComponent
{
AnimationWatchingBuilder
({
Key
key
,
Watchable
watchable
,
this
.
builder
})
:
super
(
key:
key
,
watchable:
watchable
);
final
WidgetBuilder
builder
;
Widget
build
(
BuildContext
context
)
{
return
builder
(
context
);
}
}
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