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
fc564f0c
Commit
fc564f0c
authored
Feb 27, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2238 from abarth/rm_animation_direction
Remove AnimationDirection
parents
d998edd3
3bbeee7b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
96 deletions
+57
-96
progress_indicator_demo.dart
...es/material_gallery/lib/demo/progress_indicator_demo.dart
+22
-17
animation.dart
packages/flutter/lib/src/animation/animation.dart
+2
-29
animation_controller.dart
packages/flutter/lib/src/animation/animation_controller.dart
+20
-17
animations.dart
packages/flutter/lib/src/animation/animations.dart
+4
-22
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+1
-1
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+2
-8
toggleable.dart
packages/flutter/lib/src/material/toggleable.dart
+4
-1
heroes.dart
packages/flutter/lib/src/widgets/heroes.dart
+2
-1
No files found.
examples/material_gallery/lib/demo/progress_indicator_demo.dart
View file @
fc564f0c
...
...
@@ -14,39 +14,44 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
super
.
initState
();
controller
=
new
AnimationController
(
duration:
const
Duration
(
milliseconds:
1500
)
)..
play
(
AnimationDirection
.
forward
);
)..
forward
(
);
animation
=
new
CurvedAnimation
(
parent:
controller
,
curve:
new
Interval
(
0.0
,
0.9
,
curve:
Curves
.
ease
),
reverseCurve:
Curves
.
ease
)..
addStatusListener
((
AnimationStatus
status
)
{
if
(
status
==
AnimationStatus
.
dismissed
||
status
==
AnimationStatus
.
completed
)
reverseValueAnimationDirection
();
if
(
status
==
AnimationStatus
.
dismissed
)
controller
.
forward
();
else
if
(
status
==
AnimationStatus
.
completed
)
controller
.
reverse
();
});
}
Animation
<
double
>
animation
;
AnimationController
controller
;
void
handleTap
()
{
void
_
handleTap
()
{
setState
(()
{
// valueAnimation.isAnimating is part of our build state
if
(
controller
.
isAnimating
)
if
(
controller
.
isAnimating
)
{
controller
.
stop
();
else
controller
.
resume
();
}
else
{
switch
(
controller
.
status
)
{
case
AnimationStatus
.
dismissed
:
case
AnimationStatus
.
forward
:
controller
.
forward
();
break
;
case
AnimationStatus
.
reverse
:
case
AnimationStatus
.
completed
:
controller
.
reverse
();
break
;
}
}
});
}
void
reverseValueAnimationDirection
()
{
AnimationDirection
direction
=
(
controller
.
direction
==
AnimationDirection
.
forward
)
?
AnimationDirection
.
reverse
:
AnimationDirection
.
forward
;
controller
.
play
(
direction
);
}
Widget
buildIndicators
(
BuildContext
context
,
Widget
child
)
{
Widget
_buildIndicators
(
BuildContext
context
,
Widget
child
)
{
List
<
Widget
>
indicators
=
<
Widget
>[
new
SizedBox
(
width:
200.0
,
...
...
@@ -82,13 +87,13 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
body:
new
DefaultTextStyle
(
style:
Theme
.
of
(
context
).
text
.
title
,
child:
new
GestureDetector
(
onTap:
handleTap
,
onTap:
_
handleTap
,
behavior:
HitTestBehavior
.
opaque
,
child:
new
Container
(
padding:
const
EdgeDims
.
symmetric
(
vertical:
12.0
,
horizontal:
8.0
),
child:
new
AnimatedBuilder
(
animation:
animation
,
builder:
buildIndicators
builder:
_
buildIndicators
)
)
)
...
...
packages/flutter/lib/src/animation/animation.dart
View file @
fc564f0c
...
...
@@ -4,15 +4,6 @@
import
'dart:ui'
show
Color
,
Size
,
Rect
,
VoidCallback
;
/// The direction in which an animation is running.
enum
AnimationDirection
{
/// The animation is running from beginning to end.
forward
,
/// The animation is running backwards, from end to beginning.
reverse
}
/// The status of an animation
enum
AnimationStatus
{
/// The animation is stopped at the beginning
...
...
@@ -62,9 +53,6 @@ abstract class Animation<T> {
/// The current status of this animation.
AnimationStatus
get
status
;
/// The current direction of the animation.
AnimationDirection
get
direction
;
/// The current value of the animation.
T
get
value
;
...
...
@@ -79,7 +67,6 @@ abstract class Animation<T> {
}
String
toStringDetails
()
{
assert
(
status
!=
null
);
assert
(
direction
!=
null
);
String
icon
;
switch
(
status
)
{
case
AnimationStatus
.
forward
:
...
...
@@ -89,24 +76,10 @@ abstract class Animation<T> {
icon
=
'
\
u25C0'
;
// <
break
;
case
AnimationStatus
.
completed
:
switch
(
direction
)
{
case
AnimationDirection
.
forward
:
icon
=
'
\
u23ED'
;
// >>|
break
;
case
AnimationDirection
.
reverse
:
icon
=
'
\
u29CF'
;
// <|
break
;
}
icon
=
'
\
u23ED'
;
// >>|
break
;
case
AnimationStatus
.
dismissed
:
switch
(
direction
)
{
case
AnimationDirection
.
forward
:
icon
=
'
\
u29D0'
;
// |>
break
;
case
AnimationDirection
.
reverse
:
icon
=
'
\
u23EE'
;
// |<<
break
;
}
icon
=
'
\
u23EE'
;
// |<<
break
;
}
assert
(
icon
!=
null
);
...
...
packages/flutter/lib/src/animation/animation_controller.dart
View file @
fc564f0c
...
...
@@ -13,6 +13,15 @@ import 'curves.dart';
import
'forces.dart'
;
import
'listener_helpers.dart'
;
/// The direction in which an animation is running.
enum
_AnimationDirection
{
/// The animation is running from beginning to end.
forward
,
/// The animation is running backwards, from end to beginning.
reverse
}
/// A controller for an animation.
///
/// An animation controller can drive an animation forward or backward and can
...
...
@@ -79,9 +88,6 @@ class AnimationController extends Animation<double>
/// The length of time this animation should last.
Duration
duration
;
AnimationDirection
get
direction
=>
_direction
;
AnimationDirection
_direction
=
AnimationDirection
.
forward
;
Ticker
_ticker
;
Simulation
_simulation
;
...
...
@@ -106,31 +112,28 @@ class AnimationController extends Animation<double>
/// Whether this animation is currently animating in either the forward or reverse direction.
bool
get
isAnimating
=>
_ticker
.
isTicking
;
_AnimationDirection
_direction
;
AnimationStatus
get
status
{
if
(!
isAnimating
&&
value
==
upperBound
)
return
AnimationStatus
.
completed
;
if
(!
isAnimating
&&
value
==
lowerBound
)
return
AnimationStatus
.
dismissed
;
return
_direction
==
AnimationDirection
.
forward
?
return
_direction
==
_
AnimationDirection
.
forward
?
AnimationStatus
.
forward
:
AnimationStatus
.
reverse
;
}
/// Starts running this animation forwards (towards the end).
Future
forward
()
=>
play
(
AnimationDirection
.
forward
);
/// Starts running this animation in reverse (towards the beginning).
Future
reverse
()
=>
play
(
AnimationDirection
.
reverse
);
/// Starts running this animation in the given direction.
Future
play
(
AnimationDirection
direction
)
{
_direction
=
direction
;
return
resume
();
Future
forward
()
{
_direction
=
_AnimationDirection
.
forward
;
return
animateTo
(
upperBound
);
}
/// Resumes this animation in the most recent direction.
Future
resume
()
{
return
animateTo
(
_direction
==
AnimationDirection
.
forward
?
upperBound
:
lowerBound
);
/// Starts running this animation in reverse (towards the beginning).
Future
reverse
()
{
_direction
=
_AnimationDirection
.
reverse
;
return
animateTo
(
lowerBound
);
}
/// Drives the animation from its current value to target.
...
...
@@ -166,7 +169,7 @@ class AnimationController extends Animation<double>
/// animation will complete, otherwise it will dismiss.
Future
fling
({
double
velocity:
1.0
,
Force
force
})
{
force
??=
kDefaultSpringForce
;
_direction
=
velocity
<
0.0
?
AnimationDirection
.
reverse
:
AnimationDirection
.
forward
;
_direction
=
velocity
<
0.0
?
_AnimationDirection
.
reverse
:
_
AnimationDirection
.
forward
;
return
animateWith
(
force
.
release
(
value
,
velocity
));
}
...
...
packages/flutter/lib/src/animation/animations.dart
View file @
fc564f0c
...
...
@@ -16,7 +16,6 @@ class _AlwaysCompleteAnimation extends Animation<double> {
void
addStatusListener
(
AnimationStatusListener
listener
)
{
}
void
removeStatusListener
(
AnimationStatusListener
listener
)
{
}
AnimationStatus
get
status
=>
AnimationStatus
.
completed
;
AnimationDirection
get
direction
=>
AnimationDirection
.
forward
;
double
get
value
=>
1.0
;
}
...
...
@@ -35,7 +34,6 @@ class _AlwaysDismissedAnimation extends Animation<double> {
void
addStatusListener
(
AnimationStatusListener
listener
)
{
}
void
removeStatusListener
(
AnimationStatusListener
listener
)
{
}
AnimationStatus
get
status
=>
AnimationStatus
.
dismissed
;
AnimationDirection
get
direction
=>
AnimationDirection
.
forward
;
double
get
value
=>
0.0
;
}
...
...
@@ -57,7 +55,6 @@ class AlwaysStoppedAnimation<T> extends Animation<T> {
void
addStatusListener
(
AnimationStatusListener
listener
)
{
}
void
removeStatusListener
(
AnimationStatusListener
listener
)
{
}
AnimationStatus
get
status
=>
AnimationStatus
.
forward
;
AnimationDirection
get
direction
=>
AnimationDirection
.
forward
;
}
/// Implements most of the [Animation] interface, by deferring its behavior to a
...
...
@@ -77,7 +74,6 @@ abstract class AnimationWithParentMixin<T> {
void
removeStatusListener
(
AnimationStatusListener
listener
)
=>
parent
.
removeStatusListener
(
listener
);
AnimationStatus
get
status
=>
parent
.
status
;
AnimationDirection
get
direction
=>
parent
.
direction
;
}
/// An animation that is a proxy for another animation.
...
...
@@ -92,13 +88,11 @@ class ProxyAnimation extends Animation<double>
_parent
=
animation
;
if
(
_parent
==
null
)
{
_status
=
AnimationStatus
.
dismissed
;
_direction
=
AnimationDirection
.
forward
;
_value
=
0.0
;
}
}
AnimationStatus
_status
;
AnimationDirection
_direction
;
double
_value
;
/// The animation whose value this animation will proxy.
...
...
@@ -112,7 +106,6 @@ class ProxyAnimation extends Animation<double>
return
;
if
(
_parent
!=
null
)
{
_status
=
_parent
.
status
;
_direction
=
_parent
.
direction
;
_value
=
_parent
.
value
;
if
(
isListening
)
didStopListening
();
...
...
@@ -126,7 +119,6 @@ class ProxyAnimation extends Animation<double>
if
(
_status
!=
_parent
.
status
)
notifyStatusListeners
(
_parent
.
status
);
_status
=
null
;
_direction
=
null
;
_value
=
null
;
}
}
...
...
@@ -146,7 +138,6 @@ class ProxyAnimation extends Animation<double>
}
AnimationStatus
get
status
=>
_parent
!=
null
?
_parent
.
status
:
_status
;
AnimationDirection
get
direction
=>
_parent
!=
null
?
_parent
.
direction
:
_direction
;
double
get
value
=>
_parent
!=
null
?
_parent
.
value
:
_value
;
}
...
...
@@ -186,7 +177,6 @@ class ReverseAnimation extends Animation<double>
}
AnimationStatus
get
status
=>
_reverseStatus
(
parent
.
status
);
AnimationDirection
get
direction
=>
_reverseDirection
(
parent
.
direction
);
double
get
value
=>
1.0
-
parent
.
value
;
AnimationStatus
_reverseStatus
(
AnimationStatus
status
)
{
...
...
@@ -197,13 +187,6 @@ class ReverseAnimation extends Animation<double>
case
AnimationStatus
.
dismissed
:
return
AnimationStatus
.
completed
;
}
}
AnimationDirection
_reverseDirection
(
AnimationDirection
direction
)
{
switch
(
direction
)
{
case
AnimationDirection
.
forward
:
return
AnimationDirection
.
reverse
;
case
AnimationDirection
.
reverse
:
return
AnimationDirection
.
forward
;
}
}
}
/// An animation that applies a curve to another animation.
...
...
@@ -238,7 +221,7 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
/// The curve direction is only reset when we hit the beginning or the end of
/// the timeline to avoid discontinuities in the value of any variables this
/// a animation is used to animate.
Animation
Direction
_curveDirection
;
Animation
Status
_curveDirection
;
void
_handleStatusChanged
(
AnimationStatus
status
)
{
switch
(
status
)
{
...
...
@@ -247,16 +230,16 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
_curveDirection
=
null
;
break
;
case
AnimationStatus
.
forward
:
_curveDirection
??=
Animation
Direction
.
forward
;
_curveDirection
??=
Animation
Status
.
forward
;
break
;
case
AnimationStatus
.
reverse
:
_curveDirection
??=
Animation
Direction
.
reverse
;
_curveDirection
??=
Animation
Status
.
reverse
;
break
;
}
}
double
get
value
{
final
bool
useForwardCurve
=
reverseCurve
==
null
||
(
_curveDirection
??
parent
.
direction
)
==
AnimationDirection
.
forward
;
final
bool
useForwardCurve
=
reverseCurve
==
null
||
(
_curveDirection
??
parent
.
status
)
!=
AnimationStatus
.
reverse
;
Curve
activeCurve
=
useForwardCurve
?
curve
:
reverseCurve
;
double
t
=
parent
.
value
;
...
...
@@ -324,7 +307,6 @@ class TrainHoppingAnimation extends Animation<double>
}
AnimationStatus
get
status
=>
_currentTrain
.
status
;
AnimationDirection
get
direction
=>
_currentTrain
.
direction
;
double
_lastValue
;
void
_valueChangeHandler
()
{
...
...
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
fc564f0c
...
...
@@ -51,7 +51,7 @@ class _BottomSheetState extends State<BottomSheet> {
return
renderBox
.
size
.
height
;
}
bool
get
_dismissUnderway
=>
config
.
animationController
.
direction
==
AnimationDirection
.
reverse
;
bool
get
_dismissUnderway
=>
config
.
animationController
.
status
==
AnimationStatus
.
reverse
;
void
_handleDragUpdate
(
double
delta
)
{
if
(
_dismissUnderway
)
...
...
packages/flutter/lib/src/material/tabs.dart
View file @
fc564f0c
...
...
@@ -810,7 +810,6 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
TabBarSelectionState
_selection
;
List
<
Widget
>
_items
;
AnimationDirection
_scrollDirection
=
AnimationDirection
.
forward
;
int
get
_tabCount
=>
config
.
children
.
length
;
...
...
@@ -907,16 +906,11 @@ class _TabBarViewState extends PageableListState<TabBarView> implements TabBarSe
if
(
selectedIndex
<
previousSelectedIndex
)
{
_updateItemsFromChildren
(
selectedIndex
,
previousSelectedIndex
);
_scrollDirection
=
AnimationDirection
.
reverse
;
scrollTo
(
1.0
-
animation
.
value
)
;
}
else
{
_updateItemsFromChildren
(
previousSelectedIndex
,
selectedIndex
);
_scrollDirection
=
AnimationDirection
.
forward
;
}
if
(
_scrollDirection
==
AnimationDirection
.
forward
)
scrollTo
(
animation
.
value
);
else
scrollTo
(
1.0
-
animation
.
value
);
}
}
void
dispatchOnScroll
()
{
...
...
packages/flutter/lib/src/material/toggleable.dart
View file @
fc564f0c
...
...
@@ -66,7 +66,10 @@ abstract class RenderToggleable extends RenderConstrainedBox implements Semantic
_position
..
curve
=
Curves
.
easeIn
..
reverseCurve
=
Curves
.
easeOut
;
_positionController
.
play
(
value
?
AnimationDirection
.
forward
:
AnimationDirection
.
reverse
);
if
(
value
)
_positionController
.
forward
();
else
_positionController
.
reverse
();
}
Color
get
activeColor
=>
_activeColor
;
...
...
packages/flutter/lib/src/widgets/heroes.dart
View file @
fc564f0c
...
...
@@ -456,7 +456,8 @@ class HeroController extends NavigatorObserver {
void
_addHeroToOverlay
(
Widget
hero
,
Object
tag
,
OverlayState
overlay
)
{
OverlayEntry
entry
=
new
OverlayEntry
(
builder:
(
_
)
=>
hero
);
if
(
_animation
.
direction
==
AnimationDirection
.
forward
)
assert
(
_animation
.
status
!=
AnimationStatus
.
dismissed
&&
_animation
.
status
!=
AnimationStatus
.
completed
);
if
(
_animation
.
status
==
AnimationStatus
.
forward
)
_to
.
insertHeroOverlayEntry
(
entry
,
tag
,
overlay
);
else
_from
.
insertHeroOverlayEntry
(
entry
,
tag
,
overlay
);
...
...
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